From 7278176143da752a8912f53b706542f12a21ef06 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Tue, 24 Jul 2018 19:44:00 -0700 Subject: [PATCH] asdf (#91) --- pom.xml | 3 +- .../totalfreedommod/TotalFreedomMod.java | 27 ++++--- .../bridge/CoreProtectBridge.java | 32 +++++---- .../totalfreedommod/command/Command_cage.java | 3 +- .../command/Command_premium.java | 2 +- .../command/Command_restart.java | 2 +- .../command/Command_wipecoreprotectdata.java | 6 ++ .../command/Command_wipeflatlands.java | 6 +- .../command/Command_wipeuserdata.java | 1 - .../totalfreedommod/freeze/FreezeData.java | 8 ++- .../totalfreedommod/freeze/Freezer.java | 7 +- .../totalfreedommod/fun/ItemFun.java | 1 - .../totalfreedommod/player/FPlayer.java | 31 ++++++++ .../playerverification/VPlayer.java | 15 ++-- .../totalfreedommod/world/AdminWorld.java | 2 +- .../totalfreedommod/world/Flatlands.java | 5 ++ .../world/MasterBuilderWorld.java | 3 +- src/main/resources/admins.yml | 2 +- src/main/resources/bans.yml | 2 +- src/main/resources/config.yml | 2 +- src/main/resources/masterbuilders.yml | 2 +- src/main/resources/permbans.yml | 2 +- src/main/resources/punishments.yml | 2 +- totalfreedom.iml | 71 +++++++++++++++++++ 24 files changed, 184 insertions(+), 53 deletions(-) create mode 100644 totalfreedom.iml diff --git a/pom.xml b/pom.xml index b380820b..37fdb568 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ scm:git:git@github.com:TFPatches/TotalFreedomMod.git scm:git:git@github.com:TFPatches/TotalFreedomMod.git - git@github.com:TotalFreedom/TFPatches.git + git@github.com:TFPatches/TotalFreedomMod.git @@ -151,6 +151,7 @@ net.dv8tion JDA 3.7.1_385 + provided diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 24386f7e..51e42d16 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -286,28 +286,39 @@ public class TotalFreedomMod extends AeroPlugin try { final Properties props; - final Properties gitprops; + try (InputStream in = plugin.getResource("build.properties")) { props = new Properties(); props.load(in); } - try (InputStream in = plugin.getResource("git.properties")) - { - gitprops = new Properties(); - gitprops.load(in); - } author = props.getProperty("buildAuthor", "unknown"); codename = props.getProperty("buildCodeName", "unknown"); version = props.getProperty("buildVersion", pluginVersion); number = props.getProperty("buildNumber", "1"); - date = gitprops.getProperty("git.build.time", "unknown"); + date = props.getProperty("buildDate", "unknown"); + } + catch (Exception ex) + { + FLog.severe("Could not load build properties! Did you compile with NetBeans/Maven?"); + FLog.severe(ex); + } + try + { + final Properties gitprops; + + try (InputStream in = plugin.getResource("git.properties")) + { + gitprops = new Properties(); + gitprops.load(in); + } + head = gitprops.getProperty("git.commit.id.abbrev", "unknown"); } catch (Exception ex) { - FLog.severe("Could not load build properties! Did you compile with Netbeans/Maven?"); + FLog.severe("Could not load Git properties! Is there a valid .git directory?"); FLog.severe(ex); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java index 53694f74..fa558edd 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java @@ -23,9 +23,9 @@ import java.util.List; public class CoreProtectBridge extends FreedomService { private CoreProtectAPI coreProtectAPI = null; - + private final List tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block"); - + private BukkitTask wiper; public CoreProtectBridge(TotalFreedomMod plugin) @@ -56,7 +56,7 @@ public class CoreProtectBridge extends FreedomService if (coreProtectPlugin != null && coreProtectPlugin instanceof CoreProtect) { - coreProtect = (CoreProtect)coreProtectPlugin; + coreProtect = (CoreProtect) coreProtectPlugin; } } catch (Exception ex) @@ -73,9 +73,9 @@ public class CoreProtectBridge extends FreedomService try { final CoreProtect coreProtect = getCoreProtect(); - + coreProtectAPI = coreProtect.getAPI(); - + // Check if the plugin or api is not enabled, if so, return null if (!coreProtect.isEnabled() || !coreProtectAPI.isEnabled()) { @@ -90,7 +90,7 @@ public class CoreProtectBridge extends FreedomService return coreProtectAPI; } - + public boolean isEnabled() { final CoreProtect coreProtect = getCoreProtect(); @@ -117,7 +117,7 @@ public class CoreProtectBridge extends FreedomService } }.runTaskAsynchronously(plugin); } - + // Reverts a rollback for the specifed player's edits that were in the last 24 hours. public void undoRollback(final String name) { @@ -137,7 +137,7 @@ public class CoreProtectBridge extends FreedomService } }.runTaskAsynchronously(plugin); } - + public File getDatabase() { if (!isEnabled()) @@ -145,9 +145,9 @@ public class CoreProtectBridge extends FreedomService return null; } - return(new File(getCoreProtect().getDataFolder(), "database.db")); + return (new File(getCoreProtect().getDataFolder(), "database.db")); } - + private void createAutomaticWiper() { final long interval = 10 * 20L; @@ -165,15 +165,15 @@ public class CoreProtectBridge extends FreedomService FUtil.bcastMsg("The CoreProtect log file has grown too big for the server to cope, the data is being wiped!", ChatColor.RED); PluginManager pluginManager = server.getPluginManager(); pluginManager.disablePlugin(coreProtect); - for(World world : Bukkit.getWorlds()) + for (World world : Bukkit.getWorlds()) { - if(!world.equals(plugin.wm.adminworld.getWorld())) + if (!world.equals(plugin.wm.adminworld.getWorld())) { clearDatabase(world); } } //check if still too big, if so delete all data - if(getDBSize() > ConfigEntry.COREPROTECT_FILE_LIMIT.getInteger()) + if (getDBSize() > ConfigEntry.COREPROTECT_FILE_LIMIT.getInteger()) { FUtil.deleteFolder(databaseFile); } @@ -182,6 +182,7 @@ public class CoreProtectBridge extends FreedomService } }.runTaskTimer(plugin, interval, interval); } + public double getDBSize() { double bytes = getDatabase().length(); @@ -189,6 +190,7 @@ public class CoreProtectBridge extends FreedomService double megabytes = (kilobytes / 1024); return (megabytes / 1024); } + // Wipes DB for the specified world public void clearDatabase(World world) { @@ -214,7 +216,7 @@ public class CoreProtectBridge extends FreedomService connection = DriverManager.getConnection("jdbc:sqlite:" + databaseFile); final Statement statement = connection.createStatement(); statement.setQueryTimeout(30); - + // Obtain world ID from CoreProtect database ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'"); String worldID = null; @@ -250,7 +252,7 @@ public class CoreProtectBridge extends FreedomService // This exits for flatlands wipes if (shutdown) { - if(plugin.amp.enabled) + if (plugin.amp.enabled) { plugin.amp.restartServer(); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java index a66a9bba..f3205482 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java @@ -85,6 +85,7 @@ public class Command_cage extends FreedomCommand } } } + Location location = player.getLocation().clone().add(0.0, 1.0, 0.0); if (skullName != null) { @@ -95,7 +96,7 @@ public class Command_cage extends FreedomCommand fPlayer.getCageData().cage(location, outerMaterial, innerMaterial); } player.setGameMode(GameMode.SURVIVAL); - if (outerMaterial == Material.PLAYER_HEAD) + { FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_premium.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_premium.java index f2c68025..52ee3a93 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_premium.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_premium.java @@ -71,7 +71,7 @@ public class Command_premium extends FreedomCommand catch (Exception ex) { FLog.severe(ex); - msg("There was an error querying the mojang server.", ChatColor.RED); + msg("There was an error querying the Mojang server.", ChatColor.RED); } } }.runTaskAsynchronously(plugin); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_restart.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_restart.java index 87b03b2d..638a1727 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_restart.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_restart.java @@ -15,7 +15,7 @@ public class Command_restart extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if(!plugin.amp.enabled) + if (!plugin.amp.enabled) { msg(ChatColor.RED + "AMP integration is not enabled. Please use /stop instead."); return true; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipecoreprotectdata.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipecoreprotectdata.java index 779a4e5c..f9c1850a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipecoreprotectdata.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipecoreprotectdata.java @@ -15,6 +15,12 @@ public class Command_wipecoreprotectdata extends FreedomCommand @Override public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (!plugin.cpb.isEnabled()) + { + msg("CoreProtect is not enabled on this server"); + return true; + } + FUtil.adminAction(sender.getName(), "Wiping CoreProtect data for the flatlands", true); new BukkitRunnable() diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java index 95a90bef..f507fe5b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java @@ -6,7 +6,6 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; @CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true) @CommandParameters(description = "Wipe the flatlands map. Requires manual restart after command is used.", usage = "/") @@ -20,7 +19,10 @@ public class Command_wipeflatlands extends FreedomCommand FUtil.bcastMsg("Server is going offline for flatlands wipe.", ChatColor.GRAY); - plugin.wgb.wipeRegions(plugin.wm.flatlands.getWorld()); + if (plugin.wgb.isPluginEnabled()) + { + plugin.wgb.wipeRegions(plugin.wm.flatlands.getWorld()); + } for (Player player : server.getOnlinePlayers()) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeuserdata.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeuserdata.java index 75604d70..3df058ee 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeuserdata.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeuserdata.java @@ -38,7 +38,6 @@ public class Command_wipeuserdata extends FreedomCommand FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "stats")); FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(w.getName()).getWorldFolder().getName() + "stats")); FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(w.getName()).getWorldFolder().getName() + "playerdata")); - msg("All playerdata deleted."); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java b/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java index 2c8067f7..21768e7a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java @@ -3,6 +3,8 @@ package me.totalfreedom.totalfreedommod.freeze; import lombok.Getter; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.player.FPlayer; + +import static me.totalfreedom.totalfreedommod.TotalFreedomMod.plugin; import static me.totalfreedom.totalfreedommod.player.FPlayer.AUTO_PURGE_TICKS; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -36,7 +38,7 @@ public class FreezeData final Player player = fPlayer.getPlayer(); if (player == null) { - FLog.info("Could not freeze " + fPlayer.getName() + ". Player not online!"); + FLog.info("Could not freeze " + player.getName() + ". Player not online!"); return; } @@ -62,14 +64,14 @@ public class FreezeData @Override public void run() { - if (!fPlayer.getPlugin().al.isAdminImpostor(player) && !fPlayer.getPlugin().pv.isPlayerImpostor(player)) + if (!plugin().al.isAdminImpostor(player) && plugin().pv.isPlayerImpostor(player)) { FUtil.adminAction("TotalFreedom", "Unfreezing " + player.getName(), false); setFrozen(false); } } - }.runTaskLater(fPlayer.getPlugin(), AUTO_PURGE_TICKS); + }.runTaskLater(plugin(), AUTO_PURGE_TICKS); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java b/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java index de5e5596..e0fd75d7 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java @@ -32,6 +32,11 @@ public class Freezer extends FreedomService { } + public boolean isGlobalFreeze() + { + return this.globalFreeze; + } + public void setGlobalFreeze(boolean frozen) { this.globalFreeze = frozen; @@ -65,7 +70,7 @@ public class Freezer extends FreedomService FUtil.setFlying(player, true); - Location loc = fd.getLocation(); + Location loc = player.getLocation(); if (loc == null) { loc = event.getFrom(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java index 31c26ba7..add5bd3a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java @@ -56,7 +56,6 @@ public class ItemFun extends FreedomService switch (event.getMaterial()) { - case TROPICAL_FISH: { final int RADIUS_HIT = 5; final int STRENGTH = 4; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java index 7da0a34a..16b2da6d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java @@ -141,6 +141,31 @@ public class FPlayer this.invSee = toggle; } + public boolean isEditBlocked() + { + return editBlocked; + } + + public void setEditBlocked(boolean toggle) + { + this.editBlocked = toggle; + } + + public boolean isPvpBlocked() + { + return pvpBlocked; + } + + public CageData getCageData() + { + return cageData; + } + + public void setPvpBlocked(boolean toggle) + { + this.pvpBlocked = toggle; + } + public boolean isFuckOff() { return fuckoffRadius > 0; @@ -353,6 +378,12 @@ public class FPlayer this.inAdminchat = inAdminchat; } + public FreezeData getFreezeData() + { + return freezeData; + } + + public boolean inAdminChat() { return this.inAdminchat; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/playerverification/VPlayer.java b/src/main/java/me/totalfreedom/totalfreedommod/playerverification/VPlayer.java index 7787f12f..327244bc 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/playerverification/VPlayer.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/playerverification/VPlayer.java @@ -82,20 +82,15 @@ public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable return ips.remove(ip); } + public void setDiscordId(final String discordId) + { + this.discordId = discordId; + } + @Override public boolean isValid() { return name != null && !ips.isEmpty(); } - - public boolean getForumEnabled() - { - return this.forumEnabled; - } - - public boolean getDiscordEnabled() - { - return this.discordEnabled; - } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java b/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java index a396a075..9c7d5800 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java @@ -56,7 +56,7 @@ public final class AdminWorld extends CustomWorld @Override protected World generateWorld() { - final WorldCreator worldCreator = new WorldCreator(getName()); + final WorldCreator worldCreator = new WorldCreator(WORLD_NAME); worldCreator.generateStructures(false); worldCreator.type(WorldType.NORMAL); worldCreator.environment(World.Environment.NORMAL); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java b/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java index d151a671..f3cde1bc 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java @@ -23,6 +23,7 @@ public class Flatlands extends CustomWorld { super("flatlands"); } + private static final String WORLD_NAME = "flatlands"; @Override protected World generateWorld() @@ -89,4 +90,8 @@ public class Flatlands extends CustomWorld } } + public String getName() + { + return this.WORLD_NAME; + } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java b/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java index 668861bd..7e18565a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java @@ -28,6 +28,7 @@ public final class MasterBuilderWorld extends CustomWorld // private WorldWeather weather = WorldWeather.OFF; private WorldTime time = WorldTime.INHERIT; + private static final String WORLD_NAME = "masterbuilderworld"; public MasterBuilderWorld() { @@ -43,7 +44,7 @@ public final class MasterBuilderWorld extends CustomWorld @Override protected World generateWorld() { - final WorldCreator worldCreator = new WorldCreator(getName()); + final WorldCreator worldCreator = new WorldCreator(WORLD_NAME); worldCreator.generateStructures(false); worldCreator.type(WorldType.NORMAL); worldCreator.environment(World.Environment.NORMAL); diff --git a/src/main/resources/admins.yml b/src/main/resources/admins.yml index 97028811..2957e245 100644 --- a/src/main/resources/admins.yml +++ b/src/main/resources/admins.yml @@ -1,5 +1,5 @@ # -# TotalFreedomMod 5.0 Admin List +# TotalFreedomMod 5.2 Admin List # prozza: diff --git a/src/main/resources/bans.yml b/src/main/resources/bans.yml index cea37ead..63c8af98 100644 --- a/src/main/resources/bans.yml +++ b/src/main/resources/bans.yml @@ -1,3 +1,3 @@ # -# TotalFreedomMod 5.0 Player Bans +# TotalFreedomMod 5.2 Player Bans # diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 477fac5e..1abb13e5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ # -# TotalFreedomMod 5.0 Configuration +# TotalFreedomMod 5.2 Configuration # by Madgeek1450 and Prozza # diff --git a/src/main/resources/masterbuilders.yml b/src/main/resources/masterbuilders.yml index 786cb3c3..fb615f2c 100644 --- a/src/main/resources/masterbuilders.yml +++ b/src/main/resources/masterbuilders.yml @@ -1,3 +1,3 @@ # -# TotalFreedomMod 5.0 Master Builder List +# TotalFreedomMod 5.2 Master Builder List # diff --git a/src/main/resources/permbans.yml b/src/main/resources/permbans.yml index 012f8d58..b6421acf 100644 --- a/src/main/resources/permbans.yml +++ b/src/main/resources/permbans.yml @@ -1,5 +1,5 @@ # -# TotalFreedomMod 5.0 Permanent Bans +# TotalFreedomMod 5.2 Permanent Bans # badplayer1: diff --git a/src/main/resources/punishments.yml b/src/main/resources/punishments.yml index ec2d40c0..29ae71ef 100644 --- a/src/main/resources/punishments.yml +++ b/src/main/resources/punishments.yml @@ -1,3 +1,3 @@ # -# TotalFreedomMod 5.0 Player Punishments +# TotalFreedomMod 5.2 Player Punishments # diff --git a/totalfreedom.iml b/totalfreedom.iml new file mode 100644 index 00000000..4644f95a --- /dev/null +++ b/totalfreedom.iml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file