Changed to use Utils sendMessage, now canceling event when setting ds
This commit is contained in:
parent
907c68525b
commit
311d871bf9
@ -12,7 +12,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -34,10 +33,11 @@ import com.nemez.cmdmgr.Command;
|
|||||||
import com.redstoner.annotations.AutoRegisterListener;
|
import com.redstoner.annotations.AutoRegisterListener;
|
||||||
import com.redstoner.annotations.Version;
|
import com.redstoner.annotations.Version;
|
||||||
import com.redstoner.misc.Main;
|
import com.redstoner.misc.Main;
|
||||||
|
import com.redstoner.misc.Utils;
|
||||||
import com.redstoner.modules.Module;
|
import com.redstoner.modules.Module;
|
||||||
|
|
||||||
@AutoRegisterListener
|
@AutoRegisterListener
|
||||||
@Version(major = 1, minor = 1, revision = 0, compatible = 1)
|
@Version(major = 1, minor = 1, revision = 1, compatible = 1)
|
||||||
public class DamnSpam implements Module, Listener
|
public class DamnSpam implements Module, Listener
|
||||||
{
|
{
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
@ -142,12 +142,10 @@ public class DamnSpam implements Module, Listener
|
|||||||
destroyingInput = true;
|
destroyingInput = true;
|
||||||
else if (!isAcceptableTimeout(seconds))
|
else if (!isAcceptableTimeout(seconds))
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
Utils.sendMessage(sender, null, "&cThe timeout must be -1 or within 0 and " + maxTimeout, '&');
|
||||||
"&cThe timeout must be -1 or within 0 and " + maxTimeout));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(
|
Utils.sendMessage(sender, null, "&aPlease click the input you would like to set.", '&');
|
||||||
ChatColor.translateAlternateColorCodes('&', "&aPlease click the input you would like to set."));
|
|
||||||
setPlayer((Player) sender, destroyingInput, seconds, seconds);
|
setPlayer((Player) sender, destroyingInput, seconds, seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,12 +161,10 @@ public class DamnSpam implements Module, Listener
|
|||||||
}
|
}
|
||||||
else if (!(isAcceptableTimeout(secondsOn) && isAcceptableTimeout(secondsOff)))
|
else if (!(isAcceptableTimeout(secondsOn) && isAcceptableTimeout(secondsOff)))
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
Utils.sendMessage(sender, null, "&cThe timeout must be -1 or within 0 and " + maxTimeout, '&');
|
||||||
"&cThe timeout must be -1 or within 0 and " + maxTimeout));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(
|
Utils.sendMessage(sender, null, "&aPlease click the input you would like to set.", '&');
|
||||||
ChatColor.translateAlternateColorCodes('&', "&aPlease click the input you would like to set."));
|
|
||||||
setPlayer((Player) sender, destroyingInput, secondsOff, secondsOn);
|
setPlayer((Player) sender, destroyingInput, secondsOff, secondsOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,8 +184,7 @@ public class DamnSpam implements Module, Listener
|
|||||||
{
|
{
|
||||||
if (!acceptedInputs.contains(block.getType()))
|
if (!acceptedInputs.contains(block.getType()))
|
||||||
{
|
{
|
||||||
player.sendMessage(
|
Utils.sendMessage(player, null, "&cThat block is not an acceptable input!", '&');
|
||||||
ChatColor.translateAlternateColorCodes('&', "&cThat block is not an acceptable input!"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String typeStr = block.getType().toString().toLowerCase().replace("_", " ");
|
String typeStr = block.getType().toString().toLowerCase().replace("_", " ");
|
||||||
@ -199,8 +194,8 @@ public class DamnSpam implements Module, Listener
|
|||||||
changingInput = false;
|
changingInput = false;
|
||||||
if (!buildCheck)
|
if (!buildCheck)
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
Utils.sendMessage(player, null,
|
||||||
"&cThere is no timeout to remove on this " + typeStr + "(by setting the timeout to 0)"));
|
"&cThere is no timeout to remove on this " + typeStr + "(by setting the timeout to 0)", '&');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SpamInput input = players.get(player);
|
SpamInput input = players.get(player);
|
||||||
@ -208,20 +203,20 @@ public class DamnSpam implements Module, Listener
|
|||||||
{
|
{
|
||||||
if (!inputs.containsKey(locationStr))
|
if (!inputs.containsKey(locationStr))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
Utils.sendMessage(player, null,
|
||||||
"&cThere is no timeout to remove on this " + typeStr + "(by setting the timeout to 0)"));
|
"&cThere is no timeout to remove on this " + typeStr + "(by setting the timeout to 0)",
|
||||||
|
'&');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
inputs.remove(locationStr);
|
inputs.remove(locationStr);
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
Utils.sendMessage(player, null, "&aSuccessfully removed the timeout for this " + typeStr, '&');
|
||||||
"&aSuccessfully removed the timeout for this " + typeStr));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
inputs.put(locationStr, players.get(player));
|
inputs.put(locationStr, players.get(player));
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
Utils.sendMessage(player, null, "&aSuccessfully set a timeout for this " + typeStr, '&');
|
||||||
"&aSuccessfully set a timeout for this " + typeStr));
|
|
||||||
}
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
players.remove(player);
|
players.remove(player);
|
||||||
saveInputs();
|
saveInputs();
|
||||||
return true;
|
return true;
|
||||||
@ -243,9 +238,9 @@ public class DamnSpam implements Module, Listener
|
|||||||
: "the " + typeStr + " attached to that block");
|
: "the " + typeStr + " attached to that block");
|
||||||
if (!sender.isSneaking())
|
if (!sender.isSneaking())
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou cannot destroy " + inputStr));
|
Utils.sendMessage(sender, null, "&cYou cannot destroy " + inputStr, '&');
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
Utils.sendMessage(sender, "", "&c&nSneak&c and break or set the timeout to 0 if you want to remove it.",
|
||||||
"&c&nSneak&c and break or set the timeout to 0 if you want to remove it."));
|
'&');
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -253,12 +248,11 @@ public class DamnSpam implements Module, Listener
|
|||||||
{
|
{
|
||||||
inputs.remove(posStr);
|
inputs.remove(posStr);
|
||||||
saveInputs();
|
saveInputs();
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSuccesfully removed " + inputStr));
|
Utils.sendMessage(sender, null, "&aSuccesfully removed " + inputStr, '&');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage(
|
Utils.sendMessage(sender, null, "&cYou are not allowed to remove " + inputStr, '&');
|
||||||
ChatColor.translateAlternateColorCodes('&', "&cYou are not allowed to remove " + inputStr));
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,14 +327,13 @@ public class DamnSpam implements Module, Listener
|
|||||||
if (checktime == -1)
|
if (checktime == -1)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
Utils.sendMessage(sender, null, "&cThis " + btype + " is locked permanently by /damnspam.", '&');
|
||||||
"&cThis " + btype + " is locked permanently by /damnspam."));
|
|
||||||
}
|
}
|
||||||
else if (timeLeft > 0)
|
else if (timeLeft > 0)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cThis " + btype
|
Utils.sendMessage(sender, null, "&cThis " + btype + " has a damnspam timeout of " + checktime
|
||||||
+ " has a damnspam timeout of " + checktime + ", with " + timeLeft + " left."));
|
+ ", with " + timeLeft + " left.", '&');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user