mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Various cleanup and bugfixes.
This commit is contained in:
parent
6083f94797
commit
59e6588779
@ -13,7 +13,7 @@ public class Command_adminmode extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
|
||||
if (!senderIsConsole || TFM_Util.isFromClanforge(sender.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
|
||||
return true;
|
||||
|
@ -15,11 +15,6 @@ public class Command_csay extends TFM_Command
|
||||
{
|
||||
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();
|
||||
|
@ -12,7 +12,7 @@ public class Command_kicknoob extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
|
||||
if (!senderIsConsole || TFM_Util.isFromClanforge(sender.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
|
||||
return true;
|
||||
|
@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -14,7 +15,7 @@ public class Command_list extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
final boolean is_clanforge = sender.getName().equalsIgnoreCase("remotebukkit");
|
||||
final boolean is_clanforge = TFM_Util.isFromClanforge(sender.getName());
|
||||
|
||||
StringBuilder onlineStats = new StringBuilder();
|
||||
StringBuilder onlineUsers = new StringBuilder();
|
||||
|
@ -67,7 +67,7 @@ public class Command_lockup extends TFM_Command
|
||||
startLockup(p);
|
||||
TFM_Util.playerMsg(sender, "Locked up " + p.getName() + ".");
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("off"))
|
||||
else if (TFM_Util.isStopCommand(args[1]))
|
||||
{
|
||||
final Player p;
|
||||
try
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -11,7 +12,7 @@ public class Command_moblimiter extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
|
||||
if (!senderIsConsole || TFM_Util.isFromClanforge(sender.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
|
||||
return true;
|
||||
|
@ -21,7 +21,7 @@ public class Command_mp extends TFM_Command
|
||||
{
|
||||
for (Entity ent : world.getLivingEntities())
|
||||
{
|
||||
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon)
|
||||
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient)
|
||||
{
|
||||
ent.remove();
|
||||
removed++;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -11,7 +12,7 @@ public class Command_nonuke extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
|
||||
if (!senderIsConsole || TFM_Util.isFromClanforge(sender.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
|
||||
return true;
|
||||
|
@ -12,7 +12,7 @@ public class Command_rawsay extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
|
||||
if (!senderIsConsole || TFM_Util.isFromClanforge(sender.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
|
||||
return true;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RunSystemCommand;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -11,7 +12,7 @@ public class Command_terminal extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
|
||||
if (!senderIsConsole || TFM_Util.isFromClanforge(sender.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
|
||||
return true;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -43,12 +43,7 @@ public class Command_tossmob extends TFM_Command
|
||||
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
StringBuilder output = new StringBuilder("Supported mobs: ");
|
||||
for (Entry<String, EntityType> mob : TFM_Util.mobtypes.entrySet())
|
||||
{
|
||||
output.append(mob.getKey()).append(", ");
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + output.toString());
|
||||
sender.sendMessage(ChatColor.GREEN + "Supported mobs: " + StringUtils.join(TFM_Util.mobtypes.keySet(), ", "));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class Command_ziptool extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
|
||||
if (!senderIsConsole || TFM_Util.isFromClanforge(sender.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
|
||||
return true;
|
||||
|
@ -64,6 +64,12 @@ public class TFM_EntityListener implements Listener
|
||||
{
|
||||
if (TotalFreedomMod.mobLimiterEnabled)
|
||||
{
|
||||
if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.EGG))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Entity spawned = event.getEntity();
|
||||
|
||||
if (spawned instanceof EnderDragon)
|
||||
@ -98,6 +104,11 @@ public class TFM_EntityListener implements Listener
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (spawned instanceof Bat)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.mobLimiterMax > 0)
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@ -16,6 +15,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.FileUtil;
|
||||
|
||||
public class TFM_SuperadminList
|
||||
{
|
||||
@ -41,7 +41,9 @@ public class TFM_SuperadminList
|
||||
|
||||
public static void loadSuperadminList()
|
||||
{
|
||||
convertV1List();
|
||||
try
|
||||
{
|
||||
// convertV1List();
|
||||
|
||||
superadminList.clear();
|
||||
|
||||
@ -65,6 +67,18 @@ public class TFM_SuperadminList
|
||||
|
||||
updateIndexLists();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void backupSavedList()
|
||||
{
|
||||
File a = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE);
|
||||
File b = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE + ".bak");
|
||||
FileUtil.copy(a, b);
|
||||
}
|
||||
|
||||
public static void updateIndexLists()
|
||||
{
|
||||
@ -98,26 +112,34 @@ public class TFM_SuperadminList
|
||||
}
|
||||
}
|
||||
|
||||
public static void convertV1List()
|
||||
{
|
||||
superadminList.clear();
|
||||
|
||||
TFM_Util.createDefaultConfiguration(TotalFreedomMod.SUPERADMIN_FILE, TotalFreedomMod.plugin_file);
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||
|
||||
if (!config.isConfigurationSection("superadmins"))
|
||||
{
|
||||
for (String admin_name : config.getKeys(false))
|
||||
{
|
||||
TFM_Superadmin superadmin = new TFM_Superadmin(admin_name, config.getStringList(admin_name), new Date(), "", false, new ArrayList<String>());
|
||||
superadminList.put(admin_name.toLowerCase(), superadmin);
|
||||
}
|
||||
|
||||
saveSuperadminList();
|
||||
}
|
||||
}
|
||||
|
||||
// public static void convertV1List()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// superadminList.clear();
|
||||
//
|
||||
// TFM_Util.createDefaultConfiguration(TotalFreedomMod.SUPERADMIN_FILE, TotalFreedomMod.plugin_file);
|
||||
// FileConfiguration config = YamlConfiguration.loadConfiguration(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||
//
|
||||
// if (!config.isConfigurationSection("superadmins"))
|
||||
// {
|
||||
// for (String admin_name : config.getKeys(false))
|
||||
// {
|
||||
// TFM_Superadmin superadmin = new TFM_Superadmin(admin_name, config.getStringList(admin_name), new Date(), "", false, new ArrayList<String>());
|
||||
// superadminList.put(admin_name.toLowerCase(), superadmin);
|
||||
// }
|
||||
//
|
||||
// saveSuperadminList();
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// TFM_Log.severe(ex);
|
||||
// }
|
||||
// }
|
||||
public static void saveSuperadminList()
|
||||
{
|
||||
try
|
||||
{
|
||||
updateIndexLists();
|
||||
|
||||
@ -138,11 +160,9 @@ public class TFM_SuperadminList
|
||||
config.set("superadmins." + admin_name + ".console_aliases", superadmin.getConsoleAliases());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
config.save(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||
}
|
||||
catch (IOException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
@ -245,6 +265,8 @@ public class TFM_SuperadminList
|
||||
}
|
||||
|
||||
public static boolean checkPartialSuperadminIP(String user_ip)
|
||||
{
|
||||
try
|
||||
{
|
||||
user_ip = user_ip.trim();
|
||||
|
||||
@ -289,6 +311,11 @@ public class TFM_SuperadminList
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -23,42 +23,29 @@ import org.bukkit.entity.*;
|
||||
|
||||
public class TFM_Util
|
||||
{
|
||||
private static Map<String, Integer> eject_tracker = new HashMap<String, Integer>();
|
||||
private static final Map<String, Integer> eject_tracker = new HashMap<String, Integer>();
|
||||
public static final Map<String, EntityType> mobtypes = new HashMap<String, EntityType>();
|
||||
public static final List<String> stop_commands = new ArrayList<String>();
|
||||
public static final List<String> stop_commands = Arrays.asList("stop", "off", "end", "halt", "die");
|
||||
public static final List<String> restricted_senders = Arrays.asList("rcon, remotebukkit");
|
||||
|
||||
static
|
||||
{
|
||||
mobtypes.put("blaze", EntityType.BLAZE);
|
||||
mobtypes.put("cavespider", EntityType.CAVE_SPIDER);
|
||||
mobtypes.put("chicken", EntityType.CHICKEN);
|
||||
mobtypes.put("cow", EntityType.COW);
|
||||
mobtypes.put("creeper", EntityType.CREEPER);
|
||||
mobtypes.put("enderdragon", EntityType.ENDER_DRAGON);
|
||||
mobtypes.put("enderman", EntityType.ENDERMAN);
|
||||
mobtypes.put("ghast", EntityType.GHAST);
|
||||
mobtypes.put("giant", EntityType.GIANT);
|
||||
mobtypes.put("irongolem", EntityType.IRON_GOLEM);
|
||||
mobtypes.put("mushroomcow", EntityType.MUSHROOM_COW);
|
||||
mobtypes.put("ocelot", EntityType.OCELOT);
|
||||
mobtypes.put("pig", EntityType.PIG);
|
||||
mobtypes.put("pigzombie", EntityType.PIG_ZOMBIE);
|
||||
mobtypes.put("sheep", EntityType.SHEEP);
|
||||
mobtypes.put("silverfish", EntityType.SILVERFISH);
|
||||
mobtypes.put("skeleton", EntityType.SKELETON);
|
||||
mobtypes.put("slime", EntityType.SLIME);
|
||||
mobtypes.put("snowman", EntityType.SNOWMAN);
|
||||
mobtypes.put("spider", EntityType.SPIDER);
|
||||
mobtypes.put("squid", EntityType.SQUID);
|
||||
mobtypes.put("villager", EntityType.VILLAGER);
|
||||
mobtypes.put("wolf", EntityType.WOLF);
|
||||
mobtypes.put("zombie", EntityType.ZOMBIE);
|
||||
|
||||
stop_commands.add("stop");
|
||||
stop_commands.add("off");
|
||||
stop_commands.add("end");
|
||||
stop_commands.add("halt");
|
||||
stop_commands.add("die");
|
||||
for (EntityType entity_type : EntityType.values())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (entity_type.getName() != null)
|
||||
{
|
||||
if (Creature.class.isAssignableFrom(entity_type.getEntityClass()))
|
||||
{
|
||||
mobtypes.put(entity_type.getName().toLowerCase(), entity_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TFM_Util()
|
||||
@ -910,6 +897,11 @@ public class TFM_Util
|
||||
return new Date(0L);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFromClanforge(String sender_name)
|
||||
{
|
||||
return restricted_senders.contains(sender_name.toLowerCase());
|
||||
}
|
||||
// I wrote all this before i discovered getTargetBlock >.> - might come in handy some day...
|
||||
// public static final double LOOKAT_VIEW_HEIGHT = 1.65;
|
||||
// public static final double LOOKAT_STEP_DISTANCE = 0.2;
|
||||
|
@ -255,6 +255,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
try
|
||||
{
|
||||
TFM_SuperadminList.backupSavedList();
|
||||
TFM_SuperadminList.loadSuperadminList();
|
||||
|
||||
superadmins = TFM_SuperadminList.getSuperadminNames();
|
||||
|
Loading…
Reference in New Issue
Block a user