Working on messaging

This commit is contained in:
Eric Stokes 2011-09-18 13:04:37 -06:00
parent 30704338e6
commit 9333f70add
2 changed files with 31 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}