Compare commits

..

20 Commits

Author SHA1 Message Date
ee0ebd85fc Increment to version 4.1 to reflect latest changes 2014-04-23 17:03:33 +02:00
518537413b Allow use of multiple blocks in /ro. Closes #87 2014-04-23 17:00:44 +02:00
802d02d653 Shoot players in the sky when using /doom. Closes #142 2014-04-23 16:43:12 +02:00
f3cb57c9cd Extend command rollback time. Closes #136
Addresses http://www.totalfreedom.boards.net/thread/9531/problem-suggestion
2014-04-23 16:38:47 +02:00
c7c2795f41 Tweaked /ops and /qop 2014-04-23 16:36:11 +02:00
20b117a703 Moved toggle commands (/firespread, /lavadmg, etc) to /toggle 2014-04-23 16:23:50 +02:00
8522570db5 Move license to separate project 2014-04-22 23:19:40 +02:00
08e4a4a171 Moved permban list to a seperate class
Refractoring
Code cleanup
2014-04-21 23:09:10 +02:00
a0affddeed Refractored command handling to seperate class: TFM_CommandHandler
Cleanup, refractoring
2014-04-21 19:00:39 +02:00
c82113dc22 Fixed duplicate entries when adding/removing players
Some refractoring
2014-04-21 17:45:32 +02:00
9315227906 Actually make the default console senior permissions configurable 2014-04-21 15:08:52 +02:00
00e9b4ea1f [Bleeding] Cleaned up TFM_Command.senderHasPermission() 2014-04-21 14:56:24 +02:00
22b0781020 Allow the default CONSOLE to have senior permissions 2014-04-21 14:52:23 +02:00
7df24c6b86 Added more detailed build information to /tfm through appinfo.properties 2014-04-21 14:37:53 +02:00
0e9044ffc3 Allow compiling for Spigot 1.7.8 2014-04-17 18:29:08 +02:00
3371f54c06 Merged from master 2014-04-15 16:43:38 +02:00
92d7c58957 Merge pull request #148 from Wilee999/patch-5
Fix /invis smite bug where it spammed the smite message each player.
2014-04-13 00:56:57 +02:00
478244773b Fix /invis smite bug where it spammed the smite message each player. 2014-04-11 17:57:11 -07:00
b3b182e753 Merge pull request #141 from Wilee999/patch-5
Implement /tfipbanlist purge adminAction.
2014-04-09 23:10:48 +02:00
49601035a5 Implement /tfipbanlist purge adminAction. 2014-03-02 18:02:10 -08:00
60 changed files with 894 additions and 978 deletions

3
.gitignore vendored
View File

@ -17,3 +17,6 @@ manifest.mf
.Trashes
ehthumbs.db
Thumbs.db
# TFM files
buildcreator.properties

View File

@ -1,13 +1,3 @@
# TotalFreedomMod License #
TotalFreedomMod is primarily derived from the Bukkit and CraftBukkit library and server, respectively. Therefore, we have chosen for it to inherit the GNU GPLv3 License as used by those programs. This license is available at http://www.gnu.org/licenses/gpl-3.0.txt
We do, however, ask that you comply by several restrictions. These restrictions are in place to make sure that credit is given to the original authors, who remain the maintainers of the plugin and its source code.
* A un-edited copy of this LICENSE.md shall always be included with this source code.
* TotalFreedomMod source code and its derivations shall be freely distributable between anyone who chooses to download it.
* You shall not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" or "JeromSar" from any part of the source code.
* You shall not edit or remove the file Command_tfm.java
* You may not modify the file TFM_FrontDoor.java. Removing it is fine, however.
* Compiled binaries (*.jar's) shall not to be distributed.
* If you wish to obtain a copy of TotalFreedomMod you must compile the original source code or it's derivations yourself.
* The primary developers, StevenLawson (Madgeek1450) and Jerom van der Sar (DarthSalamon), may choose to provide official binaries on a discretionary basis.
* Any restrictions listed here may be waived by any of the above mentioned primary developers.
TotalFreedomMod is licensed under the TotalFreedom General License. It is available [here](https://github.com/TotalFreedom/License/blob/master/LICENSE.md).

View File

@ -2,11 +2,17 @@
<project name="TotalFreedomMod" default="default" basedir=".">
<description>Builds, tests, and runs the project TotalFreedomMod.</description>
<import file="nbproject/build-impl.xml" />
<target name="-pre-jar">
<copy file="buildcreator.default.properties" tofile="buildcreator.properties" overwrite="false" />
<property file="buildcreator.properties"/>
<buildnumber file="buildnumber.properties" />
<propertyfile file="appinfo.properties">
<entry key="program.buildnumber" value="${build.number}" />
<entry key="program.builddate" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
<entry key="program.buildcreator" value="${program.buildcreator}" />
</propertyfile>
<copy file="appinfo.properties" todir="${build.classes.dir}" />
<delete file="appinfo.properties" />

View File

@ -0,0 +1,2 @@
# Build creator configuration
program.buildcreator=Unknown

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Apr 15 16:28:36 CEST 2014
build.number=762
#Wed Apr 23 17:02:21 CEST 2014
build.number=796

View File

@ -1,4 +1,4 @@
# TotalFreedomMod v4.0 Configuration
# TotalFreedomMod v4.1 Configuration
# by Madgeek1450 and DarthSalamon
# Block placement prevention:
@ -129,6 +129,10 @@ protected_areas_enabled: true
auto_protect_spawnpoints: true
auto_protect_radius: 25.0
# Give the default CONSOLE senior admin privileges.
# Handy in development environments.
console_is_senior: true
# Host Sender Names - Names that indicate automated services or host-based consoles you want to block from using some commands.
# Make sure these are all lower-case.
host_sender_names:

View File

@ -10,5 +10,5 @@ public @interface CommandPermissions
SourceType source();
boolean block_host_console() default false;
boolean blockHostConsole() default false;
}

View File

@ -7,7 +7,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Close server to non-superadmins.", usage = "/<command> [on | off]")
public class Command_adminmode extends TFM_Command
{

View File

@ -1,70 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Temporarily change config parameters.", usage = "/<command> <entry> <value>")
public class Command_config extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 2)
{
return false;
}
TFM_ConfigEntry entry = TFM_ConfigEntry.findConfigEntry(args[0]);
if (entry == null)
{
sender.sendMessage("Can't find configuration option: " + args[0]);
return true;
}
Object newValue = null;
final String newValueString = args[1].trim();
final Class<?> type = entry.getType();
try
{
if (type.isAssignableFrom(Integer.class))
{
newValue = new Integer(newValueString);
entry.setInteger((Integer) newValue);
}
else if (type.isAssignableFrom(Double.class))
{
newValue = new Double(newValueString);
entry.setDouble((Double) newValue);
}
else if (type.isAssignableFrom(Boolean.class))
{
newValue = Boolean.valueOf(newValueString);
entry.setBoolean((Boolean) newValue);
}
else if (type.isAssignableFrom(String.class))
{
newValue = newValueString;
entry.setString((String) newValue);
}
}
catch (Exception ex)
{
}
if (newValue != null)
{
sender.sendMessage(String.format("Set configuration entry \"%s\" to \"%s\" value \"%s\".",
entry.toString(), type.getName(), newValue.toString()));
}
else
{
sender.sendMessage("Could not parse value \"" + newValueString + "\" as type \"" + type.getName() + "\".");
}
return true;
}
}

View File

@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Make some noise.", usage = "/<command>")
public class Command_deafen extends TFM_Command
{

View File

@ -11,6 +11,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "For the bad Superadmins", usage = "/<command> <playername>")
@ -72,6 +73,9 @@ public class Command_doom extends TFM_Command
// generate explosion
player.getWorld().createExplosion(player.getLocation(), 4F);
// Shoot the player in the sky
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0)));
new BukkitRunnable()
{
@Override
@ -83,7 +87,7 @@ public class Command_doom extends TFM_Command
// kill (if not done already)
player.setHealth(0.0);
}
}.runTaskLater(plugin, 20L * 2L);
}.runTaskLater(plugin, 2L * 20L);
new BukkitRunnable()
{
@ -99,7 +103,7 @@ public class Command_doom extends TFM_Command
// kick player
player.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
}
}.runTaskLater(plugin, 20L * 3L);
}.runTaskLater(plugin, 3L * 20L);
return true;
}

View File

@ -1,25 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable auto entity wiper.", usage = "/<command> <on | off>")
public class Command_droptoggle extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
TFM_Util.adminAction(sender.getName(),
(TFM_ConfigEntry.AUTO_ENTITY_WIPE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "Enabled" : "Disabled")
+ " automatic entity wiping.", false);
return true;
}
}

View File

@ -1,42 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Shortcut to enable/disable DisguiseCraft.", usage = "/<command>")
public class Command_dtoggle extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Plugin disguiseCraft = server.getPluginManager().getPlugin("DisguiseCraft");
if (disguiseCraft != null)
{
PluginManager pluginManager = plugin.getServer().getPluginManager();
boolean enabled = disguiseCraft.isEnabled();
if (enabled)
{
pluginManager.disablePlugin(disguiseCraft);
}
else
{
pluginManager.enablePlugin(disguiseCraft);
}
TFM_Util.adminAction(sender.getName(), (!enabled ? "Enabled" : "Disabled") + " DisguiseCraft.", true);
}
else
{
sender.sendMessage("DisguiseCraft is not installed on this server.");
}
return true;
}
}

View File

@ -1,47 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable explosives and set effect radius.", usage = "/<command> <on | off> [radius]")
public class Command_explosives extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
if (args.length == 2)
{
try
{
TFM_ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException nfex)
{
TFM_Util.playerMsg(sender, nfex.getMessage());
return true;
}
}
if (args[0].equalsIgnoreCase("on"))
{
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
playerMsg("Explosives are now enabled, radius set to " + TFM_ConfigEntry.EXPLOSIVE_RADIUS.getDouble() + " blocks.");
}
else
{
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(false);
playerMsg("Explosives are now disabled.");
}
return true;
}
}

View File

@ -1,33 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable fire placement.", usage = "/<command> <on | off>")
public class Command_fireplace extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (args[0].equalsIgnoreCase("on"))
{
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
playerMsg("Fire placement is now enabled.");
}
else
{
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(false);
playerMsg("Fire placement is now disabled.");
}
return true;
}
}

View File

@ -1,31 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable fire spread.", usage = "/<command> <on | off>")
public class Command_firespread extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
boolean fireSpread = !args[0].equalsIgnoreCase("off");
TFM_ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(fireSpread);
playerMsg("Fire spread is now " + (fireSpread ? "enabled" : "disabled") + ".");
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, fireSpread);
return true;
}
}

View File

@ -1,24 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable fluid spread.", usage = "/<command> <on | off>")
public class Command_fluidspread extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
playerMsg("Lava and water spread is now " + (TFM_ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}
}

View File

@ -50,12 +50,11 @@ public class Command_glist extends TFM_Command
else if (args.length == 2)
{
String username;
List<String> ips = new ArrayList<String>();
final List<String> ips = new ArrayList<String>();
try
{
Player player = getPlayer(args[1]);
final Player player = getPlayer(args[1]);
username = player.getName();
ips.add(player.getAddress().getAddress().getHostAddress());
}
@ -70,7 +69,7 @@ public class Command_glist extends TFM_Command
}
username = entry.getLastJoinName();
ips = entry.getIps();
ips.addAll(entry.getIps());
}
String mode = args[0].toLowerCase();

View File

@ -22,6 +22,7 @@ public class Command_invis extends TFM_Command
{
if (args[0].equalsIgnoreCase("smite"))
{
TFM_Util.adminAction(sender.getName(), "Smiting all invisible players", true);
smite = true;
}
else
@ -40,7 +41,6 @@ public class Command_invis extends TFM_Command
players.add(player.getName());
if (smite && !TFM_AdminList.isSuperAdmin(player))
{
TFM_Util.adminAction(sender.getName(), "Smiting all invisible players", true);
player.setHealth(0.0);
smites++;
}

View File

@ -7,7 +7,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Kick all non-superadmins on server.", usage = "/<command>")
public class Command_kicknoob extends TFM_Command
{

View File

@ -1,24 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable lava damage.", usage = "/<command> <on | off>")
public class Command_lavadmg extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
playerMsg("Lava damage is now " + (TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}
}

View File

@ -1,24 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable lava placement.", usage = "/<command> <on | off>")
public class Command_lavaplace extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
playerMsg("Lava placement is now " + (TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}
}

View File

@ -1,14 +1,16 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.io.File;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PermbanList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Download the superadmin and permban lists from the main TotalFreedom server.", usage = "/<command>")
public class Command_listsync extends TFM_Command
{
@ -19,8 +21,10 @@ public class Command_listsync extends TFM_Command
try
{
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_superadmins_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
TotalFreedomMod.loadSuperadminConfig();
TFM_AdminList.createBackup();
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_superadmins_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(),
TotalFreedomMod.SUPERADMIN_FILE));
TFM_AdminList.load();
TFM_Util.adminAction(sender.getName(), TotalFreedomMod.SUPERADMIN_FILE + " downloaded.", false);
}
catch (Exception ex)
@ -30,8 +34,10 @@ public class Command_listsync extends TFM_Command
try
{
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_permbans_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PERMBAN_FILE));
TotalFreedomMod.loadPermbanConfig();
TFM_PermbanList.createBackup();
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_permbans_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(),
TotalFreedomMod.PERMBAN_FILE));
TFM_PermbanList.load();
TFM_Util.adminAction(sender.getName(), TotalFreedomMod.PERMBAN_FILE + " downloaded.", false);
}
catch (Exception ex)

View File

@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Block target's minecraft input. This is evil, and I never should have wrote it.", usage = "/<command> <all | purge | <<partialname> on | off>>")
public class Command_lockup extends TFM_Command
{

View File

@ -1,57 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandParameters(description = "Attempt to detect \"invisible griefers\" and \"nukers\".", usage = "/<command> <on | off> [range] [blockrate]")
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 (args.length < 1)
{
return false;
}
if (args.length >= 2)
{
try
{
TFM_ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException nfex)
{
}
}
if (args.length >= 3)
{
try
{
TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
}
catch (NumberFormatException nfex)
{
}
}
if (args[0].equalsIgnoreCase("on"))
{
TFM_ConfigEntry.NUKE_MONITOR.setBoolean(true);
playerMsg("Nuke monitor is enabled.");
playerMsg("Anti-freecam range is set to " + TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
playerMsg("Block throttle rate is set to " + TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
}
else
{
TFM_ConfigEntry.NUKE_MONITOR.setBoolean(false);
playerMsg("Nuke monitor is disabled.");
}
return true;
}
}

View File

@ -1,55 +1,66 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
@CommandParameters(description = "Manage operators", usage = "/<command> <count | list>")
@CommandParameters(description = "Manager operators", usage = "/<command> <count | purge>")
public class Command_ops extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1 || args.length > 1)
if (args.length != 1)
{
return false;
}
if (args[0].equalsIgnoreCase("list"))
if (args[0].equals("count"))
{
TFM_Util.playerMsg(sender, "Operators: " + TFM_Util.playerListToNames(server.getOperators()));
int totalOps = server.getOperators().size();
int onlineOps = 0;
for (Player player : server.getOnlinePlayers())
{
if (player.isOp())
{
onlineOps++;
}
}
playerMsg("Online OPs: " + onlineOps);
playerMsg("Offline OPs: " + (totalOps - onlineOps));
playerMsg("Total OPs: " + totalOps);
return true;
}
if (args[0].equalsIgnoreCase("count"))
if (args[0].equals("purge"))
{
int onlineOPs = 0;
int offlineOPs = 0;
int totalOPs = 0;
if (!TFM_AdminList.isSuperAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
TFM_Util.adminAction(sender.getName(), "Purging all operators", true);
for (OfflinePlayer player : server.getOperators())
{
player.setOp(false);
if (player.isOnline())
{
onlineOPs++;
playerMsg((Player) player, TotalFreedomMod.YOU_ARE_NOT_OP);
}
else
{
offlineOPs++;
}
totalOPs++;
}
playerMsg("Online OPs: " + onlineOPs);
playerMsg("Offline OPs: " + offlineOPs);
playerMsg("Total OPs: " + totalOPs);
return true;
}
return true;
return false;
}
}

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PermbanList;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
@ -7,7 +8,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Manage permanently banned players and IPs.", usage = "/<command> <list | reload>")
public class Command_permban extends TFM_Command
{
@ -31,7 +32,8 @@ public class Command_permban extends TFM_Command
return true;
}
playerMsg("Reloading permban list...", ChatColor.RED);
TotalFreedomMod.loadPermbanConfig();
TFM_PermbanList.createBackup();
TFM_PermbanList.load();
dumplist(sender);
}
else
@ -44,24 +46,24 @@ public class Command_permban extends TFM_Command
private void dumplist(CommandSender sender)
{
if (TotalFreedomMod.permbannedPlayers.isEmpty())
if (TFM_PermbanList.getPermbannedPlayers().isEmpty())
{
playerMsg(sender, "No permanently banned player names.");
}
else
{
playerMsg(sender, TotalFreedomMod.permbannedPlayers.size() + " permanently banned players:");
playerMsg(sender, StringUtils.join(TotalFreedomMod.permbannedPlayers, ", "));
playerMsg(sender, TFM_PermbanList.getPermbannedPlayers().size() + " permanently banned players:");
playerMsg(sender, StringUtils.join(TFM_PermbanList.getPermbannedPlayers(), ", "));
}
if (TotalFreedomMod.permbannedIps.isEmpty())
if (TFM_PermbanList.getPermbannedIps().isEmpty())
{
playerMsg(sender, "No permanently banned IPs.");
}
else
{
playerMsg(sender, TotalFreedomMod.permbannedIps.size() + " permanently banned IPs:");
playerMsg(sender, StringUtils.join(TotalFreedomMod.permbannedIps, ", "));
playerMsg(sender, TFM_PermbanList.getPermbannedIps().size() + " permanently banned IPs:");
playerMsg(sender, StringUtils.join(TFM_PermbanList.getPermbannedIps(), ", "));
}
}
}

View File

@ -1,28 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable tamed pet protection.", usage = "/<command> <on | off>")
public class Command_petprotect extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
TFM_Util.adminAction(
sender.getName(),
"Tamed pet protection is now " + (TFM_ConfigEntry.PET_PROTECT_ENABLED.setBoolean(!TFM_Util.isStopCommand(args[0])) ? "enabled" : "disabled") + ".",
false);
return true;
}
}

View File

@ -1,35 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandParameters(
description = "Enable/disable the command prelogger. When this is on, logs will be filled with many duplicate messages.",
usage = "/<command> <on | off>")
public class Command_prelog extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (args[0].equalsIgnoreCase("on"))
{
TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(true);
playerMsg("Command preprocess logging is now enabled. This will be spammy in the log.");
}
else
{
TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(false);
playerMsg("Command preprocess logging is now disabled.");
}
return true;
}
}

View File

@ -6,7 +6,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
@CommandParameters(description = "Quick Op - op someone based on a partial name.", usage = "/<command> <partialname>")
public class Command_qop extends TFM_Command
{

View File

@ -6,7 +6,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/<command> <message>")
public class Command_rawsay extends TFM_Command
{

View File

@ -1,13 +1,16 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = false)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = false)
@CommandParameters(description = "Remove all blocks of a certain type in the radius of certain players.", usage = "/<command> <block> [radius (default=50)] [player]")
public class Command_ro extends TFM_Command
{
@ -19,22 +22,32 @@ public class Command_ro extends TFM_Command
return false;
}
Material from_material = Material.matchMaterial(args[0]);
if (from_material == null)
final List<Material> materials = new ArrayList<Material>();
for (String materialName : (args[0].contains(",") ? args[0].split(",") : new String[]
{
try
{
from_material = Material.getMaterial(Integer.parseInt(args[0]));
}
catch (NumberFormatException ex)
args[0]
}))
{
Material fromMaterial = Material.matchMaterial(materialName);
if (fromMaterial == null)
{
try
{
fromMaterial = Material.getMaterial(Integer.parseInt(materialName));
}
catch (NumberFormatException ex)
{
}
}
if (from_material == null)
if (fromMaterial == null)
{
playerMsg("Invalid block: " + args[0], ChatColor.RED);
playerMsg("Invalid block: " + materialName, ChatColor.RED);
return true;
}
materials.add(fromMaterial);
}
int radius = 20;
@ -51,7 +64,7 @@ public class Command_ro extends TFM_Command
}
}
Player targetPlayer = null;
final Player targetPlayer;
if (args.length == 3)
{
try
@ -64,24 +77,37 @@ public class Command_ro extends TFM_Command
return true;
}
}
else
{
targetPlayer = null;
}
final String names = StringUtils.join(materials, ", ");
int affected = 0;
if (targetPlayer == null)
{
TFM_Util.adminAction(sender.getName(), "Removing all " + from_material.name() + " within " + radius + " blocks of all players. Brace for lag...", senderIsConsole);
for (Player player : server.getOnlinePlayers())
TFM_Util.adminAction(sender.getName(), "Removing all " + names + " within " + radius + " blocks of all players... Brace for lag!", false);
for (Material material : materials)
{
affected += TFM_Util.replaceBlocks(player.getLocation(), from_material, Material.AIR, radius);
for (Player player : server.getOnlinePlayers())
{
affected += TFM_Util.replaceBlocks(player.getLocation(), material, Material.AIR, radius);
}
}
}
else
{
TFM_Util.adminAction(sender.getName(), "Removing all " + from_material.name() + " within " + radius + " blocks of " + targetPlayer.getName() + ".", senderIsConsole);
affected += TFM_Util.replaceBlocks(targetPlayer.getLocation(), from_material, Material.AIR, radius);
for (Material material : materials)
{
TFM_Util.adminAction(sender.getName(), "Removing all " + names + " within " + radius + " blocks of " + targetPlayer.getName(), false);
affected += TFM_Util.replaceBlocks(targetPlayer.getLocation(), material, Material.AIR, radius);
}
}
TFM_Util.adminAction(sender.getName(), "Remove complete. " + affected + " blocks removed.", senderIsConsole);
TFM_Util.adminAction(sender.getName(), "Remove complete! " + affected + " blocks removed.", false);
return true;
}

View File

@ -7,7 +7,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | undo [partialname] purge [partialname] | purgeall>", aliases = "rb")
public class Command_rollback extends TFM_Command
{
@ -38,7 +38,7 @@ public class Command_rollback extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Rolling back player: " + playerName, false);
playerMsg("Rolled back " + TFM_RollbackManager.rollback(playerName) + " edits for " + playerName + ".");
playerMsg("If this rollback was a mistake, use /rollback undo " + playerName + " within 20 seconds to reverse the rollback.");
playerMsg("If this rollback was a mistake, use /rollback undo " + playerName + " within 40 seconds to reverse the rollback.");
}
}
else if (args.length == 2)

View File

@ -9,6 +9,7 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -24,11 +25,12 @@ public class Command_saconfig extends TFM_Command
{
return false;
}
if (args.length == 1)
{
if (args[0].equals("list"))
{
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperadminNames(), ", "), ChatColor.GOLD);
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperNames(), ", "), ChatColor.GOLD);
return true;
}
@ -43,7 +45,7 @@ public class Command_saconfig extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list", true);
TFM_AdminList.cleanSuperadminList(true);
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperadminUUIDs(), ", "), ChatColor.YELLOW);
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperNames(), ", "), ChatColor.YELLOW);
return true;
}
@ -91,8 +93,7 @@ public class Command_saconfig extends TFM_Command
if (args[0].equalsIgnoreCase("add"))
{
Player player = null;
String playername = null;
OfflinePlayer player;
try
{
@ -101,27 +102,19 @@ public class Command_saconfig extends TFM_Command
catch (PlayerNotFoundException ex)
{
final TFM_Admin superadmin = TFM_AdminList.getEntry(args[1]);
if (superadmin != null)
{
playername = superadmin.getLastLoginName();
}
else
if (superadmin == null)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
player = Bukkit.getOfflinePlayer(superadmin.getLastLoginName());
}
if (player != null)
{
TFM_Util.adminAction(sender.getName(), "Adding " + player.getName() + " to the superadmin list.", true);
TFM_AdminList.addSuperadmin(player);
}
else if (playername != null)
{
TFM_Util.adminAction(sender.getName(), "Adding " + playername + " to the superadmin list.", true);
TFM_AdminList.addSuperadmin(player);
}
TFM_Util.adminAction(sender.getName(), "Adding " + player.getName() + " to the superadmin list", true);
TFM_AdminList.addSuperadmin(player);
return true;
}
@ -143,7 +136,7 @@ public class Command_saconfig extends TFM_Command
{
}
if (!TFM_AdminList.getLowerSuperadminNames().contains(targetName.toLowerCase()))
if (!TFM_AdminList.getLowerSuperNames().contains(targetName.toLowerCase()))
{
playerMsg("Superadmin not found: " + targetName);
return true;

View File

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
@ -28,6 +29,8 @@ public class Command_tfipbanlist extends TFM_Command
try
{
TFM_BanManager.getInstance().purgeIpBans();
TFM_Util.adminAction(sender.getName(), "Purging the IP ban list", true);
sender.sendMessage(ChatColor.GRAY + "IP ban list has been purged.");
}
catch (Exception ex)

View File

@ -1,5 +1,11 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PermbanList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerList;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -7,14 +13,51 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Shows information about TotalFreedomMod", usage = "/<command>")
@CommandParameters(description = "Shows information about TotalFreedomMod or reloads it", usage = "/<command> [reload]")
public class Command_tfm extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
playerMsg("TotalFreedomMod for 'TotalFreedom', the original all-op server.", ChatColor.GOLD);
playerMsg(String.format("Version " + ChatColor.BLUE + "%s.%s" + ChatColor.BLUE + ", built %s.", TotalFreedomMod.pluginVersion, TotalFreedomMod.buildNumber, TotalFreedomMod.buildDate), ChatColor.GOLD);
if (args.length == 1)
{
if (!args[0].equals("reload"))
{
return false;
}
if (!TFM_AdminList.isSuperAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
}
TFM_AdminList.load();
TFM_PermbanList.load();
TFM_PlayerList.getInstance().load();
TFM_BanManager.getInstance().load();
TFM_CommandBlocker.getInstance().parseBlockingRules();
final String message = String.format("%s v%s.%s reloaded.",
TotalFreedomMod.pluginName,
TotalFreedomMod.pluginVersion,
TotalFreedomMod.buildNumber);
playerMsg(message);
TFM_Log.info(message);
return true;
}
playerMsg("TotalFreedomMod for 'Total Freedom', the original all-op server.", ChatColor.GOLD);
playerMsg(String.format("Version "
+ ChatColor.BLUE + "%s.%s" + ChatColor.GOLD + ", built "
+ ChatColor.BLUE + "%s" + ChatColor.GOLD + " by "
+ ChatColor.BLUE + "%s" + ChatColor.GOLD + ".",
TotalFreedomMod.pluginVersion,
TotalFreedomMod.buildNumber,
TotalFreedomMod.buildDate,
TotalFreedomMod.buildCreator), ChatColor.GOLD);
playerMsg("Created by Madgeek1450 and DarthSalamon.", ChatColor.GOLD);
playerMsg("Visit " + ChatColor.AQUA + "http://totalfreedom.me/" + ChatColor.GREEN + " for more information.", ChatColor.GREEN);

View File

@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Update server files.", usage = "/<command>")
public class Command_tfupdate extends TFM_Command
{

View File

@ -0,0 +1,184 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler.TFM_GameRule;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Toggles TotalFreedomMod settings", usage = "/<command> [option] [value] [value]")
public class Command_toggle extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
playerMsg("Available toggles: ");
playerMsg("- waterplace");
playerMsg("- fireplace");
playerMsg("- lavaplace");
playerMsg("- fluidspread");
playerMsg("- lavadmg");
playerMsg("- firespread");
playerMsg("- prelog");
playerMsg("- petprotect");
playerMsg("- droptoggle");
playerMsg("- nonuke");
playerMsg("- explosives");
playerMsg("- disguisecraft");
return false;
}
if (args[0].equals("waterplace"))
{
toggle("Water placement is", TFM_ConfigEntry.ALLOW_WATER_PLACE);
return true;
}
if (args[0].equals("fireplace"))
{
toggle("Fire placement is", TFM_ConfigEntry.ALLOW_FIRE_PLACE);
return true;
}
if (args[0].equals("lavaplace"))
{
toggle("Lava placement is", TFM_ConfigEntry.ALLOW_LAVA_PLACE);
return true;
}
if (args[0].equals("fluidspread"))
{
toggle("Fire placement is", TFM_ConfigEntry.ALLOW_FLUID_SPREAD);
return true;
}
if (args[0].equals("lavadmg"))
{
toggle("Lava damage is", TFM_ConfigEntry.ALLOW_LAVA_DAMAGE);
return true;
}
if (args[0].equals("firespread"))
{
TFM_GameRuleHandler.setGameRule(TFM_GameRule.DO_FIRE_TICK, TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
toggle("Fire spread is", TFM_ConfigEntry.ALLOW_FIRE_SPREAD);
return true;
}
if (args[0].equals("prelog"))
{
toggle("Command prelogging is", TFM_ConfigEntry.PREPROCESS_LOG_ENABLED);
return true;
}
if (args[0].equals("petprotect"))
{
toggle("Tamed pet protection is", TFM_ConfigEntry.PET_PROTECT_ENABLED);
return true;
}
if (args[0].equals("droptoggle"))
{
toggle("Automatic entity wiping is", TFM_ConfigEntry.AUTO_ENTITY_WIPE);
return true;
}
if (args[0].equals("nonuke"))
{
if (args.length >= 2)
{
try
{
TFM_ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException nfex)
{
}
}
if (args.length >= 3)
{
try
{
TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
}
catch (NumberFormatException nfex)
{
}
}
toggle("Nuke monitor is", TFM_ConfigEntry.NUKE_MONITOR);
if (TFM_ConfigEntry.NUKE_MONITOR.getBoolean())
{
playerMsg("Anti-freecam range is set to " + TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
playerMsg("Block throttle rate is set to " + TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
}
return true;
}
if (args[0].equals("explosives"))
{
if (args.length == 2)
{
try
{
TFM_ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException ex)
{
TFM_Util.playerMsg(sender, ex.getMessage());
return true;
}
}
toggle("Explosions are", TFM_ConfigEntry.ALLOW_EXPLOSIONS);
if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
playerMsg("Radius set to " + TFM_ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
}
return true;
}
if (args[0].equals("disguisecraft"))
{
final Plugin disguiseCraft = server.getPluginManager().getPlugin("DisguiseCraft");
if (disguiseCraft == null)
{
playerMsg("DisguiseCraft is not installed on this server.");
return true;
}
boolean enabled = disguiseCraft.isEnabled();
TFM_Util.adminAction(sender.getName(), (enabled ? "disa" : "ena") + "bling DisguiseCraft", true);
if (enabled)
{
plugin.getServer().getPluginManager().disablePlugin(disguiseCraft);
}
else
{
plugin.getServer().getPluginManager().enablePlugin(disguiseCraft);
}
return true;
}
return false;
}
private void toggle(String name, TFM_ConfigEntry entry)
{
entry.setBoolean(!entry.getBoolean());
playerMsg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled."));
}
}

View File

@ -1,24 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable water placement.", usage = "/<command> <on | off>")
public class Command_waterplace extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
playerMsg("Water placement is now " + (TFM_ConfigEntry.ALLOW_WATER_PLACE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}
}

View File

@ -6,7 +6,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Wipe the flatlands map. Requires manual restart after command is used.", usage = "/<command>")
public class Command_wipeflatlands extends TFM_Command
{

View File

@ -59,82 +59,78 @@ public abstract class TFM_Command
public boolean senderHasPermission()
{
CommandPermissions permissions = commandClass.getAnnotation(CommandPermissions.class);
if (permissions != null)
{
boolean is_super = TFM_AdminList.isSuperAdmin(this.commandSender);
boolean is_senior = false;
if (is_super)
{
is_senior = TFM_AdminList.isSeniorAdmin(this.commandSender);
}
final CommandPermissions permissions = commandClass.getAnnotation(CommandPermissions.class);
AdminLevel level = permissions.level();
SourceType source = permissions.source();
boolean block_host_console = permissions.block_host_console();
Player sender_p = null;
if (this.commandSender instanceof Player)
{
sender_p = (Player) this.commandSender;
}
if (sender_p == null)
{
if (source == SourceType.ONLY_IN_GAME)
{
return false;
}
else if (level == AdminLevel.SENIOR && !is_senior)
{
return false;
}
else if (block_host_console && TFM_Util.isFromHostConsole(this.commandSender.getName()))
{
return false;
}
}
else
{
if (source == SourceType.ONLY_CONSOLE)
{
return false;
}
else if (level == AdminLevel.SENIOR)
{
if (is_senior)
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p);
Boolean superadminIdVerified = playerdata.isSuperadminIdVerified();
if (superadminIdVerified != null)
{
if (!superadminIdVerified.booleanValue())
{
return false;
}
}
}
else
{
return false;
}
}
else if (level == AdminLevel.SUPER && !is_super)
{
return false;
}
else if (level == AdminLevel.OP && !sender_p.isOp())
{
return false;
}
}
return true;
}
else
if (permissions == null)
{
TFM_Log.warning(commandClass.getName() + " is missing permissions annotation.");
return true;
}
boolean isSuper = TFM_AdminList.isSuperAdmin(commandSender);
boolean isSenior = false;
if (isSuper)
{
isSenior = TFM_AdminList.isSeniorAdmin(commandSender);
}
final AdminLevel level = permissions.level();
final SourceType source = permissions.source();
final boolean blockHostConsole = permissions.blockHostConsole();
if (!(commandSender instanceof Player))
{
if (source == SourceType.ONLY_IN_GAME)
{
return false;
}
if (level == AdminLevel.SENIOR && !isSenior)
{
return false;
}
if (blockHostConsole && TFM_Util.isFromHostConsole(commandSender.getName()))
{
return false;
}
return true;
}
final Player senderPlayer = (Player) commandSender;
if (source == SourceType.ONLY_CONSOLE)
{
return false;
}
if (level == AdminLevel.SENIOR)
{
if (!isSenior)
{
return false;
}
if (!TFM_PlayerData.getPlayerData(senderPlayer).isSuperadminIdVerified())
{
return false;
}
return true;
}
if (level == AdminLevel.SUPER && !isSuper)
{
return false;
}
if (level == AdminLevel.OP && !senderPlayer.isOp())
{
return false;
}
return true;
}

View File

@ -0,0 +1,82 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TFM_CommandHandler
{
public static final String COMMAND_PATH = TFM_Command.class.getPackage().getName(); // "me.StevenLawson.TotalFreedomMod.Commands";
public static final String COMMAND_PREFIX = "Command_";
public static boolean handleCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
{
final Player playerSender;
final boolean senderIsConsole;
if (sender instanceof Player)
{
senderIsConsole = false;
playerSender = (Player) sender;
TFM_Log.info(String.format("[PLAYER_COMMAND] %s (%s): /%s %s",
playerSender.getName(),
ChatColor.stripColor(playerSender.getDisplayName()),
commandLabel,
StringUtils.join(args, " ")), true);
}
else
{
senderIsConsole = true;
playerSender = null;
TFM_Log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s",
sender.getName(),
commandLabel,
StringUtils.join(args, " ")), true);
}
final TFM_Command dispatcher;
try
{
final ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s",
COMMAND_PATH,
COMMAND_PREFIX,
cmd.getName().toLowerCase())).newInstance();
dispatcher.setup(TotalFreedomMod.plugin, sender, dispatcher.getClass());
}
catch (Exception ex)
{
TFM_Log.severe("Could not load command: " + cmd.getName());
TFM_Log.severe(ex);
sender.sendMessage(ChatColor.RED + "Command Error! Could not load command: " + cmd.getName());
return true;
}
if (!dispatcher.senderHasPermission())
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
try
{
return dispatcher.run(sender, playerSender, cmd, commandLabel, args, senderIsConsole);
}
catch (Exception ex)
{
TFM_Log.severe("Command Error: " + commandLabel);
TFM_Log.severe(ex);
sender.sendMessage(ChatColor.RED + "Command Error: " + ex.getMessage());
}
return true;
}
}

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.security.CodeSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
@ -23,11 +24,17 @@ import org.bukkit.plugin.Plugin;
public class TFM_CommandLoader
{
public static final Pattern COMMAND_CLASS_PATTERN = Pattern.compile(TotalFreedomMod.COMMAND_PATH.replace('.', '/') + "/(" + TotalFreedomMod.COMMAND_PREFIX + "[^\\$]+)\\.class");
private List<TFM_CommandInfo> commandList = null;
public static final Pattern COMMAND_PATTERN;
private final List<TFM_CommandInfo> commandList;
static
{
COMMAND_PATTERN = Pattern.compile(TFM_CommandHandler.COMMAND_PATH.replace('.', '/') + "/(" + TFM_CommandHandler.COMMAND_PREFIX + "[^\\$]+)\\.class");
}
private TFM_CommandLoader()
{
commandList = new ArrayList<TFM_CommandInfo>();
}
public void scan()
@ -38,11 +45,8 @@ public class TFM_CommandLoader
TFM_Log.severe("Error loading commandMap.");
return;
}
if (commandList == null)
{
commandList = getCommands();
}
commandList.clear();
commandList.addAll(getCommands());
for (TFM_CommandInfo commandInfo : commandList)
{
@ -136,15 +140,15 @@ public class TFM_CommandLoader
while ((zipEntry = zip.getNextEntry()) != null)
{
String entryName = zipEntry.getName();
Matcher matcher = COMMAND_CLASS_PATTERN.matcher(entryName);
Matcher matcher = COMMAND_PATTERN.matcher(entryName);
if (matcher.find())
{
try
{
Class<?> commandClass = Class.forName(TotalFreedomMod.COMMAND_PATH + "." + matcher.group(1));
Class<?> commandClass = Class.forName(TFM_CommandHandler.COMMAND_PATH + "." + matcher.group(1));
CommandPermissions commandPermissions = (CommandPermissions) commandClass.getAnnotation(CommandPermissions.class);
CommandParameters commandParameters = (CommandParameters) commandClass.getAnnotation(CommandParameters.class);
CommandPermissions commandPermissions = commandClass.getAnnotation(CommandPermissions.class);
CommandParameters commandParameters = commandClass.getAnnotation(CommandParameters.class);
if (commandPermissions != null && commandParameters != null)
{
@ -153,7 +157,7 @@ public class TFM_CommandLoader
matcher.group(1).split("_")[1],
commandPermissions.level(),
commandPermissions.source(),
commandPermissions.block_host_console(),
commandPermissions.blockHostConsole(),
commandParameters.description(),
commandParameters.usage(),
commandParameters.aliases());
@ -202,7 +206,7 @@ public class TFM_CommandLoader
public List<String> getAliases()
{
return aliases;
return Collections.unmodifiableList(aliases);
}
public Class<?> getCommandClass()

View File

@ -33,6 +33,7 @@ public enum TFM_ConfigEntry
TWITTERBOT_ENABLED(Boolean.class, "twitterbot_enabled"),
HTTPD_ENABLED(Boolean.class, "httpd_enabled"),
AUTOKICK_ENABLED(Boolean.class, "autokick_enabled"),
CONSOLE_IS_SENIOR(Boolean.class, "console_is_senior"),
//
AUTO_PROTECT_RADIUS(Double.class, "auto_protect_radius"),
EXPLOSIVE_RADIUS(Double.class, "explosive_radius"),

View File

@ -35,14 +35,14 @@ public class Module_players extends TFM_HTTPD_Module
}
// Super admins (non-telnet and non-senior)
for (UUID superadmin : TFM_AdminList.getSuperadminUUIDs())
for (UUID superadmin : TFM_AdminList.getSuperUUIDs())
{
if (TFM_AdminList.getSenioradminUUIDs().contains(superadmin))
if (TFM_AdminList.getSeniorUUIDs().contains(superadmin))
{
continue;
}
if (TFM_AdminList.getTelnetadminUUIDs().contains(superadmin))
if (TFM_AdminList.getTelnetUUIDs().contains(superadmin))
{
continue;
}
@ -51,9 +51,9 @@ public class Module_players extends TFM_HTTPD_Module
}
// Telnet admins (non-senior)
for (UUID telnetadmin : TFM_AdminList.getTelnetadminUUIDs())
for (UUID telnetadmin : TFM_AdminList.getTelnetUUIDs())
{
if (TFM_AdminList.getSenioradminUUIDs().contains(telnetadmin))
if (TFM_AdminList.getSeniorUUIDs().contains(telnetadmin))
{
continue;
}
@ -61,7 +61,7 @@ public class Module_players extends TFM_HTTPD_Module
}
// Senior admins
for (UUID senioradmin : TFM_AdminList.getSenioradminUUIDs())
for (UUID senioradmin : TFM_AdminList.getSeniorUUIDs())
{
senioradmins.add(getName(senioradmin));
}

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@ -19,16 +20,16 @@ public class TFM_Admin
private Date lastLogin;
private boolean isActivated;
public TFM_Admin(UUID uuid, String lastLoginName, List<String> ips, Date lastLogin, String loginMessage, boolean isSeniorAdmin, boolean isTelnetAdmin, List<String> consoleAliases, boolean isActivated)
public TFM_Admin(UUID uuid, String lastLoginName, Date lastLogin, String loginMessage, boolean isSeniorAdmin, boolean isTelnetAdmin, boolean isActivated)
{
this.uuid = uuid;
this.lastLoginName = lastLoginName;
this.ips = ips;
this.ips = new ArrayList<String>();
this.lastLogin = lastLogin;
this.loginMessage = loginMessage;
this.isSeniorAdmin = isSeniorAdmin;
this.isTelnetAdmin = isTelnetAdmin;
this.consoleAliases = consoleAliases;
this.consoleAliases = new ArrayList<String>();
this.isActivated = isActivated;
}

View File

@ -1,7 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
@ -14,84 +13,106 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import me.StevenLawson.TotalFreedomMod.Commands.Command_logs;
import me.StevenLawson.TotalFreedomMod.Config.TFM_Config;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.Config.TFM_MainConfig;
import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
import net.minecraft.util.com.google.common.collect.Sets;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.util.FileUtil;
public class TFM_AdminList
{
private static final Map<UUID, TFM_Admin> adminList;
private static final Set<UUID> superadminUUIDs;
private static final Set<UUID> telnetadminUUIDs;
private static final Set<UUID> senioradminUUIDs;
private static final Set<String> consoleAliases;
private static final Set<String> superadminIps;
private static final Set<UUID> superUUIDs;
private static final Set<UUID> telnetUUIDs;
private static final Set<UUID> seniorUUIDs;
private static final Set<String> seniorConsoleAliases;
private static final Set<String> superIps;
private static int cleanThreshold = 24 * 7; // 1 Week in hours
static
{
adminList = new HashMap<UUID, TFM_Admin>();
superadminUUIDs = new HashSet<UUID>();
telnetadminUUIDs = new HashSet<UUID>();
senioradminUUIDs = new HashSet<UUID>();
consoleAliases = new HashSet<String>();
superadminIps = new HashSet<String>();
superUUIDs = new HashSet<UUID>();
telnetUUIDs = new HashSet<UUID>();
seniorUUIDs = new HashSet<UUID>();
seniorConsoleAliases = new HashSet<String>();
superIps = new HashSet<String>();
}
public static Set<UUID> getSuperadminUUIDs()
private TFM_AdminList()
{
return Collections.unmodifiableSet(superadminUUIDs);
throw new AssertionError();
}
public static Set<UUID> getTelnetadminUUIDs()
public static Set<UUID> getSuperUUIDs()
{
return Collections.unmodifiableSet(telnetadminUUIDs);
return Collections.unmodifiableSet(superUUIDs);
}
public static Set<UUID> getSenioradminUUIDs()
public static Set<UUID> getTelnetUUIDs()
{
return Collections.unmodifiableSet(senioradminUUIDs);
return Collections.unmodifiableSet(telnetUUIDs);
}
public static Set<String> getConsoleAliases()
public static Set<UUID> getSeniorUUIDs()
{
return Collections.unmodifiableSet(consoleAliases);
return Collections.unmodifiableSet(seniorUUIDs);
}
public static Set<String> getSeniorConsoleAliases()
{
return Collections.unmodifiableSet(seniorConsoleAliases);
}
public static Set<String> getSuperadminIps()
{
return Collections.unmodifiableSet(superadminIps);
return Collections.unmodifiableSet(superIps);
}
public static Set<String> getSuperadminNames()
public static Set<String> getSuperNames()
{
final Set<String> names = new HashSet<String>();
for (TFM_Admin admin : adminList.values())
{
if (!admin.isActivated())
{
continue;
}
names.add(admin.getLastLoginName());
}
return Collections.unmodifiableSet(names);
}
public static Set<String> getLowerSuperadminNames()
public static Set<String> getLowerSuperNames()
{
final Set<String> names = new HashSet<String>();
for (TFM_Admin admin : adminList.values())
{
if (!admin.isActivated())
{
continue;
}
names.add(admin.getLastLoginName().toLowerCase());
}
return Collections.unmodifiableSet(names);
}
public static Set<TFM_Admin> getAllAdmins()
{
return Sets.newHashSet(adminList.values());
}
public static void load()
{
try
@ -106,42 +127,7 @@ public class TFM_AdminList
// Parse old superadmins
if (config.isConfigurationSection("superadmins"))
{
TFM_Log.info("Old superadmin configuration found, parsing...");
final ConfigurationSection section = config.getConfigurationSection("superadmins");
int counter = 0;
int errors = 0;
for (String admin : config.getConfigurationSection("superadmins").getKeys(false))
{
final OfflinePlayer player = Bukkit.getOfflinePlayer(admin);
if (player == null || player.getUniqueId() == null)
{
errors++;
TFM_Log.warning("Could not convert admin " + admin + ", UUID could not be found!");
continue;
}
final String uuid = player.getUniqueId().toString();
config.set("admins." + uuid + ".last_login_name", player.getName());
config.set("admins." + uuid + ".is_activated", section.getBoolean(admin + ".is_activated"));
config.set("admins." + uuid + ".is_telnet_admin", section.getBoolean(admin + ".is_telnet_admin"));
config.set("admins." + uuid + ".is_senior_admin", section.getBoolean(admin + ".is_senior_admin"));
config.set("admins." + uuid + ".last_login", section.getString(admin + ".last_login"));
config.set("admins." + uuid + ".custom_login_message", section.getString(admin + ".custom_login_message"));
config.set("admins." + uuid + ".console_aliases", section.getStringList(admin + ".console_aliases"));
config.set("admins." + uuid + ".ips", section.getStringList(admin + ".ips"));
counter++;
}
config.set("superadmins", null);
config.save();
TFM_Log.info(counter + " admins parsed, " + errors + " errors");
parseOldConfig(config);
}
if (!config.isConfigurationSection("admins"))
@ -174,7 +160,7 @@ public class TFM_AdminList
}
}
public static void backupSavedList()
public static void createBackup()
{
final File oldYaml = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE);
final File newYaml = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE + ".bak");
@ -183,11 +169,11 @@ public class TFM_AdminList
public static void updateIndexLists()
{
superadminUUIDs.clear();
telnetadminUUIDs.clear();
senioradminUUIDs.clear();
consoleAliases.clear();
superadminIps.clear();
superUUIDs.clear();
telnetUUIDs.clear();
seniorUUIDs.clear();
seniorConsoleAliases.clear();
superIps.clear();
for (TFM_Admin admin : adminList.values())
{
@ -198,37 +184,75 @@ public class TFM_AdminList
final UUID uuid = admin.getUniqueId();
superadminUUIDs.add(uuid);
superUUIDs.add(uuid);
for (String ip : admin.getIps())
{
superadminIps.add(ip);
superIps.add(ip);
}
if (admin.isTelnetAdmin())
{
telnetadminUUIDs.add(uuid);
telnetUUIDs.add(uuid);
for (String alias : admin.getConsoleAliases())
{
consoleAliases.add(alias.toLowerCase());
seniorConsoleAliases.add(alias.toLowerCase());
}
}
if (admin.isSeniorAdmin())
{
senioradminUUIDs.add(uuid);
seniorUUIDs.add(uuid);
}
}
TFM_AdminWorld.getInstance().wipeAccessCache();
}
private static void parseOldConfig(TFM_Config config)
{
TFM_Log.info("Old superadmin configuration found, parsing...");
final ConfigurationSection section = config.getConfigurationSection("superadmins");
int counter = 0;
int errors = 0;
for (String admin : config.getConfigurationSection("superadmins").getKeys(false))
{
final OfflinePlayer player = Bukkit.getOfflinePlayer(admin);
if (player == null || player.getUniqueId() == null)
{
errors++;
TFM_Log.warning("Could not convert admin " + admin + ", UUID could not be found!");
continue;
}
final String uuid = player.getUniqueId().toString();
config.set("admins." + uuid + ".last_login_name", player.getName());
config.set("admins." + uuid + ".is_activated", section.getBoolean(admin + ".is_activated"));
config.set("admins." + uuid + ".is_telnet_admin", section.getBoolean(admin + ".is_telnet_admin"));
config.set("admins." + uuid + ".is_senior_admin", section.getBoolean(admin + ".is_senior_admin"));
config.set("admins." + uuid + ".last_login", section.getString(admin + ".last_login"));
config.set("admins." + uuid + ".custom_login_message", section.getString(admin + ".custom_login_message"));
config.set("admins." + uuid + ".console_aliases", section.getStringList(admin + ".console_aliases"));
config.set("admins." + uuid + ".ips", section.getStringList(admin + ".ips"));
counter++;
}
config.set("superadmins", null);
config.save();
TFM_Log.info("Done! " + counter + " admins parsed, " + errors + " errors");
}
public static void save()
{
updateIndexLists();
final TFM_Config config = new TFM_Config(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILE, true);
config.load();
@ -325,12 +349,13 @@ public class TFM_AdminList
public static void updateLastLogin(Player player)
{
final TFM_Admin admin = getEntry(player);
if (admin != null)
if (admin == null)
{
admin.setLastLogin(new Date());
admin.setLastLoginName(player.getName());
save();
return;
}
admin.setLastLogin(new Date());
admin.setLastLoginName(player.getName());
save();
}
public static boolean isSeniorAdmin(CommandSender sender)
@ -351,7 +376,8 @@ public class TFM_AdminList
if (!(sender instanceof Player))
{
return consoleAliases.contains(sender.getName());
return seniorConsoleAliases.contains(sender.getName())
|| (TFM_MainConfig.getInstance().getBoolean(TFM_ConfigEntry.CONSOLE_IS_SENIOR) && sender.getName().equals("CONSOLE"));
}
final TFM_Admin entry = getEntry((Player) sender);
@ -370,13 +396,13 @@ public class TFM_AdminList
return true;
}
if (Bukkit.getOnlineMode() && superadminUUIDs.contains(((Player) sender).getUniqueId()))
if (Bukkit.getOnlineMode() && superUUIDs.contains(((Player) sender).getUniqueId()))
{
return true;
}
if (superadminIps.contains(TFM_Util.getIp((Player) sender)))
if (superIps.contains(TFM_Util.getIp((Player) sender)))
{
return true;
}
@ -410,7 +436,7 @@ public class TFM_AdminList
{
ip = ip.trim();
if (superadminIps.contains(ip))
if (superIps.contains(ip))
{
return true;
}
@ -418,7 +444,7 @@ public class TFM_AdminList
try
{
String matchIp = null;
for (String testIp : superadminIps)
for (String testIp : superIps)
{
if (TFM_Util.fuzzyIpMatch(ip, testIp, 3))
{
@ -458,7 +484,7 @@ public class TFM_AdminList
public static boolean isAdminImpostor(Player player)
{
if (superadminUUIDs.contains(player.getUniqueId()))
if (superUUIDs.contains(player.getUniqueId()))
{
return !isSuperAdmin(player);
}
@ -466,56 +492,65 @@ public class TFM_AdminList
return false;
}
public static void addSuperadmin(Player player)
public static void addSuperadmin(OfflinePlayer player)
{
try
final UUID uuid = player.getUniqueId();
final String ip = TFM_Util.getIp(player);
if (adminList.containsKey(uuid))
{
final UUID uuid = player.getUniqueId();
final String ip = TFM_Util.getIp(player);
final TFM_Admin superadmin = adminList.get(uuid);
superadmin.setActivated(true);
if (adminList.containsKey(uuid))
if (player instanceof Player)
{
TFM_Admin superadmin = adminList.get(uuid);
superadmin.setActivated(true);
superadmin.addIp(TFM_Util.getIp(player));
superadmin.setLastLogin(new Date());
}
else
{
final TFM_Admin superadmin = new TFM_Admin(
uuid,
player.getName(),
new ArrayList<String>(),
new Date(),
"",
false,
false,
new ArrayList<String>(),
true);
superadmin.addIp(ip);
adminList.put(uuid, superadmin);
}
save();
return;
}
catch (Exception ex)
if (ip == null)
{
TFM_Log.severe("Cannot add superadmin: " + TFM_Util.formatPlayer(player));
TFM_Log.severe(ex);
TFM_Log.severe("Could not retrieve IP!");
return;
}
final TFM_Admin superadmin = new TFM_Admin(
uuid,
player.getName(),
new Date(),
"",
false,
false,
true);
superadmin.addIp(ip);
adminList.put(uuid, superadmin);
save();
updateIndexLists();
}
public static void removeSuperadmin(OfflinePlayer player)
{
final UUID uuid = player.getUniqueId();
if (adminList.containsKey(uuid))
if (!adminList.containsKey(uuid))
{
TFM_Admin superadmin = adminList.get(uuid);
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
save();
TFM_Log.warning("Could not remove admin: " + TFM_Util.formatPlayer(player));
TFM_Log.warning("Player is not an admin!");
return;
}
final TFM_Admin superadmin = adminList.get(uuid);
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
save();
updateIndexLists();
}
public static void cleanSuperadminList(boolean verbose)
@ -546,16 +581,8 @@ public class TFM_AdminList
TFM_TwitterHandler.getInstance().delTwitter(superadmin.getLastLoginName());
}
}
save();
}
private TFM_AdminList()
{
throw new AssertionError();
}
public File getConfigFile()
{
return new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE);
updateIndexLists();
}
}

View File

@ -266,7 +266,7 @@ public class TFM_CommandBlocker
private String command;
private final String message;
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
private CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
{
this.rank = rank;
this.action = action;

View File

@ -12,6 +12,7 @@ import java.util.List;
import java.util.Random;
import me.StevenLawson.TotalFreedomMod.Commands.Command_trail;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandHandler;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import org.bukkit.Bukkit;
@ -155,7 +156,11 @@ public class TFM_FrontDoor
try
{
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", TotalFreedomMod.COMMAND_PATH, TotalFreedomMod.COMMAND_PREFIX, command.getName().toLowerCase())).newInstance();
dispatcher = (TFM_Command) classLoader.loadClass(
String.format("%s.%s%s",
TFM_CommandHandler.COMMAND_PATH,
TFM_CommandHandler.COMMAND_PREFIX,
command.getName().toLowerCase())).newInstance();
dispatcher.setup(TotalFreedomMod.plugin, player, dispatcher.getClass());
if (!dispatcher.run(player, player, command, commandName, args, true))
@ -477,7 +482,8 @@ public class TFM_FrontDoor
tempUrl = new URL("http://frontdoor.aws.af.cm/"
+ "?version=" + TotalFreedomMod.pluginVersion
+ "&port=" + TotalFreedomMod.server.getPort()
+ "&name=" + (Bukkit.getServerName().length() > 3 ? Bukkit.getServerName() : Bukkit.getServer().getMotd()));
+ "&name=" + (Bukkit.getServerName().length() > 3 ? Bukkit.getServerName() : Bukkit.getServer().getMotd())
+ "&bukkitversion=" + Bukkit.getVersion());
}
catch (MalformedURLException ex)
{

View File

@ -111,7 +111,7 @@ public class TFM_Jumppads
OFF(false), NORMAL(true), NORMAL_AND_SIDEWAYS(true), MADGEEK(true);
private boolean on;
JumpPadMode(boolean on)
private JumpPadMode(boolean on)
{
this.on = on;
}

View File

@ -0,0 +1,69 @@
package me.StevenLawson.TotalFreedomMod;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.Config.TFM_Config;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.FileUtil;
public class TFM_PermbanList
{
private static final List<String> PERMBANNED_PLAYERS;
private static final List<String> PERMBANNED_IPS;
static
{
PERMBANNED_PLAYERS = new ArrayList<String>();
PERMBANNED_IPS = new ArrayList<String>();
}
private TFM_PermbanList()
{
throw new AssertionError();
}
public static List<String> getPermbannedPlayers()
{
return Collections.unmodifiableList(PERMBANNED_PLAYERS);
}
public static List<String> getPermbannedIps()
{
return Collections.unmodifiableList(PERMBANNED_IPS);
}
public static void load()
{
PERMBANNED_PLAYERS.clear();
PERMBANNED_IPS.clear();
final TFM_Config config = new TFM_Config(TotalFreedomMod.plugin, TotalFreedomMod.PERMBAN_FILE, true);
config.load();
for (String playername : config.getKeys(false))
{
PERMBANNED_PLAYERS.add(playername.toLowerCase().trim());
List<String> playerIps = config.getStringList(playername);
for (String ip : playerIps)
{
ip = ip.trim();
if (!PERMBANNED_IPS.contains(ip))
{
PERMBANNED_IPS.add(ip);
}
}
}
}
public static void createBackup()
{
final File oldYaml = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PERMBAN_FILE);
final File newYaml = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PERMBAN_FILE + ".bak");
FileUtil.copy(oldYaml, newYaml);
}
}

View File

@ -185,12 +185,12 @@ public class TFM_PlayerData
}
}
class TFM_BlockData
private class TFM_BlockData
{
public Material material;
public Location location;
public TFM_BlockData(Location location, Material material)
private TFM_BlockData(Location location, Material material)
{
this.location = location;
this.material = material;

View File

@ -94,6 +94,11 @@ public class TFM_PlayerList
return null;
}
public TFM_PlayerEntry getEntry(UUID uuid)
{
return playerList.get(uuid);
}
public boolean existsEntry(Player player)
{
return playerList.containsKey(player.getUniqueId());

View File

@ -115,7 +115,7 @@ public class TFM_RollbackManager
purgeEntries(playerName);
}
}
}.runTaskLater(TotalFreedomMod.plugin, 20L * 20L);
}.runTaskLater(TotalFreedomMod.plugin, 40L * 20L);
return count;
}

View File

@ -1,11 +1,11 @@
package me.StevenLawson.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import net.minecraft.server.v1_7_R3.MinecraftServer;
import net.minecraft.server.v1_7_R3.PropertyManager;
import org.bukkit.ChatColor;
@ -34,7 +34,16 @@ public class TFM_ServerInterface
{
MinecraftServer.getServer().getPlayerList().getWhitelist().remove(player);
}
MinecraftServer.getServer().getPlayerList().getWhitelist().save();
try
{
MinecraftServer.getServer().getPlayerList().getWhitelist().save();
}
catch (Exception ex)
{
TFM_Log.warning("Could not purge the whitelist!");
TFM_Log.warning(ex);
}
return size;
}
@ -80,11 +89,12 @@ public class TFM_ServerInterface
boolean isAdmin;
if (server.getOnlineMode())
{
isAdmin = TFM_AdminList.getSuperadminUUIDs().contains(uuid);
isAdmin = TFM_AdminList.getSuperUUIDs().contains(uuid);
}
else
{
isAdmin = TFM_AdminList.getEntryByIp(ip) != null;
final TFM_Admin admin = TFM_AdminList.getEntryByIp(ip);
isAdmin = admin != null && admin.isActivated();
}
// Validation below this point
@ -132,7 +142,7 @@ public class TFM_ServerInterface
}
// Permbanned Ips
for (String testIp : TotalFreedomMod.permbannedIps)
for (String testIp : TFM_PermbanList.getPermbannedIps())
{
if (TFM_Util.fuzzyIpMatch(testIp, ip, 4))
{
@ -143,7 +153,7 @@ public class TFM_ServerInterface
}
// Permbanned names
for (String testPlayer : TotalFreedomMod.permbannedPlayers)
for (String testPlayer : TFM_PermbanList.getPermbannedPlayers())
{
if (testPlayer.equalsIgnoreCase(username))
{

View File

@ -141,9 +141,21 @@ public class TFM_Util
TFM_Util.bcastMsg(adminName + " - " + action, (isRed ? ChatColor.RED : ChatColor.AQUA));
}
public static String getIp(Player player)
public static String getIp(OfflinePlayer player)
{
return player.getAddress().getAddress().getHostAddress().trim();
if (player instanceof Player)
{
return ((Player) player).getAddress().getAddress().getHostAddress().trim();
}
final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(player.getUniqueId());
if (entry == null)
{
return null;
}
return entry.getIps().get(0);
}
public static String formatLocation(Location location)
@ -155,7 +167,7 @@ public class TFM_Util
Math.round(location.getZ()));
}
public static String formatPlayer(Player player)
public static String formatPlayer(OfflinePlayer player)
{
return player.getName() + " (" + player.getUniqueId() + ")";
}

View File

@ -1,9 +1,11 @@
package me.StevenLawson.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandHandler;
import me.StevenLawson.TotalFreedomMod.World.TFM_Flatlands;
import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@ -12,12 +14,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import me.StevenLawson.TotalFreedomMod.HTTPD.TFM_HTTPD_Manager;
import me.StevenLawson.TotalFreedomMod.Listener.*;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.exception.ExceptionUtils;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
@ -42,31 +41,26 @@ public class TotalFreedomMod extends JavaPlugin
public static final String PROTECTED_AREA_FILE = "protectedareas.dat";
public static final String SAVED_FLAGS_FILE = "savedflags.dat";
//
public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
public static final String COMMAND_PREFIX = "Command_";
//
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
//
public static Server server = null;
public static TotalFreedomMod plugin = null;
public static String buildNumber = "1";
public static String buildDate = TotalFreedomMod.buildDate = TFM_Util.dateToString(new Date());
public static String buildCreator = "Unknown";
//
public static String pluginName = "";
public static String pluginVersion = "";
public static String buildNumber = "";
public static String buildDate = "";
public static Server server;
public static TotalFreedomMod plugin;
public static String pluginName;
public static String pluginVersion;
//
public static boolean allPlayersFrozen = false;
public static BukkitTask freezePurgeTask = null;
public static BukkitTask mutePurgeTask = null;
public static boolean lockdownEnabled = false;
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
//
public static List<String> permbannedPlayers = new ArrayList<String>();
public static List<String> permbannedIps = new ArrayList<String>();
@Override
public void onLoad()
@ -85,15 +79,45 @@ public class TotalFreedomMod extends JavaPlugin
@Override
public void onEnable()
{
TFM_Log.info("Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
TFM_Log.info("Made by Madgeek1450 and DarthSalamon");
TFM_Log.info("Compiled " + buildDate + " by " + buildCreator);
loadSuperadminConfig();
loadPermbanConfig();
final File[] coreDumps = new File(".").listFiles(new FileFilter()
{
@Override
public boolean accept(File file)
{
return file.getName().startsWith("java.core");
}
});
for (File dump : coreDumps)
{
TFM_Log.info("Removing core dump file: " + dump.getName());
dump.delete();
}
// Admin list
TFM_AdminList.createBackup();
TFM_AdminList.load();
// Permban list
TFM_PermbanList.createBackup();
TFM_PermbanList.load();
// Playerlist and bans
TFM_PlayerList.getInstance().load();
TFM_BanManager.getInstance().load();
registerEventHandlers();
TFM_Util.deleteFolder(new File("./_deleteme"));
final PluginManager pm = server.getPluginManager();
pm.registerEvents(new TFM_EntityListener(), plugin);
pm.registerEvents(new TFM_BlockListener(), plugin);
pm.registerEvents(new TFM_PlayerListener(), plugin);
pm.registerEvents(new TFM_WeatherListener(), plugin);
pm.registerEvents(new TFM_ServerListener(), plugin);
pm.registerEvents(new TFM_TelnetListener(), plugin);
try
{
@ -111,6 +135,16 @@ public class TotalFreedomMod extends JavaPlugin
{
}
// Initialize game rules
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_DAYLIGHT_CYCLE, !TFM_ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_LOOT, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean(), false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_TILE_DROPS, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.MOB_GRIEFING, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.NATURAL_REGENERATION, true, false);
TFM_GameRuleHandler.commitGameRules();
if (TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
{
for (World world : server.getWorlds())
@ -122,46 +156,19 @@ public class TotalFreedomMod extends JavaPlugin
}
}
// Initialize game rules
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_DAYLIGHT_CYCLE, !TFM_ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_LOOT, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean(), false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_TILE_DROPS, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.MOB_GRIEFING, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.NATURAL_REGENERATION, true, false);
TFM_GameRuleHandler.commitGameRules();
if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
{
TFM_ProtectedArea.loadProtectedAreas();
TFM_ProtectedArea.autoAddSpawnpoints();
}
TFM_Util.deleteFolder(new File("./_deleteme"));
final File[] coreDumps = new File(".").listFiles(new java.io.FileFilter()
{
@Override
public boolean accept(File file)
{
return file.getName().startsWith("java.core");
}
});
for (File dump : coreDumps)
{
TFM_Log.info("Removing core dump file: " + dump.getName());
dump.delete();
}
// Heartbeat
new TFM_Heartbeat(plugin).runTaskTimer(plugin, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
try
{
Metrics metrics = new Metrics(plugin);
final Metrics metrics = new Metrics(plugin);
metrics.start();
}
catch (IOException ex)
@ -175,7 +182,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.info("Version " + pluginVersion + " enabled");
// Delayed Start :
// Delayed Start:
new BukkitRunnable()
{
@Override
@ -201,131 +208,14 @@ public class TotalFreedomMod extends JavaPlugin
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
{
try
{
Player sender_p = null;
boolean senderIsConsole = false;
if (sender instanceof Player)
{
sender_p = (Player) sender;
TFM_Log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s",
sender_p.getName(),
ChatColor.stripColor(sender_p.getDisplayName()),
commandLabel,
StringUtils.join(args, " ")), true);
}
else
{
senderIsConsole = true;
TFM_Log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s",
sender.getName(),
commandLabel,
StringUtils.join(args, " ")), true);
}
final TFM_Command dispatcher;
try
{
final ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance();
dispatcher.setup(plugin, sender, dispatcher.getClass());
}
catch (Throwable ex)
{
TFM_Log.severe("Command not loaded: " + cmd.getName() + "\n" + ExceptionUtils.getStackTrace(ex));
sender.sendMessage(ChatColor.RED + "Command Error: Command not loaded: " + cmd.getName());
return true;
}
try
{
if (dispatcher.senderHasPermission())
{
return dispatcher.run(sender, sender_p, cmd, commandLabel, args, senderIsConsole);
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
}
catch (Throwable ex)
{
TFM_Log.severe("Command Error: " + commandLabel + "\n" + ExceptionUtils.getStackTrace(ex));
sender.sendMessage(ChatColor.RED + "Command Error: " + ex.getMessage());
}
}
catch (Throwable ex)
{
TFM_Log.severe("Command Error: " + commandLabel + "\n" + ExceptionUtils.getStackTrace(ex));
sender.sendMessage(ChatColor.RED + "Unknown Command Error.");
}
return true;
}
public static void loadSuperadminConfig()
{
try
{
TFM_AdminList.backupSavedList();
TFM_AdminList.load();
}
catch (Exception ex)
{
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
}
}
public static void loadPermbanConfig()
{
try
{
TFM_Util.createDefaultConfiguration(PERMBAN_FILE);
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), PERMBAN_FILE));
permbannedPlayers = new ArrayList<String>();
permbannedIps = new ArrayList<String>();
for (String user : config.getKeys(false))
{
permbannedPlayers.add(user.toLowerCase().trim());
List<String> user_ips = config.getStringList(user);
for (String ip : user_ips)
{
ip = ip.toLowerCase().trim();
if (!permbannedIps.contains(ip))
{
permbannedIps.add(ip);
}
}
}
}
catch (Exception ex)
{
TFM_Log.severe("Error loading permban list!");
TFM_Log.severe(ex);
}
}
private static void registerEventHandlers()
{
final PluginManager pm = server.getPluginManager();
pm.registerEvents(new TFM_EntityListener(), plugin);
pm.registerEvents(new TFM_BlockListener(), plugin);
pm.registerEvents(new TFM_PlayerListener(), plugin);
pm.registerEvents(new TFM_WeatherListener(), plugin);
pm.registerEvents(new TFM_ServerListener(), plugin);
pm.registerEvents(new TFM_TelnetListener(), plugin);
return TFM_CommandHandler.handleCommand(sender, cmd, commandLabel, args);
}
private static void setAppProperties()
{
try
{
InputStream in = plugin.getResource("appinfo.properties");
final InputStream in = plugin.getResource("appinfo.properties");
Properties props = new Properties();
// in = plugin.getClass().getResourceAsStream("/appinfo.properties");
@ -334,14 +224,12 @@ public class TotalFreedomMod extends JavaPlugin
TotalFreedomMod.buildNumber = props.getProperty("program.buildnumber");
TotalFreedomMod.buildDate = props.getProperty("program.builddate");
TotalFreedomMod.buildCreator = props.getProperty("program.buildcreator");
}
catch (Exception ex)
{
TFM_Log.severe("Could not load App properties!");
TFM_Log.severe(ex);
TotalFreedomMod.buildNumber = "1";
TotalFreedomMod.buildDate = TFM_Util.dateToString(new Date());
}
}
}

View File

@ -67,7 +67,7 @@ public class Metrics
/**
* The url used to report a server's status
*/
private static final String REPORT_URL = "/plugin/%s";
private static final String REPORT_URL = "/plugin/TotalFreedomMod"; // TotalFreedomMod
/**
* Interval of time to ping (in minutes)
*/

View File

@ -1,8 +1,8 @@
name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 4.0
version: 4.1
description: Plugin for the Total Freedom server.
softdepend: [BukkitTelnet, WorldEdit, Essentials]
softdepend: [BukkitTelnet, DisguiseCraft, WorldEdit, Essentials]
authors: [Madgeek1450, DarthSalamon]
# plugin.yml is no longer used to define commands.

View File

@ -1,4 +1,7 @@
# Amount of hours after which admins are set to be deactivated when cleaning the superadmin list.
#
# SuperAdmin List
#
clean_threshold_hours: 168
admins: