Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #5 from kacperduras/development
Browse files Browse the repository at this point in the history
1.1.0 release.
  • Loading branch information
kacperduras committed Jul 19, 2017
2 parents be423d7 + c7d5499 commit 3b50e6f
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ jdk:
install: true
script:
- sudo apt-get update && sudo apt-get install oracle-java8-installer
- sudo apt install oracle-java8-set-default
- java -version
- sudo mkdir -p $TRAVIS_BUILD_DIR/lib/
- sudo wget https://github.com/bensku/Skript/releases/download/dev29/Skript.jar --output-document $TRAVIS_BUILD_DIR/lib/Skript.jar
- mvn validate
- mvn clean test
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ProtocolTab is a small, easy and fast in use api for managing tab list on your M
Each player can see different tab list, and everything is limited to your imagination.

## Example

### Java
```java
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -58,6 +60,16 @@ public final class ProtocolTabExample extends JavaPlugin {
}
```

### Skript
```
set %player%'s header to %string%
set %player%'s footer to %string%
set %player%'s slot number %integer% to %string%
update %player%'s tablist
```

The usage is similar to the Java API.

## Configuration
```yaml
# ProtocolTab basic configuration.
Expand Down
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<name>ProtocolTab</name>
<groupId>pl.kacperduras</groupId>
<artifactId>protocoltab</artifactId>
<version>1.0.2</version>
<version>1.1.0</version>

<repositories>
<repository>
Expand Down Expand Up @@ -37,6 +37,13 @@
<version>4.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.njol</groupId>
<artifactId>skript</artifactId>
<version>2.2-dev29</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Skript.jar</systemPath>
</dependency>
<dependency>
<groupId>com.gotofinal</groupId>
<artifactId>diorite-configs-java8</artifactId>
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/pl/kacperduras/protocoltab/ProtocolTabPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
*/
package pl.kacperduras.protocoltab;

import ch.njol.skript.Skript;
import org.bukkit.plugin.java.JavaPlugin;
import org.diorite.config.ConfigManager;
import pl.kacperduras.protocoltab.manager.ProtocolTabManager;

import java.io.File;
import java.io.IOException;

public final class ProtocolTabPlugin extends JavaPlugin {

Expand All @@ -45,11 +47,19 @@ public void onLoad() {
@Override
public void onEnable() {
this.manager = new ProtocolTabManager(this.config);

// Skript hook
if (this.getServer().getPluginManager().getPlugin("Skript") != null && Skript.isAcceptRegistrations()) {
try {
Skript.registerAddon(this).loadClasses("pl.kacperduras.protocoltab", "skript");
} catch (IOException ex) {
ex.printStackTrace();
}
}
}

@Override
public void onDisable() {

}

protected static ProtocolTabPlugin getInstance() {
Expand Down
62 changes: 62 additions & 0 deletions src/main/java/pl/kacperduras/protocoltab/skript/EffSetFooter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2017 Kacper Duras
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pl.kacperduras.protocoltab.skript;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.util.Kleenean;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import pl.kacperduras.protocoltab.ProtocolTabAPI;

public class EffSetFooter extends Effect {

private Expression<Player> playerExpression;
private Expression<String> stringExpression;

static {
Skript.registerEffect(EffSetFooter.class, "set %player%'s footer to %string%");
}

@Override
protected void execute(Event event) {
Player player = this.playerExpression.getSingle(event);
String string = this.stringExpression.getSingle(event);

if (player == null || string == null) {
return;
}

ProtocolTabAPI.getTablist(player).setFooter(string);
}

@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
this.playerExpression = (Expression<Player>) expressions[0];
this.stringExpression = (Expression<String>) expressions[1];

return true;
}

@Override
public String toString(Event event, boolean b) {
return this.getClass().getName();
}

}
62 changes: 62 additions & 0 deletions src/main/java/pl/kacperduras/protocoltab/skript/EffSetHeader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2017 Kacper Duras
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pl.kacperduras.protocoltab.skript;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.util.Kleenean;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import pl.kacperduras.protocoltab.ProtocolTabAPI;

public class EffSetHeader extends Effect {

private Expression<Player> playerExpression;
private Expression<String> stringExpression;

static {
Skript.registerEffect(EffSetHeader.class, "set %player%'s header to %string%");
}

@Override
protected void execute(Event event) {
Player player = this.playerExpression.getSingle(event);
String string = this.stringExpression.getSingle(event);

if (player == null || string == null) {
return;
}

ProtocolTabAPI.getTablist(player).setHeader(string);
}

@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
this.playerExpression = (Expression<Player>) expressions[0];
this.stringExpression = (Expression<String>) expressions[1];

return true;
}

@Override
public String toString(Event event, boolean b) {
return this.getClass().getName();
}

}
65 changes: 65 additions & 0 deletions src/main/java/pl/kacperduras/protocoltab/skript/EffSetSlot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Copyright 2017 Kacper Duras
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pl.kacperduras.protocoltab.skript;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.util.Kleenean;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import pl.kacperduras.protocoltab.ProtocolTabAPI;

public class EffSetSlot extends Effect {

static {
Skript.registerEffect(EffSetSlot.class, "set %player%'s slot number %integer% to %string%");
}

private Expression<Player> playerExpression;
private Expression<Integer> integerExpression;
private Expression<String> stringExpression;

@Override
protected void execute(Event event) {
Player player = this.playerExpression.getSingle(event);
Integer integer = this.integerExpression.getSingle(event);
String string = this.stringExpression.getSingle(event);

if (player == null || string == null || integer == null) {
return;
}

ProtocolTabAPI.getTablist(player).setSlot(integer, string);
}

@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
this.playerExpression = (Expression<Player>) expressions[0];
this.integerExpression = (Expression<Integer>) expressions[1];
this.stringExpression = (Expression<String>) expressions[2];

return true;
}

@Override
public String toString(Event event, boolean b) {
return this.getClass().getName();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright 2017 Kacper Duras
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pl.kacperduras.protocoltab.skript;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.util.Kleenean;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import pl.kacperduras.protocoltab.ProtocolTabAPI;

public class EffUpdateTablist extends Effect {

static {
Skript.registerEffect(EffUpdateTablist.class, "update %player%'s tablist");
}

private Expression<Player> playerExpression;

@Override
protected void execute(Event event) {
Player player = this.playerExpression.getSingle(event);
if (player == null) {
return;
}

ProtocolTabAPI.getTablist(player).update();
}

@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
this.playerExpression = (Expression<Player>) expressions[0];
return true;
}

@Override
public String toString(Event event, boolean b) {
return this.getClass().toString();
}

}

0 comments on commit 3b50e6f

Please sign in to comment.