mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 12:36:41 +00:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
08e4a4a171 | |||
a0affddeed | |||
c82113dc22 | |||
9315227906 | |||
00e9b4ea1f | |||
22b0781020 | |||
7df24c6b86 | |||
0e9044ffc3 | |||
3371f54c06 | |||
92d7c58957 | |||
478244773b | |||
b3b182e753 | |||
49601035a5 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -17,3 +17,6 @@ manifest.mf
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# TFM files
|
||||
buildcreator.properties
|
||||
|
@ -2,16 +2,22 @@
|
||||
<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" />
|
||||
</target>
|
||||
|
||||
|
||||
<target name="-post-jar">
|
||||
<!-- Cleanup -->
|
||||
<delete file="${dist.dir}/README.TXT" />
|
||||
|
2
buildcreator.default.properties
Normal file
2
buildcreator.default.properties
Normal file
@ -0,0 +1,2 @@
|
||||
# Build creator configuration
|
||||
program.buildcreator=Unknown
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Tue Apr 15 16:28:36 CEST 2014
|
||||
build.number=762
|
||||
#Mon Apr 21 23:08:17 CEST 2014
|
||||
build.number=787
|
||||
|
@ -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:
|
||||
|
@ -10,5 +10,5 @@ public @interface CommandPermissions
|
||||
|
||||
SourceType source();
|
||||
|
||||
boolean block_host_console() default false;
|
||||
boolean blockHostConsole() default false;
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -5,7 +5,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 = "Attempt to detect \"invisible griefers\" and \"nukers\".", usage = "/<command> <on | off> [range] [blockrate]")
|
||||
public class Command_nonuke extends TFM_Command
|
||||
{
|
||||
|
@ -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(), ", "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,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 = "Enable/disable the command prelogger. When this is on, logs will be filled with many duplicate messages.",
|
||||
usage = "/<command> <on | off>")
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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 = 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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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.getSuperUUIDs(), ", "), 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;
|
||||
|
@ -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)
|
||||
|
@ -13,8 +13,15 @@ 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);
|
||||
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);
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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()
|
||||
|
@ -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"),
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@ -14,7 +15,10 @@ 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;
|
||||
@ -26,72 +30,92 @@ 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
|
||||
@ -174,7 +198,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 +207,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,27 +222,27 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,8 +251,6 @@ public class TFM_AdminList
|
||||
|
||||
public static void save()
|
||||
{
|
||||
updateIndexLists();
|
||||
|
||||
final TFM_Config config = new TFM_Config(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILE, true);
|
||||
config.load();
|
||||
|
||||
@ -325,12 +347,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 +374,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 +394,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 +434,7 @@ public class TFM_AdminList
|
||||
{
|
||||
ip = ip.trim();
|
||||
|
||||
if (superadminIps.contains(ip))
|
||||
if (superIps.contains(ip))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -418,7 +442,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 +482,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 +490,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 +579,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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
69
src/me/StevenLawson/TotalFreedomMod/TFM_PermbanList.java
Normal file
69
src/me/StevenLawson/TotalFreedomMod/TFM_PermbanList.java
Normal 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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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() + ")";
|
||||
}
|
||||
|
@ -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("Starting " + pluginName + " v" + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber);
|
||||
TFM_Log.info("Made by Madgeek1450 and DarthSalamon, 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
*/
|
||||
@ -851,4 +851,4 @@ public class Metrics
|
||||
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ name: TotalFreedomMod
|
||||
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
||||
version: 4.0
|
||||
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.
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user