use of xyz.derkades.ublisk.utils.exception.PlayerNotFoundException in project Ublisk by Derkades.
the class StatsCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
UPlayer player = new UPlayer(sender);
if (args.length == 1) {
UPlayer target = null;
try {
target = new UPlayer(args[1]);
} catch (PlayerNotFoundException e) {
player.sendMessage(Message.PLAYER_NOT_FOUND);
return true;
}
BaseComponent[] hoverText = new ComponentBuilder("yes click me pls").create();
BaseComponent[] text = new ComponentBuilder("Click here to open " + target.getName() + "'s statistics page in your browser.").color(ChatColor.AQUA).bold(true).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText)).event(new ClickEvent(ClickEvent.Action.OPEN_URL, target.getStatsURL())).create();
player.sendMessage(text);
return true;
} else if (args.length == 0) {
BaseComponent[] hoverText = new ComponentBuilder("yes click me pls").create();
BaseComponent[] text = new ComponentBuilder("Click here to open your statistics page in your browser.").color(ChatColor.AQUA).bold(true).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText)).event(new ClickEvent(ClickEvent.Action.OPEN_URL, player.getStatsURL())).create();
player.sendMessage(text);
return true;
} else {
return false;
}
}
use of xyz.derkades.ublisk.utils.exception.PlayerNotFoundException in project Ublisk by Derkades.
the class Debug method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
UPlayer player = new UPlayer(sender);
if (player.hasPermission(Permission.COMMAND_DEBUG)) {
if (args.length == 2) {
if (args[0].equalsIgnoreCase("xp")) {
int xp = Integer.parseInt(args[1]);
player.setXP(xp);
return true;
} else if (args[0].equals("refreshxp")) {
UPlayer target;
try {
target = new UPlayer(args[1]);
} catch (PlayerNotFoundException e) {
player.sendMessage("player not found");
return true;
}
player.updateXPBar();
player.sendMessage("XP refreshed!");
player.sendMessage("XP: " + target.getXP());
player.sendMessage("Level: " + target.getLevel());
return true;
} else if (args[0].equals("life")) {
int life = Integer.parseInt(args[1]);
player.setLifeCrystals(life);
return true;
} else if (args[0].equals("vote")) {
UPlayer target;
try {
target = new UPlayer(args[1]);
} catch (PlayerNotFoundException e) {
player.sendMessage("player not found");
return true;
}
player.sendMessage("Voting points: " + target.getVotingPoints());
return true;
} else if (args[0].equals("inv")) {
UPlayer target;
try {
target = new UPlayer(args[1]);
} catch (PlayerNotFoundException e) {
player.sendMessage(Message.PLAYER_NOT_FOUND);
return true;
}
player.bukkit().openInventory(target.bukkit().getInventory());
return true;
} else if (args[0].equals("skull")) {
player.getInventory().addItem(new Item(args[1]));
return true;
} else if (args[0].equals("disablepl")) {
Main.getInstance().getServer().getPluginManager().disablePlugin(Main.getInstance().getServer().getPluginManager().getPlugin(args[1]));
return true;
} else if (args[0].equals("enablepl")) {
Main.getInstance().getServer().getPluginManager().enablePlugin(Main.getInstance().getServer().getPluginManager().getPlugin(args[1]));
return true;
} else {
player.sendMessage(Message.WRONG_USAGE);
return true;
}
} else if (args.length == 1) {
if (args[0].equals("save")) {
for (DataFile file : DataFile.values()) {
file.save();
}
return true;
} else {
player.sendMessage(Message.WRONG_USAGE);
return true;
}
} else {
player.sendMessage(Message.WRONG_USAGE);
return true;
}
} else {
player.sendMessage(Message.NO_PERMISSION);
return true;
}
} else {
sender.sendMessage(Message.NOT_A_PLAYER.toString());
return true;
}
}
Aggregations