use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class HelpMenu method onOptionClick.
@Override
public boolean onOptionClick(OptionClickEvent event) {
String name = event.getName().toLowerCase();
final UPlayer player = new UPlayer(event);
if (name.contains("commands")) {
new CommandsHelp(player).open();
} else if (name.contains("faq")) {
// TODO Open faq menu
} else if (name.equals("back")) {
new MainMenu(player).open();
} else {
player.sendMessage(Message.ERROR_MENU);
}
return false;
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class NPCClickListener method onClick.
@EventHandler(priority = EventPriority.LOW)
public void onClick(PlayerInteractEntityEvent event) {
Entity entity = event.getRightClicked();
if (!(entity instanceof Villager)) {
return;
}
event.setCancelled(true);
UPlayer player = new UPlayer(event);
NPC npc = NPC.fromName(entity.getCustomName());
if (npc == null) {
player.sendPrefixedMessage("NPC", RED + "No dialogue could be found for an npc with name " + entity.getCustomName() + RED + ", please report this error.");
return;
}
npc.talk(player);
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class Menu method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
UPlayer player = new UPlayer(sender);
new MainMenu(player).open();
return true;
} else {
sender.sendMessage(Message.NOT_A_PLAYER.toString());
return true;
}
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class MsgCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Message.NOT_A_PLAYER.toString());
return true;
}
UPlayer player = new UPlayer(sender);
// If player is muted don't send private message
if (Chat.IS_MUTED.get(player.getUniqueId())) {
player.sendMessage(Message.CANT_PM_MUTED);
return true;
}
if (args.length >= 2) {
UPlayer target;
try {
target = new UPlayer(args[0]);
} catch (PlayerNotFoundException e1) {
player.sendMessage(Message.PLAYER_NOT_FOUND);
return true;
}
List<String> list = new ArrayList<String>();
for (int x = 1; x < args.length; x++) {
list.add(args[x]);
}
String msg = String.join(" ", list);
// Play a sound if the target player has enabled sounds.
if (target.getSetting(Setting.PM_SOUND)) {
target.playSound(Sound.ENTITY_ITEM_PICKUP);
}
target.setLastSender(player);
target.sendPrivateMessage(player, msg);
return true;
} else {
player.sendMessage(Message.WRONG_USAGE);
return true;
}
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class MuteCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Message.NOT_A_PLAYER.toString());
return true;
}
UPlayer player = new UPlayer(sender);
if (player.hasPermission(Permission.COMMAND_MUTE)) {
player.sendMessage(Message.NO_PERMISSION);
return true;
}
if (args.length == 1) {
UPlayer target;
try {
target = new UPlayer(args[0]);
} catch (PlayerNotFoundException e) {
player.sendMessage(Message.PLAYER_NOT_FOUND);
return true;
}
UUID uuid = target.getUniqueId();
String targetName = target.getName();
String playerName = player.getName();
if (Chat.IS_MUTED.get(uuid)) {
player.sendPrefixedMessage("Chat", targetName + " has been unmuted.");
target.sendPrefixedMessage("Chat", "You have been unmuted by " + playerName);
Chat.IS_MUTED.put(uuid, false);
return true;
} else {
player.sendPrefixedMessage("Chat", targetName + " has been muted.");
target.sendPrefixedMessage("Chat", "You have been muted by " + playerName);
Chat.IS_MUTED.put(uuid, true);
return true;
}
} else if (args.length == 2 && args[0].equalsIgnoreCase("soft")) {
UPlayer target;
try {
target = new UPlayer(args[1]);
} catch (PlayerNotFoundException e) {
player.sendMessage(Message.PLAYER_NOT_FOUND);
return true;
}
UUID uuid = target.getUniqueId();
String targetName = target.getName();
String playerName = player.getName();
if (Chat.IS_SOFT_MUTED.get(uuid)) {
player.sendPrefixedMessage("Chat", targetName + " has been un-soft-muted.");
target.sendPrefixedMessage("Chat", "You have been un-soft-muted by " + playerName);
Chat.IS_MUTED.put(uuid, false);
return true;
} else {
player.sendPrefixedMessage("Chat", targetName + " has been soft-muted.");
target.sendPrefixedMessage("Chat", "You have been soft-muted by " + playerName);
Chat.IS_MUTED.put(uuid, true);
return true;
}
} else {
player.sendMessage(Message.WRONG_USAGE);
return true;
}
}
Aggregations