mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-07 03:11:02 +01:00
Working on messaging
This commit is contained in:
parent
30704338e6
commit
9333f70add
@ -158,16 +158,15 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
private boolean checkSendPermissions(CommandSender teleporter, Player teleportee, MVDestination destination) {
|
||||
MVMessaging message = this.plugin.getMessaging();
|
||||
if (teleporter.equals(teleportee)) {
|
||||
if(!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.teleport.self."+destination.getIdentifier(),true)) {
|
||||
teleporter.sendMessage("You don't have permission to teleport yourself to a " + ChatColor.GREEN + destination.getType() + " Destination.");
|
||||
teleporter.sendMessage(ChatColor.RED + " (multiverse.teleport.self."+destination.getIdentifier()+")");
|
||||
message.sendMessages(teleporter, new String[] {"You don't have permission to teleport yourself to a " + ChatColor.GREEN + destination.getType() + " Destination.", ChatColor.RED + " (multiverse.teleport.self."+destination.getIdentifier()+")"});
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.teleport.other."+destination.getIdentifier(),true)) {
|
||||
teleporter.sendMessage("You don't have permission to teleport another player to a " + ChatColor.GREEN + destination.getType() + " Destination.");
|
||||
teleporter.sendMessage(ChatColor.RED + " (multiverse.teleport.other."+destination.getIdentifier()+")");
|
||||
message.sendMessages(teleporter, new String[] {"You don't have permission to teleport another player to a " + ChatColor.GREEN + destination.getType() + " Destination.",ChatColor.RED + " (multiverse.teleport.other."+destination.getIdentifier()+")"});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,35 @@ public class MVMessaging {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown) {
|
||||
if(!(sender instanceof Player) || ignoreCooldown) {
|
||||
|
||||
this.sendMessages(sender, messages);
|
||||
return true;
|
||||
}
|
||||
if(!this.sentList.containsKey(sender.getName())) {
|
||||
this.sendMessages(sender, messages);
|
||||
this.sentList.put(sender.getName(), new Date());
|
||||
return true;
|
||||
} else {
|
||||
if(this.sentList.get(sender.getName()).after(new Date((new Date()).getTime() + this.cooldown))){
|
||||
this.sendMessages(sender, messages);
|
||||
this.sentList.put(sender.getName(), new Date());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendMessage(CommandSender sender, String message) {
|
||||
return this.sendMessage(sender, message, true);
|
||||
}
|
||||
|
||||
public boolean sendMessages(CommandSender sender, String[] messages) {
|
||||
boolean success = true;
|
||||
for(String s : messages) {
|
||||
success = (!(!this.sendMessage(sender, s, true) && success));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user