mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
nothing
This commit is contained in:
parent
46bd17e2c6
commit
46b4a65816
@ -5,6 +5,7 @@ import java.net.InetSocketAddress;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -22,21 +23,29 @@ import org.bukkit.util.config.Configuration;
|
|||||||
|
|
||||||
public class TotalFreedomMod extends JavaPlugin
|
public class TotalFreedomMod extends JavaPlugin
|
||||||
{
|
{
|
||||||
|
public TotalFreedomMod tfm = this;
|
||||||
|
|
||||||
private final TotalFreedomModEntityListener entityListener = new TotalFreedomModEntityListener(this);
|
private final TotalFreedomModEntityListener entityListener = new TotalFreedomModEntityListener(this);
|
||||||
private final TotalFreedomModBlockListener blockListener = new TotalFreedomModBlockListener(this);
|
private final TotalFreedomModBlockListener blockListener = new TotalFreedomModBlockListener(this);
|
||||||
private final TotalFreedomModPlayerListener playerListener = new TotalFreedomModPlayerListener(this);
|
private final TotalFreedomModPlayerListener playerListener = new TotalFreedomModPlayerListener(this);
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger("Minecraft");
|
private static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
protected static Configuration CONFIG;
|
protected static Configuration CONFIG;
|
||||||
private List<String> superadmins = new ArrayList<String>();
|
public List<String> superadmins = new ArrayList<String>();
|
||||||
private List<String> superadmin_ips = new ArrayList<String>();
|
public List<String> superadmin_ips = new ArrayList<String>();
|
||||||
public Boolean allowExplosions = false;
|
public Boolean allowExplosions = false;
|
||||||
public Boolean allowLavaDamage = false;
|
public Boolean allowLavaDamage = false;
|
||||||
public Boolean allowFire = false;
|
public Boolean allowFire = false;
|
||||||
public double explosiveRadius = 4.0;
|
public double explosiveRadius = 4.0;
|
||||||
public Boolean preprocessLogEnabled = false;
|
public Boolean preprocessLogEnabled = false;
|
||||||
public boolean nukeMonitor = false;
|
public boolean nukeMonitor = true;
|
||||||
public double nukeMonitorRange = 10.0;
|
public double nukeMonitorRange = 10.0;
|
||||||
public boolean playersFrozen = false;
|
public int nukeMonitorCount = 40;
|
||||||
|
public boolean allPlayersFrozen = false;
|
||||||
|
|
||||||
|
public HashMap userinfo = new HashMap();
|
||||||
|
|
||||||
public final static String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
|
public final static String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
|
||||||
public final static String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
public final static String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
||||||
public final static String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
public final static String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||||
@ -62,6 +71,9 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
CONFIG.setProperty("allow_fire", false);
|
CONFIG.setProperty("allow_fire", false);
|
||||||
CONFIG.setProperty("explosiveRadius", 4.0);
|
CONFIG.setProperty("explosiveRadius", 4.0);
|
||||||
CONFIG.setProperty("preprocess_log", false);
|
CONFIG.setProperty("preprocess_log", false);
|
||||||
|
CONFIG.setProperty("nuke_monitor", true);
|
||||||
|
CONFIG.setProperty("nuke_monitor_range", 10.0);
|
||||||
|
CONFIG.setProperty("nuke_monitor_count", 40);
|
||||||
CONFIG.save();
|
CONFIG.save();
|
||||||
}
|
}
|
||||||
CONFIG.load();
|
CONFIG.load();
|
||||||
@ -72,6 +84,8 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
allowFire = CONFIG.getBoolean("allow_fire", false);
|
allowFire = CONFIG.getBoolean("allow_fire", false);
|
||||||
explosiveRadius = CONFIG.getDouble("explosiveRadius", 4.0);
|
explosiveRadius = CONFIG.getDouble("explosiveRadius", 4.0);
|
||||||
preprocessLogEnabled = CONFIG.getBoolean("preprocess_log", false);
|
preprocessLogEnabled = CONFIG.getBoolean("preprocess_log", false);
|
||||||
|
nukeMonitorRange = CONFIG.getDouble("nuke_monitor_range", 10.0);
|
||||||
|
nukeMonitorCount = CONFIG.getInt("nuke_monitor_count", 40);
|
||||||
|
|
||||||
PluginManager pm = this.getServer().getPluginManager();
|
PluginManager pm = this.getServer().getPluginManager();
|
||||||
|
|
||||||
@ -88,9 +102,19 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Event.Priority.High, this);
|
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Event.Priority.High, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.High, this);
|
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.High, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Event.Priority.Normal, this);
|
||||||
|
|
||||||
log.log(Level.INFO, "[Total Freedom Mod] - Enabled! - Version: " + this.getDescription().getVersion() + " by Madgeek1450");
|
log.log(Level.INFO, "[Total Freedom Mod] - Enabled! - Version: " + this.getDescription().getVersion() + " by Madgeek1450");
|
||||||
log.log(Level.INFO, "[Total Freedom Mod] - Loaded superadmins: " + implodeStringList(", ", superadmins));
|
log.log(Level.INFO, "[Total Freedom Mod] - Loaded superadmins: " + implodeStringList(", ", superadmins));
|
||||||
|
|
||||||
|
Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
tfm.resetCounts();
|
||||||
|
}
|
||||||
|
}, 100L, 100L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -827,6 +851,22 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
{
|
{
|
||||||
p.getInventory().clear();
|
p.getInventory().clear();
|
||||||
}
|
}
|
||||||
|
else if (mode.equals("fr"))
|
||||||
|
{
|
||||||
|
TFUserInfo playerdata = (TFUserInfo) this.userinfo.get(p);
|
||||||
|
if (playerdata != null)
|
||||||
|
{
|
||||||
|
playerdata.setFrozen(!playerdata.isFrozen());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerdata = new TFUserInfo();
|
||||||
|
playerdata.setFrozen(true);
|
||||||
|
this.userinfo.put(p, playerdata);
|
||||||
|
}
|
||||||
|
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
|
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -854,19 +894,51 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
{
|
{
|
||||||
if (player == null || isUserSuperadmin(sender))
|
if (player == null || isUserSuperadmin(sender))
|
||||||
{
|
{
|
||||||
this.playersFrozen = !this.playersFrozen;
|
if (args.length == 0)
|
||||||
|
|
||||||
if (this.playersFrozen)
|
|
||||||
{
|
{
|
||||||
this.playersFrozen = true;
|
this.allPlayersFrozen = !this.allPlayersFrozen;
|
||||||
sender.sendMessage("Players are now frozen.");
|
|
||||||
tfBroadcastMessage(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA);
|
if (this.allPlayersFrozen)
|
||||||
|
{
|
||||||
|
this.allPlayersFrozen = true;
|
||||||
|
sender.sendMessage("Players are now frozen.");
|
||||||
|
tfBroadcastMessage(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.allPlayersFrozen = false;
|
||||||
|
sender.sendMessage("Players are now free to move.");
|
||||||
|
tfBroadcastMessage(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.playersFrozen = false;
|
Player p;
|
||||||
sender.sendMessage("Players are now free to move.");
|
List<Player> matches = Bukkit.matchPlayer(args[0]);
|
||||||
tfBroadcastMessage(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA);
|
if (matches.isEmpty())
|
||||||
|
{
|
||||||
|
sender.sendMessage("Can't find user " + args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p = matches.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TFUserInfo playerdata = (TFUserInfo) this.userinfo.get(p);
|
||||||
|
if (playerdata != null)
|
||||||
|
{
|
||||||
|
playerdata.setFrozen(!playerdata.isFrozen());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerdata = new TFUserInfo();
|
||||||
|
playerdata.setFrozen(true);
|
||||||
|
this.userinfo.put(p, playerdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
|
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -883,15 +955,22 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 2)
|
if (args.length >= 2)
|
||||||
{
|
{
|
||||||
this.nukeMonitorRange = Integer.parseInt(args[1]);
|
this.nukeMonitorRange = Double.parseDouble(args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 3)
|
||||||
|
{
|
||||||
|
this.nukeMonitorCount = Integer.parseInt(args[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("on"))
|
if (args[0].equalsIgnoreCase("on"))
|
||||||
{
|
{
|
||||||
this.nukeMonitor = true;
|
this.nukeMonitor = true;
|
||||||
sender.sendMessage("Nuke monitor is enabled, range is set to " + this.nukeMonitorRange + " blocks.");
|
sender.sendMessage(ChatColor.GRAY + "Nuke monitor is enabled.");
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Anti-freecam range is set to " + this.nukeMonitorRange + " blocks.");
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Block throttle rate is set to " + this.nukeMonitorCount + " blocks destroyed per 5 seconds.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -899,6 +978,12 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
sender.sendMessage("Nuke monitor is disabled.");
|
sender.sendMessage("Nuke monitor is disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CONFIG.load();
|
||||||
|
CONFIG.setProperty("nuke_monitor", this.nukeMonitor);
|
||||||
|
CONFIG.setProperty("nuke_monitor_range", this.nukeMonitorRange);
|
||||||
|
CONFIG.setProperty("nuke_monitor_count", this.nukeMonitorCount);
|
||||||
|
CONFIG.save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -984,4 +1069,17 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetCounts()
|
||||||
|
{
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
TFUserInfo playerdata = (TFUserInfo) this.userinfo.get(p);
|
||||||
|
if (playerdata != null)
|
||||||
|
{
|
||||||
|
playerdata.resetMsgCount();
|
||||||
|
playerdata.resetBlockDestroyCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,24 +46,56 @@ public class TotalFreedomModBlockListener extends BlockListener
|
|||||||
@Override
|
@Override
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
if (plugin.nukeMonitor)
|
try
|
||||||
{
|
{
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
p.setOp(false);
|
Player p = event.getPlayer();
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
|
||||||
p.getInventory().clear();
|
|
||||||
|
|
||||||
plugin.tfBroadcastMessage(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
Location player_pos = p.getLocation();
|
||||||
|
Location block_pos = event.getBlock().getLocation();
|
||||||
|
|
||||||
event.setCancelled(true);
|
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
|
||||||
|
{
|
||||||
|
p.setOp(false);
|
||||||
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
|
p.getInventory().clear();
|
||||||
|
|
||||||
|
plugin.tfBroadcastMessage(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TFUserInfo playerdata = (TFUserInfo) plugin.userinfo.get(p);
|
||||||
|
if (playerdata != null)
|
||||||
|
{
|
||||||
|
playerdata.incrementBlockDestroyCount();
|
||||||
|
|
||||||
|
if (playerdata.getBlockDestroyCount() > plugin.nukeMonitorCount)
|
||||||
|
{
|
||||||
|
plugin.tfBroadcastMessage(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||||
|
|
||||||
|
p.setOp(false);
|
||||||
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
|
p.getInventory().clear();
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerdata = new TFUserInfo();
|
||||||
|
playerdata.incrementBlockDestroyCount();
|
||||||
|
plugin.userinfo.put(p, playerdata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.info("Exception in TFM Block Listener onBlockBreak: " + ex.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
@ -59,21 +60,73 @@ class TotalFreedomModPlayerListener extends PlayerListener
|
|||||||
@Override
|
@Override
|
||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
if (plugin.playersFrozen)
|
try
|
||||||
{
|
{
|
||||||
if (plugin.isUserSuperadmin(event.getPlayer()))
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
|
boolean do_freeze = false;
|
||||||
|
if (plugin.allPlayersFrozen)
|
||||||
{
|
{
|
||||||
return;
|
if (!plugin.isUserSuperadmin(p))
|
||||||
|
{
|
||||||
|
do_freeze = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TFUserInfo playerdata = (TFUserInfo) plugin.userinfo.get(p);
|
||||||
|
if (playerdata != null)
|
||||||
|
{
|
||||||
|
if (playerdata.isFrozen())
|
||||||
|
{
|
||||||
|
do_freeze = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Location from = event.getFrom();
|
if (do_freeze)
|
||||||
Location to = event.getTo().clone();
|
{
|
||||||
|
Location from = event.getFrom();
|
||||||
|
Location to = event.getTo().clone();
|
||||||
|
|
||||||
to.setX(from.getX());
|
to.setX(from.getX());
|
||||||
to.setY(from.getY());
|
to.setY(from.getY());
|
||||||
to.setZ(from.getZ());
|
to.setZ(from.getZ());
|
||||||
|
|
||||||
event.setTo(to);
|
event.setTo(to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.severe("Exception in TFM Player Listener onMove: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerChat(PlayerChatEvent event)
|
||||||
|
{
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
|
TFUserInfo playerdata = (TFUserInfo) plugin.userinfo.get(p);
|
||||||
|
if (playerdata != null)
|
||||||
|
{
|
||||||
|
playerdata.incrementMsgCount();
|
||||||
|
|
||||||
|
if (playerdata.getMsgCount() > 10)
|
||||||
|
{
|
||||||
|
p.setOp(false);
|
||||||
|
p.kickPlayer("No Spamming");
|
||||||
|
plugin.tfBroadcastMessage(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerdata = new TFUserInfo();
|
||||||
|
playerdata.incrementMsgCount();
|
||||||
|
plugin.userinfo.put(p, playerdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ commands:
|
|||||||
usage: /<command>
|
usage: /<command>
|
||||||
nonuke:
|
nonuke:
|
||||||
description: Attempt to detect "invisible griefers" and "nukers".
|
description: Attempt to detect "invisible griefers" and "nukers".
|
||||||
usage: /<command> <on|off> [range]
|
usage: /<command> <on|off> [range] [blockrate]
|
||||||
opall:
|
opall:
|
||||||
description: Superadmin command - Op everyone on the server, optionally change everyone's gamemode at the same time.
|
description: Superadmin command - Op everyone on the server, optionally change everyone's gamemode at the same time.
|
||||||
usage: /<command> [-c|-s]
|
usage: /<command> [-c|-s]
|
||||||
|
Loading…
Reference in New Issue
Block a user