use of org.anhcraft.spaciouslib.bungee.BungeePlayerIPResponse in project SpaciousLib by anhcraft.
the class SpaciousLibTestSpigot method onEnable.
@Override
public void onEnable() {
new DirectoryManager("plugins/SpaciousLibTest/").mkdirs();
try {
new FileManager("plugins/SpaciousLibTest/test.txt").initFile(IOUtils.toByteArray(getClass().getResourceAsStream("/test.txt")));
} catch (IOException e) {
e.printStackTrace();
}
try {
new CommandBuilder("slt", new CommandRunnable() {
@Override
public void run(CommandBuilder sCommand, SubCommandBuilder subCommand, CommandSender commandSender, String[] strings, String s) {
for (String str : sCommand.getCommandsAsString(true)) {
commandSender.sendMessage(str);
}
}
}).addSubCommand(new SubCommandBuilder("particle spawn", "Spawn a specific type of particle at your location", new CommandRunnable() {
@Override
public void run(CommandBuilder sCommand, SubCommandBuilder subCommand, CommandSender commandSender, String[] strings, String s) {
commandSender.sendMessage(sCommand.getCommandAsString(subCommand, true));
}
}).addArgument(new CommandArgument("type", new CommandRunnable() {
@Override
public void run(CommandBuilder sCommand, SubCommandBuilder subCommand, CommandSender commandSender, String[] strings, String s) {
if (commandSender instanceof Player) {
Particle.Type type = StringUtils.get(strings[0].toUpperCase(), Particle.Type.values());
if (type == null) {
commandSender.sendMessage("Invalid particle type!");
} else {
Location location = ((Player) commandSender).getLocation();
for (int degree = 0; degree < 360; degree++) {
double radians = Math.toRadians(degree);
double x = Math.cos(radians) * 3;
double z = Math.sin(radians) * 3;
location.add(x, 0, z);
Particle.create(type, location, 10).sendWorld(((Player) commandSender).getWorld());
location.subtract(x, 0, z);
}
}
}
}
}, false), CommandArgument.Type.CUSTOM).addArgument(new CommandArgument("count", new CommandRunnable() {
@Override
public void run(CommandBuilder sCommand, SubCommandBuilder subCommand, CommandSender commandSender, String[] strings, String s) {
if (commandSender instanceof Player) {
Particle.Type type = StringUtils.get(strings[0], Particle.Type.values());
if (type == null) {
commandSender.sendMessage("Invalid particle type!");
} else {
Location location = ((Player) commandSender).getLocation();
for (int degree = 0; degree < 360; degree++) {
double radians = Math.toRadians(degree);
double x = Math.cos(radians) * 3;
double z = Math.sin(radians) * 3;
location.add(x, 0, z);
Particle.create(type, location, StringUtils.toIntegerNumber(strings[1])).sendWorld(((Player) commandSender).getWorld());
location.subtract(x, 0, z);
}
}
}
}
}, true), CommandArgument.Type.INTEGER_NUMBER).hideTypeCommandString()).addSubCommand(new SubCommandBuilder("particle list", "show all types of particle", new CommandRunnable() {
@Override
public void run(CommandBuilder sCommand, SubCommandBuilder subCommand, CommandSender commandSender, String[] strings, String s) {
StringBuilder pls = new StringBuilder();
for (Particle.Type p : Particle.Type.values()) {
pls.append(p.toString()).append(" ");
}
commandSender.sendMessage(pls.toString());
}
})).addSubCommand(new SubCommandBuilder("playerlist set", null, new CommandRunnable() {
@Override
public void run(CommandBuilder sCommand, SubCommandBuilder subCommand, CommandSender commandSender, String[] strings, String s) {
commandSender.sendMessage(sCommand.getCommandAsString(subCommand, true));
}
}).addArgument("header", new CommandRunnable() {
@Override
public void run(CommandBuilder sCommand, SubCommandBuilder subCommand, CommandSender commandSender, String[] strings, String s) {
commandSender.sendMessage(sCommand.getCommandAsString(subCommand, true));
}
}, CommandArgument.Type.CUSTOM, false).addArgument("footer", new CommandRunnable() {
@Override
public void run(CommandBuilder sCommand, SubCommandBuilder subCommand, CommandSender commandSender, String[] strings, String s) {
PlayerList.create(strings[0], strings[1]).sendAll();
}
}, CommandArgument.Type.CUSTOM, false)).addSubCommand(new SubCommandBuilder("playerlist remove", null, new CommandRunnable() {
@Override
public void run(CommandBuilder sCommand, SubCommandBuilder subCommand, CommandSender commandSender, String[] strings, String s) {
PlayerList.remove().sendAll();
}
})).addSubCommand(new SubCommandBuilder("camera", "View as a random nearby entity", new CommandRunnable() {
@Override
public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] strings, String s) {
if (sender instanceof Player) {
Entity e = RandomUtils.pickRandom(((Player) sender).getNearbyEntities(5, 5, 5));
Camera.create(e).sendPlayer((Player) sender);
}
}
})).addSubCommand(new SubCommandBuilder("camera reset", "Reset your view to normal", new CommandRunnable() {
@Override
public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] strings, String s) {
if (sender instanceof Player) {
if (sender instanceof Player) {
Camera.create((Player) sender).sendPlayer((Player) sender);
}
}
}
})).addSubCommand(new SubCommandBuilder("bungee tp", "Teleport you or a specific player to a server in Bungee network", new CommandRunnable() {
@Override
public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] args, String value) {
sender.sendMessage(cmd.getCommandAsString(subcmd, true));
}
}).addArgument("server", new CommandRunnable() {
@Override
public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] args, String value) {
if (sender instanceof Player) {
BungeeManager.connect((Player) sender, value);
}
}
}, CommandArgument.Type.CUSTOM, false).addArgument("player", new CommandRunnable() {
@Override
public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] args, String value) {
if (sender instanceof Player) {
BungeeManager.connect(value, args[0]);
}
}
}, CommandArgument.Type.ONLINE_PLAYER, true)).addSubCommand(new SubCommandBuilder("bungee ip", "Get your real IP", new CommandRunnable() {
@Override
public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] args, String value) {
if (sender instanceof Player) {
BungeeManager.getIP((Player) sender, new BungeePlayerIPResponse() {
@Override
public void result(String ip, int port) {
sender.sendMessage(ip + ":" + port);
}
});
}
}
})).buildExecutor(this).addSubCommand(new SubCommandBuilder("bungee data", null, new CommandRunnable() {
@Override
public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] args, String value) {
sender.sendMessage("sent successfully!");
ByteArrayOutputStream bytedata = new ByteArrayOutputStream();
DataOutputStream data = new DataOutputStream(bytedata);
try {
data.writeUTF(sender.getName());
} catch (IOException e) {
e.printStackTrace();
}
BungeeManager.forwardData("slt", bytedata.toByteArray());
}
})).buildExecutor(this).clone("sl").buildExecutor(this).clone("spaciouslib").buildExecutor(this);
} catch (Exception e) {
e.printStackTrace();
}
getServer().getPluginManager().registerEvents(this, this);
System.out.println("Starting socket server...");
SocketManager.registerServer(25568, new ServerSocketRequestHandler() {
@Override
public void request(ServerSocketClientHandler client, String data) {
System.out.println("Client >> " + data);
}
});
for (Placeholder placeholder : PlaceholderManager.getPlaceholders()) {
System.out.println(placeholder.getPlaceholder());
}
}
Aggregations