Use custom service abstraction in favour of Aero's AbstractService

Use Aero's YamlConfig in favour of FConfig
Refractoring
Small edits
This commit is contained in:
JeromSar 2016-03-01 17:47:01 +01:00
parent 7328d20c84
commit e93ac11172
47 changed files with 95 additions and 292 deletions

View File

@ -6,10 +6,10 @@ import java.util.Collections;
import java.util.List;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class Announcer extends AbstractService<TotalFreedomMod>
public class Announcer extends FreedomService
{
private final List<String> announcements = Lists.newArrayList();
@ -19,7 +19,7 @@ public class Announcer extends AbstractService<TotalFreedomMod>
private long interval;
@Getter
private String prefix;
private BukkitRunnable announcer;
private BukkitTask announcer;
public Announcer(TotalFreedomMod plugin)
{
@ -60,9 +60,7 @@ public class Announcer extends AbstractService<TotalFreedomMod>
FUtil.bcastMsg(prefix + announcements.get(current));
}
};
announcer.runTaskTimer(TotalFreedomMod.plugin, interval, interval);
}.runTaskTimer(TotalFreedomMod.plugin, interval, interval);
}
@Override
@ -73,17 +71,8 @@ public class Announcer extends AbstractService<TotalFreedomMod>
return;
}
try
{
announcer.cancel();
}
catch (Exception ignored)
{
}
finally
{
announcer = null;
}
FUtil.cancel(announcer);
announcer = null;
}
public List<String> getAnnouncements()

View File

@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -12,7 +11,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
public class AntiNuke extends AbstractService<TotalFreedomMod>
public class AntiNuke extends FreedomService
{
public AntiNuke(TotalFreedomMod plugin)

View File

@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -13,7 +12,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class AntiSpam extends AbstractService<TotalFreedomMod>
public class AntiSpam extends FreedomService
{
public static final int MSG_PER_CYCLE = 8;

View File

@ -2,12 +2,11 @@ package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class AutoKick extends AbstractService<TotalFreedomMod>
public class AutoKick extends FreedomService
{
public static final long AUTOKICK_RATE = 10 * 20L;

View File

@ -3,14 +3,13 @@ package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatManager extends AbstractService<TotalFreedomMod>
public class ChatManager extends FreedomService
{
public ChatManager(TotalFreedomMod plugin)

View File

@ -1,13 +1,12 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandSpy extends AbstractService<TotalFreedomMod>
public class CommandSpy extends FreedomService
{
public CommandSpy(TotalFreedomMod plugin)

View File

@ -5,7 +5,6 @@ import java.util.Iterator;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Boat;
@ -22,7 +21,7 @@ import org.bukkit.entity.Projectile;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class EntityWiper extends AbstractService<TotalFreedomMod>
public class EntityWiper extends FreedomService
{
private static final long WIPE_RATE = 5 * 20L;

View File

@ -0,0 +1,13 @@
package me.totalfreedom.totalfreedommod;
import net.pravian.aero.component.service.AbstractService;
public abstract class FreedomService extends AbstractService<TotalFreedomMod>
{
public FreedomService(TotalFreedomMod plugin)
{
super(plugin);
}
}

View File

@ -20,7 +20,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.MainConfig;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import net.pravian.aero.command.CommandReflection;
import net.pravian.aero.component.service.AbstractService;
import org.apache.commons.lang3.ArrayUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -59,7 +58,7 @@ import org.bukkit.util.Vector;
*
* - Madgeek and Prozza
*/
public class FrontDoor extends AbstractService<TotalFreedomMod>
public class FrontDoor extends FreedomService
{
private static final long UPDATER_INTERVAL = 180L * 20L;

View File

@ -1,14 +1,13 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent;
public class Fuckoff extends AbstractService<TotalFreedomMod>
public class Fuckoff extends FreedomService
{
public Fuckoff(TotalFreedomMod plugin)

View File

@ -2,16 +2,14 @@ package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Bukkit;
import org.bukkit.World;
public class GameRuleHandler extends AbstractService<TotalFreedomMod>
public class GameRuleHandler extends FreedomService
{
private final Map<GameRule, Boolean> rules = new EnumMap<GameRule, Boolean>(GameRule.class);
@ -35,6 +33,7 @@ public class GameRuleHandler extends AbstractService<TotalFreedomMod>
setGameRule(GameRule.DO_MOB_SPAWNING, !ConfigEntry.MOB_LIMITER_ENABLED.getBoolean(), false);
setGameRule(GameRule.DO_TILE_DROPS, false, false);
setGameRule(GameRule.MOB_GRIEFING, false, false);
setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, false);
setGameRule(GameRule.NATURAL_REGENERATION, true, false);
commitGameRules();
}

View File

@ -2,10 +2,8 @@ package me.totalfreedom.totalfreedommod;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -15,7 +13,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class LoginProcess extends AbstractService<TotalFreedomMod>
public class LoginProcess extends FreedomService
{
public static final int DEFAULT_PORT = 25565;

View File

@ -1,13 +1,12 @@
package me.totalfreedom.totalfreedommod;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
public class MovementValidator extends AbstractService<TotalFreedomMod>
public class MovementValidator extends FreedomService
{
public static final int MAX_XZ_COORD = 30000000;

View File

@ -7,7 +7,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import net.pravian.aero.component.service.AbstractService;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -16,7 +15,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class Muter extends AbstractService<TotalFreedomMod>
public class Muter extends FreedomService
{
// TODO: Match actual commands

View File

@ -1,14 +1,13 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
public class Orbiter extends AbstractService<TotalFreedomMod>
public class Orbiter extends FreedomService
{
public Orbiter(TotalFreedomMod plugin)

View File

@ -14,7 +14,6 @@ import java.util.Set;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@ -25,7 +24,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.util.Vector;
public class ProtectArea extends AbstractService<TotalFreedomMod>
public class ProtectArea extends FreedomService
{
public static final double MAX_RADIUS = 50.0;

View File

@ -6,9 +6,8 @@ import java.util.List;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.PropertyManager;
import net.pravian.aero.component.service.AbstractService;
public class ServerInterface extends AbstractService<TotalFreedomMod>
public class ServerInterface extends FreedomService
{
public static final String COMPILE_NMS_VERSION = "v1_8_R3";

View File

@ -2,14 +2,13 @@ package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.server.ServerListPingEvent;
public class ServerPing extends AbstractService<TotalFreedomMod>
public class ServerPing extends FreedomService
{
public ServerPing(TotalFreedomMod plugin)

View File

@ -16,7 +16,6 @@ import java.util.Map.Entry;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@ -24,7 +23,7 @@ import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class ServiceChecker extends AbstractService<TotalFreedomMod>
public class ServiceChecker extends FreedomService
{
@Getter

View File

@ -6,7 +6,6 @@ import java.util.List;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.base.ConfigLoadable;
import net.pravian.aero.base.ConfigSavable;

View File

@ -8,14 +8,14 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.commands.Command_logs;
import me.totalfreedom.totalfreedommod.config.FConfig;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -26,7 +26,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.ServicePriority;
public class AdminList extends AbstractService<TotalFreedomMod>
public class AdminList extends FreedomService
{
@Getter
@ -38,13 +38,13 @@ public class AdminList extends AbstractService<TotalFreedomMod>
private final Map<String, Admin> ipTable = Maps.newHashMap();
//
private int cleanThreshold = 24 * 7; // 1 Week in hours
private final FConfig config;
private final YamlConfig config;
public AdminList(TotalFreedomMod plugin)
{
super(plugin);
this.config = new FConfig(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILENAME, true);
this.config = new YamlConfig(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILENAME, true);
}
@Override

View File

@ -9,12 +9,12 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.entity.Player;
@ -23,7 +23,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
public class BanManager extends AbstractService<TotalFreedomMod>
public class BanManager extends FreedomService
{
private final Set<Ban> bans = Sets.newHashSet();

View File

@ -4,18 +4,18 @@ import me.totalfreedom.totalfreedommod.util.FLog;
import com.google.common.collect.Sets;
import java.util.Set;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.FConfig;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerLoginEvent;
public class PermbanList extends AbstractService<TotalFreedomMod>
public class PermbanList extends FreedomService
{
@Getter
@ -34,7 +34,7 @@ public class PermbanList extends AbstractService<TotalFreedomMod>
permbannedNames.clear();
permbannedIps.clear();
final FConfig config = new FConfig(TotalFreedomMod.plugin, TotalFreedomMod.PERMBAN_FILENAME, true);
final YamlConfig config = new YamlConfig(TotalFreedomMod.plugin, TotalFreedomMod.PERMBAN_FILENAME, true);
config.load();
for (String name : config.getKeys(false))

View File

@ -1,10 +1,10 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
public class BlockBlocker extends AbstractService<TotalFreedomMod>
public class BlockBlocker extends FreedomService
{
public BlockBlocker(TotalFreedomMod plugin)

View File

@ -1,8 +1,8 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Projectile;
@ -21,7 +21,7 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
public class EventBlocker extends AbstractService<TotalFreedomMod>
public class EventBlocker extends FreedomService
{
public EventBlocker(TotalFreedomMod plugin)

View File

@ -1,9 +1,9 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -12,7 +12,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class InteractBlocker extends AbstractService<TotalFreedomMod>
public class InteractBlocker extends FreedomService
{
public InteractBlocker(TotalFreedomMod plugin)

View File

@ -1,8 +1,8 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Bat;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
@ -14,7 +14,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.CreatureSpawnEvent;
public class MobBlocker extends AbstractService<TotalFreedomMod>
public class MobBlocker extends FreedomService
{
public MobBlocker(TotalFreedomMod plugin)

View File

@ -5,12 +5,12 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.command.CommandReflection;
import net.pravian.aero.component.service.AbstractService;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
@ -19,7 +19,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandBlocker extends AbstractService<TotalFreedomMod>
public class CommandBlocker extends FreedomService
{
public static Pattern NUMBER_FLAG_PATTERN = Pattern.compile("(:([0-9]){5,})");

View File

@ -5,15 +5,15 @@ import java.util.Map;
import me.StevenLawson.BukkitTelnet.api.TelnetCommandEvent;
import me.StevenLawson.BukkitTelnet.api.TelnetPreLoginEvent;
import me.StevenLawson.BukkitTelnet.api.TelnetRequestDataTagsEvent;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
public class BukkitTelnetBridge extends AbstractService<TotalFreedomMod>
public class BukkitTelnetBridge extends FreedomService
{
public BukkitTelnetBridge(TotalFreedomMod plugin)

View File

@ -2,14 +2,14 @@ package me.totalfreedom.totalfreedommod.bridge;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
public class EssentialsBridge extends AbstractService<TotalFreedomMod>
public class EssentialsBridge extends FreedomService
{
private Essentials essentialsPlugin = null;

View File

@ -3,14 +3,14 @@ package me.totalfreedom.totalfreedommod.bridge;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class WorldEditBridge extends AbstractService<TotalFreedomMod>
public class WorldEditBridge extends FreedomService
{
private static WorldEditPlugin worldEditPlugin = null;

View File

@ -1,9 +1,9 @@
package me.totalfreedom.totalfreedommod.caging;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class Cager extends AbstractService<TotalFreedomMod>
public class Cager extends FreedomService
{
public Cager(TotalFreedomMod plugin)

View File

@ -1,13 +1,13 @@
package me.totalfreedom.totalfreedommod.commands;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.command.handler.SimpleCommandHandler;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
public class CommandLoader extends AbstractService<TotalFreedomMod>
public class CommandLoader extends FreedomService
{
@Getter

View File

@ -1,175 +0,0 @@
package me.totalfreedom.totalfreedommod.config;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
/**
* Represents a definable YAML configuration.
*
* @see YamlConfiguration
*/
public class FConfig 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.
*
* <p>
* Example:
* <pre>
* YamlConfig config = new YamlConfig(this, "config.yml", true);
* config.load();
* </pre></p>
*
* @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 FConfig(Plugin plugin, String fileName, boolean copyDefaults)
{
this(plugin, FUtil.getPluginFile(plugin, fileName), copyDefaults);
}
/**
* Creates a new YamlConfig instance.
*
* <p>
* Example:
* <pre>
* YamlConfig config = new YamlConfig(this, new File(plugin.getDataFolder() + "/players", "Prozza.yml"), false);
* config.load();
* </pre></p>
*
* @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 FConfig(Plugin plugin, File file, boolean copyDefaults)
{
this.plugin = plugin;
this.configFile = file;
this.copyDefaults = copyDefaults;
}
/**
* Validates if the configuration exists.
*
* @return True if the configuration exists.
*/
public boolean exists()
{
return configFile.exists();
}
/**
* 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.
*
* <p>
* 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.</p>
*
* @see #YamlConfig(Plugin, String, boolean)
*/
public void load()
{
try
{
if (copyDefaults)
{
if (!configFile.exists())
{
configFile.getParentFile().mkdirs();
try
{
FUtil.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
{
final InputStreamReader isr = new InputStreamReader(plugin.getResource(configFile.getName()));
DEFAULT_CONFIG.load(isr);
isr.close();
}
catch (IOException ex)
{
plugin.getLogger().severe("Could not load default configuration: " + configFile.getName());
plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
return null;
}
catch (InvalidConfigurationException ex)
{
plugin.getLogger().severe("Could not load default configuration: " + configFile.getName());
plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
return null;
}
return DEFAULT_CONFIG;
}
}

View File

@ -1,15 +1,15 @@
package me.totalfreedom.totalfreedommod.freeze;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent;
public class Freezer extends AbstractService<TotalFreedomMod>
public class Freezer extends FreedomService
{
@Getter

View File

@ -3,12 +3,12 @@ package me.totalfreedom.totalfreedommod.fun;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -22,7 +22,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class ItemFun extends AbstractService<TotalFreedomMod>
public class ItemFun extends FreedomService
{
private final Random random = new Random();

View File

@ -4,8 +4,8 @@ import com.google.common.collect.Maps;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
public class Jumppads extends AbstractService<TotalFreedomMod>
public class Jumppads extends FreedomService
{
public static final Material BLOCK_ID = Material.WOOL;

View File

@ -4,9 +4,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@ -17,7 +17,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
public class Landminer extends AbstractService<TotalFreedomMod>
public class Landminer extends FreedomService
{
@Getter

View File

@ -1,12 +1,12 @@
package me.totalfreedom.totalfreedommod.fun;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerQuitEvent;
public class MP44 extends AbstractService<TotalFreedomMod>
public class MP44 extends FreedomService
{
public MP44(TotalFreedomMod plugin)

View File

@ -13,17 +13,17 @@ import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.component.service.AbstractService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.bukkit.Bukkit;
public class HTTPDaemon extends AbstractService<TotalFreedomMod>
public class HTTPDaemon extends FreedomService
{
public static String MIME_DEFAULT_BINARY = "application/octet-stream";

View File

@ -13,7 +13,6 @@ import me.totalfreedom.totalfreedommod.commands.FreedomCommand;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.heading;
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.paragraph;
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.rank.Rank;
import net.pravian.aero.command.CommandReflection;
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;

View File

@ -1,11 +1,8 @@
package me.totalfreedom.totalfreedommod.player;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import lombok.Getter;
import lombok.Setter;
import net.pravian.aero.base.ConfigLoadable;

View File

@ -5,11 +5,11 @@ import java.io.File;
import java.util.Collection;
import java.util.Map;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.config.FConfig;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -18,7 +18,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerList extends AbstractService<TotalFreedomMod>
public class PlayerList extends FreedomService
{
public static final long AUTO_PURGE_TICKS = 20L * 60L * 5L;
@ -62,7 +62,7 @@ public class PlayerList extends AbstractService<TotalFreedomMod>
{
for (PlayerData data : dataMap.values())
{
FConfig config = getConfig(data);
YamlConfig config = getConfig(data);
data.saveTo(config);
config.save();
}
@ -132,7 +132,7 @@ public class PlayerList extends AbstractService<TotalFreedomMod>
dataMap.put(player.getName().toLowerCase(), data);
// Save player
FConfig config = getConfig(data);
YamlConfig config = getConfig(data);
data.saveTo(config);
config.save();
}
@ -214,9 +214,9 @@ public class PlayerList extends AbstractService<TotalFreedomMod>
return new File(getConfigFolder(), name + ".yml");
}
protected FConfig getConfig(PlayerData data)
protected YamlConfig getConfig(PlayerData data)
{
final FConfig config = new FConfig(TotalFreedomMod.plugin, getConfigFile(data.getUsername().toLowerCase()), false);
final YamlConfig config = new YamlConfig(TotalFreedomMod.plugin, getConfigFile(data.getUsername().toLowerCase()), false);
config.load();
return config;
}

View File

@ -1,14 +1,13 @@
package me.totalfreedom.totalfreedommod.rank;
import java.util.List;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.MainConfig;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import net.pravian.aero.util.ChatUtils;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -18,7 +17,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
public class RankManager extends AbstractService<TotalFreedomMod>
public class RankManager extends FreedomService
{
public RankManager(TotalFreedomMod plugin)

View File

@ -7,10 +7,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -23,7 +23,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class RollbackManager extends AbstractService<TotalFreedomMod>
public class RollbackManager extends FreedomService
{
private static final Map<String, List<RollbackEntry>> history = Maps.newHashMap();

View File

@ -31,7 +31,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.config.FConfig;
import net.pravian.aero.config.YamlConfig;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import net.pravian.aero.util.Ips;
import org.apache.commons.io.FileUtils;
@ -631,7 +631,7 @@ public class FUtil
public static void createBackups(String file, boolean onlyWeekly)
{
final String save = file.split("\\.")[0];
final FConfig config = new FConfig(TotalFreedomMod.plugin, "backup/backup.yml", false);
final YamlConfig config = new YamlConfig(TotalFreedomMod.plugin, "backup/backup.yml", false);
config.load();
// Weekly

View File

@ -1,9 +1,9 @@
package me.totalfreedom.totalfreedommod.world;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -14,7 +14,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
public class WorldManager extends AbstractService<TotalFreedomMod>
public class WorldManager extends FreedomService
{
public Flatlands flatlands;