mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 04:37:37 +00:00
Merge branch 'master' of https://github.com/StevenLawson/TotalFreedomMod
This commit is contained in:
commit
165c949744
@ -4,10 +4,10 @@ import org.bukkit.ChatColor;
|
||||
|
||||
public class CantFindPlayerException extends Exception
|
||||
{
|
||||
// apparently, java needs this
|
||||
private static final long serialVersionUID = 1L;
|
||||
// apparently, java needs this
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CantFindPlayerException()
|
||||
public CantFindPlayerException()
|
||||
{
|
||||
super(ChatColor.GRAY + "Can't find player.");
|
||||
}
|
||||
|
@ -37,13 +37,13 @@ public class Command_fr extends TFM_Command
|
||||
if (args[0].toLowerCase().equals("purge"))
|
||||
{
|
||||
TotalFreedomMod.allPlayersFrozen = false;
|
||||
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
||||
playerdata.setFrozen(false);
|
||||
}
|
||||
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Lifting all global and player freezes", false);
|
||||
}
|
||||
else
|
||||
|
@ -33,7 +33,7 @@ public class Command_gtfo extends TFM_Command
|
||||
}
|
||||
|
||||
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||
|
||||
|
||||
//Undo WorldEdits:
|
||||
if (senderIsConsole)
|
||||
{
|
||||
@ -42,7 +42,7 @@ public class Command_gtfo extends TFM_Command
|
||||
{
|
||||
server.dispatchCommand(sender, String.format("/undo %d %s", 15, p.getName()));
|
||||
}
|
||||
|
||||
|
||||
// deop
|
||||
p.setOp(false);
|
||||
|
||||
|
@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
@ -14,33 +13,33 @@ public class Command_ops extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!(senderIsConsole || sender.isOp()))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(senderIsConsole || sender.isOp()))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 1 || args.length > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
String ops = "";
|
||||
String delim = "";
|
||||
for (OfflinePlayer p : server.getOperators()) {
|
||||
ops += delim;
|
||||
ops += p.getName();
|
||||
String ops = "";
|
||||
String delim = "";
|
||||
for (OfflinePlayer p : server.getOperators())
|
||||
{
|
||||
ops += delim;
|
||||
ops += p.getName();
|
||||
delim = ",";
|
||||
}
|
||||
|
||||
|
||||
TFM_Util.playerMsg(sender, "Operators: " + ops);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (args[0].equalsIgnoreCase("count"))
|
||||
{
|
||||
int onlineOPs = 0;
|
||||
@ -63,10 +62,10 @@ public class Command_ops extends TFM_Command
|
||||
sender.sendMessage(ChatColor.GRAY + "Online OPs: " + onlineOPs);
|
||||
sender.sendMessage(ChatColor.GRAY + "Offline OPs: " + offlineOPs);
|
||||
sender.sendMessage(ChatColor.GRAY + "Total OPs: " + totalOPs);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
if (!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole))
|
||||
@ -86,7 +85,7 @@ public class Command_ops extends TFM_Command
|
||||
p.getPlayer().sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -16,10 +16,19 @@ public class Command_qdeop extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
|
||||
if (!(senderIsConsole || sender.isOp()))
|
||||
{
|
||||
boolean matched_player = false;
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean matched_player = false;
|
||||
|
||||
String target_name = args[0].toLowerCase();
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (p.getName().toLowerCase().indexOf(target_name) > 0 || p.getDisplayName().toLowerCase().indexOf(target_name) > 0)
|
||||
{
|
||||
matched_player = true;
|
||||
|
||||
@ -27,25 +36,11 @@ public class Command_qdeop extends TFM_Command
|
||||
p.setOp(false);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
}
|
||||
if (!matched_player)
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (args[0].toLowerCase().startsWith(p.getDisplayName().toLowerCase()))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "De-opping " + p.getName(), false);
|
||||
p.setOp(false);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sender.sendMessage("No targets matched.");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (!matched_player)
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
TFM_Util.playerMsg(sender, "No targets matched.");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -18,24 +18,29 @@ public class Command_qop extends TFM_Command
|
||||
|
||||
if (!(senderIsConsole || sender.isOp()))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean matched_player = false;
|
||||
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
matched_player = true;
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Opping " + p.getName(), false);
|
||||
p.setOp(true);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
||||
boolean matched_player = false;
|
||||
|
||||
String target_name = args[0].toLowerCase();
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (p.getName().toLowerCase().indexOf(target_name) > 0 || p.getDisplayName().toLowerCase().indexOf(target_name) > 0)
|
||||
{
|
||||
matched_player = true;
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Opping " + p.getName(), false);
|
||||
p.setOp(true);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!matched_player)
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "No targets matched.");
|
||||
TFM_Util.playerMsg(sender, "No targets matched.");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class TFM_BlockListener implements Listener
|
||||
{
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockBurn(BlockBurnEvent event)
|
||||
{
|
||||
@ -78,7 +77,7 @@ public class TFM_BlockListener implements Listener
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||
|
||||
|
||||
playerdata.resetBlockDestroyCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -129,7 +128,7 @@ public class TFM_BlockListener implements Listener
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "You are placing blocks too fast.");
|
||||
|
||||
|
||||
playerdata.resetBlockPlaceCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -146,14 +145,14 @@ public class TFM_BlockListener implements Listener
|
||||
if (TotalFreedomMod.allowLavaPlace)
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed lava @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
|
||||
p.getInventory().clear(p.getInventory().getHeldItemSlot());
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
p.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -165,14 +164,14 @@ public class TFM_BlockListener implements Listener
|
||||
if (TotalFreedomMod.allowWaterPlace)
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed water @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
|
||||
p.getInventory().clear(p.getInventory().getHeldItemSlot());
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
p.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -183,14 +182,14 @@ public class TFM_BlockListener implements Listener
|
||||
if (TotalFreedomMod.allowFirePlace)
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed fire @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
|
||||
p.getInventory().clear(p.getInventory().getHeldItemSlot());
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
p.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -201,13 +200,13 @@ public class TFM_BlockListener implements Listener
|
||||
if (TotalFreedomMod.allowExplosions)
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed TNT @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
|
||||
p.getInventory().clear(p.getInventory().getHeldItemSlot());
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
|
||||
|
||||
p.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -216,7 +215,7 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockFromTo(BlockFromToEvent event)
|
||||
{
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.event.entity.*;
|
||||
|
||||
public class TFM_EntityListener implements Listener
|
||||
{
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
@ -120,7 +119,7 @@ public class TFM_EntityListener implements Listener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
|
@ -27,7 +27,6 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
@ -301,12 +300,11 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
try
|
||||
{
|
||||
String m = event.getMessage();
|
||||
Player p = event.getPlayer();
|
||||
final Player p = event.getPlayer();
|
||||
|
||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
||||
playerdata.incrementMsgCount();
|
||||
|
||||
|
||||
// check for spam
|
||||
if (playerdata.getMsgCount() > 10)
|
||||
{
|
||||
@ -337,28 +335,37 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
String message = event.getMessage().trim();
|
||||
|
||||
// strip color from messages
|
||||
message = ChatColor.stripColor(message);
|
||||
|
||||
// truncate messages that are too long
|
||||
if (m.length() > 95)
|
||||
if (message.length() > 95)
|
||||
{
|
||||
event.setMessage(m.substring(0, 95));
|
||||
message = message.substring(0, 95);
|
||||
TFM_Util.playerMsg(p, "Message was shortened, because it was too long to send.");
|
||||
}
|
||||
|
||||
|
||||
// check for caps
|
||||
int caps = 0;
|
||||
for (int i=0; i<m.length(); i++)
|
||||
{
|
||||
if (Character.isUpperCase(m.charAt(i)))
|
||||
caps++;
|
||||
}
|
||||
if(caps > 6)
|
||||
{
|
||||
event.setMessage(m.toLowerCase());
|
||||
}
|
||||
|
||||
// strip color from messages
|
||||
event.setMessage(ChatColor.stripColor(event.getMessage()));
|
||||
|
||||
if (message.length() >= 6)
|
||||
{
|
||||
int caps = 0;
|
||||
for (char c : message.toCharArray())
|
||||
{
|
||||
if (Character.isUpperCase(c))
|
||||
{
|
||||
caps++;
|
||||
}
|
||||
}
|
||||
if (((float) caps / (float) message.length()) > 0.75) //Compute a ratio so that longer sentences can have more caps.
|
||||
{
|
||||
message = message.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
// finally, set message
|
||||
event.setMessage(message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -607,7 +614,7 @@ public class TFM_PlayerListener implements Listener
|
||||
boolean is_ip_banned = false;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator ip_bans = banByIP.getEntries().keySet().iterator();
|
||||
Iterator ip_bans = banByIP.getEntries().keySet().iterator();
|
||||
while (ip_bans.hasNext())
|
||||
{
|
||||
String test_ip = (String) ip_bans.next();
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
|
||||
public class TFM_WeatherListener implements Listener
|
||||
{
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onThunderChange(ThunderChangeEvent event)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user