Add KickFromBungeeCommand
This commit is contained in:
parent
b2eab51b72
commit
18cb07f34e
|
|
@ -51,5 +51,9 @@ bukkit {
|
||||||
description = "${rootProject.name} admin command."
|
description = "${rootProject.name} admin command."
|
||||||
permission = "${rootProject.name}.command.admin"
|
permission = "${rootProject.name}.command.admin"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
register("kickfrombungee") {
|
||||||
|
description = "${rootProject.name} admin command."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package com.alttd.cometskyblock;
|
||||||
|
|
||||||
import com.alttd.cometskyblock.challenges.ChallengeHandler;
|
import com.alttd.cometskyblock.challenges.ChallengeHandler;
|
||||||
import com.alttd.cometskyblock.challenges.ChallengeLoader;
|
import com.alttd.cometskyblock.challenges.ChallengeLoader;
|
||||||
|
import com.alttd.cometskyblock.commands.KickFromBungeeCommand;
|
||||||
import com.alttd.cometskyblock.commands.admin.SkyBlockCommand;
|
import com.alttd.cometskyblock.commands.admin.SkyBlockCommand;
|
||||||
import com.alttd.cometskyblock.commands.challenges.ChallengeCommand;
|
import com.alttd.cometskyblock.commands.challenges.ChallengeCommand;
|
||||||
import com.alttd.cometskyblock.commands.island.IslandCommand;
|
import com.alttd.cometskyblock.commands.island.IslandCommand;
|
||||||
|
|
@ -102,6 +103,7 @@ public class CometSkyBlockPlugin extends JavaPlugin implements CometSkyBlockAPI
|
||||||
getCommand("island").setExecutor(new IslandCommand(this));
|
getCommand("island").setExecutor(new IslandCommand(this));
|
||||||
getCommand("challenges").setExecutor(new ChallengeCommand(this));
|
getCommand("challenges").setExecutor(new ChallengeCommand(this));
|
||||||
getCommand("skyblock").setExecutor( new SkyBlockCommand(this));
|
getCommand("skyblock").setExecutor( new SkyBlockCommand(this));
|
||||||
|
getCommand("kickfrombungee").setExecutor( new KickFromBungeeCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadEventListeners() {
|
public void loadEventListeners() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.alttd.cometskyblock.commands;
|
||||||
|
|
||||||
|
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||||
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class KickFromBungeeCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
|
if (sender.hasPermission("utility.kickfrombungee")) {
|
||||||
|
if (!(args.length == 0)) {
|
||||||
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
|
if (target != null) {
|
||||||
|
String reason = join(args, ' ' , 1, args.length);
|
||||||
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
|
out.writeUTF("KickPlayer");
|
||||||
|
out.writeUTF(target.getName());
|
||||||
|
out.writeUTF(ChatColor.translateAlternateColorCodes('&', reason));
|
||||||
|
target.sendPluginMessage(CometSkyBlockPlugin.instance(), "BungeeCord", out.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String join(final String[] array, final char delimiter, final int startIndex, final int endIndex) {
|
||||||
|
if (array == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (endIndex - startIndex <= 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
final StringBuilder stringBuilder = new StringBuilder(array.length * 5 + array.length - 1);
|
||||||
|
for (int i = startIndex; i < endIndex; i++) {
|
||||||
|
stringBuilder
|
||||||
|
.append(array[i])
|
||||||
|
.append(delimiter);
|
||||||
|
}
|
||||||
|
return stringBuilder.substring(0, stringBuilder.length() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user