use of mc.dragons.core.gameobject.user.UserHook in project DragonsOnline by UniverseCraft.
the class PlayerEventListeners method onDeath.
@EventHandler
public void onDeath(PlayerDeathEvent event) {
LOGGER.debug("Death event from " + event.getEntity().getName());
Player player = event.getEntity();
final User user = UserLoader.fromPlayer(player);
if (user == null)
return;
user.debug("death!");
player.sendMessage(ChatColor.DARK_RED + "You died!");
final int countdown = plugin.getServerOptions().getDeathCountdown();
boolean normal = true;
for (UserHook hook : userHookRegistry.getHooks()) {
if (!hook.onDeath(user)) {
normal = false;
}
}
user.debug("-normal=" + normal);
boolean fNormal = normal;
sync(() -> {
if (fNormal) {
user.sendToFloor("BeginnerTown");
}
user.respawn();
if (fNormal) {
user.getPlayer().sendTitle(ChatColor.RED + "< " + ChatColor.DARK_RED + "You are dead" + ChatColor.RED + " >", ChatColor.GRAY + "Respawning on floor 1", 0, 20 * (countdown - 2), 40);
user.setDeathCountdown(countdown);
}
}, 1);
}
use of mc.dragons.core.gameobject.user.UserHook in project DragonsOnline by UniverseCraft.
the class PrivateMessageCommands method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!requirePlayer(sender))
return true;
User user = user(sender);
if (!user.hasJoined()) {
sender.sendMessage(ChatColor.RED + "You are not joined yet!");
return true;
}
String message = StringUtil.concatArgs(args, 1);
for (UserHook hook : dragons.getUserHookRegistry().getHooks()) {
if (!hook.checkAllowChat(user, message)) {
return true;
}
}
if (user.hasActiveDialogue()) {
sender.sendMessage(ChatColor.RED + "Chat is unavailable while in active dialogue!");
return true;
}
if (label.equalsIgnoreCase("msg") || label.equalsIgnoreCase("tell") || label.equalsIgnoreCase("whisper") || label.equalsIgnoreCase("m") || label.equalsIgnoreCase("t") || label.equalsIgnoreCase("w")) {
if (args.length < 2) {
if (!label.equalsIgnoreCase("msg"))
sender.sendMessage(ChatColor.RED + "Alias for /msg.");
sender.sendMessage(ChatColor.RED + "/msg <player> <message>");
return true;
}
privateMessageCommand(user, args[0], message);
return true;
} else if (label.equalsIgnoreCase("reply") || label.equalsIgnoreCase("re") || label.equalsIgnoreCase("r")) {
if (!requirePlayer(sender))
return true;
if (args.length == 0) {
if (!label.equalsIgnoreCase("reply"))
sender.sendMessage(ChatColor.RED + "Alias for /reply.");
sender.sendMessage(ChatColor.RED + "/reply <message>");
return true;
}
String target = user.getLastReceivedMessageFrom();
message = StringUtil.concatArgs(args, 0);
if (target == null) {
sender.sendMessage(ChatColor.RED + "You don't have anyone to reply to!");
return true;
}
privateMessageCommand(user, target, message);
return true;
} else if (label.equalsIgnoreCase("togglemsg")) {
boolean all = user.getData().getBoolean("messageFriendsOnly", false);
user.getStorageAccess().set("messageFriendsOnly", !all);
sender.sendMessage(ChatColor.GREEN + "Set messaging capability to " + (all ? "EVERYONE" : "FRIENDS ONLY"));
if (!all) {
sender.sendMessage(ChatColor.GRAY + " You'll still be able to send and receive messages from staff members.");
}
} else if (label.equalsIgnoreCase("chatspy")) {
if (!requirePlayer(sender) || !requirePermission(sender, PermissionLevel.ADMIN) || !requirePermission(sender, SystemProfileFlag.MODERATION))
return true;
user.setChatSpy(!user.hasChatSpy());
sender.sendMessage(ChatColor.GREEN + "Chat spy " + (user.hasChatSpy() ? "enabled" : "disabled"));
return true;
} else if (label.equalsIgnoreCase("toggleselfmessage")) {
if (!requirePlayer(sender) || !requirePermission(sender, PermissionLevel.DEVELOPER))
return true;
user.getLocalData().append("canSelfMessage", !user.getLocalData().getBoolean("canSelfMessage", false));
sender.sendMessage(ChatColor.GREEN + "Toggled self-messaging ability.");
}
return true;
}
Aggregations