mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-16 12:26:12 +00:00
Misc
This commit is contained in:
parent
84dbc63f86
commit
90bb21b79e
@ -45,17 +45,25 @@ public class TFM_BlockListener extends BlockListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (plugin.nukeMonitor)
|
if (plugin.nukeMonitor)
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
|
TFM_UserInfo playerdata = (TFM_UserInfo) plugin.userinfo.get(p);
|
||||||
|
if (playerdata == null)
|
||||||
|
{
|
||||||
|
playerdata = new TFM_UserInfo();
|
||||||
|
plugin.userinfo.put(p, playerdata);
|
||||||
|
}
|
||||||
|
|
||||||
Location player_pos = p.getLocation();
|
Location player_pos = p.getLocation();
|
||||||
Location block_pos = event.getBlock().getLocation();
|
Location block_pos = event.getBlock().getLocation();
|
||||||
|
|
||||||
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
|
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
|
||||||
|
{
|
||||||
|
playerdata.incrementFreecamDestroyCount();
|
||||||
|
if (playerdata.getFreecamPlaceCount() > plugin.freecamTriggerCount)
|
||||||
{
|
{
|
||||||
p.setOp(false);
|
p.setOp(false);
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
@ -63,16 +71,15 @@ public class TFM_BlockListener extends BlockListener
|
|||||||
|
|
||||||
plugin.tfm_broadcastMessage(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
plugin.tfm_broadcastMessage(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
||||||
|
|
||||||
|
playerdata.resetFreecamDestroyCount();
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TFM_UserInfo playerdata = (TFM_UserInfo) plugin.userinfo.get(p);
|
|
||||||
if (playerdata != null)
|
|
||||||
{
|
|
||||||
playerdata.incrementBlockDestroyCount();
|
playerdata.incrementBlockDestroyCount();
|
||||||
|
if (playerdata.getBlockDestroyCount() > plugin.nukeMonitorCountBreak)
|
||||||
if (playerdata.getBlockDestroyCount() > plugin.nukeMonitorCount)
|
|
||||||
{
|
{
|
||||||
plugin.tfm_broadcastMessage(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
plugin.tfm_broadcastMessage(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||||
|
|
||||||
@ -84,26 +91,45 @@ public class TFM_BlockListener extends BlockListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
playerdata = new TFM_UserInfo();
|
|
||||||
playerdata.incrementBlockDestroyCount();
|
|
||||||
plugin.userinfo.put(p, playerdata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
log.info("Exception in TFM Block Listener onBlockBreak: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData());
|
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
|
if (plugin.nukeMonitor)
|
||||||
|
{
|
||||||
|
Location player_pos = p.getLocation();
|
||||||
|
Location block_pos = event.getBlock().getLocation();
|
||||||
|
|
||||||
|
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
|
||||||
|
{
|
||||||
|
TFM_UserInfo playerdata = (TFM_UserInfo) plugin.userinfo.get(p);
|
||||||
|
if (playerdata == null)
|
||||||
|
{
|
||||||
|
playerdata = new TFM_UserInfo();
|
||||||
|
plugin.userinfo.put(p, playerdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerdata.incrementFreecamPlaceCount();
|
||||||
|
if (playerdata.getFreecamPlaceCount() > plugin.freecamTriggerCount)
|
||||||
|
{
|
||||||
|
p.setOp(false);
|
||||||
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
|
p.getInventory().clear();
|
||||||
|
|
||||||
|
plugin.tfm_broadcastMessage(p.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
|
||||||
|
|
||||||
|
playerdata.resetFreecamPlaceCount();
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData());
|
||||||
if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA)
|
if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA)
|
||||||
{
|
{
|
||||||
if (plugin.allowLavaPlace)
|
if (plugin.allowLavaPlace)
|
||||||
|
@ -320,7 +320,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
|||||||
|
|
||||||
if (args.length >= 3)
|
if (args.length >= 3)
|
||||||
{
|
{
|
||||||
plugin.nukeMonitorCount = Integer.parseInt(args[2]);
|
plugin.nukeMonitorCountBreak = Integer.parseInt(args[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("on"))
|
if (args[0].equalsIgnoreCase("on"))
|
||||||
@ -328,7 +328,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
|||||||
plugin.nukeMonitor = true;
|
plugin.nukeMonitor = true;
|
||||||
sender.sendMessage(ChatColor.GRAY + "Nuke monitor is enabled.");
|
sender.sendMessage(ChatColor.GRAY + "Nuke monitor is enabled.");
|
||||||
sender.sendMessage(ChatColor.GRAY + "Anti-freecam range is set to " + plugin.nukeMonitorRange + " blocks.");
|
sender.sendMessage(ChatColor.GRAY + "Anti-freecam range is set to " + plugin.nukeMonitorRange + " blocks.");
|
||||||
sender.sendMessage(ChatColor.GRAY + "Block throttle rate is set to " + plugin.nukeMonitorCount + " blocks destroyed per 5 seconds.");
|
sender.sendMessage(ChatColor.GRAY + "Block throttle rate is set to " + plugin.nukeMonitorCountBreak + " blocks destroyed per 5 seconds.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -339,7 +339,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
|||||||
TotalFreedomMod.CONFIG.load();
|
TotalFreedomMod.CONFIG.load();
|
||||||
TotalFreedomMod.CONFIG.setProperty("nuke_monitor", plugin.nukeMonitor);
|
TotalFreedomMod.CONFIG.setProperty("nuke_monitor", plugin.nukeMonitor);
|
||||||
TotalFreedomMod.CONFIG.setProperty("nuke_monitor_range", plugin.nukeMonitorRange);
|
TotalFreedomMod.CONFIG.setProperty("nuke_monitor_range", plugin.nukeMonitorRange);
|
||||||
TotalFreedomMod.CONFIG.setProperty("nuke_monitor_count", plugin.nukeMonitorCount);
|
TotalFreedomMod.CONFIG.setProperty("nuke_monitor_count", plugin.nukeMonitorCountBreak);
|
||||||
TotalFreedomMod.CONFIG.save();
|
TotalFreedomMod.CONFIG.save();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -543,6 +543,34 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
|||||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (cmd.getName().equalsIgnoreCase("csay"))
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
String sender_name = sender.getName();
|
||||||
|
|
||||||
|
if (sender_name.equalsIgnoreCase("remotebukkit"))
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender_name = sender_name.split("-")[0];
|
||||||
|
|
||||||
|
StringBuilder outmessage_bldr = new StringBuilder();
|
||||||
|
for (int i = 0; i < args.length; i++)
|
||||||
|
{
|
||||||
|
outmessage_bldr.append(args[i]).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.tfm_broadcastMessage(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender_name, outmessage_bldr.toString().trim()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,6 @@ class TFM_PlayerListener extends PlayerListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
@ -96,11 +94,6 @@ class TFM_PlayerListener extends PlayerListener
|
|||||||
event.setTo(to);
|
event.setTo(to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
log.severe("Exception in TFM Player Listener onMove: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerChat(PlayerChatEvent event)
|
public void onPlayerChat(PlayerChatEvent event)
|
||||||
@ -141,7 +134,7 @@ class TFM_PlayerListener extends PlayerListener
|
|||||||
log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command));
|
log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command));
|
||||||
}
|
}
|
||||||
|
|
||||||
command = command.toLowerCase();
|
command = command.toLowerCase().trim();
|
||||||
|
|
||||||
boolean block_command = false;
|
boolean block_command = false;
|
||||||
|
|
||||||
@ -171,49 +164,49 @@ class TFM_PlayerListener extends PlayerListener
|
|||||||
{
|
{
|
||||||
block_command = true;
|
block_command = true;
|
||||||
}
|
}
|
||||||
else if (command.matches("^/mv\\s?create"))
|
else if (command.matches("^/mv\\s*c"))
|
||||||
{
|
{
|
||||||
if (!plugin.isUserSuperadmin(player))
|
if (!plugin.isUserSuperadmin(player))
|
||||||
{
|
{
|
||||||
block_command = true;
|
block_command = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command.matches("^/mv\\s?import"))
|
else if (command.matches("^/mv\\s*delete"))
|
||||||
{
|
{
|
||||||
if (!plugin.isUserSuperadmin(player))
|
if (!plugin.isUserSuperadmin(player))
|
||||||
{
|
{
|
||||||
block_command = true;
|
block_command = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command.matches("^/mv\\s?unload"))
|
else if (command.matches("^/mv\\s*im"))
|
||||||
{
|
{
|
||||||
if (!plugin.isUserSuperadmin(player))
|
if (!plugin.isUserSuperadmin(player))
|
||||||
{
|
{
|
||||||
block_command = true;
|
block_command = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command.matches("^/mv\\s?remove"))
|
else if (command.matches("^/mv\\s*m"))
|
||||||
{
|
{
|
||||||
if (!plugin.isUserSuperadmin(player))
|
if (!plugin.isUserSuperadmin(player))
|
||||||
{
|
{
|
||||||
block_command = true;
|
block_command = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command.matches("^/mv\\s?delete"))
|
else if (command.matches("^/mv\\s*reload"))
|
||||||
{
|
{
|
||||||
if (!plugin.isUserSuperadmin(player))
|
if (!plugin.isUserSuperadmin(player))
|
||||||
{
|
{
|
||||||
block_command = true;
|
block_command = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command.matches("^/mv\\s?confirm"))
|
else if (command.matches("^/mv\\s*remove"))
|
||||||
{
|
{
|
||||||
if (!plugin.isUserSuperadmin(player))
|
if (!plugin.isUserSuperadmin(player))
|
||||||
{
|
{
|
||||||
block_command = true;
|
block_command = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command.matches("^/mv\\s?modify"))
|
else if (command.matches("^/mv\\s*unload"))
|
||||||
{
|
{
|
||||||
if (!plugin.isUserSuperadmin(player))
|
if (!plugin.isUserSuperadmin(player))
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,10 @@ public class TFM_UserInfo
|
|||||||
{
|
{
|
||||||
private boolean user_frozen = false;
|
private boolean user_frozen = false;
|
||||||
private int msg_count = 0;
|
private int msg_count = 0;
|
||||||
private int bd_count = 0;
|
private int block_destroy_total = 0;
|
||||||
|
|
||||||
|
private int freecam_destroy_count = 0;
|
||||||
|
private int freecam_place_count = 0;
|
||||||
|
|
||||||
public TFM_UserInfo()
|
public TFM_UserInfo()
|
||||||
{
|
{
|
||||||
@ -37,16 +40,46 @@ public class TFM_UserInfo
|
|||||||
|
|
||||||
public void incrementBlockDestroyCount()
|
public void incrementBlockDestroyCount()
|
||||||
{
|
{
|
||||||
this.bd_count++;
|
this.block_destroy_total++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBlockDestroyCount()
|
public int getBlockDestroyCount()
|
||||||
{
|
{
|
||||||
return this.bd_count;
|
return this.block_destroy_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetBlockDestroyCount()
|
public void resetBlockDestroyCount()
|
||||||
{
|
{
|
||||||
this.bd_count = 0;
|
this.block_destroy_total = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementFreecamDestroyCount()
|
||||||
|
{
|
||||||
|
this.freecam_destroy_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFreecamDestroyCount()
|
||||||
|
{
|
||||||
|
return this.freecam_destroy_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetFreecamDestroyCount()
|
||||||
|
{
|
||||||
|
this.freecam_destroy_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementFreecamPlaceCount()
|
||||||
|
{
|
||||||
|
this.freecam_place_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFreecamPlaceCount()
|
||||||
|
{
|
||||||
|
return this.freecam_place_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetFreecamPlaceCount()
|
||||||
|
{
|
||||||
|
this.freecam_place_count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,10 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public boolean autoEntityWipe = false;
|
public boolean autoEntityWipe = false;
|
||||||
public double explosiveRadius = 4.0D;
|
public double explosiveRadius = 4.0D;
|
||||||
public boolean nukeMonitor = true;
|
public boolean nukeMonitor = true;
|
||||||
public int nukeMonitorCount = 40;
|
public int nukeMonitorCountBreak = 40;
|
||||||
public double nukeMonitorRange = 10.0D;
|
public double nukeMonitorRange = 10.0D;
|
||||||
public Boolean preprocessLogEnabled = false;
|
public Boolean preprocessLogEnabled = false;
|
||||||
|
public int freecamTriggerCount = 10;
|
||||||
|
|
||||||
public boolean allPlayersFrozen = false;
|
public boolean allPlayersFrozen = false;
|
||||||
public HashMap userinfo = new HashMap();
|
public HashMap userinfo = new HashMap();
|
||||||
@ -201,7 +202,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
{
|
{
|
||||||
for (Entity ent : world.getEntities())
|
for (Entity ent : world.getEntities())
|
||||||
{
|
{
|
||||||
if (ent instanceof Arrow || ent instanceof TNTPrimed || ent instanceof Item || ent instanceof ExperienceOrb)
|
if (ent instanceof Arrow || (ent instanceof TNTPrimed && !this.allowExplosions) || ent instanceof Item || ent instanceof ExperienceOrb)
|
||||||
{
|
{
|
||||||
ent.remove();
|
ent.remove();
|
||||||
removed++;
|
removed++;
|
||||||
@ -237,6 +238,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
CONFIG.setProperty("nuke_monitor_count", 40);
|
CONFIG.setProperty("nuke_monitor_count", 40);
|
||||||
CONFIG.setProperty("nuke_monitor_range", 10.0D);
|
CONFIG.setProperty("nuke_monitor_range", 10.0D);
|
||||||
CONFIG.setProperty("preprocess_log", false);
|
CONFIG.setProperty("preprocess_log", false);
|
||||||
|
CONFIG.setProperty("freecam_trigger_count", 10);
|
||||||
CONFIG.save();
|
CONFIG.save();
|
||||||
}
|
}
|
||||||
CONFIG.load();
|
CONFIG.load();
|
||||||
@ -251,9 +253,10 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
autoEntityWipe = CONFIG.getBoolean("auto_wipe", false);
|
autoEntityWipe = CONFIG.getBoolean("auto_wipe", false);
|
||||||
explosiveRadius = CONFIG.getDouble("explosiveRadius", 4.0D);
|
explosiveRadius = CONFIG.getDouble("explosiveRadius", 4.0D);
|
||||||
nukeMonitor = CONFIG.getBoolean("nuke_monitor", true);
|
nukeMonitor = CONFIG.getBoolean("nuke_monitor", true);
|
||||||
nukeMonitorCount = CONFIG.getInt("nuke_monitor_count", 40);
|
nukeMonitorCountBreak = CONFIG.getInt("nuke_monitor_count", 40);
|
||||||
nukeMonitorRange = CONFIG.getDouble("nuke_monitor_range", 10.0D);
|
nukeMonitorRange = CONFIG.getDouble("nuke_monitor_range", 10.0D);
|
||||||
preprocessLogEnabled = CONFIG.getBoolean("preprocess_log", false);
|
preprocessLogEnabled = CONFIG.getBoolean("preprocess_log", false);
|
||||||
|
freecamTriggerCount = CONFIG.getInt("freecam_trigger_count", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEventHandlers()
|
private void registerEventHandlers()
|
||||||
@ -303,6 +306,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
this.getCommand("gcmd").setExecutor(AdminCommands);
|
this.getCommand("gcmd").setExecutor(AdminCommands);
|
||||||
this.getCommand("qjail").setExecutor(AdminCommands);
|
this.getCommand("qjail").setExecutor(AdminCommands);
|
||||||
this.getCommand("umd").setExecutor(AdminCommands);
|
this.getCommand("umd").setExecutor(AdminCommands);
|
||||||
|
this.getCommand("csay").setExecutor(AdminCommands);
|
||||||
|
|
||||||
this.getCommand("explosives").setExecutor(AntiblockCommands);
|
this.getCommand("explosives").setExecutor(AntiblockCommands);
|
||||||
this.getCommand("lavadmg").setExecutor(AntiblockCommands);
|
this.getCommand("lavadmg").setExecutor(AntiblockCommands);
|
||||||
|
@ -10,6 +10,9 @@ commands:
|
|||||||
creative:
|
creative:
|
||||||
description: Quickly change your own gamemode to creative, or define someone's username to change theirs.
|
description: Quickly change your own gamemode to creative, or define someone's username to change theirs.
|
||||||
usage: /<command> [partialname]
|
usage: /<command> [partialname]
|
||||||
|
csay:
|
||||||
|
description: Telnet command - Send a chat message with chat formatting over telnet.
|
||||||
|
usage: /<command> [partialname]
|
||||||
deopall:
|
deopall:
|
||||||
description: Superadmin command - Deop everyone on the server.
|
description: Superadmin command - Deop everyone on the server.
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
Loading…
Reference in New Issue
Block a user