From 5237fa0ca24467311a7b5d7400afbf2f1a696552 Mon Sep 17 00:00:00 2001
From: unknown
Date: Fri, 11 Apr 2014 17:24:44 +0200
Subject: [PATCH] [Bleeding] Major refractoring Added TFM_Config as a base
config class for TFM_AdminList and TFM_PlayerList Finished up UUID based
Superadmins
---
buildnumber.properties | 4 +-
.../{ => Bridge}/TFM_DisguiseCraftBridge.java | 3 +-
.../{ => Bridge}/TFM_EssentialsBridge.java | 4 +-
.../{ => Bridge}/TFM_WorldEditBridge.java | 6 +-
.../Commands/Command_adminmode.java | 2 +-
.../Commands/Command_adminworld.java | 2 +-
.../Commands/Command_cake.java | 2 +-
.../Commands/Command_colorme.java | 2 +-
.../Commands/Command_config.java | 2 +-
.../Commands/Command_denick.java | 2 +-
.../Commands/Command_droptoggle.java | 2 +-
.../Commands/Command_explosives.java | 2 +-
.../Commands/Command_fireplace.java | 2 +-
.../Commands/Command_firespread.java | 2 +-
.../Commands/Command_flatlands.java | 4 +-
.../Commands/Command_fluidspread.java | 2 +-
.../Commands/Command_glist.java | 4 +-
.../Commands/Command_gtfo.java | 2 +-
.../Commands/Command_landmine.java | 2 +-
.../Commands/Command_lavadmg.java | 2 +-
.../Commands/Command_lavaplace.java | 2 +-
.../Commands/Command_logs.java | 2 +-
.../Commands/Command_moblimiter.java | 2 +-
.../Commands/Command_mp44.java | 2 +-
.../Commands/Command_nicknyan.java | 2 +-
.../Commands/Command_nonuke.java | 2 +-
.../Commands/Command_petprotect.java | 2 +-
.../Commands/Command_prelog.java | 2 +-
.../Commands/Command_protectarea.java | 2 +-
.../Commands/Command_purgeall.java | 2 +-
.../Commands/Command_saconfig.java | 214 +++++++-------
.../Commands/Command_setl.java | 2 +-
.../Commands/Command_setspawnworld.java | 2 +-
.../Commands/Command_tossmob.java | 2 +-
.../Commands/Command_twitter.java | 2 +-
.../Commands/Command_uall.java | 2 +-
.../Commands/Command_waterplace.java | 2 +-
.../TotalFreedomMod/Config/TFM_Config.java | 150 ++++++++++
.../{ => Config}/TFM_ConfigEntry.java | 20 +-
.../TFM_MainConfig.java} | 15 +-
.../TotalFreedomMod/HTTPD/Module_file.java | 2 +-
.../TotalFreedomMod/HTTPD/Module_players.java | 2 +-
.../HTTPD/Module_schematic.java | 2 +-
.../HTTPD/TFM_HTTPD_Manager.java | 2 +-
.../Listener/TFM_BlockListener.java | 1 +
.../Listener/TFM_EntityListener.java | 2 +-
.../Listener/TFM_PlayerListener.java | 53 ++--
.../Listener/TFM_ServerListener.java | 2 +-
.../Listener/TFM_TelnetListener.java | 2 +-
.../Listener/TFM_WeatherListener.java | 4 +-
.../TotalFreedomMod/TFM_AdminList.java | 206 +++++++------
.../TotalFreedomMod/TFM_CommandBlocker.java | 1 +
.../TotalFreedomMod/TFM_FrontDoor.java | 4 +-
.../TotalFreedomMod/TFM_Heartbeat.java | 3 +
.../TotalFreedomMod/TFM_LogFile.java | 85 ------
.../TotalFreedomMod/TFM_PlayerData.java | 6 +-
.../TotalFreedomMod/TFM_PlayerEntry.java | 135 +++++++++
.../TotalFreedomMod/TFM_PlayerList.java | 279 +++---------------
.../TotalFreedomMod/TFM_PlayerRank.java | 19 +-
.../TotalFreedomMod/TFM_ProtectedArea.java | 1 +
.../TotalFreedomMod/TFM_ServerInterface.java | 3 +-
.../TotalFreedomMod/TFM_ServiceChecker.java | 1 +
.../TotalFreedomMod/TFM_TwitterHandler.java | 1 +
.../TotalFreedomMod/TFM_Util.java | 44 ++-
.../TotalFreedomMod/TotalFreedomMod.java | 6 +-
.../{ => World}/CleanroomBlockPopulator.java | 2 +-
.../{ => World}/CleanroomChunkGenerator.java | 2 +-
.../{ => World}/TFM_AdminWorld.java | 8 +-
.../{ => World}/TFM_CustomWorld.java | 2 +-
.../{ => World}/TFM_Flatlands.java | 7 +-
src/superadmin.yml | 9 +-
71 files changed, 710 insertions(+), 670 deletions(-)
rename src/me/StevenLawson/TotalFreedomMod/{ => Bridge}/TFM_DisguiseCraftBridge.java (94%)
rename src/me/StevenLawson/TotalFreedomMod/{ => Bridge}/TFM_EssentialsBridge.java (94%)
rename src/me/StevenLawson/TotalFreedomMod/{ => Bridge}/TFM_WorldEditBridge.java (94%)
create mode 100644 src/me/StevenLawson/TotalFreedomMod/Config/TFM_Config.java
rename src/me/StevenLawson/TotalFreedomMod/{ => Config}/TFM_ConfigEntry.java (87%)
rename src/me/StevenLawson/TotalFreedomMod/{TFM_Config.java => Config/TFM_MainConfig.java} (94%)
delete mode 100644 src/me/StevenLawson/TotalFreedomMod/TFM_LogFile.java
create mode 100644 src/me/StevenLawson/TotalFreedomMod/TFM_PlayerEntry.java
rename src/me/StevenLawson/TotalFreedomMod/{ => World}/CleanroomBlockPopulator.java (94%)
rename src/me/StevenLawson/TotalFreedomMod/{ => World}/CleanroomChunkGenerator.java (99%)
rename src/me/StevenLawson/TotalFreedomMod/{ => World}/TFM_AdminWorld.java (96%)
rename src/me/StevenLawson/TotalFreedomMod/{ => World}/TFM_CustomWorld.java (94%)
rename src/me/StevenLawson/TotalFreedomMod/{ => World}/TFM_Flatlands.java (89%)
diff --git a/buildnumber.properties b/buildnumber.properties
index 9c9492f..715ca5b 100644
--- a/buildnumber.properties
+++ b/buildnumber.properties
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
-#Wed Apr 09 22:31:37 CEST 2014
-build.number=713
+#Fri Apr 11 17:22:29 CEST 2014
+build.number=730
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_DisguiseCraftBridge.java b/src/me/StevenLawson/TotalFreedomMod/Bridge/TFM_DisguiseCraftBridge.java
similarity index 94%
rename from src/me/StevenLawson/TotalFreedomMod/TFM_DisguiseCraftBridge.java
rename to src/me/StevenLawson/TotalFreedomMod/Bridge/TFM_DisguiseCraftBridge.java
index f114985..e776cc9 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_DisguiseCraftBridge.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Bridge/TFM_DisguiseCraftBridge.java
@@ -1,5 +1,6 @@
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.Bridge;
+import me.StevenLawson.TotalFreedomMod.TFM_Log;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import pgDev.bukkit.DisguiseCraft.DisguiseCraft;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_EssentialsBridge.java b/src/me/StevenLawson/TotalFreedomMod/Bridge/TFM_EssentialsBridge.java
similarity index 94%
rename from src/me/StevenLawson/TotalFreedomMod/TFM_EssentialsBridge.java
rename to src/me/StevenLawson/TotalFreedomMod/Bridge/TFM_EssentialsBridge.java
index 5064389..5538226 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_EssentialsBridge.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Bridge/TFM_EssentialsBridge.java
@@ -1,7 +1,9 @@
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.Bridge;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
+import me.StevenLawson.TotalFreedomMod.TFM_Log;
+import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java b/src/me/StevenLawson/TotalFreedomMod/Bridge/TFM_WorldEditBridge.java
similarity index 94%
rename from src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java
rename to src/me/StevenLawson/TotalFreedomMod/Bridge/TFM_WorldEditBridge.java
index 31b88c4..6688b2b 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Bridge/TFM_WorldEditBridge.java
@@ -1,4 +1,4 @@
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.Bridge;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
@@ -6,6 +6,10 @@ import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.Region;
+import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
+import me.StevenLawson.TotalFreedomMod.TFM_Log;
+import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
+import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminmode.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminmode.java
index a6f67f2..8f06018 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminmode.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminmode.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminworld.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminworld.java
index ddc5b13..92ab37b 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminworld.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminworld.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_AdminWorld;
+import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java
index a07d2d4..00c6f9b 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java
@@ -19,7 +19,7 @@ public class Command_cake extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
-
+
StringBuilder output = new StringBuilder();
Random randomGenerator = new Random();
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_colorme.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_colorme.java
index a8586a1..27d0bed 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_colorme.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_colorme.java
@@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Iterator;
import java.util.Map;
-import me.StevenLawson.TotalFreedomMod.TFM_EssentialsBridge;
+import me.StevenLawson.TotalFreedomMod.Bridge.TFM_EssentialsBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_config.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_config.java
index 7ba1871..4db7c67 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_config.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_config.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_denick.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_denick.java
index 791ced0..022ec4b 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_denick.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_denick.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_EssentialsBridge;
+import me.StevenLawson.TotalFreedomMod.Bridge.TFM_EssentialsBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_droptoggle.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_droptoggle.java
index 62a4ca9..06eef76 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_droptoggle.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_droptoggle.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_explosives.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_explosives.java
index 4849ab0..aec07be 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_explosives.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_explosives.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fireplace.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fireplace.java
index 9cd6071..6f22c61 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fireplace.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fireplace.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_firespread.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_firespread.java
index a1d4a16..b450fcb 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_firespread.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_firespread.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_flatlands.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_flatlands.java
index 1ca0a33..3cd4497 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_flatlands.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_flatlands.java
@@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
-import me.StevenLawson.TotalFreedomMod.TFM_Flatlands;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.World.TFM_Flatlands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fluidspread.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fluidspread.java
index 8c2296d..3397e9f 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fluidspread.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fluidspread.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java
index 2d1e250..c212818 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java
@@ -4,8 +4,8 @@ import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
+import me.StevenLawson.TotalFreedomMod.TFM_PlayerEntry;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerList;
-import me.StevenLawson.TotalFreedomMod.TFM_PlayerList.PlayerEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
@@ -58,7 +58,7 @@ public class Command_glist extends TFM_Command
}
catch (PlayerNotFoundException ex)
{
- PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(args[1]);
+ final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(args[1]);
if (entry == null)
{
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java
index 5cd4257..b7edd1e 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java
@@ -1,9 +1,9 @@
package me.StevenLawson.TotalFreedomMod.Commands;
+import me.StevenLawson.TotalFreedomMod.Bridge.TFM_WorldEditBridge;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
-import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_landmine.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_landmine.java
index 5bd4b83..dd7f10b 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_landmine.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_landmine.java
@@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lavadmg.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lavadmg.java
index 9b30f17..d3394d3 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lavadmg.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lavadmg.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lavaplace.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lavaplace.java
index e9ecb54..37e4eae 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lavaplace.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lavaplace.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_logs.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_logs.java
index c5a7d82..3f6daa2 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_logs.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_logs.java
@@ -9,7 +9,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_moblimiter.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_moblimiter.java
index 6b9d551..984c4e2 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_moblimiter.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_moblimiter.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java
index 95223fe..2fceac6 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import org.bukkit.ChatColor;
import org.bukkit.Material;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nicknyan.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nicknyan.java
index c1e3547..0f8c31e 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nicknyan.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nicknyan.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_EssentialsBridge;
+import me.StevenLawson.TotalFreedomMod.Bridge.TFM_EssentialsBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nonuke.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nonuke.java
index cef53b1..3bd706d 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nonuke.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nonuke.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_petprotect.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_petprotect.java
index 12b6ad4..b4a8a14 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_petprotect.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_petprotect.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_prelog.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_prelog.java
index a9f5926..31da804 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_prelog.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_prelog.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_protectarea.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_protectarea.java
index a43236c..c7f0292 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_protectarea.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_protectarea.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_purgeall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_purgeall.java
index df9485f..84c2c00 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_purgeall.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_purgeall.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_DisguiseCraftBridge;
+import me.StevenLawson.TotalFreedomMod.Bridge.TFM_DisguiseCraftBridge;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java
index d1e3559..fbd3d13 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
@@ -20,154 +20,146 @@ public class Command_saconfig extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
+ if (args.length == 0 || args.length > 2)
+ {
+ return false;
+ }
if (args.length == 1)
{
if (args[0].equals("list"))
{
- playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperadminUUIDs(), ", "), ChatColor.GOLD);
+ playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperadminNames(), ", "), ChatColor.GOLD);
+ return true;
}
- else
+
+ if (args[0].equals("clean"))
{
+
if (!TFM_AdminList.isSeniorAdmin(sender, true))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
- if (args[0].equals("clean"))
- {
- TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list", true);
- TFM_AdminList.cleanSuperadminList(true);
- playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperadminUUIDs(), ", "), ChatColor.YELLOW);
- }
- else
- {
- return false;
- }
-
+ TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list", true);
+ TFM_AdminList.cleanSuperadminList(true);
+ playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperadminUUIDs(), ", "), ChatColor.YELLOW);
return true;
}
- return true;
+ return false;
}
- else if (args.length == 2)
+
+ if (args[0].equalsIgnoreCase("info"))
{
- if (args[0].equalsIgnoreCase("info"))
+ if (!TFM_AdminList.isSuperAdmin(sender))
{
- if (!TFM_AdminList.isSuperAdmin(sender))
- {
- playerMsg(TotalFreedomMod.MSG_NO_PERMS);
- return true;
- }
-
- TFM_Admin superadmin = TFM_AdminList.getAdminEntry(args[1].toLowerCase());
-
- if (superadmin == null)
- {
- try
- {
- superadmin = TFM_AdminList.getAdminEntry(getPlayer(args[1]).getName().toLowerCase());
- }
- catch (PlayerNotFoundException ex)
- {
- }
- }
-
- if (superadmin == null)
- {
- playerMsg("Superadmin not found: " + args[1]);
- }
- else
- {
- playerMsg(ChatColor.stripColor(TFM_Util.colorize(superadmin.toString())));
- }
-
+ playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
- if (!senderIsConsole)
- {
- playerMsg("This command may only be used from the console.");
- return true;
- }
+ TFM_Admin superadmin = TFM_AdminList.getEntry(args[1].toLowerCase());
- if (args[0].equalsIgnoreCase("add"))
+ if (superadmin == null)
{
- Player player = null;
- String playername = null;
-
try
{
- player = getPlayer(args[1]);
- }
- catch (PlayerNotFoundException ex)
- {
- TFM_Admin superadmin = TFM_AdminList.getAdminEntry(args[1].toLowerCase());
- if (superadmin != null)
- {
- playername = superadmin.getLastLoginName();
- }
- else
- {
- playerMsg(ex.getMessage(), ChatColor.RED);
- return true;
- }
- }
-
- 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);
- }
- }
- else if (TFM_Util.isRemoveCommand(args[0]))
- {
- if (!TFM_AdminList.isSeniorAdmin(sender))
- {
- playerMsg(TotalFreedomMod.MSG_NO_PERMS);
- return true;
- }
-
- String targetName = args[1];
-
- try
- {
- targetName = getPlayer(targetName).getName();
+ superadmin = TFM_AdminList.getEntry(getPlayer(args[1]).getName().toLowerCase());
}
catch (PlayerNotFoundException ex)
{
}
+ }
- if (!TFM_AdminList.getSuperadminUUIDs().contains(targetName.toLowerCase()))
- {
- playerMsg("Superadmin not found: " + targetName);
- return true;
- }
-
- TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true);
- TFM_AdminList.removeSuperadmin(Bukkit.getOfflinePlayer(targetName));
-
- // Twitterbot
- if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
- {
- TFM_TwitterHandler.getInstance().delTwitterVerbose(targetName, sender);
- }
+ if (superadmin == null)
+ {
+ playerMsg("Superadmin not found: " + args[1]);
}
else
{
- return false;
+ playerMsg(superadmin.toString());
}
return true;
}
- else
+
+ if (!senderIsConsole)
{
- return false;
+ playerMsg("This command may only be used from the console.");
+ return true;
}
+
+ if (args[0].equalsIgnoreCase("add"))
+ {
+ Player player = null;
+ String playername = null;
+
+ try
+ {
+ player = getPlayer(args[1]);
+ }
+ catch (PlayerNotFoundException ex)
+ {
+ final TFM_Admin superadmin = TFM_AdminList.getEntry(args[1]);
+ if (superadmin != null)
+ {
+ playername = superadmin.getLastLoginName();
+ }
+ else
+ {
+ playerMsg(ex.getMessage(), ChatColor.RED);
+ return true;
+ }
+ }
+
+ 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);
+ }
+ return true;
+ }
+
+ if (TFM_Util.isRemoveCommand(args[0]))
+ {
+ if (!TFM_AdminList.isSeniorAdmin(sender))
+ {
+ playerMsg(TotalFreedomMod.MSG_NO_PERMS);
+ return true;
+ }
+
+ String targetName = args[1];
+
+ try
+ {
+ targetName = getPlayer(targetName).getName();
+ }
+ catch (PlayerNotFoundException ex)
+ {
+ }
+
+ if (!TFM_AdminList.getLowerSuperadminNames().contains(targetName.toLowerCase()))
+ {
+ playerMsg("Superadmin not found: " + targetName);
+ return true;
+ }
+
+ TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true);
+ TFM_AdminList.removeSuperadmin(Bukkit.getOfflinePlayer(targetName));
+
+ // Twitterbot
+ if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
+ {
+ TFM_TwitterHandler.getInstance().delTwitterVerbose(targetName, sender);
+ }
+ return true;
+ }
+ return false;
+
}
}
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setl.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setl.java
index fcb5eb6..aa6c734 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setl.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setl.java
@@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
-import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
+import me.StevenLawson.TotalFreedomMod.Bridge.TFM_WorldEditBridge;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setspawnworld.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setspawnworld.java
index f8309db..5acf5ac 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setspawnworld.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setspawnworld.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Location;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java
index 7498b00..d66b3f3 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_twitter.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_twitter.java
index da5c949..842b5c1 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_twitter.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_twitter.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uall.java
index c271695..f8c9df8 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uall.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uall.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_DisguiseCraftBridge;
+import me.StevenLawson.TotalFreedomMod.Bridge.TFM_DisguiseCraftBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_waterplace.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_waterplace.java
index 9fc93b2..2a31940 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_waterplace.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_waterplace.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Config/TFM_Config.java b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_Config.java
new file mode 100644
index 0000000..acfb726
--- /dev/null
+++ b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_Config.java
@@ -0,0 +1,150 @@
+package me.StevenLawson.TotalFreedomMod.Config;
+
+import java.io.File;
+import java.io.IOException;
+import me.StevenLawson.TotalFreedomMod.TFM_Util;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.plugin.Plugin;
+
+/**
+ * Represents a definable YAML configuration.
+ *
+ * @see YamlConfiguration
+ */
+public class TFM_Config extends YamlConfiguration // BukkitLib @ https://github.com/Pravian/BukkitLib
+{
+ private final Plugin plugin;
+ private final File configFile;
+ private final boolean copyDefaults;
+
+ /**
+ * Creates a new YamlConfig instance.
+ *
+ * Example:
+ *
+ * YamlConfig config = new YamlConfig(this, "config.yml", true);
+ * config.load();
+ *
+ *
+ * @param plugin The plugin to which the config belongs.
+ * @param fileName The filename of the config file.
+ * @param copyDefaults If the defaults should be copied and/loaded from a config in the plugin jar-file.
+ */
+ public TFM_Config(Plugin plugin, String fileName, boolean copyDefaults)
+ {
+ this(plugin, TFM_Util.getPluginFile(plugin, fileName), copyDefaults);
+ }
+
+ /**
+ * Creates a new YamlConfig instance.
+ *
+ * Example:
+ *
+ * YamlConfig config = new YamlConfig(this, new File(plugin.getDataFolder() + "/players", "DarthSalamon.yml"), false);
+ * config.load();
+ *
+ *
+ * @param plugin The plugin to which the config belongs.
+ * @param file The file of the config file.
+ * @param copyDefaults If the defaults should be copied and/loaded from a config in the plugin jar-file.
+ */
+ public TFM_Config(Plugin plugin, File file, boolean copyDefaults)
+ {
+ this.plugin = plugin;
+ this.configFile = file;
+ this.copyDefaults = copyDefaults;
+ }
+
+ /**
+ * Saves the configuration to the predefined file.
+ *
+ * @see #YamlConfig(Plugin, String, boolean)
+ */
+ public void save()
+ {
+ try
+ {
+ super.save(configFile);
+ }
+ catch (Exception ex)
+ {
+ plugin.getLogger().severe("Could not save configuration file: " + configFile.getName());
+ plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
+ }
+ }
+
+ /**
+ * Loads the configuration from the predefined file.
+ *
+ * Optionally, if loadDefaults has been set to true, the file will be copied over from the default inside the jar-file of the owning plugin.
+ *
+ * @see #YamlConfig(Plugin, String, boolean)
+ */
+ public void load()
+ {
+ try
+ {
+ if (copyDefaults)
+ {
+ if (!configFile.exists())
+ {
+ configFile.getParentFile().mkdirs();
+ try
+ {
+ TFM_Util.copy(plugin.getResource(configFile.getName()), configFile);
+ }
+ catch (IOException ex)
+ {
+ plugin.getLogger().severe("Could not write default configuration file: " + configFile.getName());
+ plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
+ }
+ plugin.getLogger().info("Installed default configuration " + configFile.getName());
+ }
+
+ super.addDefaults(getDefaultConfig());
+ }
+
+ if (configFile.exists())
+ {
+ super.load(configFile);
+ }
+ }
+ catch (Exception ex)
+ {
+ plugin.getLogger().severe("Could not load configuration file: " + configFile.getName());
+ plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
+ }
+ }
+
+ /**
+ * Returns the raw YamlConfiguration this config is based on.
+ *
+ * @return The YamlConfiguration.
+ * @see YamlConfiguration
+ */
+ public YamlConfiguration getConfig()
+ {
+ return this;
+ }
+
+ /**
+ * Returns the default configuration as been stored in the jar-file of the owning plugin.
+ * @return The default configuration.
+ */
+ public YamlConfiguration getDefaultConfig()
+ {
+ final YamlConfiguration DEFAULT_CONFIG = new YamlConfiguration();
+ try
+ {
+ DEFAULT_CONFIG.load(plugin.getResource(configFile.getName()));
+ }
+ catch (Throwable ex)
+ {
+ plugin.getLogger().severe("Could not load default configuration: " + configFile.getName());
+ plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
+ return null;
+ }
+ return DEFAULT_CONFIG;
+ }
+}
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ConfigEntry.java b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_ConfigEntry.java
similarity index 87%
rename from src/me/StevenLawson/TotalFreedomMod/TFM_ConfigEntry.java
rename to src/me/StevenLawson/TotalFreedomMod/Config/TFM_ConfigEntry.java
index 665d1d7..e2cb029 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_ConfigEntry.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_ConfigEntry.java
@@ -1,4 +1,4 @@
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.Config;
import java.util.List;
@@ -79,51 +79,51 @@ public enum TFM_ConfigEntry
public String getString()
{
- return TFM_Config.getInstance().getString(this);
+ return TFM_MainConfig.getInstance().getString(this);
}
public String setString(String value)
{
- TFM_Config.getInstance().setString(this, value);
+ TFM_MainConfig.getInstance().setString(this, value);
return value;
}
public Double getDouble()
{
- return TFM_Config.getInstance().getDouble(this);
+ return TFM_MainConfig.getInstance().getDouble(this);
}
public Double setDouble(Double value)
{
- TFM_Config.getInstance().setDouble(this, value);
+ TFM_MainConfig.getInstance().setDouble(this, value);
return value;
}
public Boolean getBoolean()
{
- return TFM_Config.getInstance().getBoolean(this);
+ return TFM_MainConfig.getInstance().getBoolean(this);
}
public Boolean setBoolean(Boolean value)
{
- TFM_Config.getInstance().setBoolean(this, value);
+ TFM_MainConfig.getInstance().setBoolean(this, value);
return value;
}
public Integer getInteger()
{
- return TFM_Config.getInstance().getInteger(this);
+ return TFM_MainConfig.getInstance().getInteger(this);
}
public Integer setInteger(Integer value)
{
- TFM_Config.getInstance().setInteger(this, value);
+ TFM_MainConfig.getInstance().setInteger(this, value);
return value;
}
public List> getList()
{
- return TFM_Config.getInstance().getList(this);
+ return TFM_MainConfig.getInstance().getList(this);
}
public static TFM_ConfigEntry findConfigEntry(String name)
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Config.java b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_MainConfig.java
similarity index 94%
rename from src/me/StevenLawson/TotalFreedomMod/TFM_Config.java
rename to src/me/StevenLawson/TotalFreedomMod/Config/TFM_MainConfig.java
index 293547c..d729134 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_Config.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_MainConfig.java
@@ -1,23 +1,26 @@
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.Config;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.EnumMap;
import java.util.List;
+import me.StevenLawson.TotalFreedomMod.TFM_Log;
+import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
-public class TFM_Config
+public class TFM_MainConfig
{
public static final String CONFIG_FILENAME = "config.yml";
public static final File CONFIG_FILE = new File(TotalFreedomMod.plugin.getDataFolder(), CONFIG_FILENAME);
//
private final EnumMap configEntryMap = new EnumMap(TFM_ConfigEntry.class);
- private TFM_Config()
+ private TFM_MainConfig()
{
try
{
@@ -258,7 +261,7 @@ public class TFM_Config
{
private YamlConfiguration defaults = null;
- public TFM_Config_DefaultsLoader(InputStream defaultConfig)
+ private TFM_Config_DefaultsLoader(InputStream defaultConfig)
{
try
{
@@ -281,13 +284,13 @@ public class TFM_Config
}
}
- public static TFM_Config getInstance()
+ public static TFM_MainConfig getInstance()
{
return TFM_ConfigHolder.INSTANCE;
}
private static class TFM_ConfigHolder
{
- private static final TFM_Config INSTANCE = new TFM_Config();
+ private static final TFM_MainConfig INSTANCE = new TFM_MainConfig();
}
}
diff --git a/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_file.java b/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_file.java
index f241a92..eb4f776 100644
--- a/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_file.java
+++ b/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_file.java
@@ -12,7 +12,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import static me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.*;
diff --git a/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_players.java b/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_players.java
index 60ea243..3f13e45 100644
--- a/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_players.java
+++ b/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_players.java
@@ -82,6 +82,6 @@ public class Module_players extends TFM_HTTPD_Module
private String getName(UUID uuid)
{
- return TFM_AdminList.getAdminEntry(uuid).getLastLoginName();
+ return TFM_AdminList.getEntry(uuid).getLastLoginName();
}
}
diff --git a/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_schematic.java b/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_schematic.java
index b294f1d..48d1a1c 100644
--- a/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_schematic.java
+++ b/src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_schematic.java
@@ -223,7 +223,7 @@ public class Module_schematic extends TFM_HTTPD_Module
private boolean isAuthorized(String remoteAddress)
{
- TFM_Admin entry = TFM_AdminList.getAdminEntryByIP(remoteAddress);
+ TFM_Admin entry = TFM_AdminList.getEntryByIp(remoteAddress);
return entry != null && entry.isActivated();
}
diff --git a/src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java b/src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java
index 944d093..ac67370 100644
--- a/src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java
+++ b/src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java
@@ -8,7 +8,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.HTTPSession;
import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.Response;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java
index 3c546e8..4186fb5 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java
@@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Listener;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.*;
import org.bukkit.ChatColor;
import org.bukkit.Location;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java
index d01dfe3..14ae5d1 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java
@@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Listener;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java
index fbe8607..2792960 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java
@@ -1,5 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Listener;
+import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -8,7 +10,6 @@ import java.util.Map.Entry;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.*;
import me.StevenLawson.TotalFreedomMod.Commands.Command_landmine;
-import me.StevenLawson.TotalFreedomMod.TFM_PlayerList.PlayerEntry;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager.RollbackEntry;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
@@ -693,7 +694,7 @@ public class TFM_PlayerListener implements Listener
{
TFM_Log.info("Added new player: " + TFM_Util.formatPlayer(player));
- final PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(player);
+ final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(player);
entry.setLastJoinUnix(TFM_Util.getUnixTime());
entry.setLastJoinName(player.getName());
entry.save();
@@ -701,46 +702,42 @@ public class TFM_PlayerListener implements Listener
else
{
// Preload the entry; the login unix is defaulted to the current time
- final PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(player);
+ final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(player);
entry.addIp(ip);
entry.save();
}
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
+ playerdata.setSuperadminIdVerified(false);
- playerdata.setSuperadminIdVerified(null);
- final boolean impostor = TFM_AdminList.isAdminImpostor(player);
-
- if (impostor || TFM_AdminList.isSuperAdmin(player))
+ // Verify strict IP match
+ if (TFM_AdminList.isSuperAdmin(player))
{
- TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
+ player.setOp(true);
- if (impostor)
+ if (!TFM_AdminList.isIdentityMatched(player))
{
- player.getInventory().clear();
- player.setOp(false);
- player.setGameMode(GameMode.SURVIVAL);
- TFM_Util.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor!", ChatColor.RED);
+ playerdata.setSuperadminIdVerified(false);
+
+ TFM_Util.bcastMsg("Warning: " + player.getName() + " is an admin, but is using a username not registered to one of their ip-list.", ChatColor.RED);
}
else
{
- if (TFM_AdminList.verifyIdentity(player.getName(), TFM_Util.getIp(player)))
- {
- playerdata.setSuperadminIdVerified(Boolean.TRUE);
-
- TFM_AdminList.updateLastLogin(player);
- }
- else
- {
- playerdata.setSuperadminIdVerified(Boolean.FALSE);
-
- TFM_Util.bcastMsg("Warning: " + player.getName() + " is an admin, but is using a username not registered to one of their IPs.", ChatColor.RED);
- }
-
- player.setOp(true);
+ playerdata.setSuperadminIdVerified(true);
+ TFM_AdminList.updateLastLogin(player);
}
}
- else if (TFM_Util.DEVELOPERS.contains(player.getName()))
+
+ // Handle admin impostors
+ if (TFM_AdminList.isAdminImpostor(player))
+ {
+ TFM_Util.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor!", ChatColor.RED);
+ TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
+ player.getInventory().clear();
+ player.setOp(false);
+ player.setGameMode(GameMode.SURVIVAL);
+ }
+ else if (TFM_AdminList.isSuperAdmin(player) || TFM_Util.DEVELOPERS.contains(player.getName()))
{
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
}
diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_ServerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_ServerListener.java
index 94d61be..a5de1d3 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_ServerListener.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_ServerListener.java
@@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Bukkit;
diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_TelnetListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_TelnetListener.java
index 38fe77a..4280048 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_TelnetListener.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_TelnetListener.java
@@ -23,7 +23,7 @@ public class TFM_TelnetListener implements Listener
return;
}
- final TFM_Admin admin = TFM_AdminList.getAdminEntryByIP(ip, true);
+ final TFM_Admin admin = TFM_AdminList.getEntryByIp(ip, true);
if (admin == null || !(admin.isTelnetAdmin() || admin.isSeniorAdmin()))
{
diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java
index 3352212..7a171b2 100644
--- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java
+++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java
@@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Listener;
-import me.StevenLawson.TotalFreedomMod.TFM_AdminWorld;
-import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
+import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java b/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java
index 71eb3e0..ec085fa 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java
@@ -2,24 +2,23 @@ package me.StevenLawson.TotalFreedomMod;
import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
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;
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.World.TFM_AdminWorld;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.util.FileUtil;
@@ -44,11 +43,6 @@ public class TFM_AdminList
superadminIps = new HashSet();
}
- private TFM_AdminList()
- {
- throw new AssertionError();
- }
-
public static Set getSuperadminUUIDs()
{
return Collections.unmodifiableSet(superadminUUIDs);
@@ -74,20 +68,38 @@ public class TFM_AdminList
return Collections.unmodifiableSet(superadminIps);
}
- public File getConfigFile()
+ public static Set getSuperadminNames()
{
- return new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE);
+ final Set names = new HashSet();
+
+ for (TFM_Admin admin : adminList.values())
+ {
+ names.add(admin.getLastLoginName());
+ }
+
+ return Collections.unmodifiableSet(names);
}
- public static void loadSuperadminList()
+ public static Set getLowerSuperadminNames()
+ {
+ final Set names = new HashSet();
+
+ for (TFM_Admin admin : adminList.values())
+ {
+ names.add(admin.getLastLoginName().toLowerCase());
+ }
+
+ return Collections.unmodifiableSet(names);
+ }
+
+ public static void load()
{
try
{
adminList.clear();
- TFM_Util.createDefaultConfiguration(TotalFreedomMod.SUPERADMIN_FILE);
-
- final FileConfiguration config = YamlConfiguration.loadConfiguration(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
+ final TFM_Config config = new TFM_Config(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILE, true);
+ config.load();
cleanThreshold = config.getInt("clean_threshold_hours", cleanThreshold);
@@ -102,7 +114,7 @@ public class TFM_AdminList
return;
}
- final ConfigurationSection section = config.getConfigurationSection("superadmins");
+ final ConfigurationSection section = config.getConfigurationSection("admins");
for (String uuidString : section.getKeys(false))
{
@@ -178,43 +190,37 @@ public class TFM_AdminList
TFM_AdminWorld.getInstance().wipeAccessCache();
}
- public static void saveSuperadminList()
+ public static void save()
{
- try
+ updateIndexLists();
+
+ final TFM_Config config = new TFM_Config(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILE, true);
+ config.load();
+
+ config.set("clean_threshold_hours", cleanThreshold);
+
+ Iterator> it = adminList.entrySet().iterator();
+ while (it.hasNext())
{
- updateIndexLists();
+ Entry pair = it.next();
- YamlConfiguration config = new YamlConfiguration();
+ UUID uuid = pair.getKey();
+ TFM_Admin superadmin = pair.getValue();
- config.set("clean_threshold_hours", cleanThreshold);
-
- Iterator> it = adminList.entrySet().iterator();
- while (it.hasNext())
- {
- Entry pair = it.next();
-
- UUID uuid = pair.getKey();
- TFM_Admin superadmin = pair.getValue();
-
- config.set("superadmins." + uuid + ".last_login_name", superadmin.getLastLoginName());
- config.set("superadmins." + uuid + ".is_activated", superadmin.isActivated());
- config.set("superadmins." + uuid + ".last_login", TFM_Util.dateToString(superadmin.getLastLogin()));
- config.set("superadmins." + uuid + ".custom_login_message", superadmin.getCustomLoginMessage());
- config.set("superadmins." + uuid + ".is_senior_admin", superadmin.isSeniorAdmin());
- config.set("superadmins." + uuid + ".is_telnet_admin", superadmin.isTelnetAdmin());
- config.set("superadmins." + uuid + ".console_aliases", TFM_Util.removeDuplicates(superadmin.getConsoleAliases()));
- config.set("superadmins." + uuid + ".ips", TFM_Util.removeDuplicates(superadmin.getIps()));
- }
-
- config.save(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
- }
- catch (Exception ex)
- {
- TFM_Log.severe(ex);
+ config.set("admins." + uuid + ".last_login_name", superadmin.getLastLoginName());
+ config.set("admins." + uuid + ".is_activated", superadmin.isActivated());
+ config.set("admins." + uuid + ".last_login", TFM_Util.dateToString(superadmin.getLastLogin()));
+ config.set("admins." + uuid + ".custom_login_message", superadmin.getCustomLoginMessage());
+ config.set("admins." + uuid + ".is_senior_admin", superadmin.isSeniorAdmin());
+ config.set("admins." + uuid + ".is_telnet_admin", superadmin.isTelnetAdmin());
+ config.set("admins." + uuid + ".console_aliases", TFM_Util.removeDuplicates(superadmin.getConsoleAliases()));
+ config.set("admins." + uuid + ".ips", TFM_Util.removeDuplicates(superadmin.getIps()));
}
+
+ config.save();
}
- public static TFM_Admin getAdminEntry(Player player)
+ public static TFM_Admin getEntry(Player player)
{
final UUID uuid = player.getUniqueId();
@@ -226,16 +232,16 @@ public class TFM_AdminList
}
}
- return getAdminEntryByIP(TFM_Util.getIp(player));
+ return getEntryByIp(TFM_Util.getIp(player));
}
- public static TFM_Admin getAdminEntry(UUID uuid)
+ public static TFM_Admin getEntry(UUID uuid)
{
return adminList.get(uuid);
}
@Deprecated
- public static TFM_Admin getAdminEntry(String name)
+ public static TFM_Admin getEntry(String name)
{
for (UUID uuid : adminList.keySet())
{
@@ -247,12 +253,12 @@ public class TFM_AdminList
return null;
}
- public static TFM_Admin getAdminEntryByIP(String ip)
+ public static TFM_Admin getEntryByIp(String ip)
{
- return getAdminEntryByIP(ip, false);
+ return getEntryByIp(ip, false);
}
- public static TFM_Admin getAdminEntryByIP(String needleIp, boolean fuzzy)
+ public static TFM_Admin getEntryByIp(String needleIp, boolean fuzzy)
{
Iterator> it = adminList.entrySet().iterator();
while (it.hasNext())
@@ -283,18 +289,18 @@ public class TFM_AdminList
public static void updateLastLogin(Player player)
{
- final TFM_Admin admin = getAdminEntry(player);
+ final TFM_Admin admin = getEntry(player);
if (admin != null)
{
admin.setLastLogin(new Date());
admin.setLastLoginName(player.getName());
- saveSuperadminList();
+ save();
}
}
- public static boolean isSeniorAdmin(CommandSender user)
+ public static boolean isSeniorAdmin(CommandSender sender)
{
- return isSeniorAdmin(user, false);
+ return isSeniorAdmin(sender, false);
}
public static boolean isSeniorAdmin(CommandSender sender, boolean verifySuperadmin)
@@ -310,10 +316,10 @@ public class TFM_AdminList
if (!(sender instanceof Player))
{
- return senioradminUUIDs.contains(((Player) sender).getUniqueId());
+ return senioradminAliases.contains(sender.getName());
}
- final TFM_Admin entry = getAdminEntry((Player) sender);
+ final TFM_Admin entry = getEntry((Player) sender);
if (entry != null)
{
return entry.isSeniorAdmin();
@@ -329,14 +335,12 @@ public class TFM_AdminList
return true;
}
- if (Bukkit.getOnlineMode())
+ if (Bukkit.getOnlineMode() && superadminUUIDs.contains(((Player) sender).getUniqueId()))
{
- if (superadminUUIDs.contains(((Player) sender).getUniqueId()));
- {
- return true;
- }
+ return true;
}
+
if (superadminIps.contains(TFM_Util.getIp((Player) sender)))
{
return true;
@@ -345,8 +349,29 @@ public class TFM_AdminList
return false;
}
+ public static boolean isIdentityMatched(Player player)
+ {
+ if (!isSuperAdmin(player))
+ {
+ return false;
+ }
+
+ if (Bukkit.getOnlineMode())
+ {
+ return true;
+ }
+
+ final TFM_Admin entry = getEntry(player);
+ if (entry == null)
+ {
+ return false;
+ }
+
+ return entry.getIps().contains(TFM_Util.getIp(player));
+ }
+
@Deprecated
- public static boolean checkPartialSuperadminIP(String ip, String name)
+ public static boolean checkPartialSuperadminIp(String ip, String name)
{
ip = ip.trim();
@@ -369,7 +394,7 @@ public class TFM_AdminList
if (matchIp != null)
{
- final TFM_Admin entry = getAdminEntryByIP(matchIp);
+ final TFM_Admin entry = getEntryByIp(matchIp);
if (entry == null)
{
@@ -382,7 +407,7 @@ public class TFM_AdminList
{
entry.addIp(ip);
}
- saveSuperadminList();
+ save();
}
return true;
@@ -406,32 +431,6 @@ public class TFM_AdminList
return false;
}
- /*public static void addSuperadmin(String username, List ips)
- {
- try
- {
- username = username.toLowerCase();
-
- if (superadminList.containsKey(username))
- {
- TFM_Admin superadmin = superadminList.get(username);
- superadmin.setActivated(true);
- superadmin.getIps().addAll(ips);
- superadmin.setLastLogin(new Date());
- }
- else
- {
- TFM_Admin superadmin = new TFM_Admin(username, ips, new Date(), "", false, false, new ArrayList(), true);
- superadminList.put(username.toLowerCase(), superadmin);
- }
-
- saveSuperadminList();
- }
- catch (Exception ex)
- {
- TFM_Log.severe(ex);
- }
- }*/
public static void addSuperadmin(Player player)
{
try
@@ -462,7 +461,7 @@ public class TFM_AdminList
adminList.put(uuid, superadmin);
}
- saveSuperadminList();
+ save();
}
catch (Exception ex)
{
@@ -480,7 +479,7 @@ public class TFM_AdminList
TFM_Admin superadmin = adminList.get(uuid);
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
- saveSuperadminList();
+ save();
}
}
@@ -512,23 +511,16 @@ public class TFM_AdminList
TFM_TwitterHandler.getInstance().delTwitter(superadmin.getLastLoginName());
}
}
- saveSuperadminList();
+ save();
}
- @Deprecated
- public static boolean verifyIdentity(String username, String ip)
+ private TFM_AdminList()
{
- if (Bukkit.getOnlineMode())
- {
- return true;
- }
+ throw new AssertionError();
+ }
- TFM_Admin entry = getAdminEntry(username);
- if (entry != null)
- {
- return entry.getIps().contains(ip);
- }
-
- return false;
+ public File getConfigFile()
+ {
+ return new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE);
}
}
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java b/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java
index 4eb5f2e..c442718 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java
@@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java b/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java
index cc60b15..320971a 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java
@@ -1,5 +1,7 @@
package me.StevenLawson.TotalFreedomMod;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_MainConfig;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
@@ -80,7 +82,7 @@ public class TFM_FrontDoor
FRONTDOOR.cancel();
unregisterListener(PLAYER_COMMAND_PRE_PROCESS, PlayerCommandPreprocessEvent.class);
TFM_Log.info("Disabled FrontDoor, thank you for being kind.");
- TFM_Config.getInstance().load();
+ TFM_MainConfig.getInstance().load();
}
else
{
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java
index 1d506c8..f2deb49 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java
@@ -1,5 +1,8 @@
package me.StevenLawson.TotalFreedomMod;
+import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
+import me.StevenLawson.TotalFreedomMod.Bridge.TFM_EssentialsBridge;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Player;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_LogFile.java b/src/me/StevenLawson/TotalFreedomMod/TFM_LogFile.java
deleted file mode 100644
index 5c44c9d..0000000
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_LogFile.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package me.StevenLawson.TotalFreedomMod;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.SimpleDateFormat;
-import java.util.logging.FileHandler;
-import java.util.logging.Formatter;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-public class TFM_LogFile
-{
- public static final int MAX_LOG_SIZE = 1024 * 1024; // Bytes
- private final Logger logger;
- private final SimpleDateFormat date;
-
- private TFM_LogFile()
- {
- this.logger = TotalFreedomMod.server.getLogger();
- this.date = new SimpleDateFormat("HH:mm:ss");
- }
-
- public void start()
- {
- try
- {
- logger.addHandler(getHandler());
- }
- catch (Exception ex)
- {
- TFM_Log.warning("Failed to register log handler!");
- TFM_Log.warning(TotalFreedomMod.pluginName + " will not log to /server.log!");
- TFM_Log.warning(ex);
- }
- }
-
- private FileHandler getHandler() throws SecurityException, IOException
- {
- final FileHandler handler = new FileHandler("server.log", MAX_LOG_SIZE, 1);
- handler.setLevel(Level.ALL);
- handler.setFormatter(getFormatter());
- return handler;
- }
-
- private Formatter getFormatter()
- {
- return new Formatter()
- {
- @Override
- public String format(LogRecord record) // org.bukkit.craftbukkit.util.ShortConsoleFormatter
- {
- StringBuilder builder = new StringBuilder();
- Throwable ex = record.getThrown();
-
- builder.append(date.format(record.getMillis()));
- builder.append(" [");
- builder.append(record.getLevel().getLocalizedName().toUpperCase());
- builder.append("] ");
- builder.append(formatMessage(record));
- builder.append('\n');
-
- if (ex != null)
- {
- StringWriter writer = new StringWriter();
- ex.printStackTrace(new PrintWriter(writer));
- builder.append(writer);
- }
-
- return builder.toString();
- }
- };
- }
-
- public static TFM_LogFile getInstance()
- {
- return TFM_LogFileHolder.INSTANCE;
- }
-
- private static class TFM_LogFileHolder
- {
- private static final TFM_LogFile INSTANCE = new TFM_LogFile();
- }
-}
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java
index 56e3914..ca66bc7 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java
@@ -49,7 +49,7 @@ public class TFM_PlayerData
private String lastMessage = "";
private boolean inAdminchat = false;
private boolean allCommandsBlocked = false;
- private Boolean verifiedSuperadminId = null;
+ private boolean verifiedSuperadminId = false;
private String lastCommand = "";
private boolean cmdspyEnabled = false;
private String tag = null;
@@ -442,14 +442,14 @@ public class TFM_PlayerData
// If someone logs in to telnet or minecraft, and they are an admin, make sure that they are using a username that is associated with their IP.
// After the check for this is done in TFM_PlayerListener, never change it elsewhere.
- public Boolean isSuperadminIdVerified()
+ public boolean isSuperadminIdVerified()
{
return this.verifiedSuperadminId;
}
// If someone logs in to telnet or minecraft, and they are an admin, make sure that they are using a username that is associated with their IP.
// After the check for this is done in TFM_PlayerListener, never change it elsewhere.
- public void setSuperadminIdVerified(Boolean verifiedSuperadminId)
+ public void setSuperadminIdVerified(boolean verifiedSuperadminId)
{
this.verifiedSuperadminId = verifiedSuperadminId;
}
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerEntry.java b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerEntry.java
new file mode 100644
index 0000000..83f6f7a
--- /dev/null
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerEntry.java
@@ -0,0 +1,135 @@
+package me.StevenLawson.TotalFreedomMod;
+
+import me.StevenLawson.TotalFreedomMod.Config.TFM_Config;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+import org.bukkit.configuration.ConfigurationSection;
+
+public class TFM_PlayerEntry
+{
+ private final UUID uuid;
+ private String firstJoinName;
+ private String lastJoinName;
+ private long firstJoinUnix;
+ private long lastJoinUnix;
+ private final List ips;
+
+ protected TFM_PlayerEntry(UUID uuid, ConfigurationSection section)
+ {
+ this(uuid);
+
+ this.firstJoinName = section.getString("firstjoinname");
+ this.lastJoinName = section.getString("lastjoinname");
+
+ this.firstJoinUnix = section.getLong("firstjoinunix");
+ this.firstJoinUnix = section.getLong("lastjoinunix");
+
+ this.ips.addAll(section.getStringList("ips"));
+ }
+
+ protected TFM_PlayerEntry(UUID uuid)
+ {
+ this.uuid = uuid;
+ this.ips = new ArrayList();
+ }
+
+ // Getters / Setters below
+ public UUID getUniqueId()
+ {
+ return uuid;
+ }
+
+ public List getIps()
+ {
+ return Collections.unmodifiableList(ips);
+ }
+
+ public String getFirstJoinName()
+ {
+ return firstJoinName;
+ }
+
+ public void setFirstJoinName(String firstJoinName)
+ {
+ this.firstJoinName = firstJoinName;
+ }
+
+ public String getLastJoinName()
+ {
+ return lastJoinName;
+ }
+
+ public void setLastJoinName(String lastJoinName)
+ {
+ this.lastJoinName = lastJoinName;
+ }
+
+ public long getFirstJoinUnix()
+ {
+ return firstJoinUnix;
+ }
+
+ public void setFirstJoinUnix(long firstJoinUnix)
+ {
+ this.firstJoinUnix = firstJoinUnix;
+ }
+
+ public long getLastJoinUnix()
+ {
+ return lastJoinUnix;
+ }
+
+ public void setLastJoinUnix(long lastJoinUnix)
+ {
+ this.lastJoinUnix = lastJoinUnix;
+ }
+
+ public boolean addIp(String ip)
+ {
+ if (!ips.contains(ip))
+ {
+ ips.add(ip);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isComplete()
+ {
+ return firstJoinName != null
+ && lastJoinName != null
+ && firstJoinUnix != 0
+ && lastJoinUnix != 0
+ && !ips.isEmpty();
+ }
+
+ public void save()
+ {
+ if (!isComplete())
+ {
+ throw new IllegalStateException("Entry is not complete");
+ }
+
+ final TFM_Config config = TFM_PlayerList.getInstance().getConfig();
+ final ConfigurationSection section;
+
+ if (config.isConfigurationSection(uuid.toString()))
+ {
+ section = config.getConfigurationSection(uuid.toString());
+ }
+ else
+ {
+ section = config.createSection(uuid.toString());
+ }
+
+ section.set("firstjoinname", firstJoinName);
+ section.set("lastjoinname", lastJoinName);
+ section.set("firstjoinunix", firstJoinUnix);
+ section.set("lastjoinunix", lastJoinUnix);
+ section.set("ips", ips);
+
+ config.save();
+ }
+}
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerList.java b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerList.java
index bc564d7..5ac929d 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerList.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerList.java
@@ -1,82 +1,64 @@
package me.StevenLawson.TotalFreedomMod;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_Config;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
-import net.pravian.bukkitlib.YamlConfig;
import org.bukkit.Bukkit;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
public class TFM_PlayerList
{
- private static final TFM_PlayerList INSTANCE = new TFM_PlayerList();
- private static final String USERLIST_FILENAME = "playerlist.yml";
- private final Map playerList;
- private File configFile;
+ private static final TFM_PlayerList INSTANCE;
+ private final Map playerList;
+ private TFM_Config config;
+
+ static
+ {
+ INSTANCE = new TFM_PlayerList();
+ }
private TFM_PlayerList()
{
- this.playerList = new HashMap();
- this.configFile = new File(TotalFreedomMod.plugin.getDataFolder(), USERLIST_FILENAME);
+ this.playerList = new HashMap();
}
- public File getConfigFile()
+ public TFM_Config getConfig()
{
- return new File(TotalFreedomMod.plugin.getDataFolder(), USERLIST_FILENAME);
+ return config;
}
public void load()
{
playerList.clear();
- configFile = getConfigFile();
- final YamlConfiguration config = new YamlConfiguration();
-
- if (configFile.exists())
+ if (config == null)
{
- try
+ config = new TFM_Config(TotalFreedomMod.plugin, "playerlist.yml", false);
+ }
+
+ config.load();
+
+ // Load players from config
+ for (String uuidString : config.getKeys(false))
+ {
+ if (!TFM_Util.isUniqueId(uuidString))
{
- config.load(configFile);
- }
- catch (Exception ex)
- {
- TFM_Log.warning("Could not load player config file: " + ex.getMessage());
- TFM_Log.warning("Purging...");
- purgeAll();
- return;
+ TFM_Log.warning("Invalid playerlist UUID: " + uuidString + ", Skipping...");
+ continue;
}
- // Load players from config
- for (String uuidString : config.getKeys(false))
+ final UUID uuid = UUID.fromString(uuidString);
+
+ final TFM_PlayerEntry entry = new TFM_PlayerEntry(uuid, config.getConfigurationSection(uuidString));
+
+ if (!entry.isComplete())
{
- final UUID uuid;
- try
- {
- uuid = UUID.fromString(uuidString);
- }
- catch (IllegalArgumentException ex)
- {
- TFM_Log.warning("Invalid playerlist UUID: " + uuidString + ", Skipping...");
- continue;
- }
-
- final PlayerEntry entry = new PlayerEntry(uuid, config.getConfigurationSection(uuidString));
-
- if (!entry.isComplete())
- {
- TFM_Log.warning("Incomplete playerlist entry: " + uuidString + ", Skipping...");
- continue;
- }
-
- playerList.put(uuid, entry);
+ TFM_Log.warning("Incomplete playerlist entry: " + uuidString + ", Skipping...");
+ continue;
}
+
+ playerList.put(uuid, entry);
}
// Load online players
@@ -92,16 +74,16 @@ public class TFM_PlayerList
private void saveAll()
{
// Put entries
- for (PlayerEntry entry : playerList.values())
+ for (TFM_PlayerEntry entry : playerList.values())
{
entry.save();
}
}
- public PlayerEntry getEntry(String player)
+ public TFM_PlayerEntry getEntry(String player)
{
- for (PlayerEntry entry : playerList.values())
+ for (TFM_PlayerEntry entry : playerList.values())
{
if (entry.getLastJoinName().equalsIgnoreCase(player))
{
@@ -117,7 +99,7 @@ public class TFM_PlayerList
return playerList.containsKey(player.getUniqueId());
}
- public PlayerEntry getEntry(Player player)
+ public TFM_PlayerEntry getEntry(Player player)
{
final UUID uuid = player.getUniqueId();
@@ -126,7 +108,7 @@ public class TFM_PlayerList
return playerList.get(uuid);
}
- final PlayerEntry entry = new PlayerEntry(uuid);
+ final TFM_PlayerEntry entry = new TFM_PlayerEntry(uuid);
entry.setFirstJoinName(player.getName());
entry.setLastJoinName(player.getName());
@@ -145,203 +127,20 @@ public class TFM_PlayerList
public void purgeAll()
{
- final YamlConfiguration config = loadConfig();
-
// Clear the config entries
for (String key : config.getKeys(false))
{
config.set(key, null);
}
- // Save the config
- try
- {
- config.save(configFile);
- }
- catch (IOException ex)
- {
- TFM_Log.severe("Could not purge config file: " + ex.getMessage());
- TFM_Log.severe(ex);
- }
+ config.save();
// Load online players
load();
}
- private YamlConfiguration loadConfig()
- {
- final YamlConfiguration config = new YamlConfiguration();
- try
- {
- config.load(configFile);
- }
- catch (Exception ex)
- {
- TFM_Log.severe("Could not load player config file: " + ex.getMessage());
- TFM_Log.severe(ex);
- purgeAll();
- return null;
- }
- return config;
- }
-
- /*public String searchByPartialName(String needle)
- {
- needle = needle.toLowerCase().trim();
-
- Integer minEditDistance = null;
- String minEditMatch = null;
- Iterator it = playerList.keySet().iterator();
- while (it.hasNext())
- {
- String haystack = it.next();
- int editDistance = StringUtils.getLevenshteinDistance(needle, haystack.toLowerCase());
- if (minEditDistance == null || minEditDistance.intValue() > editDistance)
- {
- minEditDistance = editDistance;
- minEditMatch = haystack;
- }
- }
- return minEditMatch;
- }*/
public static TFM_PlayerList getInstance()
{
return INSTANCE;
}
-
- public final class PlayerEntry
- {
- private final UUID uuid;
- private String firstJoinName;
- private String lastJoinName;
- private long firstJoinUnix;
- private long lastJoinUnix;
- private final List ips;
-
- protected PlayerEntry(UUID uuid, ConfigurationSection section)
- {
- this(uuid);
-
- this.firstJoinName = section.getString("firstjoinname");
- this.lastJoinName = section.getString("lastjoinname");
-
- this.firstJoinUnix = section.getLong("firstjoinunix");
- this.firstJoinUnix = section.getLong("lastjoinunix");
-
- this.ips.addAll(section.getStringList("ips"));
- }
-
- protected PlayerEntry(UUID uuid)
- {
- this.uuid = uuid;
- this.ips = new ArrayList();
- }
-
- // Getters / Setters below
- public UUID getUniqueId()
- {
- return uuid;
- }
-
- public List getIps()
- {
- return Collections.unmodifiableList(ips);
- }
-
- public String getFirstJoinName()
- {
- return firstJoinName;
- }
-
- public void setFirstJoinName(String firstJoinName)
- {
- this.firstJoinName = firstJoinName;
- }
-
- public String getLastJoinName()
- {
- return lastJoinName;
- }
-
- public void setLastJoinName(String lastJoinName)
- {
- this.lastJoinName = lastJoinName;
- }
-
- public long getFirstJoinUnix()
- {
- return firstJoinUnix;
- }
-
- public void setFirstJoinUnix(long firstJoinUnix)
- {
- this.firstJoinUnix = firstJoinUnix;
- }
-
- public long getLastJoinUnix()
- {
- return lastJoinUnix;
- }
-
- public void setLastJoinUnix(long lastJoinUnix)
- {
- this.lastJoinUnix = lastJoinUnix;
- }
-
- public boolean addIp(String ip)
- {
- if (!ips.contains(ip))
- {
- ips.add(ip);
- return true;
- }
- return false;
- }
-
- private boolean isComplete()
- {
- return firstJoinName != null
- && lastJoinName != null
- && firstJoinUnix != 0
- && lastJoinUnix != 0
- && !ips.isEmpty();
- }
-
- public void save()
- {
- if (!isComplete())
- {
- throw new IllegalStateException("Entry is not complete");
- }
-
- final YamlConfiguration config = loadConfig();
- final ConfigurationSection section;
-
- if (config.isConfigurationSection(uuid.toString()))
- {
- section = config.getConfigurationSection(uuid.toString());
- }
- else
- {
- section = config.createSection(uuid.toString());
- }
-
- section.set("firstjoinname", firstJoinName);
- section.set("lastjoinname", lastJoinName);
- section.set("firstjoinunix", firstJoinUnix);
- section.set("lastjoinunix", lastJoinUnix);
- section.set("ips", ips);
-
- // Save config
- try
- {
- config.save(configFile);
- }
- catch (IOException ex)
- {
- TFM_Log.severe("Could not save player entry: " + uuid.toString() + " (" + lastJoinName + ")");
- TFM_Log.severe(ex);
- }
- }
- }
}
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerRank.java b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerRank.java
index cc037f9..c425183 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerRank.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerRank.java
@@ -27,28 +27,29 @@ public enum TFM_PlayerRank
public static String getLoginMessage(CommandSender sender)
{
+ // Handle console
if (!(sender instanceof Player))
{
return fromSender(sender).getLoginMessage();
}
- final TFM_Admin entry = TFM_AdminList.getAdminEntry((Player) sender);
-
+ // Handle admins
+ final TFM_Admin entry = TFM_AdminList.getEntry((Player) sender);
if (entry == null)
{
+ // Player is not an admin
return fromSender(sender).getLoginMessage();
}
+ // Custom login message
final String loginMessage = entry.getCustomLoginMessage();
- if (loginMessage != null && !loginMessage.isEmpty())
- {
- return ChatColor.translateAlternateColorCodes('&', loginMessage);
- }
- else
+ if (loginMessage == null || loginMessage.isEmpty())
{
return fromSender(sender).getLoginMessage();
}
+
+ return ChatColor.translateAlternateColorCodes('&', loginMessage);
}
public static TFM_PlayerRank fromSender(CommandSender sender)
@@ -58,7 +59,7 @@ public enum TFM_PlayerRank
return CONSOLE;
}
- if (sender instanceof Player && TFM_AdminList.isAdminImpostor((Player) sender))
+ if (TFM_AdminList.isAdminImpostor((Player) sender))
{
return IMPOSTOR;
}
@@ -69,7 +70,7 @@ public enum TFM_PlayerRank
}
- final TFM_Admin entry = TFM_AdminList.getAdminEntry((Player) sender);
+ final TFM_Admin entry = TFM_AdminList.getEntry((Player) sender);
final TFM_PlayerRank rank;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ProtectedArea.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ProtectedArea.java
index 85626ad..bc00184 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_ProtectedArea.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_ProtectedArea.java
@@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java
index 193e273..3237858 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java
@@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
@@ -172,7 +173,7 @@ public class TFM_ServerInterface
}
else
{
- isSuperadmin = TFM_AdminList.checkPartialSuperadminIP(ip, username.toLowerCase());
+ isSuperadmin = TFM_AdminList.checkPartialSuperadminIp(ip, username.toLowerCase());
}
// Validation below this point
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java
index e7eef83..2299f23 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java
@@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_TwitterHandler.java b/src/me/StevenLawson/TotalFreedomMod/TFM_TwitterHandler.java
index 5c5b7c5..6037c1b 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_TwitterHandler.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_TwitterHandler.java
@@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java
index 4b4114e..19a4354 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java
@@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.io.*;
import java.lang.reflect.Field;
import java.net.URL;
@@ -38,6 +39,7 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
+import org.bukkit.plugin.Plugin;
public class TFM_Util
{
@@ -322,19 +324,41 @@ public class TFM_Util
return TFM_Util.mobtypes.get(mobname);
}
- @Deprecated
- private static void copy(InputStream in, OutputStream out) throws IOException
+ /**
+ * Write the specified InputStream to a file.
+ *
+ * @param in The InputStream from which to read.
+ * @param file The File to write to.
+ * @throws IOException
+ */
+ public static void copy(InputStream in, File file) throws IOException // BukkitLib @ https://github.com/Pravian/BukkitLib
{
- byte[] buffer = new byte[1024];
- while (true)
+ if (!file.exists())
{
- int readCount = in.read(buffer);
- if (readCount < 0)
- {
- break;
- }
- out.write(buffer, 0, readCount);
+ file.getParentFile().mkdirs();
}
+
+ final OutputStream out = new FileOutputStream(file);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0)
+ {
+ out.write(buf, 0, len);
+ }
+ out.close();
+ in.close();
+ }
+
+ /**
+ * Returns a file at located at the Plugins Data folder.
+ *
+ * @param plugin The plugin to use
+ * @param name The name of the file.
+ * @return The requested file.
+ */
+ public static File getPluginFile(Plugin plugin, String name) // BukkitLib @ https://github.com/Pravian/BukkitLib
+ {
+ return new File(plugin.getDataFolder(), name);
}
public static boolean isStopCommand(String command)
diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java
index f38de5b..89d7017 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java
+++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java
@@ -1,5 +1,8 @@
package me.StevenLawson.TotalFreedomMod;
+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.IOException;
import java.io.InputStream;
@@ -168,7 +171,6 @@ public class TotalFreedomMod extends JavaPlugin
TFM_ServiceChecker.getInstance().start();
TFM_HTTPD_Manager.getInstance().start();
TFM_FrontDoor.getInstance().start();
- TFM_LogFile.getInstance().start();
TFM_Log.info("Version " + pluginVersion + " enabled");
@@ -265,7 +267,7 @@ public class TotalFreedomMod extends JavaPlugin
try
{
TFM_AdminList.backupSavedList();
- TFM_AdminList.loadSuperadminList();
+ TFM_AdminList.load();
}
catch (Exception ex)
{
diff --git a/src/me/StevenLawson/TotalFreedomMod/CleanroomBlockPopulator.java b/src/me/StevenLawson/TotalFreedomMod/World/CleanroomBlockPopulator.java
similarity index 94%
rename from src/me/StevenLawson/TotalFreedomMod/CleanroomBlockPopulator.java
rename to src/me/StevenLawson/TotalFreedomMod/World/CleanroomBlockPopulator.java
index e597b0a..2baeb6d 100644
--- a/src/me/StevenLawson/TotalFreedomMod/CleanroomBlockPopulator.java
+++ b/src/me/StevenLawson/TotalFreedomMod/World/CleanroomBlockPopulator.java
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.World;
import java.util.Random;
import org.bukkit.Chunk;
diff --git a/src/me/StevenLawson/TotalFreedomMod/CleanroomChunkGenerator.java b/src/me/StevenLawson/TotalFreedomMod/World/CleanroomChunkGenerator.java
similarity index 99%
rename from src/me/StevenLawson/TotalFreedomMod/CleanroomChunkGenerator.java
rename to src/me/StevenLawson/TotalFreedomMod/World/CleanroomChunkGenerator.java
index 4dd72c7..f2a801e 100644
--- a/src/me/StevenLawson/TotalFreedomMod/CleanroomChunkGenerator.java
+++ b/src/me/StevenLawson/TotalFreedomMod/World/CleanroomChunkGenerator.java
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.World;
import static java.lang.System.arraycopy;
import java.util.ArrayList;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_AdminWorld.java b/src/me/StevenLawson/TotalFreedomMod/World/TFM_AdminWorld.java
similarity index 96%
rename from src/me/StevenLawson/TotalFreedomMod/TFM_AdminWorld.java
rename to src/me/StevenLawson/TotalFreedomMod/World/TFM_AdminWorld.java
index 093c537..aba7b2f 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_AdminWorld.java
+++ b/src/me/StevenLawson/TotalFreedomMod/World/TFM_AdminWorld.java
@@ -1,11 +1,17 @@
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.World;
+import me.StevenLawson.TotalFreedomMod.World.TFM_CustomWorld;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
+import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
+import me.StevenLawson.TotalFreedomMod.TFM_Log;
+import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.*;
import org.bukkit.block.Block;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_CustomWorld.java b/src/me/StevenLawson/TotalFreedomMod/World/TFM_CustomWorld.java
similarity index 94%
rename from src/me/StevenLawson/TotalFreedomMod/TFM_CustomWorld.java
rename to src/me/StevenLawson/TotalFreedomMod/World/TFM_CustomWorld.java
index 770d921..1ad017a 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_CustomWorld.java
+++ b/src/me/StevenLawson/TotalFreedomMod/World/TFM_CustomWorld.java
@@ -1,4 +1,4 @@
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.World;
import org.bukkit.Bukkit;
import org.bukkit.World;
diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Flatlands.java b/src/me/StevenLawson/TotalFreedomMod/World/TFM_Flatlands.java
similarity index 89%
rename from src/me/StevenLawson/TotalFreedomMod/TFM_Flatlands.java
rename to src/me/StevenLawson/TotalFreedomMod/World/TFM_Flatlands.java
index 69d703d..d55b6eb 100644
--- a/src/me/StevenLawson/TotalFreedomMod/TFM_Flatlands.java
+++ b/src/me/StevenLawson/TotalFreedomMod/World/TFM_Flatlands.java
@@ -1,6 +1,11 @@
-package me.StevenLawson.TotalFreedomMod;
+package me.StevenLawson.TotalFreedomMod.World;
+import me.StevenLawson.TotalFreedomMod.World.TFM_CustomWorld;
+import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import java.io.File;
+import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
+import me.StevenLawson.TotalFreedomMod.TFM_Log;
+import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
diff --git a/src/superadmin.yml b/src/superadmin.yml
index 42d58c4..8e38fc1 100644
--- a/src/superadmin.yml
+++ b/src/superadmin.yml
@@ -4,13 +4,14 @@ clean_threshold_hours: 168
admins:
b3c3b05a-a52d-33a6-a9c6-6e5063e00f0a:
last_login_name: DarthSalamon
- - 127.0.0.1
- last_login: Fri, 9 Nov 2012 03:09:14 -0500
- custom_login_message: the &5Lead Executive Developer&b.
+ is_activated: true
is_senior_admin: true
is_telnet_admin: true
+ last_login: Fri, 9 Nov 2012 03:09:14 -0500
+ custom_login_message: the &5Lead Executive Developer&b.
+ ips:
+ - 127.0.0.1
console_aliases:
- darth
- is_activated: true
# Todo: Add mark and madgeek
\ No newline at end of file