mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Misc
This commit is contained in:
parent
98ee190b57
commit
35821a75c9
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
// }
|
||||
}
|
@ -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())
|
||||
{
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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<String, CreatureType> mobtypes = new HashMap<String, CreatureType>();
|
||||
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
|
||||
|
@ -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;
|
||||
|
@ -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<TFM_LandmineData> landmines = plugin.landmines.iterator();
|
||||
while (landmines.hasNext())
|
||||
if (plugin.landminesEnabled && plugin.allowExplosions)
|
||||
{
|
||||
TFM_LandmineData landmine = landmines.next();
|
||||
|
||||
if (!landmine.player.equals(p))
|
||||
Iterator<TFM_LandmineData> 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<String, CreatureType> mobtypes = new HashMap<String, CreatureType>();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -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<String> superadmins = new ArrayList<String>();
|
||||
@ -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);
|
||||
|
@ -107,6 +107,9 @@ commands:
|
||||
skylands:
|
||||
description: Goto the skylands.
|
||||
usage: /<command>
|
||||
# stacker:
|
||||
# description: Superadmin command - Stack people onto your head. For the lulz.
|
||||
# usage: /<command> [end]
|
||||
status:
|
||||
description: Show misc. server info.
|
||||
usage: /<command>
|
||||
|
Loading…
Reference in New Issue
Block a user