-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ZorgBtw/dev
Merge dev branch to master
- Loading branch information
Showing
11 changed files
with
222 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/fr/zorg/bungeesk/bukkit/skript/expressions/ExprAllPlayersOnServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package fr.zorg.bungeesk.bukkit.skript.expressions; | ||
|
||
import ch.njol.skript.Skript; | ||
import ch.njol.skript.doc.Description; | ||
import ch.njol.skript.doc.Examples; | ||
import ch.njol.skript.doc.Name; | ||
import ch.njol.skript.doc.Since; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.ExpressionType; | ||
import ch.njol.skript.lang.SkriptParser; | ||
import ch.njol.skript.lang.util.SimpleExpression; | ||
import ch.njol.util.Kleenean; | ||
import fr.zorg.bungeesk.bukkit.sockets.ConnectionClient; | ||
import fr.zorg.bungeesk.bukkit.utils.BungeePlayer; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Name("All of the bungee players on specific server") | ||
@Description("Returns every bungee player on a specific server") | ||
@Examples("loop all bungee players on server \"lobby\":\n" + | ||
"\tsend \"%loop-bungeeplayer%\"") | ||
@Since("1.0.2") | ||
public class ExprAllPlayersOnServer extends SimpleExpression<BungeePlayer> { | ||
|
||
static { | ||
Skript.registerExpression(ExprAllPlayersOnServer.class, | ||
BungeePlayer.class, | ||
ExpressionType.SIMPLE, | ||
"[(all [[of] the]|the)] bungee players on server %string%"); | ||
} | ||
|
||
private Expression<String> server; | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { | ||
server = (Expression<String>) exprs[0]; | ||
return true; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
protected BungeePlayer[] get(Event e) { | ||
assert ConnectionClient.get() != null; | ||
String result = ConnectionClient.get().future("ALLBUNGEEPLAYERSONSERVERµ" + server.getSingle(e)); | ||
result = result.replace("lobby^", ""); | ||
List<BungeePlayer> players = new ArrayList<>(); | ||
if (result.equals("NONE")) return null; | ||
for (String player : result.split("\\^")) { | ||
String name = player.split("\\$")[0]; | ||
String uuid = player.split("\\$")[1]; | ||
players.add(new BungeePlayer(name, uuid)); | ||
} | ||
return players.toArray(new BungeePlayer[0]); | ||
} | ||
|
||
@Override | ||
public boolean isSingle() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Class<? extends BungeePlayer> getReturnType() { | ||
return BungeePlayer.class; | ||
} | ||
|
||
@Override | ||
public String toString(@Nullable Event e, boolean debug) { | ||
return "every bungee player connected on server " + server.toString(e, debug); | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/fr/zorg/bungeesk/bukkit/skript/expressions/ExprClientRealName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package fr.zorg.bungeesk.bukkit.skript.expressions; | ||
|
||
import ch.njol.skript.Skript; | ||
import ch.njol.skript.doc.Description; | ||
import ch.njol.skript.doc.Examples; | ||
import ch.njol.skript.doc.Name; | ||
import ch.njol.skript.doc.Since; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.ExpressionType; | ||
import ch.njol.skript.lang.SkriptParser; | ||
import ch.njol.skript.lang.util.SimpleExpression; | ||
import ch.njol.util.Kleenean; | ||
import fr.zorg.bungeesk.bukkit.BungeeSK; | ||
import fr.zorg.bungeesk.bukkit.sockets.ConnectionClient; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Name("Client real name") | ||
@Description("Returns the client's name in the Bungeecord proxy configuration") | ||
@Examples("set {_name} to real name of this client") | ||
@Since("1.0.2") | ||
public class ExprClientRealName extends SimpleExpression<String> { | ||
|
||
static { | ||
Skript.registerExpression(ExprClientRealName.class, | ||
String.class, | ||
ExpressionType.SIMPLE, | ||
"real name of this client", | ||
"this client's real name"); | ||
} | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { | ||
return true; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
protected String[] get(Event e) { | ||
assert ConnectionClient.get() != null; | ||
final String result = ConnectionClient.get().future("CLIENTREALNAMEµ" + BungeeSK.getInstance().getServer().getIp() + ":" + BungeeSK.getInstance().getServer().getPort()); | ||
return new String[] { result }; | ||
} | ||
|
||
@Override | ||
public boolean isSingle() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public Class<? extends String> getReturnType() { | ||
return String.class; | ||
} | ||
|
||
@Override | ||
public String toString(@Nullable Event e, boolean debug) { | ||
return "client's real name on the bungeecord"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.