diff --git a/src/config.yml b/src/config.yml index c161374d..56c43683 100644 --- a/src/config.yml +++ b/src/config.yml @@ -31,6 +31,10 @@ disable_night: true # Disable weather: disable_weather: true +# Enable misc. features: +landmines_enabled: false +mp44_enabled: false + # Superadmins: Users that can always log in and use the most powerful commands: # When online-mode = false, only superadmin_ips will be used. # The superadmin lists have been moved to superadmin.yml diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cage.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cage.java index d2fab566..d1a68221 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cage.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cage.java @@ -45,6 +45,7 @@ public class Command_cage extends TFM_Command playerdata.setCaged(false); playerdata.regenerateHistory(); playerdata.clearHistory(); + sender.sendMessage(ChatColor.GREEN + p.getName() + " uncaged."); return true; } else @@ -79,7 +80,7 @@ public class Command_cage extends TFM_Command p.setGameMode(GameMode.SURVIVAL); - TFM_Util.tfm_broadcastMessage(sender.getName() + " caged " + p.getName() + "!", ChatColor.YELLOW); + TFM_Util.bcastMsg(sender.getName() + " caged " + p.getName() + "!", ChatColor.YELLOW); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java index 1b7bab5a..6289a36c 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java @@ -32,7 +32,7 @@ public class Command_cake extends TFM_Command p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem); } - TFM_Util.tfm_broadcastMessage(output.toString()); + TFM_Util.bcastMsg(output.toString()); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_csay.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_csay.java index f4e1fdad..21fa8993 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_csay.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_csay.java @@ -28,7 +28,7 @@ public class Command_csay extends TFM_Command outmessage_bldr.append(args[i]).append(" "); } - TFM_Util.tfm_broadcastMessage(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender_name, outmessage_bldr.toString().trim())); + TFM_Util.bcastMsg(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender_name, outmessage_bldr.toString().trim())); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java index c1e379fc..1f1dcb8f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java @@ -16,7 +16,7 @@ public class Command_deopall extends TFM_Command { if (TFM_Util.isUserSuperadmin(sender, plugin) || senderIsConsole) { - TFM_Util.tfm_broadcastMessage(String.format("(%s: De-opping all players on server)", sender.getName()), ChatColor.YELLOW); + TFM_Util.bcastMsg(String.format("(%s: De-opping all players on server)", sender.getName()), ChatColor.YELLOW); for (Player p : Bukkit.getOnlinePlayers()) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_expel.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_expel.java index 7f6b8a10..8ef5c032 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_expel.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_expel.java @@ -13,14 +13,12 @@ public class Command_expel extends TFM_Command @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) + if (senderIsConsole) + { + sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); + } + else if (TFM_Util.isUserSuperadmin(sender, plugin)) { - if (senderIsConsole) - { - sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); - return true; - } - double radius = 50.0; double strength = 100.0; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java index 095ce3fa..fac88ab6 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java @@ -23,13 +23,13 @@ public class Command_fr extends TFM_Command { plugin.allPlayersFrozen = true; sender.sendMessage("Players are now frozen."); - TFM_Util.tfm_broadcastMessage(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA); + TFM_Util.bcastMsg(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA); } else { plugin.allPlayersFrozen = false; sender.sendMessage("Players are now free to move."); - TFM_Util.tfm_broadcastMessage(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA); + TFM_Util.bcastMsg(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA); } } else diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java index 8586a9ab..8a70449f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java @@ -47,33 +47,43 @@ public class Command_gadmin extends TFM_Command else if (mode.equals("nameban")) { Bukkit.getOfflinePlayer(p.getName()).setBanned(true); - TFM_Util.tfm_broadcastMessage(String.format("Banning Name: %s.", p.getName()), ChatColor.RED); + TFM_Util.bcastMsg(String.format("Banning Name: %s.", p.getName()), ChatColor.RED); p.kickPlayer("Username banned by Administrator."); } else if (mode.equals("ipban")) { String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim(); - TFM_Util.tfm_broadcastMessage(String.format("Banning IP: %s.", p.getName(), user_ip), ChatColor.RED); + String[] ip_parts = user_ip.split("\\."); + if (ip_parts.length == 4) + { + user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]); + } + TFM_Util.bcastMsg(String.format("Banning IP: %s.", p.getName(), user_ip), ChatColor.RED); Bukkit.banIP(user_ip); p.kickPlayer("IP address banned by Administrator."); } else if (mode.equals("ban")) { String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim(); - TFM_Util.tfm_broadcastMessage(String.format("Banning Name: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); + String[] ip_parts = user_ip.split("\\."); + if (ip_parts.length == 4) + { + user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]); + } + TFM_Util.bcastMsg(String.format("Banning Name: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); Bukkit.banIP(user_ip); Bukkit.getOfflinePlayer(p.getName()).setBanned(true); p.kickPlayer("IP and username banned by Administrator."); } else if (mode.equals("op")) { - TFM_Util.tfm_broadcastMessage(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); + TFM_Util.bcastMsg(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_OP); } else if (mode.equals("deop")) { - TFM_Util.tfm_broadcastMessage(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); + TFM_Util.bcastMsg(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java index df823b4b..38759881 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java @@ -33,7 +33,7 @@ public class Command_gtfo extends TFM_Command return true; } - TFM_Util.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED); + TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED); //Undo WorldEdits: Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("/undo %d %s", 15, p.getName())); @@ -60,7 +60,12 @@ public class Command_gtfo extends TFM_Command //Ban IP Address: String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim(); - TFM_Util.tfm_broadcastMessage(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); + String[] ip_parts = user_ip.split("\\."); + if (ip_parts.length == 4) + { + user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]); + } + TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); Bukkit.banIP(user_ip); //Ban Username: diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_landmine.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_landmine.java index db146b22..b5940499 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_landmine.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_landmine.java @@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_LandmineData; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -18,11 +19,33 @@ public class Command_landmine extends TFM_Command { sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); } + else if (!plugin.landminesEnabled) + { + sender.sendMessage(ChatColor.GREEN + "The landmine is currently disabled."); + } + else if (!plugin.allowExplosions) + { + sender.sendMessage(ChatColor.GREEN + "Explosions are currently disabled."); + } else if (sender.isOp()) { + double radius = 2.0; + if (args.length >= 1) + { + try + { + radius = Math.max(2.0, Math.min(6.0, Double.parseDouble(args[0]))); + } + catch (NumberFormatException ex) + { + } + } + Block landmine = sender_p.getLocation().getBlock().getRelative(BlockFace.DOWN); landmine.setType(Material.TNT); - plugin.landmines.add(new TFM_LandmineData(landmine.getLocation(), sender_p)); + plugin.landmines.add(new TFM_LandmineData(landmine.getLocation(), sender_p, radius)); + + sender.sendMessage(ChatColor.GREEN + "Landmine planted. Radius: " + radius + " blocks."); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java index 86e899e1..2c4ca4af 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java @@ -14,15 +14,16 @@ public class Command_mp44 extends TFM_Command @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - //if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) - if (senderIsConsole || sender.isOp()) + if (senderIsConsole) + { + sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); + } + else if (!plugin.mp44Enabled) + { + sender.sendMessage(ChatColor.GREEN + "The mp44 is currently disabled."); + } + else if (sender.isOp()) { - if (senderIsConsole) - { - sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); - return true; - } - if (args.length == 0) { return false; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java index fe9d50e1..76f00214 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java @@ -16,7 +16,7 @@ public class Command_opall extends TFM_Command { if (TFM_Util.isUserSuperadmin(sender, plugin) || senderIsConsole) { - TFM_Util.tfm_broadcastMessage(String.format("(%s: Opping all players on server)", sender.getName()), ChatColor.YELLOW); + TFM_Util.bcastMsg(String.format("(%s: Opping all players on server)", sender.getName()), ChatColor.YELLOW); boolean doSetGamemode = false; GameMode targetGamemode = GameMode.CREATIVE; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opme.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opme.java index 035b26e2..354a2ef0 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opme.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opme.java @@ -15,12 +15,10 @@ public class Command_opme extends TFM_Command if (senderIsConsole) { sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); - return true; } - - if (TFM_Util.isUserSuperadmin(sender, plugin)) + else if (TFM_Util.isUserSuperadmin(sender, plugin)) { - TFM_Util.tfm_broadcastMessage(String.format("(%s: Opping %s)", sender.getName(), sender.getName()), ChatColor.GRAY); + TFM_Util.bcastMsg(String.format("(%s: Opping %s)", sender.getName(), sender.getName()), ChatColor.GRAY); sender.setOp(true); sender.sendMessage(TotalFreedomMod.YOU_ARE_OP); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java index a67742e8..fbe0c96a 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java @@ -25,7 +25,7 @@ public class Command_qdeop extends TFM_Command { matched_player = true; - TFM_Util.tfm_broadcastMessage(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); + TFM_Util.bcastMsg(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qjail.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qjail.java index 1fc43a9f..0e7197fa 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qjail.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qjail.java @@ -56,7 +56,7 @@ public class Command_qjail extends TFM_Command //Send to jail "mgjail": Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tjail %s mgjail 1y", p.getName().replace(" ", "").trim())); - TFM_Util.tfm_broadcastMessage(p.getName() + " has been JAILED!", ChatColor.RED); + TFM_Util.bcastMsg(p.getName() + " has been JAILED!", ChatColor.RED); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java index 00006481..be3acc5e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java @@ -25,7 +25,7 @@ public class Command_qop extends TFM_Command { matched_player = true; - TFM_Util.tfm_broadcastMessage(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); + TFM_Util.bcastMsg(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); p.setOp(true); p.sendMessage(TotalFreedomMod.YOU_ARE_OP); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_say.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_say.java index 5c521caa..bab64aec 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_say.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_say.java @@ -21,7 +21,7 @@ public class Command_say extends TFM_Command if (senderIsConsole || sender.isOp()) { String message = TFM_Util.implodeStringList(" ", Arrays.asList(args)); - TFM_Util.tfm_broadcastMessage(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE); + TFM_Util.bcastMsg(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stacker.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stacker.java new file mode 100644 index 00000000..969efb8d --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stacker.java @@ -0,0 +1,47 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +public class Command_stacker extends TFM_Command +{ +// @Override +// public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) +// { +// if (senderIsConsole) +// { +// sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); +// } +// else if (TFM_Util.isUserSuperadmin(sender, plugin)) +// { +// if (args.length >= 1) +// { +// if (args[0].equalsIgnoreCase("end") || args[0].equalsIgnoreCase("stop")) +// { +// for (World world : Bukkit.getWorlds()) +// { +// for (LivingEntity entity : world.getLivingEntities()) +// { +// entity.leaveVehicle(); +// } +// } +// return true; +// } +// } +// +// LivingEntity parent = sender_p; +// for (LivingEntity entity : sender_p.getWorld().getLivingEntities()) +// { +// if (parent != null) +// { +// parent.setPassenger(entity); +// } +// +// parent = entity; +// } +// } +// else +// { +// sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); +// } +// +// return true; +// } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stop.java index d8331843..bb74dd44 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stop.java @@ -15,7 +15,7 @@ public class Command_stop extends TFM_Command { if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) { - TFM_Util.tfm_broadcastMessage("Server is going offline.", ChatColor.GRAY); + TFM_Util.bcastMsg("Server is going offline.", ChatColor.GRAY); for (Player p : Bukkit.getOnlinePlayers()) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfipbanlist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfipbanlist.java index be7d2259..00f87dc8 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfipbanlist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfipbanlist.java @@ -49,7 +49,7 @@ public class Command_tfipbanlist extends TFM_Command { banned_ips.append(", "); } - if (ip.matches("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}")) + if (ip.matches("^\\d{1,3}\\.\\d{1,3}\\.(\\d{1,3}|\\*)\\.(\\d{1,3}|\\*)$")) { first = false; banned_ips.append(ip.trim()); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfsmite.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfsmite.java index 635b7212..0993fa9f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfsmite.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfsmite.java @@ -48,7 +48,7 @@ public class Command_tfsmite extends TFM_Command for (Player p : targets) { - TFM_Util.tfm_broadcastMessage(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED); + TFM_Util.bcastMsg(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED); //Deop p.setOp(false); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java index a3662cd0..24430ca5 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java @@ -1,8 +1,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; -import java.util.HashMap; -import java.util.Map; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -17,14 +16,12 @@ public class Command_tossmob extends TFM_Command @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (senderIsConsole || sender.isOp()) + if (senderIsConsole) + { + sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); + } + else if (sender.isOp()) { - if (senderIsConsole) - { - sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); - return true; - } - TFM_UserInfo playerData = TFM_UserInfo.getPlayerData(sender_p, plugin); CreatureType creature = CreatureType.PIG; @@ -36,26 +33,11 @@ public class Command_tossmob extends TFM_Command sender.sendMessage(ChatColor.GREEN + "MobThrower is disabled."); return true; } - - Map mobtypes = new HashMap(); - mobtypes.put("chicken", CreatureType.CHICKEN); - mobtypes.put("cow", CreatureType.COW); - mobtypes.put("creeper", CreatureType.CREEPER); - mobtypes.put("pig", CreatureType.PIG); - mobtypes.put("sheep", CreatureType.SHEEP); - mobtypes.put("skeleton", CreatureType.SKELETON); - mobtypes.put("spider", CreatureType.SPIDER); - mobtypes.put("zombie", CreatureType.ZOMBIE); - mobtypes.put("wolf", CreatureType.WOLF); - - CreatureType creature_query = mobtypes.get(args[0].toLowerCase().trim()); - if (creature_query != null) + + if ((creature = TFM_Util.getCreatureType(args[0])) == null) { - creature = creature_query; - } - else - { - sender.sendMessage(args[0] + " is not a supported mob type. Using a pig instead."); + sender.sendMessage(ChatColor.RED + args[0] + " is not a supported mob type. Using a pig instead."); + creature = CreatureType.PIG; } } @@ -84,7 +66,7 @@ public class Command_tossmob extends TFM_Command sender.sendMessage(ChatColor.GREEN + "MobThrower is enabled. Creature: " + creature + " - Speed: " + speed + "."); sender.sendMessage(ChatColor.GREEN + "Left click while holding a stick to throw mobs!"); sender.sendMessage(ChatColor.GREEN + "Type '/tossmob off' to disable. -By Madgeek1450"); - + sender_p.setItemInHand(new ItemStack(Material.STICK, 1)); } else diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java index a5dc9b6f..3b123c90 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java @@ -4,6 +4,7 @@ import java.util.logging.Logger; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -62,7 +63,9 @@ public class TFM_BlockListener extends BlockListener p.setGameMode(GameMode.SURVIVAL); p.getInventory().clear(); - TFM_Util.tfm_broadcastMessage(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED); + TFM_Util.bcastMsg(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED); + p.kickPlayer("Freecam (extended range) block breaking is not permitted on this server."); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName())); playerdata.resetFreecamDestroyCount(); @@ -74,12 +77,13 @@ public class TFM_BlockListener extends BlockListener playerdata.incrementBlockDestroyCount(); if (playerdata.getBlockDestroyCount() > plugin.nukeMonitorCountBreak) { - TFM_Util.tfm_broadcastMessage(p.getName() + " is breaking blocks too fast!", ChatColor.RED); + TFM_Util.bcastMsg(p.getName() + " is breaking blocks too fast!", ChatColor.RED); p.setOp(false); p.setGameMode(GameMode.SURVIVAL); p.getInventory().clear(); p.kickPlayer("You are breaking blocks too fast. Nukers are not permitted on this server."); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName())); event.setCancelled(true); return; @@ -108,7 +112,9 @@ public class TFM_BlockListener extends BlockListener p.setGameMode(GameMode.SURVIVAL); p.getInventory().clear(); - TFM_Util.tfm_broadcastMessage(p.getName() + " has been flagged for possible freecam building.", ChatColor.RED); + TFM_Util.bcastMsg(p.getName() + " has been flagged for possible freecam building.", ChatColor.RED); + p.kickPlayer("Freecam (extended range) block building is not permitted on this server."); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName())); playerdata.resetFreecamPlaceCount(); @@ -120,12 +126,13 @@ public class TFM_BlockListener extends BlockListener playerdata.incrementBlockPlaceCount(); if (playerdata.getBlockPlaceCount() > plugin.nukeMonitorCountPlace) { - TFM_Util.tfm_broadcastMessage(p.getName() + " is placing blocks too fast!", ChatColor.RED); + TFM_Util.bcastMsg(p.getName() + " is placing blocks too fast!", ChatColor.RED); p.setOp(false); p.setGameMode(GameMode.SURVIVAL); p.getInventory().clear(); p.kickPlayer("You are placing blocks too fast."); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName())); event.setCancelled(true); return; diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index d8e426c3..208012ea 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -1,5 +1,6 @@ package me.StevenLawson.TotalFreedomMod.Listener; +import java.net.InetSocketAddress; import java.util.Iterator; import java.util.logging.Logger; import java.util.regex.Pattern; @@ -159,24 +160,39 @@ public class TFM_PlayerListener extends PlayerListener } } - Iterator landmines = plugin.landmines.iterator(); - while (landmines.hasNext()) + if (plugin.landminesEnabled && plugin.allowExplosions) { - TFM_LandmineData landmine = landmines.next(); - - if (!landmine.player.equals(p)) + Iterator landmines = plugin.landmines.iterator(); + while (landmines.hasNext()) { - if (p.getWorld().equals(landmine.landmine_pos.getWorld())) + TFM_LandmineData landmine = landmines.next(); + + Location landmine_pos = landmine.landmine_pos; + if (landmine_pos.getBlock().getType() != Material.TNT) { - if (p.getLocation().distance(landmine.landmine_pos) <= 2.0) + landmines.remove(); + continue; + } + + if (!landmine.player.equals(p)) + { + if (p.getWorld().equals(landmine_pos.getWorld())) { - landmine.landmine_pos.getBlock().setType(Material.AIR); - TNTPrimed primed_tnt = landmine.landmine_pos.getWorld().spawn(landmine.landmine_pos, TNTPrimed.class); - primed_tnt.setFuseTicks(100); - primed_tnt.setPassenger(p); - primed_tnt.setVelocity(new Vector(0.0, 10.0, 0.0)); - p.setGameMode(GameMode.SURVIVAL); - landmines.remove(); + if (p.getLocation().distance(landmine_pos) <= landmine.radius) + { + landmine.landmine_pos.getBlock().setType(Material.AIR); + + TNTPrimed tnt1 = landmine_pos.getWorld().spawn(landmine_pos, TNTPrimed.class); + tnt1.setFuseTicks(40); + tnt1.setPassenger(p); + tnt1.setVelocity(new Vector(0.0, 2.0, 0.0)); + + TNTPrimed tnt2 = landmine_pos.getWorld().spawn(p.getLocation(), TNTPrimed.class); + tnt2.setFuseTicks(1); + + p.setGameMode(GameMode.SURVIVAL); + landmines.remove(); + } } } } @@ -196,22 +212,22 @@ public class TFM_PlayerListener extends PlayerListener p.setOp(false); p.kickPlayer("No Spamming"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName())); - TFM_Util.tfm_broadcastMessage(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED); + TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED); playerdata.resetMsgCount(); event.setCancelled(true); return; } - - String message = event.getMessage().toLowerCase(); - if (Pattern.compile("\\sbe\\s.*admin").matcher(message).find() - || Pattern.compile("\\shave\\s.*admin").matcher(message).find()) - { - log.info("Kicked " + p.getName() + " for being annoying."); - p.kickPlayer("No, bitch."); - event.setCancelled(true); - return; - } + +// String message = event.getMessage().toLowerCase(); +// if (Pattern.compile("\\sbe\\s.*admin").matcher(message).find() +// || Pattern.compile("\\shave\\s.*admin").matcher(message).find()) +// { +// log.info("Kicked " + p.getName() + " for being annoying."); +// p.kickPlayer("No, bitch."); +// event.setCancelled(true); +// return; +// } } @Override @@ -243,10 +259,27 @@ public class TFM_PlayerListener extends PlayerListener block_command = true; } } - else if (Pattern.compile("^/time").matcher(command).find()) + else if (Pattern.compile("^/save-").matcher(command).find()) { - player.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time."); - block_command = true; + if (!TFM_Util.isUserSuperadmin(player, plugin)) + { + block_command = true; + } + } + + if (block_command) + { + player.kickPlayer("That command is prohibited."); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", player.getName())); + TFM_Util.bcastMsg(player.getName() + " was automatically kicked for using evil commands.", ChatColor.RED); + } + else + { + if (Pattern.compile("^/time").matcher(command).find()) + { + player.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time."); + block_command = true; + } } if (block_command) @@ -286,4 +319,39 @@ public class TFM_PlayerListener extends PlayerListener TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin); playerdata.disarmMP44(); } + + @Override + public void onPlayerJoin(PlayerJoinEvent event) + { + try + { + if (!Bukkit.getOnlineMode()) + { + Player p = event.getPlayer(); + if (plugin.superadmins.contains(p.getName().toLowerCase())) + { + String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim(); + if (user_ip != null && !user_ip.isEmpty()) + { + TFM_Util.checkPartialSuperadminIP(user_ip, plugin); + + if (!plugin.superadmin_ips.contains(user_ip)) + { + TFM_Util.bcastMsg(p.getName() + " might be a fake! IP: " + user_ip, ChatColor.RED); + p.setOp(false); + p.setGameMode(GameMode.SURVIVAL); + p.getInventory().clear(); + } + else + { + TFM_Util.bcastMsg(p.getName() + " is a verified superadmin.", ChatColor.GREEN); + } + } + } + } + } + catch (Throwable ex) + { + } + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java b/src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java index a3231ea5..be4b14d5 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java @@ -7,10 +7,12 @@ public class TFM_LandmineData { public Location landmine_pos; public Player player; - - public TFM_LandmineData(Location landmine_pos, Player player) + public double radius; + + public TFM_LandmineData(Location landmine_pos, Player player, double radius) { this.landmine_pos = landmine_pos; this.player = player; + this.radius = radius; } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 1de4b6c2..f1b89c78 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -5,7 +5,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.jar.JarFile; import java.util.logging.Level; import java.util.logging.Logger; @@ -17,13 +19,20 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.*; public class TFM_Util { private static final Logger log = Logger.getLogger("Minecraft"); - - public static void tfm_broadcastMessage(String message, ChatColor color) + + private TFM_Util() + { + throw new AssertionError(); + } + + public static void bcastMsg(String message, ChatColor color) { log.info(message); @@ -33,7 +42,7 @@ public class TFM_Util } } - public static void tfm_broadcastMessage(String message) + public static void bcastMsg(String message) { log.info(ChatColor.stripColor(message)); @@ -246,6 +255,57 @@ public class TFM_Util return false; } + public static boolean checkPartialSuperadminIP(String user_ip, TotalFreedomMod tfm) + { + user_ip = user_ip.trim(); + + if (tfm.superadmin_ips.contains(user_ip)) + { + return true; + } + else + { + String[] user_octets = user_ip.split("\\."); + if (user_octets.length != 4) + { + return false; + } + + boolean match_found = false; + for (String test_ip : tfm.superadmin_ips) + { + String[] test_octets = test_ip.split("\\."); + if (test_octets.length == 4) + { + if (user_octets[0].equals(test_octets[0]) && user_octets[1].equals(test_octets[1]) && user_octets[2].equals(test_octets[2])) + { + log.info("New IP '" + user_ip + "' matches old IP '" + test_ip + "' via partial match, adding it to superadmin list."); + match_found = true; + break; + } + } + } + + if (match_found) + { + tfm.superadmin_ips.add(user_ip); + + try + { + FileConfiguration sa_config = YamlConfiguration.loadConfiguration(new File(tfm.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE)); + sa_config.set("superadmin_ips", tfm.superadmin_ips); + sa_config.save(new File(tfm.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE)); + } + catch (IOException ex) + { + Logger.getLogger(TFM_Util.class.getName()).log(Level.SEVERE, null, ex); + } + } + + return match_found; + } + } + public static int wipeDropEntities(boolean wipe_tnt) { int removed = 0; @@ -285,4 +345,23 @@ public class TFM_Util return false; } } + private static final Map mobtypes = new HashMap(); + + static + { + mobtypes.put("chicken", CreatureType.CHICKEN); + mobtypes.put("cow", CreatureType.COW); + mobtypes.put("creeper", CreatureType.CREEPER); + mobtypes.put("pig", CreatureType.PIG); + mobtypes.put("sheep", CreatureType.SHEEP); + mobtypes.put("skeleton", CreatureType.SKELETON); + mobtypes.put("spider", CreatureType.SPIDER); + mobtypes.put("zombie", CreatureType.ZOMBIE); + mobtypes.put("wolf", CreatureType.WOLF); + } + + public static CreatureType getCreatureType(String mobname) + { + return TFM_Util.mobtypes.get(mobname.toLowerCase().trim()); + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 863a5c54..567391e2 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -110,6 +110,8 @@ public class TotalFreedomMod extends JavaPlugin { sender.sendMessage(ChatColor.RED + "Command Error: " + ex.getMessage()); } + + dispatcher = null; } catch (Throwable ex) { @@ -136,6 +138,8 @@ public class TotalFreedomMod extends JavaPlugin public Boolean preprocessLogEnabled = true; public Boolean disableNight = true; public Boolean disableWeather = true; + public boolean landminesEnabled = false; + public boolean mp44Enabled = false; public void loadMainConfig() { @@ -158,6 +162,8 @@ public class TotalFreedomMod extends JavaPlugin preprocessLogEnabled = config.getBoolean("preprocess_log", preprocessLogEnabled); disableNight = config.getBoolean("disable_night", disableNight); disableWeather = config.getBoolean("disable_weather", disableWeather); + landminesEnabled = config.getBoolean("landmines_enabled", landminesEnabled); + mp44Enabled = config.getBoolean("mp44_enabled", mp44Enabled); } public List superadmins = new ArrayList(); @@ -224,6 +230,7 @@ public class TotalFreedomMod extends JavaPlugin pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Event.Priority.Monitor, this); pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Event.Priority.Monitor, this); + pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Event.Priority.Monitor, this); pm.registerEvent(Event.Type.WEATHER_CHANGE, weatherListener, Event.Priority.High, this); pm.registerEvent(Event.Type.THUNDER_CHANGE, weatherListener, Event.Priority.High, this); diff --git a/src/plugin.yml b/src/plugin.yml index db0db990..214de5aa 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -107,6 +107,9 @@ commands: skylands: description: Goto the skylands. usage: / +# stacker: +# description: Superadmin command - Stack people onto your head. For the lulz. +# usage: / [end] status: description: Show misc. server info. usage: /