From 7b7f09e45711cec00745db1d889e775486f8429a Mon Sep 17 00:00:00 2001
From: Seth <13510767+ZeroEpoch1969@users.noreply.github.com>
Date: Thu, 9 Jul 2020 17:07:03 -0700
Subject: [PATCH] 1.16 Update (#219)
---
.gitignore | 8 +-
.idea/artifacts/TotalFreedomMod_jar.xml | 8 -
.idea/compiler.xml | 1 -
.idea/encodings.xml | 2 +-
.idea/misc.xml | 11 +
.idea/modules.xml | 8 -
.idea/vcs.xml | 6 +
TotalFreedomMod.iml | 165 --------
pom.xml | 47 ++-
.../totalfreedommod/Announcer.java | 9 +-
.../totalfreedommod/AntiNuke.java | 11 +-
.../totalfreedommod/AntiSpam.java | 16 +-
.../totalfreedommod/AutoEject.java | 12 +-
.../totalfreedommod/AutoKick.java | 9 +-
.../totalfreedommod/BackupManager.java | 17 +-
.../totalfreedommod/ChatManager.java | 37 +-
.../totalfreedommod/CommandSpy.java | 11 +-
.../totalfreedommod/EntityWiper.java | 9 +-
.../totalfreedommod/FreedomService.java | 19 +-
.../FreedomServiceHandler.java | 26 ++
.../totalfreedom/totalfreedommod/Fuckoff.java | 11 +-
.../totalfreedommod/GameRuleHandler.java | 8 +-
.../totalfreedommod/LogViewer.java | 10 +-
.../totalfreedommod/LoginProcess.java | 60 ++-
.../totalfreedommod/Monitors.java | 9 +-
.../totalfreedommod/MovementValidator.java | 20 +-
.../totalfreedom/totalfreedommod/Muter.java | 15 +-
.../totalfreedom/totalfreedommod/Orbiter.java | 10 +-
.../totalfreedommod/ProtectArea.java | 9 +-
.../totalfreedommod/SavedFlags.java | 10 +-
.../totalfreedommod/ServerInterface.java | 18 +-
.../totalfreedommod/ServerPing.java | 10 +-
.../totalfreedommod/TotalFreedomMod.java | 206 +++++-----
.../totalfreedommod/admin/ActivityLog.java | 17 +-
.../admin/ActivityLogEntry.java | 6 +-
.../totalfreedommod/admin/Admin.java | 81 ++--
.../totalfreedommod/admin/AdminList.java | 68 +---
.../totalfreedommod/banning/Ban.java | 23 +-
.../totalfreedommod/banning/BanManager.java | 48 ++-
.../totalfreedommod/banning/PermbanList.java | 15 +-
.../blocking/BlockBlocker.java | 32 +-
.../totalfreedommod/blocking/EditBlocker.java | 11 +-
.../blocking/EventBlocker.java | 42 +-
.../blocking/InteractBlocker.java | 29 +-
.../totalfreedommod/blocking/MobBlocker.java | 12 +-
.../totalfreedommod/blocking/PVPBlocker.java | 13 +-
.../blocking/PotionBlocker.java | 10 +-
.../totalfreedommod/blocking/SignBlocker.java | 28 +-
.../blocking/command/CommandBlocker.java | 52 +--
.../bridge/BukkitTelnetBridge.java | 10 +-
.../bridge/CoreProtectBridge.java | 10 +-
.../bridge/EssentialsBridge.java | 10 +-
.../bridge/LibsDisguisesBridge.java | 14 +-
.../bridge/WorldEditBridge.java | 10 +-
.../bridge/WorldGuardBridge.java | 11 +-
.../totalfreedommod/caging/Cager.java | 11 +-
.../command/CommandLoader.java | 62 +--
.../command/Command_adminworld.java | 1 -
.../command/Command_announce.java | 2 +-
.../totalfreedommod/command/Command_ban.java | 7 +-
.../totalfreedommod/command/Command_bird.java | 2 +-
.../totalfreedommod/command/Command_cage.java | 8 -
.../command/Command_clearchat.java | 51 +--
.../command/Command_clearinventory.java | 2 +-
.../command/Command_clownfish.java | 29 ++
.../command/Command_coins.java | 10 +-
.../command/Command_consolesay.java | 2 -
.../totalfreedommod/command/Command_cuck.java | 54 ---
.../command/Command_curse.java | 2 +-
.../command/Command_disguisetoggle.java | 5 +-
.../command/Command_donator.java | 87 +++++
.../totalfreedommod/command/Command_doom.java | 6 +-
.../command/Command_enchant.java | 1 -
.../command/Command_explode.java | 29 +-
.../command/Command_fireball.java | 2 +-
.../command/Command_gadmin.java | 211 ----------
.../command/Command_glist.java | 24 +-
.../totalfreedommod/command/Command_glow.java | 32 ++
.../command/Command_grapplinghook.java | 2 +-
.../command/Command_jumppads.java | 6 -
.../totalfreedommod/command/Command_kick.java | 5 +-
.../command/Command_lightningrod.java | 2 +-
.../command/Command_linkdiscord.java | 79 ++--
.../command/Command_links.java | 2 +-
.../totalfreedommod/command/Command_list.java | 3 +-
.../command/Command_manageshop.java | 64 +--
.../command/Command_manuallyverify.java | 57 +++
.../command/Command_massmurder.java | 42 ++
.../command/Command_masterbuilderworld.java | 1 -
.../command/Command_mbconfig.java | 213 +++-------
.../command/Command_modifyitem.java | 9 +-
.../totalfreedommod/command/Command_mute.java | 3 +-
.../command/Command_myadmin.java | 58 +--
.../command/Command_mymasterbuilder.java | 237 -----------
.../command/Command_nickclean.java | 48 ++-
.../command/Command_notes.java | 34 +-
.../command/Command_opall.java | 1 -
.../command/Command_permban.java | 4 +-
...y.java => Command_playerverification.java} | 61 +--
.../command/Command_premium.java | 6 +-
.../command/Command_reactionbar.java | 13 +-
.../command/Command_realtime.java | 64 ---
.../totalfreedommod/command/Command_ride.java | 22 +-
.../command/Command_rideablepearl.java | 2 +-
...ommand_campfire.java => Command_rock.java} | 19 +-
.../command/Command_saconfig.java | 132 ++-----
.../command/Command_serverstats.java | 4 +-
.../totalfreedommod/command/Command_shop.java | 4 +-
.../command/Command_smite.java | 3 +-
.../command/Command_spawnmob.java | 4 +-
.../command/Command_stackingpotato.java | 29 ++
.../totalfreedommod/command/Command_stop.java | 41 +-
.../totalfreedommod/command/Command_tag.java | 37 +-
.../totalfreedommod/command/Command_tban.java | 8 +-
.../command/Command_tempban.java | 5 +-
.../command/Command_toggle.java | 8 +-
.../command/Command_totalfreedommod.java | 8 +-
.../command/Command_trail.java | 18 +-
.../command/Command_unban.java | 2 +-
.../command/Command_uncage.java | 47 +++
.../command/Command_undisguiseall.java | 7 -
.../command/Command_unlinkdiscord.java | 39 +-
.../command/Command_unmute.java | 36 +-
.../command/Command_vanish.java | 22 +-
.../command/Command_verify.java | 293 +++-----------
.../command/Command_verifynoadmin.java | 4 +-
.../totalfreedommod/command/Command_warn.java | 2 +-
.../command/Command_wildcard.java | 28 +-
.../command/Command_wipeflatlands.java | 1 -
.../command/FreedomCommand.java | 332 +++++++++++-----
.../command/FreedomCommandExecutor.java | 221 -----------
.../totalfreedommod/config/ConfigEntry.java | 10 +-
.../totalfreedommod/config/IConfig.java | 10 +
.../totalfreedommod/config/MainConfig.java | 18 +-
.../totalfreedommod/config/YamlConfig.java | 67 ++++
.../totalfreedommod/discord/Discord.java | 156 ++------
.../discord/PrivateMessageListener.java | 35 +-
.../totalfreedommod/freeze/FreezeData.java | 2 +-
.../totalfreedommod/freeze/Freezer.java | 10 +-
.../totalfreedommod/fun/CurseListener.java | 11 +-
.../totalfreedommod/fun/ItemFun.java | 333 ++++++++--------
.../totalfreedommod/fun/Jumppads.java | 6 -
.../totalfreedommod/fun/Landminer.java | 10 +-
.../totalfreedommod/fun/MP44.java | 11 +-
.../totalfreedommod/fun/MobStacker.java | 53 ---
.../totalfreedommod/fun/RealTimer.java | 71 ----
.../totalfreedommod/fun/Trailer.java | 15 +-
.../totalfreedommod/httpd/HTTPDaemon.java | 6 -
.../httpd/module/HTTPDModule.java | 15 +-
.../httpd/module/Module_admins.java | 2 -
.../httpd/module/Module_bans.java | 3 -
.../httpd/module/Module_help.java | 3 +-
.../httpd/module/Module_list.java | 4 +-
.../httpd/module/Module_logs.java | 2 +-
.../httpd/module/Module_players.java | 7 +-
.../httpd/module/Module_schematic.java | 6 +-
.../masterbuilder/MasterBuilder.java | 188 ---------
.../masterbuilder/MasterBuilderList.java | 295 --------------
.../permissions/PermissionConfig.java | 18 +-
.../permissions/PermissionManager.java | 16 +-
.../totalfreedommod/player/FPlayer.java | 5 +-
.../totalfreedommod/player/PlayerData.java | 257 +++++++++---
.../totalfreedommod/player/PlayerList.java | 368 +++++++++++-------
.../PlayerVerification.java | 203 ----------
.../playerverification/VPlayer.java | 166 --------
.../punishments/Punishment.java | 6 +-
.../punishments/PunishmentList.java | 10 +-
.../totalfreedommod/rank/Displayable.java | 5 +-
.../totalfreedommod/rank/Rank.java | 25 +-
.../totalfreedommod/rank/RankManager.java | 101 ++---
.../totalfreedommod/rank/Title.java | 22 +-
.../totalfreedommod/shop/Shop.java | 338 ++++++----------
.../totalfreedommod/shop/ShopData.java | 107 -----
.../totalfreedommod/shop/ShopItem.java | 19 +-
.../totalfreedommod/shop/Votifier.java | 56 +++
.../totalfreedommod/sql/SQLite.java | 177 +++++++--
.../totalfreedommod/util/FLog.java | 4 -
.../totalfreedommod/util/FUtil.java | 59 ++-
.../totalfreedommod/util/Groups.java | 36 +-
.../totalfreedommod/world/CustomWorld.java | 15 +-
.../totalfreedommod/world/WorldManager.java | 9 +-
.../world/WorldRestrictions.java | 16 +-
src/main/java/org/bstats/Metrics.java | 1 -
src/main/resources/admins.yml | 31 --
src/main/resources/backup/backup.yml | 0
src/main/resources/bans.yml | 3 -
src/main/resources/config.yml | 25 +-
src/main/resources/masterbuilders.yml | 3 -
src/main/resources/plugin.yml | 1 -
189 files changed, 2912 insertions(+), 4951 deletions(-)
delete mode 100644 .idea/artifacts/TotalFreedomMod_jar.xml
create mode 100644 .idea/misc.xml
delete mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
delete mode 100644 TotalFreedomMod.iml
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/FreedomServiceHandler.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_cuck.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_donator.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_gadmin.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_manuallyverify.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_massmurder.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_mymasterbuilder.java
rename src/main/java/me/totalfreedom/totalfreedommod/command/{Command_playerverify.java => Command_playerverification.java} (69%)
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_realtime.java
rename src/main/java/me/totalfreedom/totalfreedommod/command/{Command_campfire.java => Command_rock.java} (60%)
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommandExecutor.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/config/IConfig.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/fun/RealTimer.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/masterbuilder/MasterBuilder.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/masterbuilder/MasterBuilderList.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/playerverification/PlayerVerification.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/playerverification/VPlayer.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/shop/ShopData.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/shop/Votifier.java
delete mode 100644 src/main/resources/admins.yml
create mode 100644 src/main/resources/backup/backup.yml
delete mode 100644 src/main/resources/bans.yml
delete mode 100644 src/main/resources/masterbuilders.yml
diff --git a/.gitignore b/.gitignore
index b63d0ccc..c2ccd287 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,7 +19,11 @@ manifest.mf
# IntelliJ excludes
*.ipr
*.iws
-/.idea
+/.idea/modules.xml
+/.idea/discord.xml
+/.idea/jarRepositories.xml
+/.idea/workspace.xml
+/.idea/libraries
*.iml
# Maven excludes
@@ -32,5 +36,3 @@ manifest.mf
.Trashes
ehthumbs.db
Thumbs.db
-
-TotalFreedomMod\.iml
diff --git a/.idea/artifacts/TotalFreedomMod_jar.xml b/.idea/artifacts/TotalFreedomMod_jar.xml
deleted file mode 100644
index 483f1042..00000000
--- a/.idea/artifacts/TotalFreedomMod_jar.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- $PROJECT_DIR$/target
-
-
-
-
-
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 8ceb59f3..58d3e434 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -11,7 +11,6 @@
-
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index af673e73..0400b665 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -1,8 +1,8 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..43612005
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index bf19ff78..00000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TotalFreedomMod.iml b/TotalFreedomMod.iml
deleted file mode 100644
index c84a53a3..00000000
--- a/TotalFreedomMod.iml
+++ /dev/null
@@ -1,165 +0,0 @@
-
-
-
-
-
-
- PAPER
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index ed03305a..774a145b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,11 +90,6 @@
http://maven.sk89q.com/repo/
-
- CodeMC
- https://repo.codemc.org/repository/maven-public
-
-
papermc
https://papermc.io/repo/repository/maven-public/
@@ -138,14 +133,7 @@
org.spigotmc
spigot
- 1.15-R0.1-SNAPSHOT
- provided
-
-
-
- com.github.Pravian
- Aero
- 5f82926
+ 1.16.1-R0.1-SNAPSHOT
provided
@@ -159,8 +147,7 @@
com.github.TFPatches
TF-LibsDisguises
- 11aea9b3cd
- provided
+ 0cfa32159a
@@ -201,7 +188,7 @@
com.destroystokyo.paper
paper-api
- 1.15.1-R0.1-SNAPSHOT
+ 1.16.1-R0.1-SNAPSHOT
provided
@@ -219,9 +206,9 @@
- com.github.ConnorLinfoot
- ActionBarAPI
- 5b2d642d3d
+ org.bukkit
+ bukkit
+ 1.16.1-R0.1-SNAPSHOT
provided
@@ -232,6 +219,24 @@
provided
+
+ org.reflections
+ reflections
+ 0.9.11
+
+
+
+ javassist
+ javassist
+ 3.12.1.GA
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.10
+
+
@@ -376,7 +381,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 2.4.3
+ 3.2.4
package
@@ -390,6 +395,8 @@
commons-io:commons-io
org.apache.commons:commons-lang3
commons-codec:commons-codec
+ org.reflections:reflections
+ javassist:javassist
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java b/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java
index 62a32038..2fd04e50 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java
@@ -21,13 +21,8 @@ public class Announcer extends FreedomService
private String prefix;
private BukkitTask announcer;
- public Announcer(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
@@ -64,7 +59,7 @@ public class Announcer extends FreedomService
}
@Override
- protected void onStop()
+ public void onStop()
{
if (announcer == null)
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java b/src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java
index a25334d9..444368d0 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java
@@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
-import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -13,19 +12,13 @@ import org.bukkit.event.block.BlockPlaceEvent;
public class AntiNuke extends FreedomService
{
-
- public AntiNuke(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java b/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java
index 2fe8b7f0..54764e87 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java
@@ -1,5 +1,7 @@
package me.totalfreedom.totalfreedommod;
+import java.util.ArrayList;
+import java.util.List;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
@@ -10,13 +12,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerKickEvent;
-import org.bukkit.event.player.PlayerLoginEvent;
-import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
public class AntiSpam extends FreedomService
{
@@ -27,13 +24,8 @@ public class AntiSpam extends FreedomService
//
public BukkitTask cycleTask = null;
- public AntiSpam(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
new BukkitRunnable()
{
@@ -47,7 +39,7 @@ public class AntiSpam extends FreedomService
}
@Override
- protected void onStop()
+ public void onStop()
{
FUtil.cancel(cycleTask);
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java b/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java
index 42dee85a..a3055f1f 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java
@@ -8,7 +8,6 @@ import java.util.Map;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@@ -19,25 +18,20 @@ public class AutoEject extends FreedomService
private final Map ejects = new HashMap<>(); // ip -> amount
- public AutoEject(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
public void autoEject(Player player, String kickMessage)
{
EjectMethod method = EjectMethod.STRIKE_ONE;
- final String ip = Ips.getIp(player);
+ final String ip = FUtil.getIp(player);
if (!ejects.containsKey(ip))
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java b/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java
index e4bb380c..b7016dc3 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java
@@ -15,13 +15,8 @@ public class AutoKick extends FreedomService
private long autoKickTicks;
private double autoKickThreshold;
- public AutoKick(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
@@ -43,7 +38,7 @@ public class AutoKick extends FreedomService
}
@Override
- protected void onStop()
+ public void onStop()
{
FUtil.cancel(kickTask);
kickTask = null;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java b/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java
index 52a29576..5c798087 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java
@@ -1,18 +1,23 @@
package me.totalfreedom.totalfreedommod;
+import com.sk89q.worldedit.bukkit.BukkitConfiguration;
import java.io.File;
+import me.totalfreedom.totalfreedommod.config.YamlConfig;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.component.PluginComponent;
-import net.pravian.aero.config.YamlConfig;
import org.bukkit.util.FileUtil;
+import org.yaml.snakeyaml.Yaml;
-public class BackupManager extends PluginComponent
+public class BackupManager extends FreedomService
{
-
- public BackupManager(TotalFreedomMod plugin)
+ @Override
+ public void onStart()
+ {
+ }
+
+ @Override
+ public void onStop()
{
- super(plugin);
}
public void createBackups(String file)
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java b/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java
index 4d50d6ba..8829ab8b 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java
@@ -1,47 +1,39 @@
package me.totalfreedom.totalfreedommod;
import com.google.common.base.Strings;
-import java.time.LocalDate;
-import java.time.Period;
import java.util.Date;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Displayable;
-import me.totalfreedom.totalfreedommod.shop.ShopData;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
+import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
+import org.bukkit.Sound;
+import org.bukkit.SoundCategory;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
-import org.bukkit.Sound;
-import org.bukkit.SoundCategory;
+import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
public class ChatManager extends FreedomService
{
-
- public ChatManager(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
{
try
@@ -66,15 +58,10 @@ public class ChatManager extends FreedomService
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
{
event.setCancelled(true);
- ShopData data = plugin.sh.getData(player);
+ PlayerData data = plugin.pl.getData(player);
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
- plugin.sh.save(data);
- plugin.sh.reactionString = "";
- Date currentTime = new Date();
- long seconds = (currentTime.getTime() - plugin.sh.reactionStartTime.getTime()) / 1000;
- String reactionMessage = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] "
- + ChatColor.GREEN + player.getName() + ChatColor.AQUA + " won in " + seconds + " seconds!";
- FUtil.bcastMsg(reactionMessage, false);
+ plugin.pl.save(data);
+ plugin.sh.endReaction(player.getName());
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
return;
}
@@ -82,7 +69,7 @@ public class ChatManager extends FreedomService
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
{
event.setCancelled(true);
- playerMsg(player, "Chat is currently disabled.", ChatColor.RED);
+ playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
return;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/CommandSpy.java b/src/main/java/me/totalfreedom/totalfreedommod/CommandSpy.java
index db9a157a..4da218d3 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/CommandSpy.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/CommandSpy.java
@@ -5,23 +5,16 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import org.bukkit.ChatColor;
public class CommandSpy extends FreedomService
{
-
- public CommandSpy(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java b/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java
index 5bd0099d..61c2400c 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java
@@ -16,11 +16,6 @@ public class EntityWiper extends FreedomService
{
private BukkitTask wiper;
- public EntityWiper(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
public List BLACKLIST = Arrays.asList(
EntityType.ARMOR_STAND,
EntityType.PAINTING,
@@ -31,7 +26,7 @@ public class EntityWiper extends FreedomService
);
@Override
- protected void onStart()
+ public void onStart()
{
// Continuous Entity Wiper
wiper = new BukkitRunnable()
@@ -45,7 +40,7 @@ public class EntityWiper extends FreedomService
}
@Override
- protected void onStop()
+ public void onStop()
{
wiper.cancel();
wiper = null;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java b/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java
index 3cce8459..e324847c 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java
@@ -1,13 +1,24 @@
package me.totalfreedom.totalfreedommod;
-import net.pravian.aero.component.service.AbstractService;
+import me.totalfreedom.totalfreedommod.util.FLog;
+import org.bukkit.Server;
+import org.bukkit.event.Listener;
-public abstract class FreedomService extends AbstractService
+public abstract class FreedomService implements Listener
{
+ protected final TotalFreedomMod plugin;
+ protected final Server server;
+ protected final FLog logger;
- public FreedomService(TotalFreedomMod plugin)
+ public FreedomService()
{
- super(plugin);
+ plugin = TotalFreedomMod.getPlugin();
+ server = plugin.getServer();
+ logger = new FLog();
+ plugin.getServer().getPluginManager().registerEvents(this, plugin);
+ plugin.fsh.add(this);
}
+ public abstract void onStart();
+ public abstract void onStop();
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/FreedomServiceHandler.java b/src/main/java/me/totalfreedom/totalfreedommod/FreedomServiceHandler.java
new file mode 100644
index 00000000..d8960ab8
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/FreedomServiceHandler.java
@@ -0,0 +1,26 @@
+package me.totalfreedom.totalfreedommod;
+
+import java.util.ArrayList;
+import java.util.List;
+import lombok.Getter;
+
+public class FreedomServiceHandler
+{
+ @Getter
+ private List services;
+
+ public FreedomServiceHandler()
+ {
+ this.services = new ArrayList<>();
+ }
+
+ public void add(FreedomService service)
+ {
+ services.add(service);
+ }
+
+ public int getServiceAmount()
+ {
+ return services.size();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java b/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java
index 8db1fe14..06b03f89 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java
@@ -9,18 +9,13 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class Fuckoff extends FreedomService
{
- public Fuckoff(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -53,7 +48,7 @@ public class Fuckoff extends FreedomService
if (distanceSquared < (fuckoffRange * fuckoffRange))
{
- onlinePlayer.setVelocity(onlinePlayer.getLocation().toVector().subtract(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
+ fuckoffPlayer.setVelocity(onlinePlayer.getLocation().toVector().add(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
break;
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java b/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java
index cfa202cc..36490da8 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java
@@ -13,10 +13,8 @@ public class GameRuleHandler extends FreedomService
private final Map rules = new EnumMap<>(GameRule.class);
- public GameRuleHandler(TotalFreedomMod plugin)
+ public GameRuleHandler()
{
- super(plugin);
-
for (GameRule gameRule : GameRule.values())
{
rules.put(gameRule, gameRule.getDefaultValue());
@@ -24,7 +22,7 @@ public class GameRuleHandler extends FreedomService
}
@Override
- protected void onStart()
+ public void onStart()
{
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
@@ -41,7 +39,7 @@ public class GameRuleHandler extends FreedomService
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java b/src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java
index b7fe358c..802256bc 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java
@@ -23,19 +23,13 @@ import org.bukkit.scheduler.BukkitRunnable;
public class LogViewer extends FreedomService
{
-
- public LogViewer(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
index f5a189ff..119912b5 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
@@ -5,11 +5,10 @@ import java.util.List;
import java.util.regex.Pattern;
import lombok.Getter;
import lombok.Setter;
-import me.totalfreedom.totalfreedommod.command.Command_vanish;
+import me.rayzr522.jsonmessage.JSONMessage;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.player.FPlayer;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
@@ -22,7 +21,6 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.scheduler.BukkitRunnable;
-import me.rayzr522.jsonmessage.JSONMessage;
public class LoginProcess extends FreedomService
{
@@ -38,18 +36,13 @@ public class LoginProcess extends FreedomService
@Setter
private static boolean lockdownEnabled = false;
- public LoginProcess(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -194,7 +187,7 @@ public class LoginProcess extends FreedomService
{
final Player player = event.getPlayer();
final FPlayer fPlayer = plugin.pl.getPlayer(player);
- final VPlayer verificationPlayer = plugin.pv.getVerificationPlayer(player);
+ final PlayerData playerData = plugin.pl.getData(player);
player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60);
player.setOp(true);
@@ -210,6 +203,12 @@ public class LoginProcess extends FreedomService
return;
}
+ if (!playerData.hasVerification() && !playerData.getIps().contains(FUtil.getIp(player)))
+ {
+ playerData.addIp(FUtil.getIp(player));
+ plugin.pl.save(playerData);
+ }
+
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
{
player.getInventory().clear();
@@ -237,35 +236,24 @@ public class LoginProcess extends FreedomService
if (!plugin.al.isAdmin(player))
{
- if (plugin.mbl.isMasterBuilder(player))
+ String tag = playerData.getTag();
+ if (tag != null)
{
- MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
- if (masterBuilder.getTag() != null)
- {
- fPlayer.setTag(FUtil.colorize(masterBuilder.getTag()));
- }
+ fPlayer.setTag(FUtil.colorize(tag));
}
- else
+ int noteCount = playerData.getNotes().size();
+ if (noteCount != 0)
{
- VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
- if (vPlayer.getEnabled() && vPlayer.getTag() != null)
+ String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + ".";
+ JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
+ .tooltip("Click here to view them.")
+ .runCommand("/notes " + player.getName() + " list");
+ FLog.info(noteMessage);
+ for (Player p : server.getOnlinePlayers())
{
- fPlayer.setTag(FUtil.colorize(vPlayer.getTag()));
- }
- int noteCount = vPlayer.getNotes().size();
- if (noteCount != 0)
- {
- String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + ".";
- JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
- .tooltip("Click here to view them.")
- .runCommand("/notes " + player.getName() + " list");
- FLog.info(noteMessage);
- for (Player p : server.getOnlinePlayers())
+ if (plugin.al.isAdminImpostor(p))
{
- if (plugin.al.isAdminImpostor(p))
- {
- notice.send(p);
- }
+ notice.send(p);
}
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
index e9616fb9..7147f9a0 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
@@ -18,18 +18,13 @@ public class Monitors extends FreedomService
private final DecimalFormat decimalFormat = new DecimalFormat("#");
private String potionSpyPrefix = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "PotionSpy" + ChatColor.DARK_GRAY + "] ";
- public Monitors(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java b/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java
index e00aa068..0666c0cb 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java
@@ -5,12 +5,12 @@ import ca.momothereal.mojangson.value.MojangsonCompound;
import ca.momothereal.mojangson.value.MojangsonValue;
import java.util.List;
import java.util.Objects;
-import net.minecraft.server.v1_15_R1.NBTTagCompound;
-import net.minecraft.server.v1_15_R1.NBTTagList;
+import net.minecraft.server.v1_16_R1.NBTTagCompound;
+import net.minecraft.server.v1_16_R1.NBTTagList;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
-import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -19,7 +19,6 @@ import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
-import org.jetbrains.annotations.NotNull;
public class MovementValidator extends FreedomService
{
@@ -27,18 +26,13 @@ public class MovementValidator extends FreedomService
public static final int MAX_XYZ_COORD = 29999998;
public static final int MAX_DISTANCE_TRAVELED = 100;
- public MovementValidator(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -137,7 +131,7 @@ public class MovementValidator extends FreedomService
private Boolean exploitItem(ItemStack item)
{
- net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
+ net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
NBTTagList modifiers = getAttributeList(nmsStack);
MojangsonCompound compound = new MojangsonCompound();
boolean foundNegative = false;
@@ -174,7 +168,7 @@ public class MovementValidator extends FreedomService
}
- private NBTTagList getAttributeList(net.minecraft.server.v1_15_R1.ItemStack stack)
+ private NBTTagList getAttributeList(net.minecraft.server.v1_16_R1.ItemStack stack)
{
if (stack.getTag() == null)
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Muter.java b/src/main/java/me/totalfreedom/totalfreedommod/Muter.java
index 67dccc21..97891bef 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/Muter.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/Muter.java
@@ -21,32 +21,25 @@ public class Muter extends FreedomService
{
public static final List MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
- public final List MUTED_PLAYERS = new ArrayList();
-
- public Muter(TotalFreedomMod plugin)
- {
- super(plugin);
- }
+ public final List MUTED_PLAYERS = new ArrayList<>();
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
- @EventHandler(priority = EventPriority.LOW)
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
{
Player player = event.getPlayer();
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
- FLog.info("checking mute");
-
if (!fPlayer.isMuted())
{
return;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java b/src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java
index fee5e8b7..d830199c 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java
@@ -9,19 +9,13 @@ import org.bukkit.util.Vector;
public class Orbiter extends FreedomService
{
-
- public Orbiter(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ProtectArea.java b/src/main/java/me/totalfreedom/totalfreedommod/ProtectArea.java
index 6172695e..9dbcde21 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/ProtectArea.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/ProtectArea.java
@@ -32,13 +32,8 @@ public class ProtectArea extends FreedomService
//
private final Map areas = Maps.newHashMap();
- public ProtectArea(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
@@ -68,7 +63,7 @@ public class ProtectArea extends FreedomService
}
@Override
- protected void onStop()
+ public void onStop()
{
save();
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java b/src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java
index 20371d6b..8a0cd287 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java
@@ -12,19 +12,13 @@ import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
public class SavedFlags extends FreedomService
{
-
- public SavedFlags(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ServerInterface.java b/src/main/java/me/totalfreedom/totalfreedommod/ServerInterface.java
index 2d69d9ea..033281ad 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/ServerInterface.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/ServerInterface.java
@@ -4,28 +4,22 @@ import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.minecraft.server.v1_15_R1.EntityPlayer;
-import net.minecraft.server.v1_15_R1.MinecraftServer;
+import net.minecraft.server.v1_16_R1.EntityPlayer;
+import net.minecraft.server.v1_16_R1.MinecraftServer;
import org.bukkit.Bukkit;
-import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
+import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
public class ServerInterface extends FreedomService
{
-
- public static final String COMPILE_NMS_VERSION = "v1_15_R1";
-
- public ServerInterface(TotalFreedomMod plugin)
- {
- super(plugin);
- }
+ public static final String COMPILE_NMS_VERSION = "v1_16_R1";
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java b/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java
index c4657fa2..a5a91ab8 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java
@@ -9,19 +9,13 @@ import org.bukkit.event.server.ServerListPingEvent;
public class ServerPing extends FreedomService
{
-
- public ServerPing(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java
index c13ae3e3..1b3c5924 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java
@@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod;
import java.io.File;
import java.io.InputStream;
import java.util.Properties;
+import java.util.Set;
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.banning.BanManager;
@@ -24,6 +25,7 @@ import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
import me.totalfreedom.totalfreedommod.caging.Cager;
import me.totalfreedom.totalfreedommod.command.CommandLoader;
+import me.totalfreedom.totalfreedommod.command.FreedomCommand;
import me.totalfreedom.totalfreedommod.config.MainConfig;
import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.freeze.Freezer;
@@ -32,38 +34,38 @@ import me.totalfreedom.totalfreedommod.fun.ItemFun;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.fun.Landminer;
import me.totalfreedom.totalfreedommod.fun.MP44;
-import me.totalfreedom.totalfreedommod.fun.MobStacker;
-import me.totalfreedom.totalfreedommod.fun.RealTimer;
import me.totalfreedom.totalfreedommod.fun.Trailer;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderList;
-import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
import me.totalfreedom.totalfreedommod.player.PlayerList;
-import me.totalfreedom.totalfreedommod.playerverification.PlayerVerification;
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
import me.totalfreedom.totalfreedommod.rank.RankManager;
import me.totalfreedom.totalfreedommod.shop.Shop;
+import me.totalfreedom.totalfreedommod.shop.Votifier;
import me.totalfreedom.totalfreedommod.sql.SQLite;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.MethodTimer;
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
import me.totalfreedom.totalfreedommod.world.WorldManager;
-import net.pravian.aero.component.service.ServiceManager;
-import net.pravian.aero.plugin.AeroPlugin;
+import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
import org.bstats.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
+import org.reflections.Reflections;
import org.spigotmc.SpigotConfig;
-public class TotalFreedomMod extends AeroPlugin
+public class TotalFreedomMod extends JavaPlugin
{
-
+ private static TotalFreedomMod plugin;
+ public static TotalFreedomMod getPlugin()
+ {
+ return plugin;
+ }
public static final String CONFIG_FILENAME = "config.yml";
//
public static final BuildProperties build = new BuildProperties();
@@ -74,8 +76,11 @@ public class TotalFreedomMod extends AeroPlugin
public MainConfig config;
public PermissionConfig permissions;
//
+ // Service Handler
+ public FreedomServiceHandler fsh;
+ // Command Loader
+ public CommandLoader cl;
// Services
- public ServiceManager services;
public ServerInterface si;
public SavedFlags sf;
public WorldManager wm;
@@ -83,7 +88,6 @@ public class TotalFreedomMod extends AeroPlugin
public AdminList al;
public ActivityLog acl;
public RankManager rm;
- public CommandLoader cl;
public CommandBlocker cb;
public EventBlocker eb;
public BlockBlocker bb;
@@ -95,6 +99,7 @@ public class TotalFreedomMod extends AeroPlugin
public AntiSpam as;
public PlayerList pl;
public Shop sh;
+ public Votifier vo;
public SQLite sql;
public Announcer an;
public ChatManager cm;
@@ -121,21 +126,16 @@ public class TotalFreedomMod extends AeroPlugin
public CurseListener cul;
public ItemFun it;
public Landminer lm;
- public MobStacker ms;
public MP44 mp;
public Jumppads jp;
public Trailer tr;
public HTTPDaemon hd;
- public MasterBuilderList mbl;
public WorldRestrictions wr;
public SignBlocker snp;
- public PlayerVerification pv;
public EntityWiper ew;
- public RealTimer rt;
//public HubWorldRestrictions hwr;
//
// Bridges
- public ServiceManager bridges;
public BukkitTelnetBridge btb;
public EssentialsBridge esb;
public LibsDisguisesBridge ldb;
@@ -144,19 +144,20 @@ public class TotalFreedomMod extends AeroPlugin
public WorldGuardBridge wgb;
@Override
- public void load()
+ public void onLoad()
{
+ plugin = this;
TotalFreedomMod.pluginName = plugin.getDescription().getName();
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
FLog.setPluginLogger(plugin.getLogger());
- FLog.setServerLogger(server.getLogger());
+ FLog.setServerLogger(getServer().getLogger());
build.load(plugin);
}
@Override
- public void enable()
+ public void onEnable()
{
FLog.info("Created by Madgeek1450 and Prozza");
FLog.info("Version " + build.version);
@@ -172,14 +173,31 @@ public class TotalFreedomMod extends AeroPlugin
FUtil.deleteCoreDumps();
FUtil.deleteFolder(new File("./_deleteme"));
- BackupManager backups = new BackupManager(this);
+ fsh = new FreedomServiceHandler();
+ cl = new CommandLoader();
+
+ Reflections commandDir = new Reflections("me.totalfreedom.totalfreedommod.command");
+
+ Set> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
+
+ for (Class extends FreedomCommand> commandClass : commandClasses)
+ {
+ try
+ {
+ cl.add(commandClass.newInstance());
+ }
+ catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
+ {
+ FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_" , ""));
+ }
+ }
+
+ BackupManager backups = new BackupManager();
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
- backups.createBackups(AdminList.CONFIG_FILENAME);
backups.createBackups(PermbanList.CONFIG_FILENAME);
backups.createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
- backups.createBackups(MasterBuilder.CONFIG_FILENAME);
backups.createBackups(PunishmentList.CONFIG_FILENAME);
- backups.createBackups("");
+ backups.createBackups("database.db");
config = new MainConfig(this);
config.load();
@@ -188,82 +206,78 @@ public class TotalFreedomMod extends AeroPlugin
permissions.load();
// Start services
- services = new ServiceManager<>(plugin);
- si = services.registerService(ServerInterface.class);
- sf = services.registerService(SavedFlags.class);
- wm = services.registerService(WorldManager.class);
- lv = services.registerService(LogViewer.class);
- sql = services.registerService(SQLite.class);
- al = services.registerService(AdminList.class);
- acl = services.registerService(ActivityLog.class);
- rm = services.registerService(RankManager.class);
- cl = services.registerService(CommandLoader.class);
- cb = services.registerService(CommandBlocker.class);
- eb = services.registerService(EventBlocker.class);
- bb = services.registerService(BlockBlocker.class);
- mb = services.registerService(MobBlocker.class);
- ib = services.registerService(InteractBlocker.class);
- pb = services.registerService(PotionBlocker.class);
- lp = services.registerService(LoginProcess.class);
- nu = services.registerService(AntiNuke.class);
- as = services.registerService(AntiSpam.class);
- mbl = services.registerService(MasterBuilderList.class);
- wr = services.registerService(WorldRestrictions.class);
- pl = services.registerService(PlayerList.class);
- sh = services.registerService(Shop.class);
- an = services.registerService(Announcer.class);
- cm = services.registerService(ChatManager.class);
- dc = services.registerService(Discord.class);
- pul = services.registerService(PunishmentList.class);
- bm = services.registerService(BanManager.class);
- pm = services.registerService(PermbanList.class);
- pem = services.registerService(PermissionManager.class);
- pa = services.registerService(ProtectArea.class);
- gr = services.registerService(GameRuleHandler.class);
- snp = services.registerService(SignBlocker.class);
- ew = services.registerService(EntityWiper.class);
+ si = new ServerInterface();
+ sf = new SavedFlags();
+ wm = new WorldManager();
+ lv = new LogViewer();
+ sql = new SQLite();
+ al = new AdminList();
+ acl = new ActivityLog();
+ rm = new RankManager();
+ cb = new CommandBlocker();
+ eb = new EventBlocker();
+ bb = new BlockBlocker();
+ mb = new MobBlocker();
+ ib = new InteractBlocker();
+ pb = new PotionBlocker();
+ lp = new LoginProcess();
+ nu = new AntiNuke();
+ as = new AntiSpam();
+ wr = new WorldRestrictions();
+ pl = new PlayerList();
+ sh = new Shop();
+ vo = new Votifier();
+ an = new Announcer();
+ cm = new ChatManager();
+ dc = new Discord();
+ pul = new PunishmentList();
+ bm = new BanManager();
+ pm = new PermbanList();
+ pem = new PermissionManager();
+ pa = new ProtectArea();
+ gr = new GameRuleHandler();
+ snp = new SignBlocker();
+ ew = new EntityWiper();
// Single admin utils
- cs = services.registerService(CommandSpy.class);
- ca = services.registerService(Cager.class);
- fm = services.registerService(Freezer.class);
- or = services.registerService(Orbiter.class);
- mu = services.registerService(Muter.class);
- ebl = services.registerService(EditBlocker.class);
- pbl = services.registerService(PVPBlocker.class);
- fo = services.registerService(Fuckoff.class);
- ak = services.registerService(AutoKick.class);
- ae = services.registerService(AutoEject.class);
- mo = services.registerService(Monitors.class);
+ cs = new CommandSpy();
+ ca = new Cager();
+ fm = new Freezer();
+ or = new Orbiter();
+ mu = new Muter();
+ ebl = new EditBlocker();
+ pbl = new PVPBlocker();
+ fo = new Fuckoff();
+ ak = new AutoKick();
+ ae = new AutoEject();
+ mo = new Monitors();
- mv = services.registerService(MovementValidator.class);
- sp = services.registerService(ServerPing.class);
- pv = services.registerService(PlayerVerification.class);
+ mv = new MovementValidator();
+ sp = new ServerPing();
// Fun
- cul = services.registerService(CurseListener.class);
- it = services.registerService(ItemFun.class);
- lm = services.registerService(Landminer.class);
- ms = services.registerService(MobStacker.class);
- mp = services.registerService(MP44.class);
- jp = services.registerService(Jumppads.class);
- tr = services.registerService(Trailer.class);
- rt = services.registerService(RealTimer.class);
-
+ cul = new CurseListener();
+ it = new ItemFun();
+ lm = new Landminer();
+ mp = new MP44();
+ jp = new Jumppads();
+ tr = new Trailer();
// HTTPD
- hd = services.registerService(HTTPDaemon.class);
- services.start();
+ hd = new HTTPDaemon();
// Start bridges
- bridges = new ServiceManager<>(plugin);
- btb = bridges.registerService(BukkitTelnetBridge.class);
- cpb = bridges.registerService(CoreProtectBridge.class);
- esb = bridges.registerService(EssentialsBridge.class);
- ldb = bridges.registerService(LibsDisguisesBridge.class);
- web = bridges.registerService(WorldEditBridge.class);
- wgb = bridges.registerService(WorldGuardBridge.class);
- bridges.start();
+ btb = new BukkitTelnetBridge();
+ cpb = new CoreProtectBridge();
+ esb = new EssentialsBridge();
+ ldb = new LibsDisguisesBridge();
+ web = new WorldEditBridge();
+ wgb = new WorldGuardBridge();
+
+ for (FreedomService service : fsh.getServices())
+ service.onStart();
+
+ FLog.info("Started " + fsh.getServiceAmount() + "services.");
timer.update();
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
@@ -285,13 +299,15 @@ public class TotalFreedomMod extends AeroPlugin
}
@Override
- public void disable()
+ public void onDisable()
{
// Stop services and bridges
- bridges.stop();
- services.stop();
+ for (FreedomService service : fsh.getServices())
+ {
+ service.onStop();
+ }
- server.getScheduler().cancelTasks(plugin);
+ getServer().getScheduler().cancelTasks(plugin);
FLog.info("Plugin disabled");
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLog.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLog.java
index c36b130a..41ab9505 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLog.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLog.java
@@ -4,10 +4,9 @@ import com.google.common.collect.Maps;
import java.util.Map;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.config.YamlConfig;
import me.totalfreedom.totalfreedommod.util.FLog;
-import net.pravian.aero.config.YamlConfig;
-import net.pravian.aero.util.Ips;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
@@ -28,21 +27,19 @@ public class ActivityLog extends FreedomService
private final YamlConfig config;
- public ActivityLog(TotalFreedomMod plugin)
+ public ActivityLog()
{
- super(plugin);
-
this.config = new YamlConfig(plugin, FILENAME, true);
}
@Override
- protected void onStart()
+ public void onStart()
{
load();
}
@Override
- protected void onStop()
+ public void onStop()
{
save();
}
@@ -110,7 +107,7 @@ public class ActivityLog extends FreedomService
ActivityLogEntry activityLog = getEntryByName(player.getName());
if (activityLog == null)
{
- String ip = Ips.getIp(player);
+ String ip = FUtil.getIp(player);
activityLog = getEntryByIp(ip);
if (activityLog != null)
{
@@ -129,7 +126,7 @@ public class ActivityLog extends FreedomService
config.save();
}
}
- String ip = Ips.getIp(player);
+ String ip = FUtil.getIp(player);
if (!activityLog.getIps().contains(ip))
{
activityLog.addIp(ip);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLogEntry.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLogEntry.java
index db7ae845..6ff54333 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLogEntry.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLogEntry.java
@@ -6,15 +6,13 @@ import java.util.Date;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
+import me.totalfreedom.totalfreedommod.config.IConfig;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.base.ConfigLoadable;
-import net.pravian.aero.base.ConfigSavable;
-import net.pravian.aero.base.Validatable;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
-public class ActivityLogEntry implements ConfigLoadable, ConfigSavable, Validatable
+public class ActivityLogEntry implements IConfig
{
@Getter
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java
index aca96ae0..b87aa1fd 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java
@@ -1,8 +1,8 @@
package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Lists;
-import java.util.Arrays;
-import java.util.Collections;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -12,10 +12,9 @@ import lombok.Setter;
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.StringUtils;
-import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class Admin
@@ -31,7 +30,6 @@ public class Admin
private Rank rank = Rank.SUPER_ADMIN;
@Getter
private final List ips = Lists.newArrayList();
- private final List backupCodes = Lists.newArrayList();
@Getter
@Setter
private Date lastLogin = new Date();
@@ -40,12 +38,6 @@ public class Admin
private String loginMessage = null;
@Getter
@Setter
- private String discordID = null;
- @Getter
- @Setter
- private String tag = null;
- @Getter
- @Setter
private Boolean commandSpy = false;
@Getter
@Setter
@@ -60,32 +52,33 @@ public class Admin
@Setter
private Boolean logStick = false;
- public static final String CONFIG_FILENAME = "admins.yml";
-
public Admin(Player player)
{
this.name = player.getName();
- this.ips.add(Ips.getIp(player));
+ this.ips.add(FUtil.getIp(player));
}
- public Admin(String username, List ips, Rank rank, Boolean active, Date lastLogin, String loginMessage, String tag, String discordID, List backupCodes, Boolean commandSpy, Boolean potionSpy, String acFormat, Boolean oldTags, Boolean logStick)
+ public Admin(ResultSet resultSet)
{
- this.name = username;
- this.active = active;
- this.rank = rank;
- this.ips.clear();
- this.ips.addAll(ips);
- this.lastLogin = lastLogin;
- this.loginMessage = loginMessage;
- this.tag = tag;
- this.discordID = discordID;
- this.backupCodes.clear();
- this.backupCodes.addAll(backupCodes);
- this.commandSpy = commandSpy;
- this.potionSpy = potionSpy;
- this.acFormat = acFormat;
- this.oldTags = oldTags;
- this.logStick = logStick;
+ try
+ {
+ this.name = resultSet.getString("username");
+ this.active = resultSet.getBoolean("active");
+ this.rank = Rank.findRank(resultSet.getString("rank"));
+ this.ips.clear();
+ this.ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
+ this.lastLogin = new Date(resultSet.getLong("last_login"));
+ this.loginMessage = resultSet.getString("login_message");
+ this.commandSpy = resultSet.getBoolean("command_spy");
+ this.potionSpy = resultSet.getBoolean("potion_spy");
+ this.acFormat = resultSet.getString("ac_format");
+ this.oldTags = resultSet.getBoolean("old_tags");
+ this.logStick = resultSet.getBoolean("log_stick");
+ }
+ catch (SQLException e)
+ {
+ FLog.severe("Failed to load admin: " + e.getMessage());
+ }
}
@Override
@@ -99,13 +92,10 @@ public class Admin
.append("- Custom Login Message: ").append(loginMessage).append("\n")
.append("- Rank: ").append(rank.getName()).append("\n")
.append("- Is Active: ").append(active).append("\n")
- .append("- Discord ID: ").append(discordID).append("\n")
- .append("- Tag: ").append(tag).append("\n").append(ChatColor.GRAY)
.append("- Potion Spy: ").append(potionSpy).append("\n")
.append("- Admin Chat Format: ").append(acFormat).append("\n")
.append("- Old Tags: ").append(oldTags).append("\n")
- .append("- Log Stick: ").append(logStick).append("\n")
- .append("- Backup Codes: ").append(backupCodes.size()).append("/10");
+ .append("- Log Stick: ").append(logStick).append("\n");
return output.toString();
}
@@ -114,7 +104,7 @@ public class Admin
{
name = player.getName();
ips.clear();
- ips.add(Ips.getIp(player));
+ ips.add(FUtil.getIp(player));
}
public Map toSQLStorable()
@@ -125,11 +115,8 @@ public class Admin
put("active", active);
put("rank", rank.toString());
put("ips", FUtil.listToString(ips));
- put("backup_codes", FUtil.listToString(backupCodes));
put("last_login", lastLogin.getTime());
put("login_message", loginMessage);
- put("discord_id", discordID);
- put("tag", tag);
put("command_spy", commandSpy);
put("potion_spy", potionSpy);
put("ac_format", acFormat);
@@ -179,22 +166,6 @@ public class Admin
ips.clear();
}
- public List getBackupCodes()
- {
- return Collections.unmodifiableList(backupCodes);
- }
-
- public void setBackupCodes(List codes)
- {
- backupCodes.clear();
- backupCodes.addAll(codes);
- }
-
- public void removeBackupCode(String code)
- {
- backupCodes.remove(code);
- }
-
public void setActive(boolean active)
{
this.active = active;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java
index 80d4ecd2..ee55af72 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java
@@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.admin;
-import com.google.common.base.Function;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.sql.ResultSet;
@@ -13,23 +12,16 @@ 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.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.config.YamlConfig;
-import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.plugin.ServicePriority;
public class AdminList extends FreedomService
{
-
- public static final String CONFIG_FILENAME = "admins.yml";
-
@Getter
private final Set allAdmins = Sets.newHashSet(); // Includes disabled admins
// Only active admins below
@@ -40,42 +32,21 @@ public class AdminList extends FreedomService
public final List verifiedNoAdmins = new ArrayList<>();
public final Map> verifiedNoAdminIps = Maps.newHashMap();
public static ArrayList vanished = new ArrayList<>();
- //
- private final YamlConfig config;
-
- public AdminList(TotalFreedomMod plugin)
- {
- super(plugin);
-
- this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
- }
@Override
- protected void onStart()
+ public void onStart()
{
load();
-
- server.getServicesManager().register(Function.class, new Function()
- {
- @Override
- public Boolean apply(Player player)
- {
- return isAdmin(player);
- }
- }, plugin, ServicePriority.Normal);
-
deactivateOldEntries(false);
}
@Override
- protected void onStop()
+ public void onStop()
{
}
public void load()
{
- config.load();
-
allAdmins.clear();
try
{
@@ -83,28 +54,14 @@ public class AdminList extends FreedomService
{
while (adminSet.next())
{
- String name = adminSet.getString("username");
- List ips = FUtil.stringToList(adminSet.getString("ips"));
- Rank rank = Rank.findRank(adminSet.getString("rank"));
- Boolean active = adminSet.getBoolean("active");;
- Date lastLogin = new Date(adminSet.getLong("last_login"));
- String loginMessage = adminSet.getString("login_message");
- String tag = adminSet.getString("tag");
- String discordID = adminSet.getString("discord_id");
- List backupCodes = FUtil.stringToList(adminSet.getString("backup_codes"));
- Boolean commandSpy = adminSet.getBoolean("command_spy");
- Boolean potionSpy = adminSet.getBoolean("potion_spy");
- String acFormat = adminSet.getString("ac_format");
- Boolean oldTags = adminSet.getBoolean("old_tags");
- Boolean logStick = adminSet.getBoolean("log_stick");
- Admin admin = new Admin(name, ips, rank, active, lastLogin, loginMessage, tag, discordID, backupCodes, commandSpy, potionSpy, acFormat, oldTags, logStick);
+ Admin admin = new Admin(adminSet);
allAdmins.add(admin);
}
}
}
catch (SQLException e)
{
- FLog.severe("Failed to get adminlist: " + e.getMessage());
+ FLog.severe("Failed to load adminlist: " + e.getMessage());
}
updateTables();
@@ -149,6 +106,17 @@ public class AdminList extends FreedomService
return admin != null && admin.isActive();
}
+ public boolean isTelnetAdmin(CommandSender sender)
+ {
+ Admin admin = getAdmin(sender);
+ if (admin == null)
+ {
+ return false;
+ }
+
+ return admin.getRank().ordinal() >= Rank.TELNET_ADMIN.ordinal();
+ }
+
public boolean isSeniorAdmin(CommandSender sender)
{
Admin admin = getAdmin(sender);
@@ -173,7 +141,7 @@ public class AdminList extends FreedomService
public Admin getAdmin(Player player)
{
// Find admin
- String ip = Ips.getIp(player);
+ String ip = FUtil.getIp(player);
Admin admin = getEntryByName(player.getName());
// Admin by name
@@ -257,7 +225,7 @@ public class AdminList extends FreedomService
public boolean isVerifiedAdmin(Player player)
{
- return verifiedNoAdmins.contains(player.getName()) && verifiedNoAdminIps.get(player.getName()).contains(Ips.getIp(player));
+ return verifiedNoAdmins.contains(player.getName()) && verifiedNoAdminIps.get(player.getName()).contains(FUtil.getIp(player));
}
public boolean isIdentityMatched(Player player)
@@ -356,7 +324,7 @@ public class AdminList extends FreedomService
for (Map.Entry entry : admin.toSQLStorable().entrySet())
{
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
- if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null)
+ if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
{
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java b/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java
index 681474a3..1c5b7a23 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Lists;
-import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList;
@@ -14,14 +13,14 @@ import java.util.Set;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.config.IConfig;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.base.Validatable;
-import net.pravian.aero.util.Ips;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
-public class Ban implements Validatable
+public class Ban implements IConfig
{
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
@@ -81,7 +80,7 @@ public class Ban implements Validatable
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
{
- return new Ban(null, Arrays.asList(Ips.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
+ return new Ban(null, Arrays.asList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
}
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
@@ -116,7 +115,7 @@ public class Ban implements Validatable
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
{
return new Ban(player.getName(),
- Ips.getIp(player),
+ FUtil.getIp(player),
by.getName(),
Date.from(Instant.now()),
expiry,
@@ -126,7 +125,7 @@ public class Ban implements Validatable
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
{
return new Ban(player.getName(),
- FUtil.getFuzzyIp(Ips.getIp(player)),
+ FUtil.getFuzzyIp(FUtil.getIp(player)),
by.getName(),
Date.from(Instant.now()),
expiry,
@@ -235,6 +234,16 @@ public class Ban implements Validatable
return hash;
}
+ @Override
+ public void loadFrom(ConfigurationSection cs)
+ {
+ }
+
+ @Override
+ public void saveTo(ConfigurationSection cs)
+ {
+ }
+
@Override
public boolean isValid()
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java b/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java
index 7455afb3..76ee3c27 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java
@@ -9,17 +9,14 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
-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.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -36,13 +33,8 @@ public class BanManager extends FreedomService
//
- public BanManager(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
bans.clear();
try
@@ -79,7 +71,7 @@ public class BanManager extends FreedomService
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -121,7 +113,7 @@ public class BanManager extends FreedomService
continue;
}
- if (Ips.fuzzyIpMatch(ip, loopIp, 4))
+ if (FUtil.fuzzyIpMatch(ip, loopIp, 4))
{
return loopBan;
}
@@ -180,10 +172,23 @@ public class BanManager extends FreedomService
public boolean addBan(Ban ban)
{
- if (getByUsername(ban.getUsername()) != null)
+ if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
{
removeBan(ban);
}
+ else
+ {
+
+ for (String ip : ban.getIps())
+ {
+ if (getByIp(ip) != null)
+ {
+ removeBan(ban);
+ break;
+ }
+ }
+ }
+
if (bans.add(ban))
{
plugin.sql.addBan(ban);
@@ -219,7 +224,7 @@ public class BanManager extends FreedomService
public void onPlayerLogin(PlayerLoginEvent event)
{
final String username = event.getPlayer().getName();
- final String ip = Ips.getIp(event);
+ final String ip = FUtil.getIp(event);
// Regular ban
Ban ban = getByUsername(username);
@@ -246,14 +251,19 @@ public class BanManager extends FreedomService
}
// Unban admins
- for (String storedIp : data.getIps())
+ Ban ban = getByUsername(player.getName());
+ if (ban != null)
{
- unbanIp(storedIp);
- unbanIp(FUtil.getFuzzyIp(storedIp));
+ removeBan(ban);
+ }
+ else
+ {
+ ban = getByIp(FUtil.getIp(player));
+ if (ban != null)
+ {
+ removeBan(ban);
+ }
}
-
- unbanUsername(player.getName());
- player.setOp(true);
}
private void updateViews()
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/banning/PermbanList.java b/src/main/java/me/totalfreedom/totalfreedommod/banning/PermbanList.java
index 2c4c38c2..7265bab6 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/banning/PermbanList.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/banning/PermbanList.java
@@ -4,12 +4,10 @@ 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.YamlConfig;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-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;
@@ -25,13 +23,8 @@ public class PermbanList extends FreedomService
@Getter
private final Set permbannedIps = Sets.newHashSet();
- public PermbanList(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
permbannedNames.clear();
permbannedIps.clear();
@@ -49,7 +42,7 @@ public class PermbanList extends FreedomService
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -57,7 +50,7 @@ public class PermbanList extends FreedomService
public void onPlayerLogin(PlayerLoginEvent event)
{
final String username = event.getPlayer().getName();
- final String ip = Ips.getIp(event);
+ final String ip = FUtil.getIp(event);
// Permbanned IPs
for (String testIp : getPermbannedIps())
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java
index a0176022..c457a0fd 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java
@@ -2,15 +2,11 @@ package me.totalfreedom.totalfreedommod.blocking;
import java.util.List;
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 me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Banner;
-import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.block.banner.Pattern;
import org.bukkit.entity.Player;
@@ -23,19 +19,13 @@ import org.bukkit.inventory.meta.SkullMeta;
public class BlockBlocker extends FreedomService
{
-
- public BlockBlocker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -68,6 +58,7 @@ public class BlockBlocker extends FreedomService
break;
}
case FIRE:
+ case SOUL_FIRE:
{
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{
@@ -142,7 +133,7 @@ public class BlockBlocker extends FreedomService
case PLAYER_WALL_HEAD:
{
Skull skull = (Skull) event.getBlockPlaced().getState();
- if (skull.hasOwner())
+ if (skull.getOwner() != null)
{
if (skull.getOwner().contains("\u00A7"))
{
@@ -168,18 +159,25 @@ public class BlockBlocker extends FreedomService
}
break;
}
+ case RESPAWN_ANCHOR:
+ {
+ if (!ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
+ {
+ player.sendMessage(ChatColor.GRAY + "Respawn anchors are disabled.");
+ player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
+ event.setCancelled(true);
+ }
+ break;
+ }
}
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
{
Banner banner = (Banner) event.getBlockPlaced().getState();
- List patterns = banner.getPatterns();
- Banner handBanner = (Banner) (((Block) event.getItemInHand()).getState());
- List handPatterns = banner.getPatterns();
+ List patterns = banner.getPatterns();;
if (patterns.size() >= 2)
{
banner.setPatterns(patterns.subList(0, 2));
- handBanner.setPatterns(handPatterns.subList(0, 2));
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EditBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EditBlocker.java
index e41f0b00..0a7217e0 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EditBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EditBlocker.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import org.bukkit.ChatColor;
@@ -12,19 +11,13 @@ import org.bukkit.event.block.BlockPlaceEvent;
public class EditBlocker extends FreedomService
{
-
- public EditBlocker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java
index 33050e97..4b54e31e 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java
@@ -1,28 +1,23 @@
package me.totalfreedom.totalfreedommod.blocking;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
+import org.bukkit.block.data.AnaloguePowerable;
+import org.bukkit.block.data.BlockData;
+import org.bukkit.block.data.Powerable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
-import org.bukkit.event.block.BlockBurnEvent;
-import org.bukkit.event.block.BlockDispenseEvent;
-import org.bukkit.event.block.BlockFromToEvent;
-import org.bukkit.event.block.BlockIgniteEvent;
-import org.bukkit.event.block.BlockPistonExtendEvent;
-import org.bukkit.event.block.BlockPistonRetractEvent;
-import org.bukkit.event.block.BlockRedstoneEvent;
-import org.bukkit.event.block.LeavesDecayEvent;
-import org.bukkit.event.block.BlockGrowEvent;
+import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
@@ -32,22 +27,17 @@ import org.bukkit.event.entity.FireworkExplodeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
+import org.bukkit.material.Redstone;
public class EventBlocker extends FreedomService
{
-
- public EventBlocker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -206,7 +196,7 @@ public class EventBlocker extends FreedomService
}
}
- @EventHandler(priority = EventPriority.HIGH)
+ //@EventHandler(priority = EventPriority.HIGH)
public void onBlockRedstone(BlockRedstoneEvent event)
{
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
@@ -215,6 +205,20 @@ public class EventBlocker extends FreedomService
}
}
+ // TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
+ private ArrayList redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
+ @EventHandler
+ public void onBlockPhysics(BlockPhysicsEvent event) {
+ if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
+ {
+ // Check if the block is involved with redstone.
+ if(event.getBlock().getBlockData() instanceof AnaloguePowerable || event.getBlock().getBlockData() instanceof Powerable || redstoneBlocks.contains(event.getBlock().getType()))
+ {
+ event.setCancelled(true);
+ }
+ }
+ }
+
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerRespawn(PlayerRespawnEvent event)
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java
index ac95a1eb..f227f290 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java
@@ -1,13 +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.Groups;
import org.bukkit.ChatColor;
import org.bukkit.Material;
-import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -16,19 +13,13 @@ import org.bukkit.inventory.ItemStack;
public class InteractBlocker extends FreedomService
{
-
- public InteractBlocker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -56,15 +47,9 @@ public class InteractBlocker extends FreedomService
@EventHandler(priority = EventPriority.HIGH)
public void onRightClickBell(PlayerInteractEvent event)
{
- if (event.getClickedBlock() != null)
+ if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.BELL) && !ConfigEntry.ALLOW_BELLS.getBoolean())
{
- if (event.getClickedBlock().getType().equals(Material.BELL))
- {
- if (!ConfigEntry.ALLOW_BELLS.getBoolean())
- {
- event.setCancelled(true);
- }
- }
+ event.setCancelled(true);
}
}
@@ -89,12 +74,14 @@ public class InteractBlocker extends FreedomService
return;
}
- if (Groups.BED_COLORS.contains(event.getMaterial()) && event.getClickedBlock().getBiome().equals(Biome.NETHER))
+ // TODO: lookup new biomes that have bed explosions in 1.16
+
+ /*if (Groups.BED_COLORS.contains(event.getMaterial()) && event.getClickedBlock().getBiome().equals(Biome.NETHER))
{
player.sendMessage(ChatColor.RED + "You can't sleep in hell.");
event.setCancelled(true);
return;
- }
+ }*/
switch (event.getMaterial())
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java
index 521f5140..f8a9bcc7 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java
@@ -1,9 +1,7 @@
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 org.bukkit.attribute.Attributable;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Bat;
@@ -22,19 +20,13 @@ import org.bukkit.event.entity.EntitySpawnEvent;
public class MobBlocker extends FreedomService
{
-
- public MobBlocker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java
index 3850660e..b6efd382 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java
@@ -1,32 +1,25 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Arrow;
+import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.entity.Trident;
-import org.bukkit.entity.FishHook;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class PVPBlocker extends FreedomService
{
-
- public PVPBlocker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java
index 935274c4..1799d5d4 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java
@@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.blocking;
import java.util.Collection;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.entity.ThrownPotion;
@@ -19,18 +18,13 @@ public class PotionBlocker extends FreedomService
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
- public PotionBlocker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java
index c97d30a7..bfbaaa3e 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java
@@ -1,12 +1,10 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import net.minecraft.server.v1_15_R1.NBTTagCompound;
+import net.minecraft.server.v1_16_R1.NBTTagCompound;
import org.bukkit.ChatColor;
-import org.bukkit.Material;
import org.bukkit.Tag;
-import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -19,19 +17,13 @@ import org.bukkit.inventory.ItemStack;
public class SignBlocker extends FreedomService
{
-
- public SignBlocker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -43,7 +35,7 @@ public class SignBlocker extends FreedomService
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
{
ItemStack sign = event.getItemInHand();
- net.minecraft.server.v1_15_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
+ net.minecraft.server.v1_16_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
String line1 = bet.getString("Text1");
@@ -55,16 +47,6 @@ public class SignBlocker extends FreedomService
player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs.");
event.setCancelled(true);
}
- if (line1.contains("translate") || line2.contains("translate") || line3.contains("translate") || line4.contains("translate"))
- {
- player.sendMessage(ChatColor.GRAY + "You are not allowed to place broken strings that Mojang never fixed.");
- event.setCancelled(true);
- }
- if (line1.contains("translation.test.") || line2.contains("translation.test.") || line3.contains("translation.test.") || line4.contains("translation.test."))
- {
- player.sendMessage(ChatColor.BOLD + "No.");
- event.setCancelled(true);
- }
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java
index 55243c78..a0414fa2 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java
@@ -2,24 +2,25 @@ package me.totalfreedom.totalfreedommod.blocking.command;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import java.lang.reflect.Field;
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.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.command.CommandReflection;
import org.apache.commons.lang.StringUtils;
-import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
+import org.bukkit.command.SimpleCommandMap;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.SimplePluginManager;
public class CommandBlocker extends FreedomService
{
@@ -29,34 +30,43 @@ public class CommandBlocker extends FreedomService
private final Map entryList = Maps.newHashMap();
private final List unknownCommands = Lists.newArrayList();
- public CommandBlocker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
load();
}
@Override
- protected void onStop()
+ public void onStop()
{
entryList.clear();
}
+ public static CommandMap getCommandMap()
+ {
+ try
+ {
+ SimplePluginManager simplePluginManager = (SimplePluginManager) Bukkit.getServer().getPluginManager();
+
+ Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
+ commandMapField.setAccessible(true);
+
+ SimpleCommandMap simpleCommandMap = (SimpleCommandMap) commandMapField.get(simplePluginManager);
+ return simpleCommandMap;
+ }
+ catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
+ {
+ FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
+ }
+ return null;
+ }
+
public void load()
{
entryList.clear();
unknownCommands.clear();
- final CommandMap commandMap = CommandReflection.getCommandMap();
- if (commandMap == null)
- {
- FLog.severe("Error loading commandMap.");
- return;
- }
+ final CommandMap commandMap = getCommandMap();
@SuppressWarnings("unchecked")
List blockedCommands = (List)ConfigEntry.BLOCKED_COMMANDS.getList();
@@ -106,9 +116,9 @@ public class CommandBlocker extends FreedomService
continue;
}
- final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
- entryList.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
+ final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
+ entryList.put(commandName, blockedCommandEntry);
if (command != null)
{
for (String alias : command.getAliases())
@@ -130,12 +140,6 @@ public class CommandBlocker extends FreedomService
// CommandBlocker handles messages and broadcasts
event.setCancelled(true);
}
-
- if (event.getMessage().contains("translation.test.invalid") || event.getMessage().contains("translation.test.invalid2"))
- {
- event.setCancelled(true);
- FUtil.playerMsg(event.getPlayer(), ChatColor.RED + "No crishy crashy faggy");
- }
}
public boolean isCommandBlocked(String command, CommandSender sender)
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java
index 384ea886..607ad49d 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java
@@ -10,7 +10,6 @@ import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
import me.totalfreedom.bukkittelnet.session.ClientSession;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
@@ -24,18 +23,13 @@ public class BukkitTelnetBridge extends FreedomService
private BukkitTelnet bukkitTelnetPlugin = null;
- public BukkitTelnetBridge(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java
index 98d94a0e..1665f317 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java
@@ -9,7 +9,6 @@ import java.sql.Statement;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.coreprotect.CoreProtect;
@@ -28,18 +27,13 @@ public class CoreProtectBridge extends FreedomService
private BukkitTask wiper;
- public CoreProtectBridge(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java
index 324c05f2..6cbedec7 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java
@@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.bridge;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
@@ -26,18 +25,13 @@ public class EssentialsBridge extends FreedomService
private Essentials essentialsPlugin = null;
- public EssentialsBridge(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java
index e6ff80d0..20cc105e 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java
@@ -2,10 +2,9 @@ package me.totalfreedom.totalfreedommod.bridge;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.LibsDisguises;
-import me.totalfreedom.libsdisguises.BlockedDisguises;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
+import me.libraryaddict.disguise.BlockedDisguises;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -14,18 +13,13 @@ public class LibsDisguisesBridge extends FreedomService
private LibsDisguises libsDisguisesPlugin = null;
- public LibsDisguisesBridge(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -120,6 +114,6 @@ public class LibsDisguisesBridge extends FreedomService
{
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
- return libsDisguises != null && libsDisguises.isEnabled();
+ return libsDisguises != null;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java
index 7e33051b..b254c1b4 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java
@@ -4,7 +4,6 @@ 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.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -15,18 +14,13 @@ public class WorldEditBridge extends FreedomService
//
private WorldEditPlugin worldeditPlugin = null;
- public WorldEditBridge(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java
index 364c9983..048f7ac3 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java
@@ -7,27 +7,20 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import java.util.Map;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.World;
import org.bukkit.plugin.Plugin;
public class WorldGuardBridge extends FreedomService
{
-
- public WorldGuardBridge(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java b/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java
index 4a4e8945..f006955c 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java
@@ -1,7 +1,6 @@
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 org.bukkit.ChatColor;
@@ -17,19 +16,13 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class Cager extends FreedomService
{
-
- public Cager(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java b/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java
index c0920815..02892679 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java
@@ -1,45 +1,59 @@
package me.totalfreedom.totalfreedommod.command;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
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 org.bukkit.ChatColor;
public class CommandLoader extends FreedomService
{
-
@Getter
- private final SimpleCommandHandler handler;
+ private final List commands;
- public CommandLoader(TotalFreedomMod plugin)
+ public CommandLoader()
{
- super(plugin);
-
- handler = new SimpleCommandHandler<>(plugin);
+ commands = new ArrayList<>();
}
@Override
- protected void onStart()
+ public void onStart()
{
- handler.clearCommands();
- handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory(plugin));
- handler.setCommandClassPrefix("Command_");
- handler.setPermissionMessage(ChatColor.RED + "You do not have permission to use this command.");
- handler.setOnlyConsoleMessage(ChatColor.RED + "This command can only be used from the console.");
- handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players.");
-
- handler.loadFrom(FreedomCommand.class.getPackage());
- handler.registerAll(plugin.getDescription().getName(), true);
-
- FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
}
@Override
- protected void onStop()
+ public void onStop()
{
- handler.clearCommands();
}
+ public void add(FreedomCommand command)
+ {
+ commands.add(command);
+ command.register();
+ }
+
+ public FreedomCommand getByName(String name)
+ {
+ for (FreedomCommand command : commands)
+ {
+ if (name.equals(command.getName()))
+ return command;
+ }
+ return null;
+ }
+
+ public boolean isAlias(String alias)
+ {
+ for (FreedomCommand command : commands)
+ {
+ if (Arrays.asList(command.getAliases().split(",")).contains(alias))
+ return true;
+ }
+ return false;
+ }
+
+ public int getCommandAmount()
+ {
+ return commands.size();
+ }
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java
index 120c1570..09a251e4 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java
@@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_announce.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_announce.java
index d22fb4f7..4abaf2b0 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_announce.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_announce.java
@@ -12,7 +12,7 @@ public class Command_announce extends FreedomCommand
{
@Override
- protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java
index f31cd46e..dce660e1 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java
@@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
@@ -74,7 +73,7 @@ public class Command_ban extends FreedomCommand
return true;
}
- username = entry.getUsername();
+ username = entry.getName();
ips.addAll(entry.getIps());
}
else
@@ -82,7 +81,7 @@ public class Command_ban extends FreedomCommand
final PlayerData entry = plugin.pl.getData(player);
username = player.getName();
//ips.addAll(entry.getIps());/
- ips.add(Ips.getIp(player));
+ ips.add(FUtil.getIp(player));
// Deop
player.setOp(false);
@@ -152,7 +151,7 @@ public class Command_ban extends FreedomCommand
player.kickPlayer(ban.bakeKickMessage());
for (Player p : Bukkit.getOnlinePlayers())
{
- if (Ips.getIp(p).equals(Ips.getIp(player)))
+ if (FUtil.getIp(p).equals(FUtil.getIp(player)))
{
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java
index 83125968..4eb70a01 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java
@@ -2,13 +2,13 @@ package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.List;
+import java.util.Random;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
-import java.util.Random;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/")
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 44d62109..2eda0ebc 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java
@@ -48,14 +48,6 @@ public class Command_cage extends FreedomCommand
final FPlayer fPlayer = plugin.pl.getPlayer(player);
- if (fPlayer.getCageData().isCaged())
- {
- FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
- final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
- playerdata.getCageData().setCaged(false);
- return true;
- }
-
Material outerMaterial = Material.GLASS;
Material innerMaterial = Material.AIR;
if (args.length >= 2 && args[1] != null)
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearchat.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearchat.java
index 3db4e552..1fee90d2 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearchat.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearchat.java
@@ -1,16 +1,12 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.stream.IntStream;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
+@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Clears the chat for players who are not opt-out.", usage = "/", aliases = "cc")
public class Command_clearchat extends FreedomCommand
{
@@ -19,51 +15,12 @@ public class Command_clearchat extends FreedomCommand
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (plugin.al.isAdmin(playerSender))
+ for (Player player : server.getOnlinePlayers())
{
- for (Player player : server.getOnlinePlayers())
+ if (!plugin.al.isAdmin(player))
{
- boolean optedOut = false;
-
- if (plugin.al.isAdmin(player))
- {
- optedOut = true;
- }
- else if (plugin.mbl.isMasterBuilder(player) && plugin.mbl.getMasterBuilder(player).isClearChatOptOut())
- {
- optedOut = true;
- }
- else if (plugin.pv.getVerificationPlayer(player).getEnabled() && plugin.pv.getVerificationPlayer(player).isClearChatOptOut())
- {
- optedOut = true;
- }
-
- if (!optedOut)
- {
- IntStream.range(0, 100).mapToObj(i -> "").forEach(player::sendMessage);
- }
+ IntStream.range(0, 100).mapToObj(i -> "").forEach(player::sendMessage);
}
- FUtil.adminAction(sender.getName(), "Cleared chat", true);
- }
- else if (plugin.mbl.isMasterBuilder(playerSender))
- {
- MasterBuilder mb = plugin.mbl.getMasterBuilder(playerSender);
- mb.setClearChatOptOut(!mb.isClearChatOptOut());
- msg((mb.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
- plugin.mbl.save();
- plugin.mbl.updateTables();
- }
- else if (plugin.pv.getVerificationPlayer(playerSender).getEnabled())
- {
- VPlayer vp = plugin.pv.getVerificationPlayer(playerSender);
- vp.setClearChatOptOut(!vp.isClearChatOptOut());
- msg((vp.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
- plugin.pv.saveVerificationData(vp);
- return true;
- }
- else
- {
- msg("Only Master Builders, admins, and players with verification enabled can opt-out of clear chat.", ChatColor.RED);
}
return true;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java
index 1c22b100..f005d52f 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java
@@ -67,7 +67,7 @@ public class Command_clearinventory extends FreedomCommand
@Override
public List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
- if (args.length == 1 && plugin.al.isAdmin(playerSender))
+ if (args.length == 1 && plugin.al.isAdmin(sender))
{
List players = FUtil.getPlayerList();
players.add("-a");
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java
new file mode 100644
index 00000000..11338c59
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java
@@ -0,0 +1,29 @@
+package me.totalfreedom.totalfreedommod.command;
+
+import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.shop.ShopItem;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
+@CommandParameters(description = "Obtain a clown fish", usage = "/")
+public class Command_clownfish extends FreedomCommand
+{
+
+ @Override
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ {
+ if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH))
+ {
+ playerSender.getInventory().addItem(plugin.sh.getClownFish());
+ msg("You have been given a Clown Fish", ChatColor.GREEN);
+ }
+ else
+ {
+ msg("You do not own a Clown Fish! Purchase one from the shop.", ChatColor.RED);
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java
index d5b12c38..36bf5758 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java
@@ -1,16 +1,16 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.util.FUtil;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.shop.ShopData;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
-@CommandParameters(description = "Shows the amount of coins you have or another player", usage = "/ [playername]")
+@CommandParameters(description = "Shows the amount of coins you have or another player has", usage = "/ [playername]")
public class Command_coins extends FreedomCommand
{
@@ -48,8 +48,8 @@ public class Command_coins extends FreedomCommand
p = playerSender;
}
}
- ShopData sd = plugin.sh.getData(p);
- msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
+ PlayerData playerData = plugin.pl.getData(p);
+ msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
return true;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java
index e49cc3d7..745e20ed 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java
@@ -1,10 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
-import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cuck.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cuck.java
deleted file mode 100644
index ea1598b5..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cuck.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package me.totalfreedom.totalfreedommod.command;
-
-import java.util.Collections;
-import java.util.List;
-import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.ChatColor;
-
-@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
-@CommandParameters(description = "Cuck someone - sends an unclearable title to the specified player.", usage = "/ ")
-public class Command_cuck extends FreedomCommand
-{
-
- @Override
- public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (FUtil.isPaper())
- {
- msg("This command won't work on Paper!", ChatColor.RED);
- return true;
- }
-
- if (args.length == 0)
- {
- return false;
- }
-
- final Player player = getPlayer(args[0]);
-
- if (player == null)
- {
- msg(FreedomCommand.PLAYER_NOT_FOUND);
- return true;
- }
-
- player.remove();
- msg("Cucked " + player.getName());
- player.sendTitle(ChatColor.DARK_RED + "HAHA CUCKED", ChatColor.RED + "relog if u want to be uncucked loser", 20, 200, 60);
- return true;
- }
-
- @Override
- public List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
- {
- if (args.length == 1 && plugin.al.isAdmin(sender))
- {
- return FUtil.getPlayerList();
- }
- return Collections.emptyList();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_curse.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_curse.java
index a8bdfa74..c17b9eea 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_curse.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_curse.java
@@ -4,10 +4,10 @@ import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
+import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.ChatColor;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Curse someone - sends a cursed texture pack to the specified player.", usage = "/ ")
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java
index 99482fdf..64121cf0 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java
@@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
-import me.totalfreedom.libsdisguises.BlockedDisguises;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
@@ -21,7 +20,7 @@ public class Command_disguisetoggle extends FreedomCommand
return true;
}
- FUtil.adminAction(sender.getName(), (BlockedDisguises.disabled ? "Enabling" : "Disabling") + " disguises", false);
+ FUtil.adminAction(sender.getName(), (plugin.ldb.isDisguisesEnabled() ? "Disabling" : "Enabling") + " disguises", false);
if (plugin.ldb.isDisguisesEnabled())
{
@@ -33,7 +32,7 @@ public class Command_disguisetoggle extends FreedomCommand
plugin.ldb.setDisguisesEnabled(true);
}
- msg("Disguises are now " + (BlockedDisguises.disabled ? "disabled." : "enabled."));
+ msg("Disguises are now " + (plugin.ldb.isDisguisesEnabled() ? "enabled." : "disabled."));
return true;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_donator.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_donator.java
new file mode 100644
index 00000000..1c352851
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_donator.java
@@ -0,0 +1,87 @@
+package me.totalfreedom.totalfreedommod.command;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
+import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.util.FLog;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
+@CommandParameters(description = "Adds or removes donators", usage = "/ [forum_user]")
+public class Command_donator extends FreedomCommand
+{
+
+ @Override
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ {
+ if (!FUtil.isFromHostConsole(sender.getName()) && !ConfigEntry.SERVER_OWNERS.getStringList().contains(sender.getName()))
+ {
+ return noPerms();
+ }
+
+ Boolean mode = args[0].equals("add");
+ String name = args[1];
+ String ip = args[2];
+ String pkg = args[3];
+ String forum_id = null;
+
+ if (args.length > 4)
+ {
+ forum_id = args[4];
+ }
+
+ PlayerData data = plugin.pl.getData(name);
+
+ if (data == null)
+ {
+ data = plugin.pl.getDataByIp(ip);
+ }
+
+ if (data != null)
+ {
+ data.setDonator(mode);
+ plugin.pl.save(data);
+ }
+
+ Player player = getPlayer(name);
+
+ if (player != null)
+ {
+ plugin.rm.updateDisplay(player);
+ }
+
+ if (forum_id != null && !forum_id.equals("0"))
+ {
+ String baseurl = ConfigEntry.DONATION_PROBOARDS_URL.getString();
+ String group_id = ConfigEntry.DONATION_GROUP_ID.getString();
+ String session_id = ConfigEntry.DONATION_SESSION_ID.getString();
+ String csrf_token = ConfigEntry.DONATION_CSRF_TOKEN.getString();
+ if (baseurl == null || group_id == null || session_id == null || csrf_token == null)
+ {
+ return true;
+ }
+ String url = baseurl + "/user/group_members/" + (mode ? "adding" : "remove");
+ List headers = Arrays.asList("Cookie:session_id=" + session_id, "X-Requested-With:XMLHttpRequest");
+ String payload = "group_id=" + group_id + "&user_ids[]=" + forum_id + "&csrf_token=" + csrf_token;
+
+ try
+ {
+ String result = FUtil.postRequestToEndpoint(url, "POST", headers, payload);
+ msg(result);
+ }
+ catch (IOException e)
+ {
+ FLog.severe(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java
index 3c0a9e50..dbcac1e9 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java
@@ -7,8 +7,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
@@ -55,7 +53,7 @@ public class Command_doom extends FreedomCommand
plugin.al.updateTables();
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
{
- plugin.dc.syncRoles(admin);
+ plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
}
}
@@ -100,7 +98,7 @@ public class Command_doom extends FreedomCommand
final String kickReason = (reason == null ? "FUCKOFF, and get your shit together!" : reason);
// Log doom
- plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.DOOM, reason));
+ plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.DOOM, reason));
new BukkitRunnable()
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java
index 105cb105..a431abf7 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java
@@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java
index 2c6e9a99..ef4068b1 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java
@@ -4,12 +4,11 @@ import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.ChatColor;
-import org.bukkit.Particle;
-import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.util.Vector;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Surprise someone.", usage = "/ ")
@@ -32,10 +31,26 @@ public class Command_explode extends FreedomCommand
return true;
}
- msg("Exploded " + player.getName());
- player.setHealth(0.0);
- player.getWorld().createExplosion(player.getLocation(), 0F, false);
-
+ player.setFlying(false);
+ player.setVelocity(player.getVelocity().clone().add(new Vector(0, 50, 0)));
+ for (int i = 1; i <= 3; i++)
+ {
+ FUtil.createExplosionOnDelay(player.getLocation(), 2L, i * 10);
+ }
+ new BukkitRunnable()
+ {
+ @Override
+ public void run()
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ player.getWorld().strikeLightning(player.getLocation());
+ player.getWorld().createExplosion(player.getLocation(), 4L);
+ }
+ player.setHealth(0.0);
+ msg("Exploded " + player.getName());
+ }
+ }.runTaskLater(plugin, 40);
return true;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java
index 8cd14f59..e5366424 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java
@@ -15,7 +15,7 @@ public class Command_fireball extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (plugin.sh.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
+ if (plugin.pl.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
{
playerSender.getInventory().addItem(plugin.sh.getFireBall());
msg("You have been given a Fire Ball", ChatColor.GREEN);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gadmin.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gadmin.java
deleted file mode 100644
index 3cb8547c..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gadmin.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package me.totalfreedom.totalfreedommod.command;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Iterator;
-import java.util.UUID;
-import me.totalfreedom.totalfreedommod.banning.Ban;
-import me.totalfreedom.totalfreedommod.freeze.FreezeData;
-import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.ChatColor;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
-@CommandParameters(
- description = "Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci, fr, smite.",
- usage = "/ [list | [ ] ]")
-//codebeat:disable
-//basically a deprecated command that still exists
-public class Command_gadmin extends FreedomCommand
-{
-
- private enum GadminMode
- {
-
- LIST("list"),
- KICK("kick"),
- NAMEBAN("nameban"),
- IPBAN("ipban"),
- BAN("ban"),
- OP("op"),
- DEOP("deop"),
- CI("ci"),
- FR("fr"),
- SMITE("smite");
- private final String modeName;
-
- private GadminMode(String command)
- {
- this.modeName = command;
- }
-
- public String getModeName()
- {
- return modeName;
- }
-
- public static GadminMode findMode(String needle)
- {
- for (final GadminMode mode : GadminMode.values())
- {
- if (needle.equalsIgnoreCase(mode.getModeName()))
- {
- return mode;
- }
- }
- return null;
- }
- }
-
- public String getPlayerHash(Player player)
- {
- return UUID.nameUUIDFromBytes(player.getName().toLowerCase().getBytes(StandardCharsets.UTF_8)).toString().substring(0, 4);
- }
-
- @Override
- public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (args.length == 0)
- {
- return false;
- }
-
- final GadminMode mode = GadminMode.findMode(args[0].toLowerCase());
- if (mode == null)
- {
- msg("Invalid mode: " + args[0], ChatColor.RED);
- return true;
- }
-
- final Iterator extends Player> it = server.getOnlinePlayers().iterator();
-
- if (mode == GadminMode.LIST)
- {
- msg("[ Real Name ] : [ Display Name ] - Hash:");
- while (it.hasNext())
- {
- final Player player = it.next();
- sender.sendMessage(ChatColor.GRAY + String.format("[ %s ] : [ %s ] - %s",
- player.getName(),
- ChatColor.stripColor(player.getDisplayName()),
- getPlayerHash(player)));
- }
- return true;
- }
-
- if (args.length < 2)
- {
- return false;
- }
-
- Player target = null;
- while (it.hasNext() && target == null)
- {
- final Player player = it.next();
- final String hash = getPlayerHash(player);
-
- if (hash.equalsIgnoreCase(args[1]))
- {
- target = player;
- }
- }
-
- if (target == null)
- {
- msg("Invalid player hash: " + args[1], ChatColor.RED);
- return true;
- }
-
- switch (mode)
- {
- case KICK:
- {
- FUtil.adminAction(sender.getName(), String.format("Kicking: %s.", target.getName()), false);
- target.kickPlayer("Kicked by Administrator");
-
- break;
- }
- case NAMEBAN:
- {
- FUtil.adminAction(sender.getName(), String.format("Banning Name: %s.", target.getName()), true);
- plugin.bm.addBan(Ban.forPlayerName(target, sender, null, null));
- target.kickPlayer("Username banned by Administrator.");
-
- break;
- }
- case IPBAN:
- {
- String ip = target.getAddress().getAddress().getHostAddress();
- String[] ip_parts = ip.split("\\.");
- if (ip_parts.length == 4)
- {
- ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
- }
- FUtil.adminAction(sender.getName(), String.format("Banning IP: %s.", ip), true);
- plugin.bm.addBan(Ban.forPlayerIp(ip, sender, null, null));
-
- target.kickPlayer("IP address banned by Administrator.");
-
- break;
- }
- case BAN:
- {
- String ip = target.getAddress().getAddress().getHostAddress();
- String[] ip_parts = ip.split("\\.");
- if (ip_parts.length == 4)
- {
- ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
- }
- FUtil.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", target.getName(), ip), true);
-
- plugin.bm.addBan(Ban.forPlayer(target, sender));
-
- target.kickPlayer("IP and username banned by Administrator.");
-
- break;
- }
- case OP:
- {
- FUtil.adminAction(sender.getName(), String.format("Opping %s.", target.getName()), false);
- target.setOp(true);
- target.sendMessage(FreedomCommand.YOU_ARE_OP);
-
- break;
- }
- case DEOP:
- {
- FUtil.adminAction(sender.getName(), String.format("Deopping %s.", target.getName()), false);
- target.setOp(false);
- target.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
-
- break;
- }
- case CI:
- {
- target.getInventory().clear();
-
- break;
- }
- case FR:
- {
- FreezeData fd = plugin.pl.getPlayer(target).getFreezeData();
- fd.setFrozen(!fd.isFrozen());
-
- msg(target.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
- target.sendMessage(ChatColor.AQUA + "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
-
- break;
- }
- case SMITE:
- {
- Command_smite.smite(sender, target);
-
- break;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glist.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glist.java
index 24cb91c0..cf634396 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glist.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glist.java
@@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -25,25 +24,6 @@ public class Command_glist extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (args.length < 1)
- {
- return false;
- }
-
- if (args.length == 1)
- {
- if ("purge".equals(args[0]))
- {
- checkRank(Rank.SENIOR_ADMIN);
- plugin.pl.purgeAllData();
- msg("Purged playerbase.");
-
- return true;
- }
-
- return false;
- }
-
if (args.length < 2)
{
return false;
@@ -71,13 +51,13 @@ public class Command_glist extends FreedomCommand
return true;
}
- username = entry.getUsername();
+ username = entry.getName();
ips.addAll(entry.getIps());
}
else
{
final PlayerData entry = plugin.pl.getData(player);
- username = entry.getUsername();
+ username = entry.getName();
ips.addAll(entry.getIps());
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java
new file mode 100644
index 00000000..62100467
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java
@@ -0,0 +1,32 @@
+package me.totalfreedom.totalfreedommod.command;
+
+import me.totalfreedom.totalfreedommod.rank.Rank;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
+
+@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
+@CommandParameters(description = "Toggles the glowing outline effect because y'all lazy as fuck", usage = "/")
+public class Command_glow extends FreedomCommand
+{
+
+ @Override
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ {
+ boolean glowing = false;
+ if (playerSender.getPotionEffect(PotionEffectType.GLOWING) != null)
+ {
+ playerSender.removePotionEffect(PotionEffectType.GLOWING);
+ }
+ else
+ {
+ PotionEffect glow = new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false);
+ playerSender.addPotionEffect(glow);
+ glowing = true;
+ }
+ msg("You " + (glowing ? "are now" : "no longer") + " glowing.");
+ return true;
+ }
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java
index c423ab3e..5ee72d2e 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java
@@ -15,7 +15,7 @@ public class Command_grapplinghook extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (plugin.sh.getData(playerSender).hasItem(ShopItem.GRAPPLING_HOOK))
+ if (plugin.pl.getData(playerSender).hasItem(ShopItem.GRAPPLING_HOOK))
{
playerSender.getInventory().addItem(plugin.sh.getGrapplingHook());
msg("You have been given a Grappling Hook", ChatColor.GREEN);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java
index a63f66af..1f6e7faf 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java
@@ -1,16 +1,10 @@
package me.totalfreedom.totalfreedommod.command;
-import com.google.common.collect.ContiguousSet;
-import com.google.common.collect.DiscreteDomain;
-import com.google.common.collect.Range;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Set;
-import java.util.stream.DoubleStream;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java
index c5515873..4b8edaf2 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java
@@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -16,7 +15,7 @@ import org.bukkit.entity.Player;
public class Command_kick extends FreedomCommand
{
@Override
- protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
@@ -53,7 +52,7 @@ public class Command_kick extends FreedomCommand
player.kickPlayer(builder.toString());
- plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.KICK, reason));
+ plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.KICK, reason));
return true;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java
index 358a188c..ee2ffd8a 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java
@@ -15,7 +15,7 @@ public class Command_lightningrod extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (plugin.sh.getData(playerSender).hasItem(ShopItem.LIGHTNING_ROD))
+ if (plugin.pl.getData(playerSender).hasItem(ShopItem.LIGHTNING_ROD))
{
playerSender.getInventory().addItem(plugin.sh.getLightningRod());
msg("You have been given a Lightning Rod", ChatColor.GREEN);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java
index 3d17eb49..41d9d809 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java
@@ -1,9 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
-import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.discord.Discord;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -11,7 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Link your Discord account to your Minecraft account", usage = "/")
+@CommandParameters(description = "Link your Discord account to your Minecraft account", usage = "/ [ ]")
public class Command_linkdiscord extends FreedomCommand
{
@@ -24,64 +22,37 @@ public class Command_linkdiscord extends FreedomCommand
return true;
}
+ if (args.length > 1 && plugin.al.isAdmin(playerSender))
+ {
+ PlayerData playerData = plugin.pl.getData(args[0]);
+ if (playerData == null)
+ {
+ msg(PLAYER_NOT_FOUND);
+ return true;
+ }
+
+ playerData.setDiscordID(args[1]);
+ msg("Linked " + args[0] + "'s discord account.", ChatColor.GREEN);
+ return true;
+ }
+
String code;
- if (plugin.al.isAdmin(playerSender))
+ PlayerData data = plugin.pl.getData(playerSender);
+ if (data.getDiscordID() != null)
{
- Admin admin = plugin.al.getAdmin(playerSender);
- if (admin.getDiscordID() != null)
- {
- msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
- return true;
- }
-
- if (Discord.ADMIN_LINK_CODES.containsValue(admin))
- {
- code = Discord.getCodeForAdmin(admin);
- }
- else
- {
- code = plugin.dc.generateCode(5);
- Discord.ADMIN_LINK_CODES.put(code, admin);
- }
+ msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
+ return true;
}
- else if (plugin.mbl.isMasterBuilder(playerSender))
- {
- MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(playerSender);
- if (masterBuilder.getDiscordID() != null)
- {
- msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
- return true;
- }
- if (Discord.MASTER_BUILDER_LINK_CODES.containsValue(masterBuilder))
- {
- code = Discord.getCodeForMasterBuilder(masterBuilder);
- }
- else
- {
- code = plugin.dc.generateCode(5);
- Discord.MASTER_BUILDER_LINK_CODES.put(code, masterBuilder);
- }
+ if (Discord.LINK_CODES.containsValue(data))
+ {
+ code = Discord.getCode(data);
}
else
{
- VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
- if (data.getDiscordId() != null)
- {
- msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
- return true;
- }
-
- if (Discord.PLAYER_LINK_CODES.containsValue(data))
- {
- code = Discord.getCodeForPlayer(data);
- }
- else
- {
- code = plugin.dc.generateCode(5);
- Discord.PLAYER_LINK_CODES.put(code, data);
- }
+ code = plugin.dc.generateCode(5);
+ Discord.LINK_CODES.put(code, data);
}
msg("Your linking code is " + ChatColor.AQUA + code, ChatColor.GREEN);
msg("Take this code and DM the server bot (" + plugin.dc.formatBotTag() + ") the code (do not put anything else in the message, only the code)");
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java
index c1d2efa0..5bd21b6d 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java
@@ -16,7 +16,7 @@ import org.bukkit.entity.Player;
public class Command_links extends FreedomCommand
{
@Override
- protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
YamlConfiguration config = plugin.config.configuration;
ConfigurationSection section = config.getConfigurationSection("social_links");
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java
index cf5c9e34..64b6ac07 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java
@@ -7,10 +7,9 @@ import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.md_5.bungee.api.ChatColor;
import org.apache.commons.lang.StringUtils;
-import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java
index a7b65792..95945e16 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.shop.ShopData;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
@@ -48,21 +48,21 @@ public class Command_manageshop extends FreedomCommand
msg(PLAYER_NOT_FOUND);
return true;
}
- ShopData shopData = plugin.sh.getData(player);
- shopData.setCoins(shopData.getCoins() + amount);
- plugin.sh.save(shopData);
- msg("Successfully added " + amount + " coins to " + player.getName() + ". Their new balance is " + shopData.getCoins(), ChatColor.GREEN);
- player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + shopData.getCoins());
+ PlayerData playerData = plugin.pl.getData(player);
+ playerData.setCoins(playerData.getCoins() + amount);
+ plugin.pl.save(playerData);
+ msg("Successfully added " + amount + " coins to " + player.getName() + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
+ player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
return true;
}
else
{
for (Player player : server.getOnlinePlayers())
{
- ShopData shopData = plugin.sh.getData(player);
- shopData.setCoins(shopData.getCoins() + amount);
- plugin.sh.save(shopData);
- player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + shopData.getCoins());
+ PlayerData playerData = plugin.pl.getData(player);
+ playerData.setCoins(playerData.getCoins() + amount);
+ plugin.pl.save(playerData);
+ player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
}
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
return true;
@@ -85,29 +85,29 @@ public class Command_manageshop extends FreedomCommand
msg(PLAYER_NOT_FOUND);
return true;
}
- ShopData shopData = plugin.sh.getData(player);
- shopData.setCoins(shopData.getCoins() + amount);
- if (shopData.getCoins() < 0)
+ PlayerData playerData = plugin.pl.getData(player);
+ playerData.setCoins(playerData.getCoins() + amount);
+ if (playerData.getCoins() < 0)
{
- shopData.setCoins(0);
+ playerData.setCoins(0);
}
- plugin.sh.save(shopData);
- msg("Successfully removed " + amount + " coins from " + player.getName() + ". Their new balance is " + shopData.getCoins(), ChatColor.GREEN);
- player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + shopData.getCoins());
+ plugin.pl.save(playerData);
+ msg("Successfully removed " + amount + " coins from " + player.getName() + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
+ player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
return true;
}
else
{
for (Player player : server.getOnlinePlayers())
{
- ShopData shopData = plugin.sh.getData(player);
- shopData.setCoins(shopData.getCoins() - amount);
- if (shopData.getCoins() < 0)
+ PlayerData playerData = plugin.pl.getData(player);
+ playerData.setCoins(playerData.getCoins() - amount);
+ if (playerData.getCoins() < 0)
{
- shopData.setCoins(0);
+ playerData.setCoins(0);
}
- plugin.sh.save(shopData);
- player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + shopData.getCoins());
+ plugin.pl.save(playerData);
+ player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
}
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
return true;
@@ -128,9 +128,9 @@ public class Command_manageshop extends FreedomCommand
msg(PLAYER_NOT_FOUND);
return true;
}
- ShopData shopData = plugin.sh.getData(player);
- shopData.setCoins(amount);
- plugin.sh.save(shopData);
+ PlayerData playerData = plugin.pl.getData(player);
+ playerData.setCoins(amount);
+ plugin.pl.save(playerData);
msg("Successfully set " + player.getName() + "'s coins to " + amount, ChatColor.GREEN);
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount);
return true;
@@ -171,9 +171,9 @@ public class Command_manageshop extends FreedomCommand
return true;
}
- ShopData shopData = plugin.sh.getData(player);
- shopData.giveItem(item);
- plugin.sh.save(shopData);
+ PlayerData playerData = plugin.pl.getData(player);
+ playerData.giveItem(item);
+ plugin.pl.save(playerData);
msg("Successfully gave the " + item.getName() + " to " + player.getName(), ChatColor.GREEN);
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you");
return true;
@@ -194,9 +194,9 @@ public class Command_manageshop extends FreedomCommand
return true;
}
- ShopData shopData = plugin.sh.getData(player);
- shopData.removeItem(item);
- plugin.sh.save(shopData);
+ PlayerData playerData = plugin.pl.getData(player);
+ playerData.removeItem(item);
+ plugin.pl.save(playerData);
msg("Successfully took the " + item.getName() + " from " + player.getName(), ChatColor.GREEN);
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you");
return true;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manuallyverify.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manuallyverify.java
new file mode 100644
index 00000000..8141e729
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manuallyverify.java
@@ -0,0 +1,57 @@
+package me.totalfreedom.totalfreedommod.command;
+
+import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
+@CommandParameters(description = "Manually verify someone", usage = "/ ", aliases="mv")
+public class Command_manuallyverify extends FreedomCommand
+{
+ @Override
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ {
+
+ if (!plugin.dc.enabled)
+ {
+ msg("The Discord verification system is currently disabled", ChatColor.RED);
+ return true;
+ }
+
+ if (args.length == 0)
+ {
+ return false;
+ }
+
+ final Player player = getPlayer(args[0]);
+ if (player == null)
+ {
+ msg(FreedomCommand.PLAYER_NOT_FOUND);
+ return true;
+ }
+
+ if (!plugin.pl.isImposter(player))
+ {
+ msg("That player is not an impostor.");
+ return true;
+ }
+
+ FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
+ player.setOp(true);
+ player.sendMessage(YOU_ARE_OP);
+
+ if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
+ {
+ plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
+ player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
+ }
+
+ plugin.pl.verify(player, null);
+ plugin.rm.updateDisplay(player);
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_massmurder.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_massmurder.java
new file mode 100644
index 00000000..e5ed5857
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_massmurder.java
@@ -0,0 +1,42 @@
+package me.totalfreedom.totalfreedommod.command;
+
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.rank.Rank;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
+@CommandParameters(description = "seth's personal command", usage = "/ ", aliases = "genocide")
+public class Command_massmurder extends FreedomCommand
+{
+
+ @Override
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ {
+ if (!ConfigEntry.SERVER_OWNERS.getStringList().contains(playerSender.getName()))
+ {
+ return noPerms();
+ }
+
+ if (args.length < 1)
+ {
+ return false;
+ }
+
+ int count = 0;
+ for (String name : args)
+ {
+ Player player = getPlayer(name);
+ if (player != null)
+ {
+ player.setHealth(0);
+ count++;
+ }
+ }
+
+ msg("Mass murdered a school of " + count);
+
+ return true;
+ }
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java
index 8a8547ba..b3d02757 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java
@@ -4,7 +4,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.world.WorldTime;
import me.totalfreedom.totalfreedommod.world.WorldWeather;
import org.bukkit.World;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java
index 7e7c6371..c140d0f8 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java
@@ -1,23 +1,19 @@
package me.totalfreedom.totalfreedommod.command;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-@CommandPermissions(level = Rank.OP, source = SourceType.BOTH, blockHostConsole = true)
-@CommandParameters(description = "List, add, or remove master builders, reload the master builder list, or view the info of master builders.", usage = "/ >")
+@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
+@CommandParameters(description = "List, add, or remove master builders, reload the master builder list, or view the info of master builders.", usage = "/ >>")
public class Command_mbconfig extends FreedomCommand
{
@@ -33,50 +29,7 @@ public class Command_mbconfig extends FreedomCommand
{
case "list":
{
- msg("Master Builders: " + StringUtils.join(plugin.mbl.getMasterBuilderNames(), ", "), ChatColor.GOLD);
-
- return true;
- }
-
- case "reload":
- {
- checkRank(Rank.SENIOR_ADMIN);
-
- FUtil.adminAction(sender.getName(), "Reloading the Master Builder list", true);
- plugin.mbl.load();
- msg("Master Builder list reloaded!");
- return true;
- }
-
- case "info":
- {
- if (args.length < 2)
- {
- return false;
- }
-
- checkRank(Rank.SUPER_ADMIN);
-
- MasterBuilder masterBuilder = plugin.mbl.getEntryByName(args[1]);
-
- if (masterBuilder == null)
- {
- final Player player = getPlayer(args[1]);
- if (player != null)
- {
- masterBuilder = plugin.mbl.getMasterBuilder(player);
- }
- }
-
- if (masterBuilder == null)
- {
- msg("Master Builder not found: " + args[1]);
- }
- else
- {
- msg(masterBuilder.toString());
- }
-
+ msg("Master Builders: " + StringUtils.join(plugin.pl.getMasterBuilderNames(), ", "), ChatColor.GOLD);
return true;
}
@@ -87,89 +40,43 @@ public class Command_mbconfig extends FreedomCommand
return false;
}
- checkConsole();
- checkRank(Rank.TELNET_ADMIN);
+ if (!plugin.pl.canManageMasterBuilders(sender.getName()))
+ {
+ return noPerms();
+ }
- // Player already on the list?
final Player player = getPlayer(args[1]);
- if (player != null && plugin.mbl.isMasterBuilder(player))
+ PlayerData data = plugin.pl.getData(player);
+
+ if (data.isMasterBuilder() && plugin.pl.isPlayerImpostor(player))
+ {
+ FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the Master Builder list", true);
+ player.setOp(true);
+ player.sendMessage(YOU_ARE_OP);
+
+ if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
+ {
+ plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
+ player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
+ }
+ plugin.pl.verify(player, null);
+ plugin.rm.updateDisplay(player);
+ }
+ else if (!data.isMasterBuilder())
+ {
+ FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the Master Builder list", true);
+ data.setMasterBuilder(true);
+ data.setVerification(true);
+ plugin.pl.save(data);
+ plugin.rm.updateDisplay(player);
+ return true;
+ }
+ else
{
msg("That player is already on the Master Builder list.");
return true;
}
-
- // Find the entry
- String name = player != null ? player.getName() : args[1];
- MasterBuilder masterBuilder = null;
- for (MasterBuilder loopMasterBuilder : plugin.mbl.getAllMasterBuilders().values())
- {
- if (loopMasterBuilder.getName().equalsIgnoreCase(name))
- {
- masterBuilder = loopMasterBuilder;
- break;
- }
- }
-
- if (masterBuilder == null) // New entry
- {
- checkRank(Rank.SENIOR_ADMIN);
- if (!FUtil.canManageMasterBuilders(sender.getName()))
- {
- noPerms();
- }
-
- if (player == null)
- {
- msg(FreedomCommand.PLAYER_NOT_FOUND);
- return true;
- }
-
- FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the Master Builder list", true);
- plugin.mbl.addMasterBuilder(new MasterBuilder(player));
- if (player != null)
- {
- plugin.rm.updateDisplay(player);
- }
- }
- else // Existing admin
- {
- FUtil.adminAction(sender.getName(), "Readding " + masterBuilder.getName() + " to the Master Builder list", true);
-
- if (player != null)
- {
- masterBuilder.setName(player.getName());
- masterBuilder.addIp(Ips.getIp(player));
- }
-
- masterBuilder.setLastLogin(new Date());
-
- plugin.mbl.save();
- plugin.mbl.updateTables();
- if (player != null)
- {
- plugin.rm.updateDisplay(player);
- }
- }
-
- if (player != null)
- {
- final FPlayer fPlayer = plugin.pl.getPlayer(player);
- if (fPlayer.getFreezeData().isFrozen())
- {
- fPlayer.getFreezeData().setFrozen(false);
- msg(player.getPlayer(), "You have been unfrozen.");
- }
-
- if (!player.isOp())
- {
- player.setOp(true);
- player.sendMessage(YOU_ARE_OP);
- }
- plugin.pv.removeEntry(player.getName()); // master builders can't have player verification entries
- }
- return true;
}
-
case "remove":
{
if (args.length < 2)
@@ -177,28 +84,28 @@ public class Command_mbconfig extends FreedomCommand
return false;
}
- checkConsole();
- checkRank(Rank.SENIOR_ADMIN);
- if (!FUtil.canManageMasterBuilders(sender.getName()))
+ if (!plugin.pl.canManageMasterBuilders(sender.getName()))
{
- noPerms();
+ return noPerms();
}
Player player = getPlayer(args[1]);
- MasterBuilder masterBuilder = player != null ? plugin.mbl.getMasterBuilder(player) : plugin.mbl.getEntryByName(args[1]);
+ PlayerData data = plugin.pl.getData(player);
- if (masterBuilder == null)
+ if (!data.isMasterBuilder())
{
msg("Master Builder not found: " + args[1]);
return true;
}
- FUtil.adminAction(sender.getName(), "Removing " + masterBuilder.getName() + " from the Master Builder list", true);
- plugin.mbl.removeMasterBuilder(masterBuilder);
- if (player != null)
+ FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
+ data.setMasterBuilder(false);
+ if (data.getDiscordID() == null)
{
- plugin.rm.updateDisplay(player);
+ data.setVerification(false);
}
+ plugin.pl.save(data);
+ plugin.rm.updateDisplay(player);
return true;
}
@@ -211,39 +118,21 @@ public class Command_mbconfig extends FreedomCommand
@Override
public List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
- if (sender instanceof Player)
+ if (args.length == 1)
{
- if (args.length == 1)
- {
- List arguments = new ArrayList<>();
- arguments.add("list");
- if (plugin.al.isAdmin(sender))
- {
- arguments.add("info");
- }
- return arguments;
- }
- else if (args.length == 2 && args[0].equals("info") && plugin.al.isAdmin(sender))
- {
- return plugin.al.getActiveAdminNames();
- }
- return Collections.emptyList();
+ return Arrays.asList("add", "remove", "list");
}
- else
+ else if (args.length == 2)
{
- if (args.length == 1)
+ if (args[0].equals("add"))
{
- return Arrays.asList("add", "remove", "reload", "list", "info");
+ return FUtil.getPlayerList();
}
- else if (args.length == 2)
+ else if (args[0].equals("remove"))
{
- if (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info"))
- {
- return FUtil.getPlayerList();
- }
+ return plugin.pl.getMasterBuilderNames();
}
}
-
return Collections.emptyList();
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java
index 8c788dcb..75d81ba9 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java
@@ -4,15 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.minecraft.server.v1_15_R1.NBTTagCompound;
-import net.minecraft.server.v1_15_R1.NBTTagInt;
-import net.minecraft.server.v1_15_R1.NBTTagList;
-import net.minecraft.server.v1_15_R1.NBTTagString;
+import net.minecraft.server.v1_16_R1.NBTTagCompound;
+import net.minecraft.server.v1_16_R1.NBTTagList;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
-import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -189,7 +186,7 @@ public class Command_modifyitem extends FreedomCommand
return true;
}
- private NBTTagList getAttributeList(net.minecraft.server.v1_15_R1.ItemStack stack)
+ private NBTTagList getAttributeList(net.minecraft.server.v1_16_R1.ItemStack stack)
{
if (stack.getTag() == null)
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java
index 898dd696..6a79f1ae 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java
@@ -9,7 +9,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
@@ -153,7 +152,7 @@ public class Command_mute extends FreedomCommand
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
msg("Muted " + player.getName());
- plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.MUTE, reason));
+ plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.MUTE, reason));
}
else
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java
index c1bcff31..5ad14123 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java
@@ -6,9 +6,9 @@ import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -16,12 +16,12 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Manage your admin entry.", usage = "/ [-o ] | setlogin | clearlogin | setacformat | clearacformat> | oldtags | logstick | syncroles | genbackupcodes>")
+@CommandParameters(description = "Manage your admin entry.", usage = "/ [-o ] | setlogin | clearlogin | setacformat | clearacformat> | oldtags | logstick | syncroles>")
public class Command_myadmin extends FreedomCommand
{
@Override
- protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
@@ -59,7 +59,7 @@ public class Command_myadmin extends FreedomCommand
}
}
- final String targetIp = Ips.getIp(targetPlayer);
+ final String targetIp = FUtil.getIp(targetPlayer);
switch (args[0])
{
@@ -86,6 +86,8 @@ public class Command_myadmin extends FreedomCommand
plugin.al.save(target);
plugin.al.updateTables();
+ plugin.pl.syncIps(target);
+
msg(counter + " IPs removed.");
msg(targetPlayer, target.getIps().get(0) + " is now your only IP address");
return true;
@@ -130,6 +132,8 @@ public class Command_myadmin extends FreedomCommand
plugin.al.save(target);
plugin.al.updateTables();
+ plugin.pl.syncIps(target);
+
msg("Removed IP " + args[1]);
msg("Current IPs: " + StringUtils.join(target.getIps(), ", "));
return true;
@@ -154,9 +158,9 @@ public class Command_myadmin extends FreedomCommand
msg("Your login message cannot be more than 64 characters (excluding your rank and your name)", ChatColor.RED);
return true;
}
- String previewMessage = plugin.rm.craftLoginMessage(targetPlayer, message);
FUtil.adminAction(sender.getName(), "Setting personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
target.setLoginMessage(message);
+ String previewMessage = plugin.rm.craftLoginMessage(targetPlayer, message);
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
msg("> " + previewMessage);
plugin.al.save(target);
@@ -173,17 +177,6 @@ public class Command_myadmin extends FreedomCommand
return true;
}
- case "settag":
- {
- msg("Please use /tag set to set your tag.", ChatColor.RED);
- return true;
- }
-
- case "cleartag":
- {
- msg("Please use /tag off to remove your tag.", ChatColor.RED);
- return true;
- }
case "setacformat":
{
String format = StringUtils.join(args, " ", 1, args.length);
@@ -229,12 +222,13 @@ public class Command_myadmin extends FreedomCommand
msg("Role syncing is not enabled.", ChatColor.RED);
return true;
}
- boolean synced = plugin.dc.syncRoles(target);
- if (target.getDiscordID() == null)
+ PlayerData playerData = plugin.pl.getData(target.getName());
+ if (playerData.getDiscordID() == null)
{
msg("Please run /linkdiscord first!", ChatColor.RED);
return true;
}
+ boolean synced = plugin.dc.syncRoles(target, playerData.getDiscordID());
if (synced)
{
msg("Successfully synced your roles.", ChatColor.GREEN);
@@ -249,29 +243,7 @@ public class Command_myadmin extends FreedomCommand
}
case "genbackupcodes":
- if (!plugin.dc.enabled)
- {
- msg("The Discord verification system is currently disabled.", ChatColor.RED);
- return true;
- }
- else if (target.getDiscordID() == null || target.getDiscordID().isEmpty())
- {
- msg("Discord verification is not enabled for you.", ChatColor.RED);
- return true;
- }
-
- msg("Generating backup codes...", ChatColor.GREEN);
-
- boolean generated = plugin.dc.sendBackupCodes(target);
-
- if (generated)
- {
- msg("Your backup codes have been sent to your discord account. They can be re-generated at anytime.", ChatColor.GREEN);
- }
- else
- {
- msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED);
- }
+ msg("Moved to /pv genbackupcodes", ChatColor.RED);
return true;
default:
@@ -290,7 +262,7 @@ public class Command_myadmin extends FreedomCommand
}
List singleArguments = Arrays.asList("clearips", "setlogin", "setacformat");
- List doubleArguments = Arrays.asList("clearip", "clearlogin", "clearacformat", "oldtags", "logstick", "syncroles", "genbackupcodes");
+ List doubleArguments = Arrays.asList("clearip", "clearlogin", "clearacformat", "oldtags", "logstick", "syncroles");
if (args.length == 1)
{
List options = new ArrayList<>();
@@ -312,7 +284,7 @@ public class Command_myadmin extends FreedomCommand
if (args[0].equals("clearip"))
{
List ips = plugin.al.getAdmin(sender).getIps();
- ips.remove(Ips.getIp(playerSender));
+ ips.remove(FUtil.getIp((Player) sender));
return ips;
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mymasterbuilder.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mymasterbuilder.java
deleted file mode 100644
index 0dcea829..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mymasterbuilder.java
+++ /dev/null
@@ -1,237 +0,0 @@
-package me.totalfreedom.totalfreedommod.command;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
-import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
-import org.apache.commons.lang.StringUtils;
-import org.bukkit.ChatColor;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Manage your Master Builder entry", usage = "/ [-o ] | genbackupcodes>", aliases = "mymb")
-public class Command_mymasterbuilder extends FreedomCommand
-{
-
- @Override
- protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (args.length < 1)
- {
- return false;
- }
-
- Player init = null;
- MasterBuilder target = plugin.mbl.getMasterBuilder(playerSender);
- Player targetPlayer = playerSender;
-
- // -o switch
- if (args[0].equals("-o"))
- {
- if (!FUtil.canManageMasterBuilders(playerSender.getName()))
- {
- return noPerms();
- }
- init = playerSender;
- targetPlayer = getPlayer(args[1]);
- if (targetPlayer == null)
- {
- msg(FreedomCommand.PLAYER_NOT_FOUND);
- return true;
- }
-
- target = plugin.mbl.getMasterBuilder(playerSender);
- if (target == null)
- {
- msg("That player is not a Master Builder", ChatColor.RED);
- return true;
- }
-
- // Shift 2
- args = Arrays.copyOfRange(args, 2, args.length);
- if (args.length < 1)
- {
- return false;
- }
- }
-
- final String targetIp = Ips.getIp(targetPlayer);
-
- switch (args[0])
- {
- case "clearips":
- {
- if (args.length != 1)
- {
- return false; // Double check: the player might mean "clearip"
- }
-
- if (init == null)
- {
- FUtil.adminAction(sender.getName(), "Clearing my IPs", false);
- }
- else
- {
- FUtil.adminAction(sender.getName(), "Clearing " + target.getName() + "' IPs", true);
- }
-
- int counter = target.getIps().size() - 1;
- target.clearIPs();
- target.addIp(targetIp);
-
- plugin.mbl.save();
- plugin.mbl.updateTables();
-
- msg(counter + " IPs removed.");
- msg(targetPlayer, target.getIps().get(0) + " is now your only IP address");
- return true;
- }
-
- case "clearip":
- {
- if (args.length != 2)
- {
- return false; // Double check: the player might mean "clearips"
- }
-
- if (!target.getIps().contains(args[1]))
- {
- if (init == null)
- {
- msg("That IP is not registered to you.");
- }
- else
- {
- msg("That IP does not belong to that player.");
- }
- return true;
- }
-
- if (targetIp.equals(args[1]))
- {
- if (init == null)
- {
- msg("You cannot remove your current IP.");
- }
- else
- {
- msg("You cannot remove that Master Builders's current IP.");
- }
- return true;
- }
-
- FUtil.adminAction(sender.getName(), "Removing an IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
-
- target.removeIp(args[1]);
- plugin.mbl.save();
- plugin.mbl.updateTables();
-
- msg("Removed IP " + args[1]);
- msg("Current IPs: " + StringUtils.join(target.getIps(), ", "));
- return true;
- }
-
- case "genbackupcodes":
- if (!plugin.dc.enabled)
- {
- msg("The Discord verification system is currently disabled.", ChatColor.RED);
- return true;
- }
- else if (target.getDiscordID() == null || target.getDiscordID().isEmpty())
- {
- msg("Discord verification is not enabled for you.", ChatColor.RED);
- return true;
- }
-
- msg("Generating backup codes...", ChatColor.GREEN);
-
- boolean generated = plugin.dc.sendBackupCodes(target);
-
- if (generated)
- {
- msg("Your backup codes have been sent to your discord account. They can be re-generated at anytime.", ChatColor.GREEN);
- }
- else
- {
- msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED);
- }
- return true;
-
- default:
- {
- return false;
- }
- }
- }
-
- @Override
- public List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
- {
-
- if (!plugin.mbl.isMasterBuilder(playerSender) && !FUtil.canManageMasterBuilders(playerSender.getName()))
- {
- return Collections.emptyList();
- }
-
- List singleArguments = Arrays.asList("clearips");
- List doubleArguments = Arrays.asList("clearip", "genbackupcodes");
- if (args.length == 1)
- {
- List options = new ArrayList<>();
- options.add("-o");
- options.addAll(singleArguments);
- options.addAll(doubleArguments);
- return options;
- }
- else if (args.length == 2)
- {
- if (args[0].equals("-o"))
- {
- return FUtil.getPlayerList();
- }
- else
- {
- if (doubleArguments.contains(args[0]))
- {
- if (args[0].equals("clearip"))
- {
- if (args[0].equals("clearip"))
- {
- List ips = plugin.mbl.getMasterBuilder(sender).getIps();
- ips.remove(Ips.getIp(playerSender));
- return ips;
- }
- }
- }
- }
- }
- else if (args.length == 3)
- {
- if (args[0].equals("-o"))
- {
- List options = new ArrayList<>();
- options.addAll(singleArguments);
- options.addAll(doubleArguments);
- return options;
- }
- }
- else if (args.length == 4)
- {
- if (args[0].equals("-o") && args[2].equals("clearip"))
- {
- MasterBuilder masterBuilder = plugin.mbl.getEntryByName(args[1]);
- if (masterBuilder != null)
- {
- return masterBuilder.getIps();
- }
- }
- }
- return FUtil.getPlayerList();
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickclean.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickclean.java
index 6e0cf40a..78fa7015 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickclean.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickclean.java
@@ -12,7 +12,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
-@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of all players on server.", usage = "/", aliases = "nc")
+@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of one or all players on server.", usage = "/ [player]", aliases = "nc")
public class Command_nickclean extends FreedomCommand
{
@@ -25,21 +25,43 @@ public class Command_nickclean extends FreedomCommand
{
FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
+ if (args.length > 1)
+ {
+ Player player = getPlayer(args[0]);
+
+ if (player == null)
+ {
+ msg(PLAYER_NOT_FOUND);
+ return true;
+ }
+
+ FUtil.adminAction(sender.getName(), "Cleaning " + player.getName() + "'s nickname", false);
+ cleanNickname(player);
+ return true;
+ }
+
+
+ FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
for (final Player player : server.getOnlinePlayers())
{
- final String playerName = player.getName();
- final String nickName = plugin.esb.getNickname(playerName);
- if (nickName != null && !nickName.isEmpty() && !nickName.equalsIgnoreCase(playerName))
- {
- final Matcher matcher = REGEX.matcher(nickName);
- if (matcher.find())
- {
- final String newNickName = matcher.replaceAll("");
- msg(ChatColor.RESET + playerName + ": \"" + nickName + ChatColor.RESET + "\" -> \"" + newNickName + ChatColor.RESET + "\".");
- plugin.esb.setNickname(playerName, newNickName);
- }
- }
+ cleanNickname(player);
}
return true;
}
+
+ public void cleanNickname(Player player)
+ {
+ final String playerName = player.getName();
+ final String nickName = plugin.esb.getNickname(playerName);
+ if (nickName != null && !nickName.isEmpty() && !nickName.equalsIgnoreCase(playerName))
+ {
+ final Matcher matcher = REGEX.matcher(nickName);
+ if (matcher.find())
+ {
+ final String newNickName = matcher.replaceAll("");
+ msg(ChatColor.RESET + playerName + ": \"" + nickName + ChatColor.RESET + "\" -> \"" + newNickName + ChatColor.RESET + "\".");
+ plugin.esb.setNickname(playerName, newNickName);
+ }
+ }
+ }
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_notes.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_notes.java
index 4ae49c10..43c63234 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_notes.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_notes.java
@@ -3,13 +3,11 @@ package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
import me.totalfreedom.totalfreedommod.player.PlayerData;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -28,7 +26,7 @@ public class Command_notes extends FreedomCommand
return false;
}
- VPlayer vPlayer;
+ PlayerData playerData;
final Player player = getPlayer(args[0]);
if (player == null)
@@ -41,23 +39,21 @@ public class Command_notes extends FreedomCommand
return true;
}
- vPlayer = plugin.pv.getVerificationPlayer(entry.getUsername());
+ playerData = plugin.pl.getData(entry.getName());
}
else
{
- vPlayer = plugin.pv.getVerificationPlayer(player);
+ playerData = plugin.pl.getData(player);
}
if (args[1].equals("list"))
{
final StringBuilder noteList = new StringBuilder();
- noteList.append(ChatColor.GREEN + "Player notes for " + vPlayer.getName() + ":");
+ noteList.append(ChatColor.GREEN + "Player notes for " + playerData.getName() + ":");
int id = 1;
- for (Map, ?> noteMap : vPlayer.getNotes())
+ for (String note : playerData.getNotes())
{
- String admin = String.valueOf(noteMap.keySet().toArray()[0]);
- String note = String.valueOf(noteMap.get(admin));
- String noteLine = id + ". " + admin + ": " + note;
+ String noteLine = id + ". " + note;
noteList.append("\n" + ChatColor.GOLD + noteLine);
id++;
}
@@ -70,9 +66,9 @@ public class Command_notes extends FreedomCommand
{
return false;
}
- String note = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
- vPlayer.addNote(sender.getName(), note);
- plugin.pv.saveVerificationData(vPlayer);
+ String note = sender.getName() + ": " + StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
+ playerData.addNote(note);
+ plugin.pl.save(playerData);
msg("Note added.", ChatColor.GREEN);
return true;
}
@@ -93,9 +89,9 @@ public class Command_notes extends FreedomCommand
return true;
}
id--;
- if (vPlayer.removeNote(id))
+ if (playerData.removeNote(id))
{
- plugin.pv.saveVerificationData(vPlayer);
+ plugin.pl.save(playerData);
msg("Note removed.");
}
else
@@ -106,9 +102,9 @@ public class Command_notes extends FreedomCommand
}
else if (args[1].equals("clear"))
{
- int count = vPlayer.getNotes().size();
- vPlayer.clearNotes();
- plugin.pv.saveVerificationData(vPlayer);
+ int count = playerData.getNotes().size();
+ playerData.clearNotes();
+ plugin.pl.save(playerData);
msg("Cleared " + count + " notes.", ChatColor.GREEN);
return true;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java
index 672f9c43..b728a7fd 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java
@@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permban.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permban.java
index 893d6864..ba8f8ef8 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permban.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permban.java
@@ -25,8 +25,8 @@ public class Command_permban extends FreedomCommand
}
msg("Reloading permban list...", ChatColor.RED);
- plugin.pm.stop();
- plugin.pm.start();
+ plugin.pm.onStop();
+ plugin.pm.onStart();
msg("Reloaded permban list.");
msg(plugin.pm.getPermbannedIps().size() + " IPs and "
+ plugin.pm.getPermbannedNames().size() + " usernames loaded.");
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_playerverify.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_playerverification.java
similarity index 69%
rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_playerverify.java
rename to src/main/java/me/totalfreedom/totalfreedommod/command/Command_playerverification.java
index 63d1f977..3ae7b928 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_playerverify.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_playerverification.java
@@ -4,22 +4,22 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import net.pravian.aero.util.Ips;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Manage your verification", usage = "/ ", aliases = "playerverification,pv")
-public class Command_playerverify extends FreedomCommand
+@CommandParameters(description = "Manage your verification", usage = "/ | status | genbackupcodes>", aliases = "playerverify,pv")
+public class Command_playerverification extends FreedomCommand
{
@Override
- protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- VPlayer target = plugin.pv.getVerificationPlayer(playerSender);
+ PlayerData target = plugin.pl.getData(playerSender);
List ips = new ArrayList<>();
ips.addAll(target.getIps());
@@ -31,16 +31,29 @@ public class Command_playerverify extends FreedomCommand
int cleared = 0;
for (String ip : ips)
{
- if (!ip.equals(Ips.getIp(playerSender)))
+ if (!ip.equals(FUtil.getIp(playerSender)))
{
target.removeIp(ip);
cleared++;
}
}
- msg("Cleared all IP's except your current IP \"" + Ips.getIp(playerSender) + "\"");
+ msg("Cleared all IP's except your current IP \"" + FUtil.getIp(playerSender) + "\"");
msg("Cleared " + cleared + " IP's.");
- plugin.pv.saveVerificationData(target);
+ plugin.pl.save(target);
+ plugin.pl.syncIps(target);
+ return true;
+ }
+ else if (args[0].equalsIgnoreCase("clearip"))
+ {
+ if (args.length < 2)
+ {
+ return false;
+ }
+ target.removeIp(args[1]);
+ msg("Removed" + args[1] + " from your list of IPs");
+ plugin.pl.save(target);
+ plugin.pl.syncIps(target);
return true;
}
}
@@ -50,13 +63,7 @@ public class Command_playerverify extends FreedomCommand
return false;
}
- if (plugin.al.isAdmin(sender))
- {
- msg("This command is only for OP's.", ChatColor.RED);
- return true;
- }
-
- VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
+ PlayerData data = plugin.pl.getData(playerSender);
switch (args[0].toLowerCase())
{
@@ -66,37 +73,37 @@ public class Command_playerverify extends FreedomCommand
msg("The Discord verification system is currently disabled.", ChatColor.RED);
return true;
}
- else if (data.getEnabled())
+ else if (data.hasVerification())
{
msg("Discord verification is already enabled for you.", ChatColor.RED);
return true;
}
- else if (data.getDiscordId() == null)
+ else if (data.getDiscordID() == null)
{
msg("Please link a discord account with /linkdiscord.", ChatColor.RED);
return true;
}
- data.setEnabled(true);
- plugin.pv.saveVerificationData(data);
+ data.setVerification(true);
+ plugin.pl.save(data);
msg("Re-enabled Discord verification.", ChatColor.GREEN);
return true;
case "disable":
- if (!data.getEnabled())
+ if (!data.hasVerification())
{
msg("Discord verification is already disabled for you.", ChatColor.RED);
return true;
}
- data.setEnabled(false);
- plugin.pv.saveVerificationData(data);
+ data.setVerification(false);
+ plugin.pl.save(data);
msg("Disabled Discord verification.", ChatColor.GREEN);
return true;
case "status":
- boolean enabled = target.getEnabled();
- boolean specified = target.getDiscordId() != null;
+ boolean enabled = target.hasVerification();
+ boolean specified = target.getDiscordID() != null;
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
- msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + target.getDiscordId() : ChatColor.RED + "not set"));
+ msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + target.getDiscordID() : ChatColor.RED + "not set"));
msg(ChatColor.GRAY + "Backup Codes: " + data.getBackupCodes().size() + "/" + "10");
return true;
@@ -106,7 +113,7 @@ public class Command_playerverify extends FreedomCommand
msg("The Discord verification system is currently disabled.", ChatColor.RED);
return true;
}
- else if (!data.getEnabled())
+ else if (!data.hasVerification())
{
msg("Discord verification is not enabled for you.", ChatColor.RED);
return 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 2e35d00c..d0dae66b 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_premium.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_premium.java
@@ -1,12 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.InputStreamReader;
+import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
-import java.net.URLConnection;
-import java.io.IOException;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java
index 981a9f19..1d27ba8c 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java
@@ -1,24 +1,25 @@
package me.totalfreedom.totalfreedommod.command;
-import com.connorlinfoot.actionbarapi.ActionBarAPI;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import org.bukkit.ChatColor;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Brings the current reaction string up on your action bar", usage = "/")
+@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
+@CommandParameters(description = "Forcefully start a reaction", usage = "/")
public class Command_reactionbar extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (!plugin.sh.reactionString.isEmpty())
+ if (!FUtil.isDeveloper(sender.getName()))
{
- ActionBarAPI.sendActionBar(playerSender, ChatColor.BOLD + plugin.sh.reactionString, 15 * 20);
+ return noPerms();
}
+ plugin.sh.forceStartReaction();
+ msg("Started a reaction.");
return true;
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_realtime.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_realtime.java
deleted file mode 100644
index a9d68701..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_realtime.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package me.totalfreedom.totalfreedommod.command;
-
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
-import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Sync your time with the real world time.", usage = "/ | off>", aliases = "rt")
-public class Command_realtime extends FreedomCommand
-{
- @Override
- public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- VPlayer player = plugin.pv.getVerificationPlayer(playerSender);
- if (args.length == 0 || args.length > 2)
- {
- return false;
- }
- if (args.length == 2)
- {
- if (args[0].equalsIgnoreCase("on"))
- {
- int tz;
- try
- {
- tz = Integer.parseInt(args[1]);
- }
- catch (NumberFormatException ex)
- {
- msg("Invalid UTC offset.");
- return true;
- }
- if (FUtil.timeZoneOutOfBounds(tz))
- {
- msg("Invalid UTC offset.");
- return true;
- }
- player.setUtcOffset(tz);
- player.setRealTime(true);
- plugin.rt.enable(playerSender);
- plugin.pv.saveVerificationData(player);
- msg("Your in-game time is now synced with real time.");
- return true;
- }
- }
- if (args[0].equalsIgnoreCase("off"))
- {
- if (!player.isRealTime())
- {
- msg("You aren't on real time.");
- return true;
- }
- player.setRealTime(false);
- msg("Your in-game time is no longer synced with real time.");
- plugin.rt.disable(playerSender);
- plugin.pv.saveVerificationData(player);
- return true;
- }
- return true;
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java
index acf462a9..c64707ce 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java
@@ -4,8 +4,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TimerTask;
import me.totalfreedom.totalfreedommod.player.FPlayer;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
@@ -76,8 +77,9 @@ public class Command_ride extends FreedomCommand
{
if (args[1].equalsIgnoreCase("normal") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("ask"))
{
- VPlayer vPlayerSender = plugin.pv.getVerificationPlayer(playerSender);
- vPlayerSender.setRideMode(args[1].toLowerCase());
+ PlayerData playerDataSender = plugin.pl.getData(playerSender);
+ playerDataSender.setRideMode(args[1].toLowerCase());
+ plugin.pl.save(playerDataSender);
msg("Ride mode is now set to " + args[1].toLowerCase() + ".");
return true;
}
@@ -90,7 +92,7 @@ public class Command_ride extends FreedomCommand
return true;
}
- final VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
+ final PlayerData playerData = plugin.pl.getData(player);
if (player == playerSender)
{
@@ -98,19 +100,13 @@ public class Command_ride extends FreedomCommand
return true;
}
- if (vPlayer.getRideMode().equals("off") && !isAdmin(sender))
+ if (playerData.getRideMode().equals("off") && !isAdmin(sender))
{
msg("That player cannot be ridden.", ChatColor.RED);
return true;
}
- if (player.getName().equals("Catholic_Mario"))
- {
- msg("no", ChatColor.RED);
- return true;
- }
-
- if (vPlayer.getRideMode().equals("ask") && !isAdmin(sender))
+ if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName()))
{
msg("Sent a request to the player.", ChatColor.GREEN);
player.sendMessage(ChatColor.AQUA + sender.getName() + " has requested to ride you.");
@@ -118,7 +114,7 @@ public class Command_ride extends FreedomCommand
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.");
player.sendMessage(ChatColor.AQUA + "Request will expire after 30 seconds.");
RIDE_REQUESTS.put(player, playerSender);
- FreedomCommandExecutor.timer.schedule(new TimerTask()
+ timer.schedule(new TimerTask()
{
@Override
public void run()
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java
index 23923be1..b4e02d6f 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java
@@ -15,7 +15,7 @@ public class Command_rideablepearl extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (plugin.sh.getData(playerSender).hasItem(ShopItem.RIDEABLE_PEARL))
+ if (plugin.pl.getData(playerSender).hasItem(ShopItem.RIDEABLE_PEARL))
{
playerSender.getInventory().addItem(plugin.sh.getRideablePearl());
msg("You have been given a Rideable Ender Pearl", ChatColor.GREEN);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_campfire.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java
similarity index 60%
rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_campfire.java
rename to src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java
index d35c7b6a..b60e79c1 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_campfire.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java
@@ -11,25 +11,18 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
-@CommandParameters(description = "You know the words - gives a campfire to everyone on the server.", usage = "/")
-public class Command_campfire extends FreedomCommand
+@CommandParameters(description = "You have thrown a rock, but you have also summoned a meteor!", usage = "/")
+public class Command_rock extends FreedomCommand
{
- public static final String CAMPFIRE_LYRICS = "Let's gather round the campfire, and sing our campfire song....";
+ public static final String ROCK_LYRICS = ChatColor.BLUE + "You have thrown a rock, but you have also summoned a meteor!";
@Override
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{
- final StringBuilder output = new StringBuilder();
-
- for (final String word : CAMPFIRE_LYRICS.split(" "))
- {
- output.append(FUtil.randomChatColor()).append(word).append(" ");
- }
-
- final ItemStack heldItem = new ItemStack(Material.CAMPFIRE);
+ final ItemStack heldItem = new ItemStack(Material.STONE);
final ItemMeta heldItemMeta = heldItem.getItemMeta();
- heldItemMeta.setDisplayName(ChatColor.DARK_RED + "The " + ChatColor.DARK_RED + "Campfire");
+ heldItemMeta.setDisplayName(ChatColor.BLUE + "Rock");
heldItem.setItemMeta(heldItemMeta);
for (final Player player : this.server.getOnlinePlayers())
@@ -41,7 +34,7 @@ public class Command_campfire extends FreedomCommand
}
}
- FUtil.bcastMsg(output.toString());
+ FUtil.bcastMsg(ROCK_LYRICS);
return true;
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java
index 3162b1f3..7c6ea709 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java
@@ -7,12 +7,9 @@ import java.util.Date;
import java.util.List;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.player.FPlayer;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -109,7 +106,7 @@ public class Command_saconfig extends FreedomCommand
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
{
- plugin.dc.syncRoles(admin);
+ plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
}
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
@@ -166,7 +163,7 @@ public class Command_saconfig extends FreedomCommand
return true;
}
- if (player != null && plugin.al.isAdmin(player))
+ if (plugin.al.isAdmin(player))
{
msg("That player is already admin.");
return true;
@@ -177,14 +174,14 @@ public class Command_saconfig extends FreedomCommand
Admin admin = null;
for (Admin loopAdmin : plugin.al.getAllAdmins())
{
- if (loopAdmin.getName().equalsIgnoreCase(name))
+ if (loopAdmin.getName().equalsIgnoreCase(name) || loopAdmin.getIps().contains(FUtil.getIp(player)))
{
admin = loopAdmin;
break;
}
}
- if (plugin.pv.isPlayerImpostor(player))
+ if (plugin.pl.isPlayerImpostor(player))
{
msg("This player was labeled as a Player impostor and is not an admin, therefore they cannot be added to the admin list.", ChatColor.RED);
return true;
@@ -192,11 +189,6 @@ public class Command_saconfig extends FreedomCommand
if (admin == null) // New admin
{
- if (plugin.mbl.isMasterBuilderImpostor(player))
- {
- msg("This player was labeled as a Master Builder impostor and is not an admin, therefore they cannot be added to the admin list.", ChatColor.RED);
- return true;
- }
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
@@ -206,81 +198,25 @@ public class Command_saconfig extends FreedomCommand
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
admin = new Admin(player);
- // Attempt to find discord account
- if (plugin.mbl.isMasterBuilder(player))
- {
- MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
- admin.setDiscordID(plugin.mbl.getMasterBuilder(player).getDiscordID());
- }
- else if (plugin.pv.getVerificationPlayer(player.getName()) != null)
- {
- VPlayer vPlayer = plugin.pv.getVerificationPlayer(player.getName());
- if (vPlayer.getDiscordId() != null)
- {
- admin.setDiscordID(vPlayer.getDiscordId());
- }
- }
plugin.al.addAdmin(admin);
plugin.rm.updateDisplay(player);
}
else // Existing admin
{
- FUtil.adminAction(sender.getName(), "Re-adding " + admin.getName() + " to the admin list", true);
+ FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the admin list", true);
if (player != null)
{
String oldName = admin.getName();
+ if (oldName != player.getName())
admin.setName(player.getName());
plugin.sql.updateAdminName(oldName, admin.getName());
- admin.addIp(Ips.getIp(player));
- }
-
- // Handle master builders
- if (!plugin.mbl.isMasterBuilder(player))
- {
- MasterBuilder masterBuilder = null;
- for (MasterBuilder loopMasterBuilder : plugin.mbl.getAllMasterBuilders().values())
- {
- if (loopMasterBuilder.getName().equalsIgnoreCase(name))
- {
- masterBuilder = loopMasterBuilder;
- break;
- }
- }
-
- if (masterBuilder != null)
- {
- if (player != null)
- {
- masterBuilder.setName(player.getName());
- masterBuilder.addIp(Ips.getIp(player));
- }
-
- masterBuilder.setLastLogin(new Date());
-
- plugin.mbl.save();
- plugin.mbl.updateTables();
- }
+ admin.addIp(FUtil.getIp(player));
}
admin.setActive(true);
admin.setLastLogin(new Date());
- // Attempt to find discord account
- if (plugin.mbl.isMasterBuilder(player))
- {
- MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
- admin.setDiscordID(plugin.mbl.getMasterBuilder(player).getDiscordID());
- }
- else if (plugin.pv.getVerificationPlayer(admin.getName()) != null)
- {
- VPlayer vPlayer = plugin.pv.getVerificationPlayer(admin.getName());
- if (vPlayer.getDiscordId() != null)
- {
- admin.setDiscordID(vPlayer.getDiscordId());
- }
- }
-
if (plugin.al.isVerifiedAdmin(player))
{
plugin.al.verifiedNoAdmins.remove(player.getName());
@@ -296,7 +232,7 @@ public class Command_saconfig extends FreedomCommand
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
{
- plugin.dc.syncRoles(admin);
+ plugin.dc.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
}
}
@@ -314,7 +250,6 @@ public class Command_saconfig extends FreedomCommand
player.setOp(true);
player.sendMessage(YOU_ARE_OP);
}
- plugin.pv.removeEntry(player.getName()); // admins can't have player verification entries
}
return true;
}
@@ -348,7 +283,7 @@ public class Command_saconfig extends FreedomCommand
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
{
- plugin.dc.syncRoles(admin);
+ plugin.dc.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
}
return true;
@@ -364,41 +299,34 @@ public class Command_saconfig extends FreedomCommand
@Override
public List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
- if (sender instanceof Player)
+ if (args.length == 1)
{
- if (args.length == 1)
+ List arguments = new ArrayList<>();
+ arguments.add("list");
+ if (plugin.al.isAdmin(sender))
{
- List arguments = new ArrayList<>();
- arguments.add("list");
- if (plugin.al.isAdmin(sender))
- {
- arguments.add("info");
- }
- return arguments;
+ arguments.add("info");
}
- else if (args.length == 2 && args[0].equals("info") && plugin.al.isAdmin(sender))
+ if (plugin.al.isTelnetAdmin(sender))
{
- return plugin.al.getActiveAdminNames();
+ arguments.add("add");
+ arguments.add("remove");
}
- return Collections.emptyList();
+ if (plugin.al.isSeniorAdmin(sender))
+ {
+ arguments.add("reload");
+ arguments.add("clean");
+ arguments.add("setrank");
+ }
+ return arguments;
}
- else
+ if (args.length == 2 && (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info")))
{
- if (args.length == 1)
- {
- return Arrays.asList("add", "remove", "clean", "reload", "setrank", "info", "list");
- }
- else if (args.length == 2)
- {
- if (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info"))
- {
- return FUtil.getPlayerList();
- }
- }
- else if (args.length == 3 && args[0].equals("setrank"))
- {
- return Arrays.asList("super_admin", "telnet_admin", "senior_admin");
- }
+ return FUtil.getPlayerList();
+ }
+ if (args.length == 3 && args[0].equals("setrank"))
+ {
+ return Arrays.asList("SUPER_ADMIN", "TELNET_ADMIN", "SENIOR_ADMIN");
}
return Collections.emptyList();
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java
index 711e5bc1..8da61478 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java
@@ -1,11 +1,11 @@
package me.totalfreedom.totalfreedommod.command;
-import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.rank.Rank;
+import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.ChatColor;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Check the status of the server, including opped players, staff, etc.", usage = "/", aliases = "ss")
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java
index ae3e5fff..89c6381a 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
-import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -20,7 +20,7 @@ public class Command_shop extends FreedomCommand
msg("The shop is currently disabled!", ChatColor.RED);
return true;
}
- playerSender.openInventory(plugin.sh.generateShopGUI(plugin.sh.getData(playerSender)));
+ playerSender.openInventory(plugin.sh.generateShopGUI(plugin.pl.getData(playerSender)));
return true;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java
index b2212dc0..f6066ec7 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java
@@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
@@ -60,7 +59,7 @@ public class Command_smite extends FreedomCommand
smite(sender, player, reason, silent);
- plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
+ plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
return true;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java
index 9ba087ae..d27eea10 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java
@@ -3,8 +3,8 @@ package me.totalfreedom.totalfreedommod.command;
import java.util.List;
import java.util.Set;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.EnumUtils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -20,7 +20,7 @@ public class Command_spawnmob extends FreedomCommand
{
@Override
- protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length > 0 && args[0].equalsIgnoreCase("list"))
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java
new file mode 100644
index 00000000..7a1514f5
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java
@@ -0,0 +1,29 @@
+package me.totalfreedom.totalfreedommod.command;
+
+import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.shop.ShopItem;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
+@CommandParameters(description = "Obtain a stacking potato", usage = "/")
+public class Command_stackingpotato extends FreedomCommand
+{
+
+ @Override
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ {
+ if (plugin.pl.getData(playerSender).hasItem(ShopItem.STACKING_POTATO))
+ {
+ playerSender.getInventory().addItem(plugin.sh.getStackingPotato());
+ msg("You have been given a Stacking Potato", ChatColor.GREEN);
+ }
+ else
+ {
+ msg("You do not own the Stacking Potato! Purchase one from the shop.", ChatColor.RED);
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java
index 50d6981d..af0f6ba2 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java
@@ -20,27 +20,26 @@ public class Command_stop extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (STOP_CONFIRM.containsKey(sender))
- {
- FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
-
- for (Player player : server.getOnlinePlayers())
- {
- player.kickPlayer(ChatColor.LIGHT_PURPLE + STOP_CONFIRM.get(sender));
- }
-
- STOP_CONFIRM.remove(sender);
-
- server.shutdown();
- }
String reason = "Server is going offline, come back in about 20 seconds.";
- if (args.length > 0)
+ if (args.length != 0)
{
reason = StringUtils.join(args, " ");
}
+ if (sender.getName().equals("CONSOLE"))
+ {
+ shutdown(reason);
+ return true;
+ }
+ else if (STOP_CONFIRM.containsKey(sender))
+ {
+ shutdown(STOP_CONFIRM.get(sender));
+ return true;
+ }
+
+
msg("Warning: You're about to stop the server. Type /stop again to confirm you want to do this.");
STOP_CONFIRM.put(sender, reason);
@@ -58,4 +57,18 @@ public class Command_stop extends FreedomCommand
}.runTaskLater(plugin, 15 * 20);
return true;
}
+
+ public void shutdown(String reason)
+ {
+ FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
+
+ for (Player player : server.getOnlinePlayers())
+ {
+ player.kickPlayer(ChatColor.LIGHT_PURPLE + reason);
+ }
+
+ STOP_CONFIRM.remove(sender);
+
+ server.shutdown();
+ }
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java
index 1fdb8332..aac55cb7 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java
@@ -2,10 +2,8 @@ package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.List;
-import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.player.FPlayer;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.ArrayUtils;
@@ -23,11 +21,12 @@ public class Command_tag extends FreedomCommand
public static final List FORBIDDEN_WORDS = Arrays.asList(
"admin", "owner", "moderator", "developer", "console", "dev", "staff", "mod", "sra", "tca", "sta", "sa");
- public boolean save = false;
-
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
+
+ boolean save = false;
+
if (args.length < 1)
{
return false;
@@ -35,11 +34,6 @@ public class Command_tag extends FreedomCommand
if (args[0].equals("-s") || args[0].equals("-save"))
{
- if (!plugin.al.isAdmin(playerSender) && !plugin.mbl.isMasterBuilder(playerSender) && !plugin.pv.getVerificationPlayer(playerSender).getEnabled())
- {
- msg("Only admins, Master Builders, and players with verification enabled can save their tags.", ChatColor.RED);
- return true;
- }
save = true;
args = ArrayUtils.remove(args, 0);
}
@@ -199,25 +193,8 @@ public class Command_tag extends FreedomCommand
public void save(Player player, String tag)
{
- if (plugin.al.isAdmin(player))
- {
- Admin admin = plugin.al.getAdmin(player);
- admin.setTag(tag);
- plugin.al.save(admin);
- plugin.al.updateTables();
- }
- else if (plugin.mbl.isMasterBuilder(player))
- {
- MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
- masterBuilder.setTag(tag);
- plugin.mbl.save();
- plugin.mbl.updateTables();
- }
- else if (plugin.pv.getVerificationPlayer(player).getEnabled())
- {
- VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
- vPlayer.setTag(tag);
- plugin.pv.saveVerificationData(vPlayer);
- }
+ PlayerData playerData = plugin.pl.getData(player);
+ playerData.setTag(tag);
+ plugin.pl.save(playerData);
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tban.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tban.java
index cf2aed2e..a768890b 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tban.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tban.java
@@ -1,8 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.player.PlayerData;
@@ -10,11 +8,7 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
-import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -47,7 +41,7 @@ public class Command_tban extends FreedomCommand
return true;
}
- username = entry.getUsername();
+ username = entry.getName();
ips.addAll(entry.getIps());
}
else
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java
index 556059dd..dacca6ab 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java
@@ -10,7 +10,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Location;
@@ -47,7 +46,7 @@ public class Command_tempban extends FreedomCommand
return true;
}
- username = entry.getUsername();
+ username = entry.getName();
ips.addAll(entry.getIps());
}
else
@@ -97,7 +96,7 @@ public class Command_tempban extends FreedomCommand
plugin.bm.addBan(ban);
player.kickPlayer(ban.bakeKickMessage());
- plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
+ plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
return true;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java
index 20f06d2b..f32840e8 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java
@@ -46,6 +46,7 @@ public class Command_toggle extends FreedomCommand
msg("- spawners");
msg("- 4chan");
msg("- beehives");
+ msg("- respawnanchors");
msg("- autotp");
msg("- autoclear");
return false;
@@ -215,6 +216,11 @@ public class Command_toggle extends FreedomCommand
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
return true;
}
+ else if (args[0].equalsIgnoreCase("respawnanchors"))
+ {
+ toggle("Respawn anchors are", ConfigEntry.ALLOW_RESPAWN_ANCHORS);
+ return true;
+ }
else if (args[0].equalsIgnoreCase("autotp"))
{
toggle("Teleportation on join is", ConfigEntry.AUTO_TP);
@@ -245,7 +251,7 @@ public class Command_toggle extends FreedomCommand
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
- "autotp", "autoclear");
+ "respawnanchors", "autotp", "autoclear");
}
return Collections.emptyList();
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java
index f1e80b09..a29b4ffa 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java
@@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
+import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
@@ -34,8 +35,11 @@ public class Command_totalfreedommod extends FreedomCommand
}
plugin.config.load();
- plugin.services.stop();
- plugin.services.start();
+ for (FreedomService service : plugin.fsh.getServices())
+ {
+ service.onStop();
+ service.onStart();
+ }
final String message = String.format("%s v%s reloaded.",
TotalFreedomMod.pluginName,
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java
index 18a57acd..558abb63 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java
@@ -1,22 +1,19 @@
package me.totalfreedom.totalfreedommod.command;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/ [off]")
+@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/")
public class Command_trail extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (args.length > 0 && "off".equals(args[0]))
+ if (plugin.tr.contains(playerSender))
{
plugin.tr.remove(playerSender);
msg("Trail disabled.");
@@ -30,15 +27,4 @@ public class Command_trail extends FreedomCommand
return true;
}
- @Override
- public List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
- {
- if (args.length == 1 && plugin.al.isAdmin(sender))
- {
- return Arrays.asList("off");
- }
-
- return Collections.emptyList();
- }
-
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java
index 181baf8a..0c86fa72 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java
@@ -31,7 +31,7 @@ public class Command_unban extends FreedomCommand
return true;
}
- username = entry.getUsername();
+ username = entry.getName();
ips.addAll(entry.getIps());
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java
new file mode 100644
index 00000000..d218d570
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java
@@ -0,0 +1,47 @@
+package me.totalfreedom.totalfreedommod.command;
+
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
+@CommandParameters(description = "Uncage a player", usage = "/ ")
+public class Command_uncage extends FreedomCommand
+{
+
+ @Override
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ {
+
+ if (args.length == 0)
+ {
+ return false;
+ }
+
+ Player player = getPlayer(args[0]);
+ if (player == null)
+ {
+ sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
+ return true;
+ }
+
+ final FPlayer fPlayer = plugin.pl.getPlayer(player);
+
+ if (fPlayer.getCageData().isCaged())
+ {
+ FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
+ final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
+ playerdata.getCageData().setCaged(false);
+ }
+ else
+ {
+ msg("That player is not caged!", ChatColor.RED);
+ }
+
+ return true;
+ }
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java
index dc5e3509..f280fd57 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java
@@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
-import me.totalfreedom.libsdisguises.BlockedDisguises;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
@@ -21,12 +20,6 @@ public class Command_undisguiseall extends FreedomCommand
return true;
}
- if (BlockedDisguises.disabled)
- {
- msg("Disguises are not enabled.");
- return true;
- }
-
boolean admins = false;
if (args.length > 0 && args[0].equalsIgnoreCase("-a"))
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java
index 57170c85..07556280 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
-import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -9,7 +8,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/")
+@CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/ [player]")
public class Command_unlinkdiscord extends FreedomCommand
{
@@ -22,32 +21,30 @@ public class Command_unlinkdiscord extends FreedomCommand
return true;
}
- if (plugin.al.isAdmin(playerSender))
+ if (args.length != 0 && plugin.al.isAdmin(playerSender))
{
- Admin admin = plugin.al.getAdmin(playerSender);
- if (admin.getDiscordID() == null)
+ PlayerData playerData = plugin.pl.getData(args[0]);
+ if (playerData == null)
{
- msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
+ msg(PLAYER_NOT_FOUND);
return true;
}
- admin.setDiscordID(null);
- plugin.al.save(admin);
- msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
+
+ playerData.setDiscordID(null);
+ msg("Unlinked " + args[0] + "'s discord account.", ChatColor.GREEN);
return true;
}
- else
+
+ PlayerData data = plugin.pl.getData(playerSender);
+ if (data.getDiscordID() == null)
{
- VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
- if (data.getDiscordId() == null)
- {
- msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
- return true;
- }
- data.setDiscordId(null);
- data.setEnabled(false);
- plugin.pv.saveVerificationData(data);
- msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
+ msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
return true;
}
+ data.setDiscordID(null);
+ data.setVerification(false);
+ plugin.pl.save(data);
+ msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
+ return true;
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java
index 40c934d7..ec329f91 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java
@@ -1,9 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
@@ -57,18 +53,11 @@ public class Command_unmute extends FreedomCommand
playerdata.setMuted(false);
msg(player, "You have been unmuted.", ChatColor.RED);
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
- if (quiet)
+ if (!quiet)
{
- playerdata.setMuted(false);
- return true;
+ FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
}
-
- FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
- playerdata.setMuted(false);
- msg("Unmuted " + player.getName());
-
- msg(player, "You have been unmuted.", ChatColor.RED);
- player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
+ return true;
}
else
{
@@ -77,23 +66,4 @@ public class Command_unmute extends FreedomCommand
return true;
}
-
- @Override
- public List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
- {
- if (!plugin.al.isAdmin(sender))
- {
- return null;
- }
-
- if (args.length == 1)
- {
- List arguments = new ArrayList<>();
- arguments.addAll(FUtil.getPlayerList());
- arguments.addAll(Arrays.asList("list", "purge", "all"));
- return arguments;
- }
-
- return Collections.emptyList();
- }
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java
index f620a861..0a50072a 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
-import java.util.ArrayList;
import me.totalfreedom.totalfreedommod.admin.Admin;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
@@ -11,8 +11,6 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@@ -23,7 +21,6 @@ public class Command_vanish extends FreedomCommand
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{
Displayable display = plugin.rm.getDisplay(playerSender);
- String loginMsg = display.getColoredLoginMessage();
String displayName = display.getColor() + playerSender.getName();
String tag = display.getColoredTag();
Admin admin = plugin.al.getAdmin(playerSender);
@@ -38,21 +35,18 @@ public class Command_vanish extends FreedomCommand
if (plugin.al.vanished.contains(playerSender))
{
msg(ChatColor.GOLD + "You have been unvanished.");
- if (admin.hasLoginMessage())
- {
- loginMsg = FUtil.colorize(admin.getLoginMessage()).replace("%rank%", plugin.rm.getDisplay(admin).getName()).replace("%coloredrank%", plugin.rm.getDisplay(admin).getColoredName()).replace("%name%", admin.getName());
- }
if (!silent)
{
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
FUtil.bcastMsg(playerSender.getName() + " joined the game.", ChatColor.YELLOW);
plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**");
}
- if (admin.getTag() != null)
+ PlayerData playerData = plugin.pl.getData(playerSender);
+ if (playerData.getTag() != null)
{
- tag = FUtil.colorize(admin.getTag());
+ tag = FUtil.colorize(playerData.getTag());
}
- plugin.pl.getPlayer(playerSender).setTag(tag);
+ plugin.pl.getData(playerSender).setTag(tag);
FLog.info(playerSender.getName() + " is no longer vanished.");
for (Player player : server.getOnlinePlayers())
{
@@ -79,9 +73,13 @@ public class Command_vanish extends FreedomCommand
{
{
if (plugin.al.isAdmin(player))
- playerMsg(player, ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins." );
+ {
+ playerMsg(player, ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins.");
+ }
if (!plugin.al.isAdmin(player))
+ {
player.hidePlayer(plugin, playerSender);
+ }
}
}
plugin.esb.setVanished(playerSender.getName(), true);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verify.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verify.java
index e8d703c4..0fdc0173 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verify.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verify.java
@@ -1,14 +1,9 @@
package me.totalfreedom.totalfreedommod.command;
-import java.util.Date;
-import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.player.FPlayer;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -22,258 +17,76 @@ public class Command_verify extends FreedomCommand
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (args.length == 1 && plugin.al.isAdmin(playerSender))
+ if (!plugin.dc.enabled)
{
- final Player player = getPlayer(args[0]);
- if (player == null)
- {
- msg(FreedomCommand.PLAYER_NOT_FOUND);
- return true;
- }
- if (!plugin.pv.isPlayerImpostor(player))
- {
- msg("That player is not an impostor.");
- return true;
- }
- FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
- player.setOp(true);
- player.sendMessage(YOU_ARE_OP);
- if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
- {
- plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
- player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
- }
- plugin.pv.verifyPlayer(player, null);
- plugin.rm.updateDisplay(player);
+ msg("The Discord verification system is currently disabled", ChatColor.RED);
return true;
}
- else
+
+ if (senderIsConsole)
{
- if (!plugin.dc.enabled)
- {
- msg("The Discord verification system is currently disabled", ChatColor.RED);
- return true;
- }
+ msg("/manuallyverify ", ChatColor.WHITE);
+ return true;
+ }
- if (senderIsConsole || plugin.al.isAdmin(playerSender))
- {
- msg("/verify ", ChatColor.WHITE);
- return true;
- }
+ if (!plugin.pl.isImposter(playerSender))
+ {
+ msg("You are not an impostor, therefore you do not need to verify.", ChatColor.RED);
+ return true;
+ }
- if (!plugin.pv.isPlayerImpostor(playerSender) && !plugin.al.isAdminImpostor(playerSender) && !plugin.mbl.isMasterBuilderImpostor(playerSender))
- {
- msg("You are not an impostor, therefore you do not need to verify.", ChatColor.RED);
- return true;
- }
+ PlayerData playerData = plugin.pl.getData(playerSender);
- String discordId = "";
+ String discordId = playerData.getDiscordID();
- if (plugin.pv.isPlayerImpostor(playerSender))
+ if (playerData.getDiscordID() == null)
+ {
+ msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
+ return true;
+ }
+
+ if (args.length == 0)
+ {
+ String code = plugin.dc.generateCode(10);
+ plugin.dc.addVerificationCode(code, playerData);
+ plugin.dc.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + FUtil.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete();
+ msg("A verification code has been sent to your account, please copy the code and run /verify ", ChatColor.GREEN);
+ return true;
+ }
+
+ String code = args[0];
+ String backupCode = null;
+
+ if (plugin.pl.isImposter(playerSender))
+ {
+ PlayerData mapPlayer = plugin.dc.getVerificationCodes().get(code);
+ if (mapPlayer == null)
{
- VPlayer vPlayer = plugin.pv.getVerificationPlayer(playerSender);
- if (vPlayer.getDiscordId() == null)
+ if (!playerData.getBackupCodes().contains(plugin.dc.getMD5(code)))
{
- msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
+ msg("You have entered an invalid verification code", ChatColor.RED);
return true;
}
- discordId = vPlayer.getDiscordId();
- }
- else if (plugin.al.isAdminImpostor(playerSender))
- {
- Admin admin = plugin.al.getEntryByName(playerSender.getName());
- if (admin.getDiscordID() == null)
+ else
{
- msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
- return true;
+ backupCode = plugin.dc.getMD5(code);
}
- discordId = admin.getDiscordID();
- }
- else if (plugin.mbl.isMasterBuilderImpostor(playerSender))
- {
- MasterBuilder masterBuilder = plugin.mbl.getEntryByName(playerSender.getName());
- if (masterBuilder.getDiscordID() == null)
- {
- msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
- return true;
- }
- discordId = masterBuilder.getDiscordID();
- }
-
- if (args.length < 1)
- {
- String code = plugin.dc.generateCode(10);
- if (plugin.pv.isPlayerImpostor(playerSender))
- {
- VPlayer vPlayer = plugin.pv.getVerificationPlayer(playerSender);
- plugin.dc.addPlayerVerificationCode(code, vPlayer);
- }
- else if (plugin.al.isAdminImpostor(playerSender))
- {
- Admin admin = plugin.al.getEntryByName(playerSender.getName());
- plugin.dc.addAdminVerificationCode(code, admin);
- }
- else if (plugin.mbl.isMasterBuilderImpostor(playerSender))
- {
- MasterBuilder masterBuilder = plugin.mbl.getEntryByName(playerSender.getName());
- plugin.dc.addMasterBuilderVerificationCode(code, masterBuilder);
- }
- plugin.dc.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + Ips.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete();
- msg("A verification code has been sent to your account, please copy the code and run /verify ", ChatColor.GREEN);
}
else
{
- String code = args[0];
- String backupCode = null;
-
- if (plugin.pv.isPlayerImpostor(playerSender))
- {
- VPlayer vPlayer = plugin.pv.getVerificationPlayer(playerSender);
- VPlayer mapPlayer = plugin.dc.getPlayerVerificationCodes().get(code);
- if (mapPlayer == null)
- {
- if (!vPlayer.getBackupCodes().contains(plugin.dc.getMD5(code)))
- {
- msg("You have entered an invalid verification code", ChatColor.RED);
- return true;
- }
- else
- {
- backupCode = plugin.dc.getMD5(code);
- }
- }
- else
- {
- plugin.dc.removePlayerVerificationCode(code);
- }
-
- final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
- FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
- playerSender.setOp(true);
- msg(YOU_ARE_OP);
- if (fPlayer.getFreezeData().isFrozen())
- {
- fPlayer.getFreezeData().setFrozen(false);
- msg("You have been unfrozen.");
- }
- plugin.pv.verifyPlayer(playerSender, backupCode);
- plugin.rm.updateDisplay(playerSender);
- return true;
- }
- else if (plugin.al.isAdminImpostor(playerSender))
- {
- Admin admin = plugin.al.getEntryByName(playerSender.getName());
- Admin mapAdmin = plugin.dc.getAdminVerificationCodes().get(code);
- if (mapAdmin == null)
- {
- if (!admin.getBackupCodes().contains(plugin.dc.getMD5(code)))
- {
- msg("You have entered an invalid verification code", ChatColor.RED);
- return true;
- }
- else
- {
- backupCode = plugin.dc.getMD5(code);
- }
- }
- else
- {
- plugin.dc.removeAdminVerificationCode(code);
- }
-
- FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
- FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Re-adding " + admin.getName() + " to the admin list", true);
-
- admin.setName(playerSender.getName());
- admin.addIp(Ips.getIp(playerSender));
-
- if (backupCode != null)
- {
- admin.removeBackupCode(backupCode);
- }
-
- if (!plugin.mbl.isMasterBuilder(playerSender))
- {
- MasterBuilder masterBuilder = null;
- for (MasterBuilder loopMasterBuilder : plugin.mbl.getAllMasterBuilders().values())
- {
- if (loopMasterBuilder.getName().equalsIgnoreCase(playerSender.getName()))
- {
- masterBuilder = loopMasterBuilder;
- break;
- }
- }
-
- if (masterBuilder != null)
- {
- masterBuilder.setName(playerSender.getName());
- masterBuilder.addIp(Ips.getIp(playerSender));
-
- masterBuilder.setLastLogin(new Date());
-
- plugin.mbl.save();
- plugin.mbl.updateTables();
- }
- }
-
- admin.setActive(true);
- admin.setLastLogin(new Date());
- plugin.al.save(admin);
- plugin.al.updateTables();
- plugin.rm.updateDisplay(playerSender);
- playerSender.setOp(true);
- msg(YOU_ARE_OP);
- final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
- if (fPlayer.getFreezeData().isFrozen())
- {
- fPlayer.getFreezeData().setFrozen(false);
- msg("You have been unfrozen.");
- }
- return true;
- }
- else if (plugin.mbl.isMasterBuilderImpostor(playerSender))
- {
- MasterBuilder masterBuilder = plugin.mbl.getEntryByName(playerSender.getName());
- MasterBuilder mapMasterBuilder = plugin.dc.getMasterBuilderVerificationCodes().get(code);
- if (mapMasterBuilder == null)
- {
- if (!masterBuilder.getBackupCodes().contains(plugin.dc.getMD5(code)))
- {
- msg("You have entered an invalid verification code", ChatColor.RED);
- return true;
- }
- else
- {
- backupCode = plugin.dc.getMD5(code);
- }
- }
- else
- {
- plugin.dc.removeMasterBuilderVerificationCode(code);
- }
-
- if (backupCode != null)
- {
- masterBuilder.removeBackupCode(backupCode);
- }
-
- final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
- FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
- masterBuilder.setLastLogin(new Date());
- masterBuilder.addIp(Ips.getIp(playerSender));
- plugin.mbl.save();
- plugin.mbl.updateTables();
- plugin.rm.updateDisplay(playerSender);
- playerSender.setOp(true);
- msg(YOU_ARE_OP);
- if (fPlayer.getFreezeData().isFrozen())
- {
- fPlayer.getFreezeData().setFrozen(false);
- msg("You have been unfrozen.");
- }
- return true;
- }
+ plugin.dc.removeVerificationCode(code);
}
+
+ final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
+ if (fPlayer.getFreezeData().isFrozen())
+ {
+ fPlayer.getFreezeData().setFrozen(false);
+ msg("You have been unfrozen.");
+ }
+ FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
+ playerSender.setOp(true);
+ plugin.pl.verify(playerSender, backupCode);
+ return true;
}
return true;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java
index 8355170b..9b786908 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java
@@ -1,13 +1,11 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -40,7 +38,7 @@ public class Command_verifynoadmin extends FreedomCommand
{
plugin.al.verifiedNoAdmins.add(player.getName());
}
- String ip = Ips.getIp(player);
+ String ip = FUtil.getIp(player);
if (!plugin.al.verifiedNoAdminIps.containsKey(player.getName()))
{
List ips = new ArrayList<>();
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java
index 476463f2..ad7f46aa 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java
@@ -46,7 +46,7 @@ public class Command_warn extends FreedomCommand
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
- msg(player, ChatColor.RED + "[WARNING] You received a warning: " + warnReason);
+ msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason);
player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60);
msg(ChatColor.GREEN + "You have successfully warned " + player.getName());
final StringBuilder adminNotice = new StringBuilder()
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java
index 0ae10af1..64050f4e 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java
@@ -1,8 +1,11 @@
package me.totalfreedom.totalfreedommod.command;
+import java.nio.channels.FileLock;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -31,16 +34,33 @@ public class Command_wildcard extends FreedomCommand
}
Command runCmd = server.getPluginCommand(args[0]);
- if (runCmd == null)
+ FreedomCommand fCmd = plugin.cl.getByName(args[0]);
+ boolean alias = plugin.cl.isAlias(args[0]);
+ if (runCmd == null && fCmd == null && !alias)
{
msg("Unknown command: " + args[0], ChatColor.RED);
return true;
}
- if (BLOCKED_COMMANDS.contains(runCmd.getName()))
+ List aliases = new ArrayList<>();
+
+ if (runCmd != null)
{
- msg("Did you really think that was going to work?", ChatColor.RED);
- return true;
+ aliases = runCmd.getAliases();
+ }
+
+ if (fCmd != null)
+ {
+ aliases = Arrays.asList(fCmd.getAliases().split(","));
+ }
+
+ for (String blockedCommand : BLOCKED_COMMANDS)
+ {
+ if (blockedCommand.equals(args[0].toLowerCase()) || aliases.contains(blockedCommand))
+ {
+ msg("Did you really think that was going to work?", ChatColor.RED);
+ return true;
+ }
}
String baseCommand = StringUtils.join(args, " ");
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 c216449c..a0b71336 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java
@@ -8,7 +8,6 @@ import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.Server;
@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 = "/")
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java b/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java
index a788d1e4..0b1e3dba 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java
@@ -1,98 +1,233 @@
package me.totalfreedom.totalfreedommod.command;
import com.google.common.collect.Lists;
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.command.AbstractCommandBase;
-import net.pravian.aero.util.Players;
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
+import org.bukkit.Server;
import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
+import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
+import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.spigotmc.SpigotConfig;
-public abstract class FreedomCommand extends AbstractCommandBase
+public abstract class FreedomCommand implements CommandExecutor, TabCompleter
{
+ public static final String COMMAND_PREFIX = "Command_";
+
+ @Getter
+ private static CommandMap commandMap;
+ @Getter
+ private final String name;
+ private final String description;
+ private final String usage;
+ @Getter
+ private final String aliases;
+ private final Rank level;
+ private final SourceType source;
+ private final boolean blockHostConsole;
+ private final int cooldown;
+ private final CommandParameters params;
+ @Getter
+ private final CommandPermissions perms;
+
+ protected CommandSender sender;
+
+ protected final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
+ protected final Server server = plugin.getServer();
public static final String UNKNOWN_COMMAND = ChatColor.WHITE + SpigotConfig.unknownCommandMessage;
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
- //
- @Getter
- private final CommandParameters params;
- @Getter
- private final CommandPermissions perms;
- //
+ public static final String ONLY_CONSOLE = ChatColor.RED + "Only console senders may execute this command!";
+ public static final String ONLY_IN_GAME = ChatColor.RED + "Only in-game players may execute this command!";
+ public static final String NO_PERMISSION = ChatColor.RED + "You do not have permission to execute this command.";
- public FreedomCommand()
+ public static final Timer timer = new Timer();
+ public static final Map COOLDOWN_TIMERS = new HashMap<>();
+
+ FreedomCommand()
{
- this.params = getClass().getAnnotation(CommandParameters.class);
- if (params == null)
- {
- FLog.warning("Ignoring command usage for command " + getClass().getSimpleName() + ". Command is not annotated!");
- }
-
- this.perms = getClass().getAnnotation(CommandPermissions.class);
- if (perms == null)
- {
- FLog.warning("Ignoring permissions for command " + getClass().getSimpleName() + ". Command is not annotated!");
- }
+ params = getClass().getAnnotation(CommandParameters.class);
+ perms = getClass().getAnnotation(CommandPermissions.class);
+ this.name = getClass().getSimpleName().replace(COMMAND_PREFIX, "").toLowerCase();
+ this.description = params.description();
+ this.usage = params.usage();
+ this.aliases = params.aliases();
+ this.level = perms.level();
+ this.source = perms.source();
+ this.blockHostConsole = perms.blockHostConsole();
+ this.cooldown = perms.cooldown();
}
- @Override
- public final boolean runCommand(final CommandSender sender, final Command command, final String label, final String[] args)
+ public void register()
{
- setVariables(sender, command, label, args);
-
- try
- {
- return run(sender, playerSender, command, label, args, isConsole());
- }
- catch (CommandFailException ex)
- {
- msg(ex.getMessage());
- return true;
- }
- catch (Exception ex)
- {
- FLog.severe("Uncaught exception executing command: " + command.getName());
- FLog.severe(ex);
- sender.sendMessage(ChatColor.RED + "Command error: " + (ex.getMessage() == null ? "Unknown cause" : ex.getMessage()));
- return true;
- }
+ FCommand cmd = new FCommand(this.name);
+ if (this.aliases != null) cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ",")));
+ if (this.description != null) cmd.setDescription(this.description);
+ if (this.usage != null) cmd.setUsage(this.usage);
+ getCommandMap().register("", cmd);
+ cmd.setExecutor(this);
}
- protected List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
- return null;
+ public static CommandMap getCommandMap()
+ {
+ if (commandMap == null)
+ {
+ try
+ {
+ final Field f = Bukkit.getServer().getPluginManager().getClass().getDeclaredField("commandMap");
+ f.setAccessible(true);
+ commandMap = (CommandMap) f.get(Bukkit.getServer().getPluginManager());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return commandMap;
}
- @Override
- public List tabComplete(CommandSender sender, Command command, String alias, String[] args)
+ private final class FCommand extends Command
{
- List options = getTabCompleteOptions(sender, command, alias, args);
- if (options == null)
+ private FreedomCommand cmd = null;
+ private FCommand(String command)
{
+ super(command);
+ }
+ public void setExecutor(FreedomCommand cmd)
+ {
+ this.cmd = cmd;
+ }
+
+ public boolean execute(CommandSender sender, String commandLabel, String[] args)
+ {
+ if (cmd != null)
+ {
+ cmd.sender = sender;
+
+ if (COOLDOWN_TIMERS.containsKey(sender) && COOLDOWN_TIMERS.containsValue(cmd))
+ {
+ msg(ChatColor.RED + "You are on cooldown for this command.");
+ return true;
+ }
+
+ if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()))
+ {
+ msg(ChatColor.RED + "Host console is not allowed to use this command!");
+ return true;
+ }
+
+ if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
+ {
+ msg(NO_PERMISSION);
+ return true;
+ }
+
+ if (perms.source() == SourceType.ONLY_CONSOLE && sender instanceof Player)
+ {
+ msg(ONLY_CONSOLE);
+ return true;
+ }
+
+ if (perms.source() == SourceType.ONLY_IN_GAME && sender instanceof ConsoleCommandSender)
+ {
+ msg(ONLY_IN_GAME);
+ return true;
+ }
+
+ if (perms.cooldown() != 0 && !isAdmin(sender))
+ {
+ COOLDOWN_TIMERS.put(sender, cmd);
+ timer.schedule(new TimerTask()
+ {
+ @Override
+ public void run()
+ {
+ COOLDOWN_TIMERS.remove(sender);
+ }
+ }, perms.cooldown() * 1000);
+ }
+ return cmd.onCommand(sender, this, commandLabel, args);
+ }
+ return false;
+ }
+
+ @Override
+ public List tabComplete(CommandSender sender, String alias, String[] args)
+ {
+ if (cmd != null)
+ {
+ return cmd.onTabComplete(sender, this, alias, args);
+ }
return null;
}
- return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.newArrayList());
}
- protected abstract boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole);
+ protected void msg(CommandSender sender, String message)
+ {
+ sender.sendMessage(ChatColor.GRAY + message);
+ }
+
+ protected void msg(Player player, String message)
+ {
+ player.sendMessage(ChatColor.GRAY + message);
+ }
+
+ protected void msg(Player player, String message, ChatColor color)
+ {
+ player.sendMessage(color + message);
+ }
+
+ protected void msg(String message)
+ {
+ msg(sender, message);
+ }
+
+ protected void msg(String message, ChatColor color)
+ {
+ msg(color + message);
+ }
+
+ protected void msg(String message, net.md_5.bungee.api.ChatColor color)
+ {
+ msg(color + message);
+ }
+
+ protected boolean isAdmin(Player player)
+ {
+ return plugin.al.isAdmin(player);
+ }
+
+ protected boolean isAdmin(CommandSender sender)
+ {
+ return plugin.al.isAdmin(sender);
+ }
protected void checkConsole()
{
if (!isConsole())
{
- throw new CommandFailException(getHandler().getOnlyConsoleMessage());
+ throw new CommandFailException(ONLY_CONSOLE);
}
}
@@ -100,15 +235,7 @@ public abstract class FreedomCommand extends AbstractCommandBase", cmd.getLabel()));
+ return true;
+ }
+ }
+ catch (CommandFailException ex)
+ {
+ msg(ChatColor.RED + ex.getMessage());
+ }
+ return false;
+ }
+
+ public List onTabComplete(CommandSender sender, Command command, String alias, String[] args)
+ {
+ List options = getTabCompleteOptions(sender, command, alias, args);
+ if (options == null)
+ {
+ return null;
+ }
+ return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.newArrayList());
+ }
+
+ public abstract boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole);
+
+ protected List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
+ {
+ return FUtil.getPlayerList();
}
protected boolean isConsole()
{
- return !(sender instanceof Player);
+ return sender instanceof ConsoleCommandSender;
}
protected Player getPlayer(String name)
{
- return Players.getPlayer(name);
+ return Bukkit.getPlayer(name);
}
protected Player getPlayer(String name, Boolean nullVanished)
{
- Player player = Players.getPlayer(name);
+ Player player = Bukkit.getPlayer(name);
if (nullVanished && plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
{
return null;
}
- return Players.getPlayer(name);
- }
-
- protected void msg(final CommandSender sender, final String message, final ChatColor color)
- {
- if (sender == null)
- {
- return;
- }
- sender.sendMessage(color + message);
- }
-
- protected void msg(final String message, final ChatColor color)
- {
- msg(sender, message, color);
- }
-
- protected void msg(final CommandSender sender, final String message)
- {
- msg(sender, message, ChatColor.GRAY);
- }
-
- protected void msg(final String message)
- {
- msg(sender, message);
- }
-
- protected boolean isAdmin(CommandSender sender)
- {
- return plugin.al.isAdmin(sender);
+ return player;
}
protected Admin getAdmin(CommandSender sender)
@@ -189,12 +325,16 @@ public abstract class FreedomCommand extends AbstractCommandBase> extends AbstractCommandExecutor
-{
-
- private final TotalFreedomMod plugin;
- //
- public static Map commandCooldown = new HashMap<>();
- public static final Timer timer = new Timer();
-
- public FreedomCommandExecutor(TotalFreedomMod plugin, AeroCommandHandler> handler, String name, C command)
- {
- super(handler, name, command);
- this.plugin = plugin;
- }
-
- protected FreedomCommand getCommand()
- {
- return commandBase instanceof FreedomCommand ? (FreedomCommand)commandBase : null;
- }
-
- @Override
- public void setupCommand(PluginCommand pluginCommand)
- {
- final FreedomCommand command = getCommand();
- if (command == null)
- {
- return;
- }
-
- final CommandParameters params = command.getParams();
- if (params == null)
- {
- return;
- }
-
- String aliasString = params.aliases();
-
- if (aliasString.length() > 0)
- {
- pluginCommand.setAliases(Arrays.asList(params.aliases().split(",")));
- }
- pluginCommand.setDescription(params.description());
- pluginCommand.setUsage(params.usage());
-
- // Check if permisions are correctly set up
- CommandPermissions perms = command.getPerms();
- if (perms != null)
- {
- if (perms.level().isConsole())
- {
- FLog.warning("[Command] " + pluginCommand.getName() + " - permission is set to a console rank, "
- + "should be set to player variant with 'source = SourceType.ONLY_CONSOLE'");
- }
- }
- }
-
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
- {
- if (!hasPermission(sender, true))
- {
- return true;
- }
-
- if (isOnCooldown(sender))
- {
- return true;
- }
-
- try
- {
- boolean run = commandBase.runCommand(sender, command, label, args);
- FreedomCommand c = getCommand();
- CommandPermissions perms = c.getPerms();
- if (perms.cooldown() > 0 && !plugin.al.isAdmin(sender))
- {
- commandCooldown.put(sender, c);
- timer.schedule(new TimerTask()
- {
- @Override
- public void run()
- {
- commandCooldown.remove(sender);
- }
- }, perms.cooldown() * 1000);
- }
- return run;
- }
- catch (Exception ex)
- {
- // If this is ever ran, TFM failed :
- FLog.severe("Unhandled command exception: " + command.getName());
- FLog.severe(ex);
- sender.sendMessage(ChatColor.RED + "Unhandled Command Error: " + command.getName());
- return true;
- }
- }
-
- @Override
- public boolean hasPermission(CommandSender sender, boolean sendMsg)
- {
- final FreedomCommand command = getCommand();
- if (command == null)
- {
- return true;
- }
-
- final CommandPermissions perms = command.getPerms();
- if (perms == null)
- {
- return true;
- }
-
- // Block host console
- if (FUtil.isFromHostConsole(sender.getName())
- && perms.blockHostConsole())
- {
- if (sendMsg)
- {
- sender.sendMessage(handler.getPermissionMessage());
- }
- return false;
- }
-
- final Player player = sender instanceof Player ? (Player)sender : null;
-
- // Only console
- if (perms.source() == SourceType.ONLY_CONSOLE
- && player != null)
- {
- if (sendMsg)
- {
- sender.sendMessage(handler.getOnlyConsoleMessage());
- }
- return false;
- }
-
- // Only in game
- if (perms.source() == SourceType.ONLY_IN_GAME
- && player == null)
- {
- if (sendMsg)
- {
- sender.sendMessage(handler.getOnlyPlayerMessage());
- }
- return false;
- }
-
- // Player permissions
- if (player != null)
- {
- Rank rank = plugin.rm.getRank(player);
- boolean result = rank.isAtLeast(perms.level());
- if (!result && sendMsg)
- {
- sender.sendMessage(handler.getPermissionMessage());
- }
- return result;
- }
-
- // Console permissions
- Rank rank = plugin.rm.getRank(sender);
- boolean result = rank.isAtLeast(perms.level());
- if (!result && sendMsg)
- {
- sender.sendMessage(handler.getPermissionMessage());
- }
- return result;
- }
-
- public boolean isOnCooldown(CommandSender sender)
- {
- final FreedomCommand command = getCommand();
- if (commandCooldown.containsKey(sender) && commandCooldown.containsValue(command))
- {
- sender.sendMessage(ChatColor.RED + "You're on cooldown for this command.");
- return true;
- }
- return false;
- }
-
- public static class FreedomExecutorFactory implements AeroCommandExecutorFactory
- {
-
- private final TotalFreedomMod plugin;
-
- public FreedomExecutorFactory(TotalFreedomMod plugin)
- {
- this.plugin = plugin;
- }
-
- @Override
- public AeroCommandExecutor extends AeroCommandBase>> newExecutor(AeroCommandHandler> handler, String name, AeroCommandBase> command)
- {
- return new FreedomCommandExecutor<>(plugin, handler, name, command);
- }
-
- }
-
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java
index 448f1705..c08dd21b 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java
@@ -31,6 +31,7 @@ public enum ConfigEntry
ALLOW_JUKEBOXES(Boolean.class, "allow.jukeboxes"),
ALLOW_SPAWNERS(Boolean.class, "allow.spawners"),
ALLOW_BEEHIVES(Boolean.class, "allow.beehives"),
+ ALLOW_RESPAWN_ANCHORS(Boolean.class, "allow.respawnanchors"),
AUTO_TP(Boolean.class, "allow.auto_tp"),
AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
//
@@ -82,18 +83,26 @@ public enum ConfigEntry
DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"),
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
//
+ DONATION_PROBOARDS_URL(String.class, "donation.proboards_url"),
+ DONATION_GROUP_ID(String.class, "donation.donator_group_id"),
+ DONATION_SESSION_ID(String.class, "donation.session_id"),
+ DONATION_CSRF_TOKEN(String.class, "donation.csrf_token"),
+ //
SHOP_ENABLED(Boolean.class, "shop.enabled"),
SHOP_TITLE(String.class, "shop.title"),
SHOP_PREFIX(String.class, "shop.prefix"),
SHOP_COINS_PER_VOTE(Integer.class, "shop.coins_per_vote"),
SHOP_REACTIONS_ENABLED(Boolean.class, "shop.reactions.enabled"),
SHOP_REACTIONS_INTERVAL(Integer.class, "shop.reactions.interval"),
+ SHOP_REACTIONS_TIME(Double.class, "shop.reactions.time"),
SHOP_REACTIONS_COINS_PER_WIN(Integer.class, "shop.reactions.coins_per_win"),
SHOP_REACTIONS_STRING_LENGTH(Integer.class, "shop.reactions.string_length"),
SHOP_PRICES_GRAPPLING_HOOK(Integer.class, "shop.prices.grappling_hook"),
SHOP_PRICES_LIGHTNING_ROD(Integer.class, "shop.prices.lightning_rod"),
SHOP_PRICES_FIRE_BALL(Integer.class, "shop.prices.fire_ball"),
SHOP_PRICES_RIDEABLE_PEARL(Integer.class, "shop.prices.rideable_pearl"),
+ SHOP_PRICES_STACKING_POTATO(Integer.class, "shop.prices.stacking_potato"),
+ SHOP_PRICES_CLOWN_FISH(Integer.class, "shop.prices.clown_fish"),
//
ADMINLIST_CLEAN_THESHOLD_HOURS(Integer.class, "adminlist.clean_threshold_hours"),
ADMINLIST_CONSOLE_IS_SENIOR(Boolean.class, "adminlist.console_is_senior"),
@@ -146,7 +155,6 @@ public enum ConfigEntry
BLOCKED_COMMANDS(List.class, "blocked_commands"),
HOST_SENDER_NAMES(List.class, "host_sender_names"),
FAMOUS_PLAYERS(List.class, "famous_players"),
- NOADMIN_IPS(List.class, "noadmin_ips"),
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
ADMIN_INFO(List.class, "admininfo"),
VOTING_INFO(List.class, "votinginfo"),
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/IConfig.java b/src/main/java/me/totalfreedom/totalfreedommod/config/IConfig.java
new file mode 100644
index 00000000..8da9901e
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/config/IConfig.java
@@ -0,0 +1,10 @@
+package me.totalfreedom.totalfreedommod.config;
+
+import org.bukkit.configuration.ConfigurationSection;
+
+public interface IConfig
+{
+ void loadFrom(ConfigurationSection cs);
+ void saveTo(ConfigurationSection cs);
+ boolean isValid();
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java b/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java
index 8da95ec1..bfcf6cba 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java
@@ -6,14 +6,14 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.EnumMap;
import java.util.List;
+import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
-import net.pravian.aero.component.PluginComponent;
import org.apache.commons.io.FileUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
-public class MainConfig extends PluginComponent
+public class MainConfig extends FreedomService
{
public static final String CONFIG_FILENAME = "config.yml";
@@ -22,10 +22,20 @@ public class MainConfig extends PluginComponent
private final ConfigDefaults defaults;
public YamlConfiguration configuration;
+ @Override
+ public void onStart()
+ {
+
+ }
+
+ @Override
+ public void onStop()
+ {
+
+ }
+
public MainConfig(TotalFreedomMod plugin)
{
- super(plugin);
-
entries = new EnumMap<>(ConfigEntry.class);
ConfigDefaults tempDefaults = null;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java b/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java
new file mode 100644
index 00000000..bd4585b8
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java
@@ -0,0 +1,67 @@
+package me.totalfreedom.totalfreedommod.config;
+
+import java.io.File;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+public class YamlConfig extends YamlConfiguration
+{
+ private final TotalFreedomMod plugin;
+ private final File file;
+ private final boolean copyDefaults;
+
+ public YamlConfig(TotalFreedomMod plugin, String name, boolean copyDefaults)
+ {
+ this.plugin = plugin;
+ this.file = new File(plugin.getDataFolder(), name);
+ this.copyDefaults = copyDefaults;
+
+ if (copyDefaults)
+ {
+ options().copyDefaults(true);
+ }
+
+ if (!file.exists())
+ {
+ plugin.saveResource(name, false);
+ }
+ load();
+ }
+
+ public YamlConfig(TotalFreedomMod plugin, String name)
+ {
+ this(plugin, name, true);
+ }
+
+ public void load()
+ {
+ try
+ {
+ super.load(file);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void save()
+ {
+ try
+ {
+ super.save(file);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void clear()
+ {
+ for (String key : super.getKeys(false))
+ {
+ super.set(key, null);
+ }
+ }
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java
index 234c5976..f579382a 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java
@@ -16,11 +16,9 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import javax.security.auth.login.LoginException;
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.masterbuilder.MasterBuilder;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.dv8tion.jda.api.AccountType;
@@ -33,13 +31,13 @@ import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.PrivateChannel;
import net.dv8tion.jda.api.entities.Role;
-import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.SelfUser;
+import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.events.ReadyEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory;
-import net.pravian.aero.util.StringUtils;
import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
import org.bukkit.GameRule;
import org.bukkit.entity.Player;
@@ -51,13 +49,9 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class Discord extends FreedomService
{
- public static HashMap PLAYER_LINK_CODES = new HashMap<>();
- public static HashMap PLAYER_VERIFICATION_CODES = new HashMap<>();
- public static HashMap ADMIN_LINK_CODES = new HashMap<>();
- public static HashMap ADMIN_VERIFICATION_CODES = new HashMap<>();
- public static HashMap MASTER_BUILDER_LINK_CODES = new HashMap<>();
- public static HashMap MASTER_BUILDER_VERIFICATION_CODES = new HashMap<>();
- public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR = new ScheduledThreadPoolExecutor(5, new CountingThreadFactory(this::poolIdentifier, "RateLimit"));
+ public static HashMap LINK_CODES = new HashMap<>();
+ public static HashMap VERIFICATION_CODES = new HashMap<>();
+ public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR;
public List> sentMessages = new ArrayList<>();
public static JDA bot = null;
@@ -65,11 +59,6 @@ public class Discord extends FreedomService
Random random = new Random();
- public Discord(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
public void startBot()
{
enabled = !Strings.isNullOrEmpty(ConfigEntry.DISCORD_TOKEN.getString());
@@ -79,6 +68,8 @@ public class Discord extends FreedomService
}
if (bot != null)
{
+ RATELIMIT_EXECUTOR = new ScheduledThreadPoolExecutor(5, new CountingThreadFactory(this::poolIdentifier, "RateLimit"));
+ RATELIMIT_EXECUTOR.setRemoveOnCancelPolicy(true);
for (Object object : bot.getRegisteredListeners())
{
bot.removeEventListener(object);
@@ -86,7 +77,6 @@ public class Discord extends FreedomService
}
try
{
- RATELIMIT_EXECUTOR.setRemoveOnCancelPolicy(true);
bot = new JDABuilder(AccountType.BOT)
.setToken(ConfigEntry.DISCORD_TOKEN.getString())
.addEventListeners(new PrivateMessageListener())
@@ -153,58 +143,20 @@ public class Discord extends FreedomService
}
}
- public boolean sendBackupCodes(VPlayer vPlayer)
+ public boolean sendBackupCodes(PlayerData playerData)
{
List codes = generateBackupCodes();
List encryptedCodes = generateEncryptedBackupCodes(codes);
- net.dv8tion.jda.api.entities.User user = bot.getUserById(vPlayer.getDiscordId());
- File file = generateBackupCodesFile(vPlayer.getName(), codes);
+ net.dv8tion.jda.api.entities.User user = bot.getUserById(playerData.getDiscordID());
+ File file = generateBackupCodesFile(playerData.getName(), codes);
if (file == null)
{
return false;
}
PrivateChannel privateChannel = user.openPrivateChannel().complete();
privateChannel.sendMessage("Do not share these codes with anyone as they can be used to impose as you.").addFile(file).complete();
- vPlayer.setBackupCodes(encryptedCodes);
- plugin.pv.saveVerificationData(vPlayer);
- file.delete();
- return true;
- }
-
- public boolean sendBackupCodes(Admin admin)
- {
- List codes = generateBackupCodes();
- List encryptedCodes = generateEncryptedBackupCodes(codes);
- net.dv8tion.jda.api.entities.User user = bot.getUserById(admin.getDiscordID());
- File file = generateBackupCodesFile(admin.getName(), codes);
- if (file == null)
- {
- return false;
- }
- PrivateChannel privateChannel = user.openPrivateChannel().complete();
- privateChannel.sendMessage("Do not share these codes with anyone as they can be used to impose as you.").addFile(file).complete();
- admin.setBackupCodes(encryptedCodes);
- plugin.al.save(admin);
- plugin.al.updateTables();
- file.delete();
- return true;
- }
-
- public boolean sendBackupCodes(MasterBuilder masterBuilder)
- {
- List codes = generateBackupCodes();
- List encryptedCodes = generateEncryptedBackupCodes(codes);
- net.dv8tion.jda.api.entities.User user = bot.getUserById(masterBuilder.getDiscordID());
- File file = generateBackupCodesFile(masterBuilder.getName(), codes);
- if (file == null)
- {
- return false;
- }
- PrivateChannel privateChannel = user.openPrivateChannel().complete();
- privateChannel.sendMessage("Do not share these codes with anyone as they can be used to impose as you.").addFile(file).complete();
- masterBuilder.setBackupCodes(encryptedCodes);
- plugin.mbl.save();
- plugin.mbl.updateTables();
+ playerData.setBackupCodes(encryptedCodes);
+ plugin.pl.save(playerData);
file.delete();
return true;
}
@@ -283,49 +235,19 @@ public class Discord extends FreedomService
return DigestUtils.md5Hex(string);
}
- public void addPlayerVerificationCode(String code, VPlayer vPlayer)
+ public void addVerificationCode(String code, PlayerData playerData)
{
- PLAYER_VERIFICATION_CODES.put(code, vPlayer);
+ VERIFICATION_CODES.put(code, playerData);
}
- public void removePlayerVerificationCode(String code)
+ public void removeVerificationCode(String code)
{
- PLAYER_VERIFICATION_CODES.remove(code);
+ VERIFICATION_CODES.remove(code);
}
- public HashMap getPlayerVerificationCodes()
+ public HashMap getVerificationCodes()
{
- return PLAYER_VERIFICATION_CODES;
- }
-
- public void addAdminVerificationCode(String code, Admin admin)
- {
- ADMIN_VERIFICATION_CODES.put(code, admin);
- }
-
- public void removeAdminVerificationCode(String code)
- {
- ADMIN_VERIFICATION_CODES.remove(code);
- }
-
- public HashMap getAdminVerificationCodes()
- {
- return ADMIN_VERIFICATION_CODES;
- }
-
- public void addMasterBuilderVerificationCode(String code, MasterBuilder masterBuilder)
- {
- MASTER_BUILDER_VERIFICATION_CODES.put(code, masterBuilder);
- }
-
- public void removeMasterBuilderVerificationCode(String code)
- {
- MASTER_BUILDER_VERIFICATION_CODES.remove(code);
- }
-
- public HashMap getMasterBuilderVerificationCodes()
- {
- return MASTER_BUILDER_VERIFICATION_CODES;
+ return VERIFICATION_CODES;
}
@EventHandler(priority = EventPriority.MONITOR)
@@ -358,7 +280,7 @@ public class Discord extends FreedomService
}
@Override
- protected void onStart()
+ public void onStart()
{
startBot();
}
@@ -383,35 +305,11 @@ public class Discord extends FreedomService
return user.getName() + "#" + user.getDiscriminator();
}
- public static String getCodeForAdmin(Admin admin)
+ public static String getCode(PlayerData playerData)
{
- for (String code : ADMIN_LINK_CODES.keySet())
+ for (String code : LINK_CODES.keySet())
{
- if (ADMIN_LINK_CODES.get(code).equals(admin))
- {
- return code;
- }
- }
- return null;
- }
-
- public static String getCodeForPlayer(VPlayer playerData)
- {
- for (String code : PLAYER_LINK_CODES.keySet())
- {
- if (PLAYER_LINK_CODES.get(code).equals(playerData))
- {
- return code;
- }
- }
- return null;
- }
-
- public static String getCodeForMasterBuilder(MasterBuilder masterBuilder)
- {
- for (String code : MASTER_BUILDER_LINK_CODES.keySet())
- {
- if (MASTER_BUILDER_LINK_CODES.get(code).equals(masterBuilder))
+ if (LINK_CODES.get(code).equals(playerData))
{
return code;
}
@@ -420,7 +318,7 @@ public class Discord extends FreedomService
}
@Override
- protected void onStop()
+ public void onStop()
{
if (bot != null)
{
@@ -477,9 +375,9 @@ public class Discord extends FreedomService
return true;
}
- public static boolean syncRoles(Admin admin)
+ public static boolean syncRoles(Admin admin, String discordID)
{
- if (admin.getDiscordID() == null)
+ if (discordID == null)
{
return false;
}
@@ -491,7 +389,7 @@ public class Discord extends FreedomService
return false;
}
- Member member = server.getMemberById(admin.getDiscordID());
+ Member member = server.getMemberById(discordID);
if (member == null)
{
return false;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java
index 16199ed3..f627f067 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java
@@ -1,9 +1,7 @@
package me.totalfreedom.totalfreedommod.discord;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
@@ -18,34 +16,15 @@ public class PrivateMessageListener extends ListenerAdapter
{
String code = event.getMessage().getContentRaw();
String name;
- if (Discord.ADMIN_LINK_CODES.get(code) != null)
+ if (Discord.LINK_CODES.get(code) != null)
{
- Admin admin = Discord.ADMIN_LINK_CODES.get(code);
- name = admin.getName();
- admin.setDiscordID(event.getMessage().getAuthor().getId());
- TotalFreedomMod.plugin().al.save(admin);
- TotalFreedomMod.plugin().al.updateTables();
- Discord.ADMIN_LINK_CODES.remove(code);
- Discord.syncRoles(admin);
- }
- else if (Discord.PLAYER_LINK_CODES.get(code) != null)
- {
- VPlayer player = Discord.PLAYER_LINK_CODES.get(code);
+ PlayerData player = Discord.LINK_CODES.get(code);
name = player.getName();
- player.setDiscordId(event.getMessage().getAuthor().getId());
- player.setEnabled(true);
+ player.setDiscordID(event.getMessage().getAuthor().getId());
+ player.setVerification(true);
- TotalFreedomMod.plugin().pv.saveVerificationData(player);
- Discord.PLAYER_LINK_CODES.remove(code);
- }
- else if (Discord.MASTER_BUILDER_LINK_CODES.get(code) != null)
- {
- MasterBuilder masterBuilder = Discord.MASTER_BUILDER_LINK_CODES.get(code);
- name = masterBuilder.getName();
- masterBuilder.setDiscordID(event.getMessage().getAuthor().getId());
- TotalFreedomMod.plugin().mbl.save();
- TotalFreedomMod.plugin().mbl.updateTables();
- Discord.MASTER_BUILDER_LINK_CODES.remove(code);
+ TotalFreedomMod.plugin().pl.save(player);
+ Discord.LINK_CODES.remove(code);
}
else
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java b/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java
index 3f7a42d4..e22d8ed8 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java
@@ -62,7 +62,7 @@ public class FreezeData
@Override
public void run()
{
- if (!plugin().al.isAdminImpostor(player) && plugin().pv.isPlayerImpostor(player))
+ if (!plugin().al.isAdminImpostor(player) && plugin().pl.isPlayerImpostor(player))
{
FUtil.adminAction("TotalFreedom", "Unfreezing " + player.getName(), false);
setFrozen(false);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java b/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java
index 8e5b704f..e830be9b 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java
@@ -2,7 +2,6 @@ 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 org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -16,19 +15,14 @@ public class Freezer extends FreedomService
@Getter
private boolean globalFreeze = false;
- public Freezer(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
globalFreeze = false;
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/CurseListener.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/CurseListener.java
index 0f219a52..4a29f514 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/fun/CurseListener.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/CurseListener.java
@@ -2,13 +2,11 @@ package me.totalfreedom.totalfreedommod.fun;
import java.util.HashMap;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
-
import static org.bukkit.event.player.PlayerResourcePackStatusEvent.Status;
public class CurseListener extends FreedomService
@@ -16,18 +14,13 @@ public class CurseListener extends FreedomService
public HashMap cursedPlayers = new HashMap();
- public CurseListener(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java
index 0f484b2c..b1c608bd 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java
@@ -5,43 +5,39 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
-import java.util.Timer;
-import java.util.TimerTask;
import java.util.UUID;
-import javax.security.auth.login.FailedLoginException;
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.shop.ShopData;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
-import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.Sound;
import org.bukkit.SoundCategory;
+import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Firework;
-import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.ProjectileHitEvent;
-import org.bukkit.event.entity.ProjectileLaunchEvent;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.Sound;
-import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
-import org.bukkit.entity.TNTPrimed;
+import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.ProjectileHitEvent;
+import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.player.PlayerFishEvent;
+import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@@ -94,21 +90,65 @@ public class ItemFun extends FreedomService
return cooldownTracker.get(player.getName()).contains(item.getDataName());
}
- public ItemFun(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
+ @EventHandler
+ public void onPlayerEntityInteract(PlayerInteractEntityEvent event)
+ {
+
+ Player player = event.getPlayer();
+
+ Entity entity = event.getRightClicked();
+
+ if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO) || entity.getType().equals(EntityType.PLAYER))
+ {
+ return;
+ }
+
+ if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.STACKING_POTATO, player.getInventory().getItemInMainHand(), plugin.sh.getStackingPotato()))
+ {
+ return;
+ }
+
+ player.addPassenger(entity);
+ player.sendMessage("Stacked " + entity.getName());
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onEntityDamage(EntityDamageByEntityEvent event)
+ {
+
+ Entity entity = event.getEntity();
+
+ if (entity instanceof Player || !(event.getDamager() instanceof Player))
+ {
+ return;
+ }
+
+ Player player = (Player)event.getDamager();
+
+ if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO))
+ {
+ return;
+ }
+
+ if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.STACKING_POTATO, player.getInventory().getItemInMainHand(), plugin.sh.getStackingPotato()))
+ {
+ return;
+ }
+
+ event.setCancelled(true);
+ entity.addPassenger(player);
+ }
+
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event)
{
@@ -123,22 +163,101 @@ public class ItemFun extends FreedomService
switch (event.getMaterial())
{
+ case BONE:
+ {
+ if (!fPlayer.mobThrowerEnabled())
+ {
+ break;
+ }
+
+ Location player_pos = player.getLocation();
+ Vector direction = player_pos.getDirection().normalize();
+
+ LivingEntity rezzed_mob = (LivingEntity)player.getWorld().spawnEntity(player_pos.add(direction.multiply(2.0)), fPlayer.mobThrowerCreature());
+ rezzed_mob.setVelocity(direction.multiply(fPlayer.mobThrowerSpeed()));
+ fPlayer.enqueueMob(rezzed_mob);
+
+ event.setCancelled(true);
+ break;
+ }
+
+ case GUNPOWDER:
+ {
+ if (!fPlayer.isMP44Armed())
+ {
+ break;
+ }
+
+ event.setCancelled(true);
+
+ if (fPlayer.toggleMP44Firing())
+ {
+ fPlayer.startArrowShooter(plugin);
+ }
+ else
+ {
+ fPlayer.stopArrowShooter();
+ }
+ break;
+ }
+
+ case BLAZE_ROD:
+ {
+ if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.LIGHTNING_ROD, player.getInventory().getItemInMainHand(), plugin.sh.getLightningRod()))
+ {
+ break;
+ }
+
+ if (onCooldown(player, ShopItem.LIGHTNING_ROD))
+ {
+ player.sendMessage(ChatColor.RED + "You're are currently on a cooldown for 10 seconds.");
+ break;
+ }
+
+ event.setCancelled(true);
+ Block targetBlock = player.getTargetBlock(null, 20);
+
+ for (int i = 0; i < 5; i++)
+ {
+ player.getWorld().strikeLightning(targetBlock.getLocation());
+ }
+ cooldown(player, ShopItem.LIGHTNING_ROD, 10);
+ break;
+ }
+
+ case FIRE_CHARGE:
+ {
+ if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.FIRE_BALL, player.getInventory().getItemInMainHand(), plugin.sh.getFireBall()))
+ {
+ break;
+ }
+
+ if (onCooldown(player, ShopItem.FIRE_BALL))
+ {
+ player.sendMessage(ChatColor.RED + "You're are currently on a cool-down for 5 seconds.");
+ break;
+ }
+
+ event.setCancelled(true);
+ Entity fireball = player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREBALL);
+ FIRE_BALL_UUIDS.add(fireball.getUniqueId());
+ fireball.setVelocity(player.getLocation().getDirection().multiply(2));
+ cooldown(player, ShopItem.FIRE_BALL, 5);
+ break;
+ }
case TROPICAL_FISH:
{
final int RADIUS_HIT = 5;
final int STRENGTH = 4;
- if (!plugin.al.isSeniorAdmin(player))
+ if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.CLOWN_FISH, player.getInventory().getItemInMainHand(), plugin.sh.getClownFish()))
{
- final StringBuilder msg = new StringBuilder();
- final char[] chars = ("That's clownery, luv").toCharArray();
- for (char c : chars)
- {
- msg.append(FUtil.randomChatColor()).append(c);
- }
- player.sendMessage(msg.toString());
+ break;
+ }
- player.getEquipment().getItemInMainHand().setType(Material.POTATO);
+ if (onCooldown(player, ShopItem.CLOWN_FISH))
+ {
+ player.sendMessage(ChatColor.RED + "You're are currently on a cool-down for 30 seconds.");
break;
}
@@ -180,155 +299,13 @@ public class ItemFun extends FreedomService
{
if (sound.toString().contains("HIT"))
{
- playerLoc.getWorld().playSound(randomOffset(playerLoc, 5.0), sound, 100.0f, randomDoubleRange(0.5, 2.0).floatValue());
+ playerLoc.getWorld().playSound(randomOffset(playerLoc, 5.0), sound, 20f, randomDoubleRange(0.5, 2.0).floatValue());
}
}
+ cooldown(player, ShopItem.CLOWN_FISH, 30);
}
break;
}
-
- case CARROT:
- {
- if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean() || !plugin.al.isSeniorAdmin(player) || plugin.wr.doRestrict(player))
- {
- break;
- }
-
- Location location = player.getLocation().clone();
-
- Vector playerPosition = location.toVector().add(new Vector(0.0, 1.65, 0.0));
- Vector playerDirection = location.getDirection().normalize();
-
- double distance = 150.0;
- Block targetBlock = DepreciationAggregator.getTargetBlock(player, null, Math.round((float)distance));
- if (targetBlock != null)
- {
- distance = location.distance(targetBlock.getLocation());
- }
-
- final List affected = new ArrayList<>();
-
- Block lastBlock = null;
- for (double offset = 0.0; offset <= distance; offset += (distance / 25.0))
- {
- Block block = playerPosition.clone().add(playerDirection.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
-
- if (!block.equals(lastBlock))
- {
- if (block.isEmpty())
- {
- affected.add(block);
- block.setType(Material.TNT);
- }
- else
- {
- break;
- }
- }
-
- lastBlock = block;
- }
-
- new BukkitRunnable()
- {
- @Override
- public void run()
- {
- for (Block tntBlock : affected)
- {
- TNTPrimed tnt = tntBlock.getWorld().spawn(tntBlock.getLocation(), TNTPrimed.class);
- tnt.setFuseTicks(5);
- tntBlock.setType(Material.AIR);
- }
- }
- }.runTaskLater(plugin, 30L);
-
- event.setCancelled(true);
- break;
- }
-
- case BONE:
- {
- if (!fPlayer.mobThrowerEnabled())
- {
- break;
- }
-
- Location player_pos = player.getLocation();
- Vector direction = player_pos.getDirection().normalize();
-
- LivingEntity rezzed_mob = (LivingEntity)player.getWorld().spawnEntity(player_pos.add(direction.multiply(2.0)), fPlayer.mobThrowerCreature());
- rezzed_mob.setVelocity(direction.multiply(fPlayer.mobThrowerSpeed()));
- fPlayer.enqueueMob(rezzed_mob);
-
- event.setCancelled(true);
- break;
- }
-
- case GUNPOWDER:
- {
- if (!fPlayer.isMP44Armed())
- {
- break;
- }
-
- event.setCancelled(true);
-
- if (fPlayer.toggleMP44Firing())
- {
- fPlayer.startArrowShooter(plugin);
- }
- else
- {
- fPlayer.stopArrowShooter();
- }
- break;
- }
-
- case BLAZE_ROD:
- {
- if (!plugin.sh.isRealItem(plugin.sh.getData(player), ShopItem.LIGHTNING_ROD, player.getInventory().getItemInMainHand(), plugin.sh.getLightningRod()))
- {
- break;
- }
-
- if (onCooldown(player, ShopItem.LIGHTNING_ROD))
- {
- player.sendMessage(ChatColor.RED + "You're are currently on a cooldown for 10 seconds.");
- break;
- }
-
- event.setCancelled(true);
- Block targetBlock = player.getTargetBlock(null, 20);
-
- for (int i = 0; i < 5; i++)
- {
- player.getWorld().strikeLightning(targetBlock.getLocation());
- }
- cooldown(player, ShopItem.LIGHTNING_ROD, 10);
- break;
- }
-
- case FIRE_CHARGE:
- {
- if (!plugin.sh.isRealItem(plugin.sh.getData(player), ShopItem.FIRE_BALL, player.getInventory().getItemInMainHand(), plugin.sh.getFireBall()))
- {
- break;
- }
-
- if (onCooldown(player, ShopItem.FIRE_BALL))
- {
- player.sendMessage(ChatColor.RED + "You're are currently on a cooldown for 5 seconds.");
- break;
- }
-
- event.setCancelled(true);
- Entity fireball = player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREBALL);
- FIRE_BALL_UUIDS.add(fireball.getUniqueId());
- fireball.setVelocity(player.getLocation().getDirection().multiply(2));
- cooldown(player, ShopItem.FIRE_BALL, 5);
- break;
- }
}
}
@@ -339,7 +316,7 @@ public class ItemFun extends FreedomService
if (entity instanceof EnderPearl && entity.getShooter() instanceof Player)
{
Player player = (Player)entity.getShooter();
- if (plugin.sh.isRealItem(plugin.sh.getData(player), ShopItem.RIDEABLE_PEARL, player.getInventory().getItemInMainHand(), plugin.sh.getRideablePearl()))
+ if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.RIDEABLE_PEARL, player.getInventory().getItemInMainHand(), plugin.sh.getRideablePearl()))
{
entity.addPassenger(player);
}
@@ -397,10 +374,10 @@ public class ItemFun extends FreedomService
public void onFish(PlayerFishEvent event)
{
Player player = event.getPlayer();
- ShopData sd = plugin.sh.getData(player);
+ PlayerData data = plugin.pl.getData(player);
PlayerInventory inv = event.getPlayer().getInventory();
ItemStack rod = inv.getItemInMainHand();
- if (plugin.sh.isRealItem(plugin.sh.getData(player), ShopItem.GRAPPLING_HOOK, player.getInventory().getItemInMainHand(), plugin.sh.getGrapplingHook()))
+ if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.GRAPPLING_HOOK, player.getInventory().getItemInMainHand(), plugin.sh.getGrapplingHook()))
{
if (event.getState() == PlayerFishEvent.State.REEL_IN || event.getState() == PlayerFishEvent.State.IN_GROUND)
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java
index 89da7781..4cd6269b 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java
@@ -6,7 +6,6 @@ import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -27,11 +26,6 @@ public class Jumppads extends FreedomService
private double strength = 1 + 0.1F;
public HashMap players = new HashMap<>();
- public Jumppads(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
public void onStart()
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java
index afe11dfb..07853dda 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java
@@ -5,7 +5,6 @@ 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 org.bukkit.GameMode;
import org.bukkit.Location;
@@ -23,19 +22,14 @@ public class Landminer extends FreedomService
@Getter
private final List landmines = new ArrayList<>();
- public Landminer(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
landmines.clear();
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/MP44.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/MP44.java
index 763aa278..a961d505 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/fun/MP44.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/MP44.java
@@ -1,26 +1,19 @@
package me.totalfreedom.totalfreedommod.fun;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerQuitEvent;
public class MP44 extends FreedomService
{
-
- public MP44(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java
deleted file mode 100644
index 3885b066..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package me.totalfreedom.totalfreedommod.fun;
-
-import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.inventory.ItemStack;
-
-public class MobStacker extends FreedomService
-{
-
- public MobStacker(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
- @Override
- protected void onStart()
- {
- }
-
- @Override
- protected void onStop()
- {
- }
-
- @EventHandler(priority = EventPriority.MONITOR)
- public void onEntityDamage(EntityDamageByEntityEvent event)
- {
- if (event.getEntity() instanceof Player || !(event.getDamager() instanceof Player))
- {
- return;
- }
-
- Player attacker = (Player)event.getDamager();
-
- if (!plugin.al.isAdmin(attacker))
- {
- return;
- }
-
- ItemStack item = attacker.getInventory().getItemInMainHand();
-
- if (item != null && item.getType().equals(Material.POTATO))
- {
- event.setCancelled(true);
- attacker.addPassenger(event.getEntity());
- }
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/RealTimer.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/RealTimer.java
deleted file mode 100644
index ea7d042f..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/fun/RealTimer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package me.totalfreedom.totalfreedommod.fun;
-
-import java.util.HashMap;
-import java.util.Map;
-import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.scheduler.BukkitRunnable;
-import org.bukkit.scheduler.BukkitTask;
-
-public class RealTimer extends FreedomService
-{
- public RealTimer(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
- private Map tasks = new HashMap<>();
-
- @Override
- protected void onStart()
- {
- }
-
- @Override
- protected void onStop()
- {
- }
-
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerJoin(PlayerJoinEvent event)
- {
- enable(event.getPlayer());
- }
-
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerQuit(PlayerQuitEvent event)
- {
- disable(event.getPlayer());
- }
-
- public void enable(Player player)
- {
- VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
- if (vPlayer.isRealTime())
- {
- tasks.put(player, new BukkitRunnable()
- {
- @Override
- public void run()
- {
- player.setPlayerTime(FUtil.getTimeInTicks(vPlayer.getUtcOffset()), false);
- }
- }.runTaskTimer(plugin, 0L, 20));
- }
- }
-
- public void disable(Player player)
- {
- if (!tasks.containsKey(player))
- return;
- tasks.get(player).cancel();
- tasks.remove(player);
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java
index bf480e7c..f1de102d 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java
@@ -4,7 +4,6 @@ import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -20,18 +19,13 @@ public class Trailer extends FreedomService
private final Random random = new Random();
private final Set trailPlayers = new HashSet<>(); // player name
- public Trailer(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -91,4 +85,9 @@ public class Trailer extends FreedomService
{
trailPlayers.add(player.getName());
}
+
+ public boolean contains(Player player)
+ {
+ return trailPlayers.contains(player.getName());
+ }
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java
index 867b0a96..6f4275a7 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java
@@ -8,7 +8,6 @@ import java.util.Map;
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.Response;
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
@@ -39,11 +38,6 @@ public class HTTPDaemon extends FreedomService
private HTTPD httpd;
public Map modules = new HashMap<>();
- public HTTPDaemon(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
public void onStart()
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java
index 36f2a848..74b3b2da 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java
@@ -3,15 +3,15 @@ package me.totalfreedom.totalfreedommod.httpd.module;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;
+import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
import me.totalfreedom.totalfreedommod.util.FLog;
-import net.pravian.aero.component.PluginComponent;
-public abstract class HTTPDModule extends PluginComponent
+public abstract class HTTPDModule extends FreedomService
{
protected final String uri;
@@ -23,7 +23,6 @@ public abstract class HTTPDModule extends PluginComponent
public HTTPDModule(TotalFreedomMod plugin, HTTPSession session)
{
- super(plugin);
this.uri = session.getUri();
this.method = session.getMethod();
this.headers = session.getHeaders();
@@ -32,6 +31,16 @@ public abstract class HTTPDModule extends PluginComponent
this.session = session;
}
+ @Override
+ public void onStart()
+ {
+ }
+
+ @Override
+ public void onStop()
+ {
+ }
+
public String getBody()
{
return null;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_admins.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_admins.java
index 405617c5..064b109e 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_admins.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_admins.java
@@ -1,9 +1,7 @@
package me.totalfreedom.totalfreedommod.httpd.module;
-import java.io.File;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
public class Module_admins extends HTTPDModule
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_bans.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_bans.java
index 70850c26..900e0fb6 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_bans.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_bans.java
@@ -1,10 +1,7 @@
package me.totalfreedom.totalfreedommod.httpd.module;
-import java.io.File;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.banning.BanManager;
-import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
public class Module_bans extends HTTPDModule
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java
index 703b0b7e..19afdd68 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java
@@ -12,7 +12,6 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.rank.Displayable;
-import net.pravian.aero.command.CommandReflection;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
@@ -33,7 +32,7 @@ public class Module_help extends HTTPDModule
@Override
public String getBody()
{
- final CommandMap map = CommandReflection.getCommandMap();
+ final CommandMap map = FreedomCommand.getCommandMap();
if (map == null || !(map instanceof SimpleCommandMap))
{
return paragraph("Error loading commands.");
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java
index eff3e06c..c2e05c43 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java
@@ -50,7 +50,7 @@ public class Module_list extends HTTPDModule
imposters.add(player.getName());
}
- if (plugin.mbl.isMasterBuilder(player))
+ if (plugin.pl.getData(player).isMasterBuilder())
{
masterbuilders.add(player.getName());
}
@@ -146,7 +146,7 @@ public class Module_list extends HTTPDModule
public boolean isImposter(Player player)
{
- if (plugin.al.isAdminImpostor(player) || plugin.pv.isPlayerImpostor(player) || plugin.mbl.isMasterBuilderImpostor(player))
+ if (plugin.al.isAdminImpostor(player) || plugin.pl.isPlayerImpostor(player))
{
return true;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logs.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logs.java
index 73f184bb..cd065fec 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logs.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logs.java
@@ -17,7 +17,7 @@ public class Module_logs extends Module_file
@Override
public NanoHTTPD.Response getResponse()
{
- if (ConfigEntry.LOGS_SECRET.getString().equals(params.get("password")))
+ if (ConfigEntry.LOGS_SECRET.getString().equals(params.get("password")) && !ConfigEntry.LOGS_SECRET.getString().isEmpty())
{
FLog.info(session.getSocket().getInetAddress() + " is downloading latest.log.");
return serveFile("latest.log", params, new File("./logs"));
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java
index 793ed450..fcd9a89d 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java
@@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -66,11 +65,7 @@ public class Module_players extends HTTPDModule
}
}
- // Master Builders
- for (MasterBuilder masterBuilder : plugin.mbl.getAllMasterBuilders().values())
- {
- masterbuilders.add(masterBuilder.getName());
- }
+ masterbuilders.addAll(plugin.pl.getMasterBuilderNames());
// Developers
developers.addAll(FUtil.DEVELOPERS);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java
index b7379cda..0b5fecb5 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java
@@ -21,7 +21,7 @@ import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
-import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringEscapeUtils;
@@ -271,8 +271,8 @@ public class Module_schematic extends HTTPDModule
private boolean isAuthorized(String remoteAddress)
{
Admin adminEntry = plugin.al.getEntryByIp(remoteAddress);
- MasterBuilder masterBuilderEntry = plugin.mbl.getEntryByIp(remoteAddress);
- return ((adminEntry != null && adminEntry.isActive()) || masterBuilderEntry != null);
+ PlayerData data = plugin.pl.getDataByIp(remoteAddress);
+ return ((adminEntry != null && adminEntry.isActive()) || data != null && data.isMasterBuilder());
}
private static class SchematicTransferException extends Exception
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/masterbuilder/MasterBuilder.java b/src/main/java/me/totalfreedom/totalfreedommod/masterbuilder/MasterBuilder.java
deleted file mode 100644
index f4a8f4af..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/masterbuilder/MasterBuilder.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package me.totalfreedom.totalfreedommod.masterbuilder;
-
-import com.google.common.collect.Lists;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import lombok.Getter;
-import lombok.Setter;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.base.ConfigLoadable;
-import net.pravian.aero.base.ConfigSavable;
-import net.pravian.aero.base.Validatable;
-import net.pravian.aero.util.Ips;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.Validate;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.entity.Player;
-
-public class MasterBuilder implements ConfigLoadable, ConfigSavable, Validatable
-{
-
- @Getter
- private String configKey;
- @Getter
- @Setter
- private String name;
- @Getter
- private final List ips = Lists.newArrayList();
- private final List backupCodes = Lists.newArrayList();
- @Getter
- @Setter
- private Date lastLogin = new Date();
- @Getter
- @Setter
- private String discordID = null;
- @Getter
- @Setter
- private String tag = null;
- @Getter
- @Setter
- private boolean clearChatOptOut = false;
-
- public static final String CONFIG_FILENAME = "masterbuilders.yml";
-
- public MasterBuilder(Player player)
- {
- this.configKey = player.getName().toLowerCase();
- this.name = player.getName();
- this.ips.add(Ips.getIp(player));
- }
-
- public MasterBuilder(String configKey)
- {
- this.configKey = configKey;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder output = new StringBuilder();
-
- output.append("MasterBuilder: ").append(name).append("\n")
- .append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
- .append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
- .append("- Discord ID: ").append(discordID).append("\n")
- .append("- Tag: ").append(tag).append("\n")
- .append("- Clear Chat Opt Out: ").append(clearChatOptOut)
- .append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
-
- return output.toString();
- }
-
- public void loadFrom(Player player)
- {
- configKey = player.getName().toLowerCase();
- name = player.getName();
- ips.clear();
- ips.add(Ips.getIp(player));
- }
-
- @Override
- public void loadFrom(ConfigurationSection cs)
- {
- name = cs.getString("username", configKey);
- ips.clear();
- ips.addAll(cs.getStringList("ips"));
- backupCodes.clear();
- backupCodes.addAll(cs.getStringList("backupCodes"));
- lastLogin = FUtil.stringToDate(cs.getString("last_login"));
- discordID = cs.getString("discord_id", null);
- tag = cs.getString("tag", null);
- clearChatOptOut = cs.getBoolean("clearChatOptOut", false);
- }
-
- @Override
- public void saveTo(ConfigurationSection cs)
- {
- Validate.isTrue(isValid(), "Could not save master builder entry: " + name + ". Entry not valid!");
- cs.set("username", name);
- cs.set("ips", Lists.newArrayList(ips));
- cs.set("backupCodes", Lists.newArrayList(backupCodes));
- cs.set("last_login", FUtil.dateToString(lastLogin));
- cs.set("discord_id", discordID);
- cs.set("tag", tag);
- cs.set("clearChatOptOut", clearChatOptOut);
- }
-
- public void addIp(String ip)
- {
- if (!ips.contains(ip))
- {
- ips.add(ip);
- }
- }
-
- public void addIps(List ips)
- {
- for (String ip : ips)
- {
- addIp(ip);
- }
- }
-
- public void removeIp(String ip)
- {
- ips.remove(ip);
- }
-
- public void clearIPs()
- {
- ips.clear();
- }
-
- public List getBackupCodes()
- {
- return Collections.unmodifiableList(backupCodes);
- }
-
- public void setBackupCodes(List codes)
- {
- backupCodes.clear();
- backupCodes.addAll(codes);
- }
-
- public void removeBackupCode(String code)
- {
- backupCodes.remove(code);
- }
-
- @Override
- public boolean isValid()
- {
- return configKey != null
- && name != null
- && !ips.isEmpty()
- && lastLogin != null;
- }
-
- public String getConfigKey()
- {
- return this.configKey;
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName(final String name)
- {
- this.name = name;
- }
-
- public List getIps()
- {
- return this.ips;
- }
-
- public Date getLastLogin()
- {
- return this.lastLogin;
- }
-
- public void setLastLogin(final Date lastLogin)
- {
- this.lastLogin = lastLogin;
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/masterbuilder/MasterBuilderList.java b/src/main/java/me/totalfreedom/totalfreedommod/masterbuilder/MasterBuilderList.java
deleted file mode 100644
index e7da380b..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/masterbuilder/MasterBuilderList.java
+++ /dev/null
@@ -1,295 +0,0 @@
-package me.totalfreedom.totalfreedommod.masterbuilder;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Maps;
-import java.util.Date;
-import java.util.Map;
-import java.util.Set;
-import lombok.Getter;
-import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import me.totalfreedom.totalfreedommod.util.FLog;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.config.YamlConfig;
-import net.pravian.aero.util.Ips;
-import org.bukkit.command.CommandSender;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.ServicePriority;
-
-public class MasterBuilderList extends FreedomService
-{
-
- public static final String CONFIG_FILENAME = "masterbuilders.yml";
-
- @Getter
- private final Map masterBuilders = Maps.newHashMap();
- private final Map nameTable = Maps.newHashMap();
- private final Map ipTable = Maps.newHashMap();
- //
- private final YamlConfig config;
-
- public MasterBuilderList(TotalFreedomMod plugin)
- {
- super(plugin);
-
- this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
- }
-
- @Override
- protected void onStart()
- {
- load();
-
- server.getServicesManager().register(Function.class, new Function()
- {
- @Override
- public Boolean apply(Player player)
- {
- return isMasterBuilder(player);
- }
- }, plugin, ServicePriority.Normal);
- }
-
- @Override
- protected void onStop()
- {
- save();
- }
-
- public void load()
- {
- config.load();
-
- masterBuilders.clear();
- for (String key : config.getKeys(false))
- {
- ConfigurationSection section = config.getConfigurationSection(key);
- if (section == null)
- {
- logger.warning("Invalid master builder list format: " + key);
- continue;
- }
-
- MasterBuilder masterBuilder = new MasterBuilder(key);
- masterBuilder.loadFrom(section);
-
- if (!masterBuilder.isValid())
- {
- FLog.warning("Could not load master builder: " + key + ". Missing details!");
- continue;
- }
-
- masterBuilders.put(key, masterBuilder);
- }
-
- updateTables();
- FLog.info("Loaded " + masterBuilders.size() + " master builders with " + ipTable.size() + " IPs");
- }
-
- public void save()
- {
- // Clear the config
- for (String key : config.getKeys(false))
- {
- config.set(key, null);
- }
-
- for (MasterBuilder masterBuilder : masterBuilders.values())
- {
- masterBuilder.saveTo(config.createSection(masterBuilder.getConfigKey()));
- }
-
- config.save();
- }
-
- public synchronized boolean isMasterbuilderSync(CommandSender sender)
- {
- return isMasterBuilder(sender);
- }
-
- public boolean isMasterBuilder(CommandSender sender)
- {
- if (!(sender instanceof Player))
- {
- return true;
- }
-
- MasterBuilder masterBuilder = getMasterBuilder((Player)sender);
-
- return masterBuilder != null;
- }
-
- public Map getAllMasterBuilders()
- {
- return this.masterBuilders;
- }
-
- public MasterBuilder getMasterBuilder(CommandSender sender)
- {
- if (sender instanceof Player)
- {
- return getMasterBuilder((Player)sender);
- }
-
- return getEntryByName(sender.getName());
- }
-
- public MasterBuilder getMasterBuilder(Player player)
- {
- String ip = Ips.getIp(player);
- MasterBuilder masterBuilder = getEntryByName(player.getName());
-
- // By name
- if (masterBuilder != null)
- {
- // Check if we're in online mode or if we have a matching IP
- if (server.getOnlineMode() || masterBuilder.getIps().contains(ip))
- {
- if (!masterBuilder.getIps().contains(ip))
- {
- // Add the new IP if needed
- masterBuilder.addIp(ip);
- save();
- updateTables();
- }
- return masterBuilder;
- }
- }
-
- // By ip
- masterBuilder = getEntryByIp(ip);
- if (masterBuilder != null)
- {
- // Set the new username
- masterBuilder.setName(player.getName());
- save();
- updateTables();
- }
-
- return null;
- }
-
- public MasterBuilder getEntryByName(String name)
- {
- return nameTable.get(name.toLowerCase());
- }
-
- public MasterBuilder getEntryByIp(String ip)
- {
- return ipTable.get(ip);
- }
-
- public MasterBuilder getEntryByIpFuzzy(String needleIp)
- {
- final MasterBuilder directMasterBuilder = getEntryByIp(needleIp);
- if (directMasterBuilder != null)
- {
- return directMasterBuilder;
- }
-
- for (String ip : ipTable.keySet())
- {
- if (FUtil.fuzzyIpMatch(needleIp, ip, 3))
- {
- return ipTable.get(ip);
- }
- }
-
- return null;
- }
-
- public void updateLastLogin(Player player)
- {
- final MasterBuilder masterBuilder = getMasterBuilder(player);
- if (masterBuilder == null)
- {
- return;
- }
-
- masterBuilder.setLastLogin(new Date());
- masterBuilder.setName(player.getName());
- save();
- }
-
- public boolean isMasterBuilderImpostor(Player player)
- {
- return getEntryByName(player.getName()) != null && !isMasterBuilder(player);
- }
-
- public boolean isIdentityMatched(Player player)
- {
- if (server.getOnlineMode())
- {
- return true;
- }
-
- MasterBuilder masterBuilder = getMasterBuilder(player);
- return masterBuilder != null && masterBuilder.getName().equalsIgnoreCase(player.getName());
- }
-
- public boolean addMasterBuilder(MasterBuilder masterBuilder)
- {
- if (!masterBuilder.isValid())
- {
- logger.warning("Could not add master builder: " + masterBuilder.getConfigKey() + " master builder is missing details!");
- return false;
- }
-
- final String key = masterBuilder.getConfigKey();
-
- // Store master builder, update views
- masterBuilders.put(key, masterBuilder);
- updateTables();
-
- // Save master builder
- masterBuilder.saveTo(config.createSection(key));
- config.save();
-
- return true;
- }
-
- public boolean removeMasterBuilder(MasterBuilder masterBuilder)
- {
- // Remove master builder, update views
- if (masterBuilders.remove(masterBuilder.getConfigKey()) == null)
- {
- return false;
- }
- updateTables();
-
- // 'Unsave' master builder
- config.set(masterBuilder.getConfigKey(), null);
- config.save();
-
- return true;
- }
-
- public void updateTables()
- {
- nameTable.clear();
- ipTable.clear();
-
- for (MasterBuilder masterBuilder : masterBuilders.values())
- {
- nameTable.put(masterBuilder.getName().toLowerCase(), masterBuilder);
-
- for (String ip : masterBuilder.getIps())
- {
- ipTable.put(ip, masterBuilder);
- }
-
- }
- }
-
- public Set getMasterBuilderNames()
- {
- return nameTable.keySet();
- }
-
- public Set getMasterBuilderIps()
- {
- return ipTable.keySet();
- }
-
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java
index bdcf3f9f..e1a004da 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java
@@ -6,14 +6,14 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.EnumMap;
import java.util.List;
+import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
-import net.pravian.aero.component.PluginComponent;
import org.apache.commons.io.FileUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
-public class PermissionConfig extends PluginComponent
+public class PermissionConfig extends FreedomService
{
public static final String PERMISSIONS_FILENAME = "permissions.yml";
@@ -24,8 +24,6 @@ public class PermissionConfig extends PluginComponent
public PermissionConfig(TotalFreedomMod plugin)
{
- super(plugin);
-
entries = new EnumMap<>(PermissionEntry.class);
PermissionDefaults tempDefaults = null;
@@ -59,6 +57,18 @@ public class PermissionConfig extends PluginComponent
defaults = tempDefaults;
}
+ @Override
+ public void onStart()
+ {
+
+ }
+
+ @Override
+ public void onStop()
+ {
+
+ }
+
public void load()
{
try
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java
index 5b2b4607..5ebc094d 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java
@@ -4,7 +4,6 @@ import com.google.common.collect.Maps;
import java.util.List;
import java.util.Map;
import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.rank.Title;
@@ -23,19 +22,14 @@ public class PermissionManager extends FreedomService
public Map attachments = Maps.newHashMap();
- public PermissionManager(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
@Override
- protected void onStart()
+ public void onStart()
{
loadPermissionNodes();
}
@Override
- protected void onStop()
+ public void onStop()
{
}
@@ -72,7 +66,9 @@ public class PermissionManager extends FreedomService
seniorAdminPermissions.addAll(telnetAdminPermissions);
permissions.put(Rank.SENIOR_ADMIN, seniorAdminPermissions);
- FLog.info("Loaded " + permissions.values().size() + " permission nodes");
+ int count = PermissionEntry.OPERATORS.getEntry().size() + PermissionEntry.MASTER_BUILDERS.getEntry().size() + PermissionEntry.SUPER_ADMINS.getEntry().size() + PermissionEntry.TELNET_ADMINS.getEntry().size() + PermissionEntry.SENIOR_ADMINS.getEntry().size();
+
+ FLog.info("Loaded " + count + " permission nodes");
}
public void setPermissions(Player player)
@@ -106,7 +102,7 @@ public class PermissionManager extends FreedomService
}
}
- if (plugin.mbl.isMasterBuilder(player) && !plugin.al.isAdmin(player))
+ if (plugin.pl.getData(player).isMasterBuilder() && !plugin.al.isAdmin(player))
{
if (nodes != null)
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java
index d341969c..00324db8 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java
@@ -9,7 +9,6 @@ import me.totalfreedom.totalfreedommod.caging.CageData;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Arrow;
@@ -79,7 +78,7 @@ public class FPlayer
public FPlayer(TotalFreedomMod plugin, Player player)
{
- this(plugin, player.getName(), Ips.getIp(player));
+ this(plugin, player.getName(), FUtil.getIp(player));
}
private FPlayer(TotalFreedomMod plugin, String name, String ip)
@@ -100,7 +99,7 @@ public class FPlayer
{
for (Player onlinePlayer : Bukkit.getOnlinePlayers())
{
- if (Ips.getIp(onlinePlayer).equals(ip))
+ if (FUtil.getIp(onlinePlayer).equals(ip))
{
player = onlinePlayer;
break;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java
index e2eb011d..30b44617 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java
@@ -1,59 +1,114 @@
package me.totalfreedom.totalfreedommod.player;
import com.google.common.collect.Lists;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import lombok.Getter;
import lombok.Setter;
-import net.pravian.aero.base.ConfigLoadable;
-import net.pravian.aero.base.ConfigSavable;
-import net.pravian.aero.base.Validatable;
-import org.apache.commons.lang.Validate;
-import org.bukkit.configuration.ConfigurationSection;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.shop.ShopItem;
+import me.totalfreedom.totalfreedommod.util.FLog;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Player;
-public class PlayerData implements ConfigLoadable, ConfigSavable, Validatable
+public class PlayerData
{
@Getter
@Setter
- private String username;
- @Getter
- @Setter
- private long firstJoinUnix;
- @Getter
- @Setter
- private long lastJoinUnix;
+ private String name;
private final List ips = Lists.newArrayList();
+ private final List notes = Lists.newArrayList();
+ @Getter
+ @Setter
+ private String tag = null;
+ @Getter
+ @Setter
+ private String discordID = null;
+ private final List backupCodes = Lists.newArrayList();
+ @Setter
+ private boolean donator = false;
+ @Setter
+ private Boolean masterBuilder = false;
+ @Setter
+ private Boolean verification = false;
+ @Getter
+ @Setter
+ private String rideMode = "ask";
+ @Getter
+ @Setter
+ private int coins;
+ private List items = Lists.newArrayList();
+ @Getter
+ @Setter
+ private int totalVotes;
+
+ public PlayerData(ResultSet resultSet)
+ {
+ try
+ {
+ name = resultSet.getString("username");
+ ips.clear();
+ ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
+ notes.clear();
+ notes.addAll(FUtil.stringToList(resultSet.getString("notes")));
+ tag = resultSet.getString("tag");
+ discordID = resultSet.getString("discord_id");
+ backupCodes.clear();
+ backupCodes.addAll(FUtil.stringToList(resultSet.getString("backup_codes")));
+ masterBuilder = resultSet.getBoolean("master_builder");
+ verification = resultSet.getBoolean("verification");
+ rideMode = resultSet.getString("ride_mode");
+ coins = resultSet.getInt("coins");
+ items.clear();
+ items.addAll(FUtil.stringToList(resultSet.getString("items")));
+ totalVotes = resultSet.getInt("total_votes");
+ }
+ catch (SQLException e)
+ {
+ FLog.severe("Failed to load player: " + e.getMessage());
+ }
+
+ // Force verification for Master Builders
+ if (masterBuilder && !verification)
+ {
+ verification = true;
+ TotalFreedomMod.plugin().pl.save(this);
+ }
+ else if (!masterBuilder && discordID == null && verification)
+ {
+ this.verification = false;
+ TotalFreedomMod.plugin().pl.save(this);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder output = new StringBuilder();
+
+ output.append("Player: ").append(name).append("\n")
+ .append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
+ .append("- Discord ID: ").append(discordID).append("\n")
+ .append("- Master Builder: ").append(masterBuilder).append("\n")
+ .append("- Has Verification: ").append(verification).append("\n")
+ .append("- Coins: ").append(coins).append("\n")
+ .append("- Total Votes: ").append(totalVotes).append("\n")
+ .append("- Tag: ").append(tag).append("\n")
+ .append("- Ride Mode: ").append(rideMode)
+ .append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
+
+ return output.toString();
+ }
public PlayerData(Player player)
{
- this(player.getName());
- }
-
- public PlayerData(String username)
- {
- this.username = username;
- }
-
- @Override
- public void loadFrom(ConfigurationSection cs)
- {
- this.username = cs.getString("username", username);
- this.ips.clear();
- this.ips.addAll(cs.getStringList("ips"));
- this.firstJoinUnix = cs.getLong("first_join", 0);
- this.lastJoinUnix = cs.getLong("last_join", 0);
- }
-
- @Override
- public void saveTo(ConfigurationSection cs)
- {
- Validate.isTrue(isValid(), "Could not save player entry: " + username + ". Entry not valid!");
- cs.set("username", username);
- cs.set("ips", ips);
- cs.set("first_join", firstJoinUnix);
- cs.set("last_join", lastJoinUnix);
+ this.name = player.getName();
}
public List getIps()
@@ -61,23 +116,127 @@ public class PlayerData implements ConfigLoadable, ConfigSavable, Validatable
return Collections.unmodifiableList(ips);
}
- // IP utils
public boolean addIp(String ip)
{
- return ips.contains(ip) ? false : ips.add(ip);
+ return !ips.contains(ip) && ips.add(ip);
}
- public boolean removeIp(String ip)
+ public void removeIp(String ip)
{
- return ips.remove(ip);
+ ips.remove(ip);
}
- @Override
- public boolean isValid()
+ public void clearIps()
{
- return username != null
- && firstJoinUnix != 0
- && lastJoinUnix != 0
- && !ips.isEmpty();
+ ips.clear();
+ }
+
+ public void addIps(List ips)
+ {
+ ips.addAll(ips);
+ }
+
+ public List getNotes()
+ {
+ return Collections.unmodifiableList(notes);
+ }
+
+ public void clearNotes()
+ {
+ notes.clear();
+ }
+
+ public List getBackupCodes()
+ {
+ return Collections.unmodifiableList(backupCodes);
+ }
+
+ public void setBackupCodes(List codes)
+ {
+ backupCodes.clear();
+ backupCodes.addAll(codes);
+ }
+
+ public void removeBackupCode(String code)
+ {
+ backupCodes.remove(code);
+ }
+
+ public void addNote(String note)
+ {
+ notes.add(note);
+ }
+
+ public boolean removeNote(int id) throws IndexOutOfBoundsException
+ {
+ try
+ {
+ notes.remove(id);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public void giveItem(ShopItem item)
+ {
+ items.add(item.getDataName());
+ }
+
+ public List getItems()
+ {
+ return Collections.unmodifiableList(items);
+ }
+
+ public boolean hasItem(ShopItem item)
+ {
+ if (items.contains(item.getDataName()))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public void removeItem(ShopItem item)
+ {
+ items.remove(item.getDataName());
+ }
+
+ public boolean hasVerification()
+ {
+ return verification;
+ }
+
+ public boolean isDonator()
+ {
+ return donator;
+ }
+
+ public boolean isMasterBuilder()
+ {
+ return masterBuilder;
+ }
+
+ public Map toSQLStorable()
+ {
+ Map map = new HashMap()
+ {{
+ put("username", name);
+ put("ips", FUtil.listToString(ips));
+ put("notes", FUtil.listToString(notes));
+ put("tag", tag);
+ put("discord_id", discordID);
+ put("backup_codes", FUtil.listToString(backupCodes));
+ put("donator", masterBuilder);
+ put("master_builder", masterBuilder);
+ put("verification", verification);
+ put("ride_mode", rideMode);
+ put("coins", coins);
+ put("items", FUtil.listToString(items));
+ put("total_votes", totalVotes);
+ }};
+ return map;
}
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java
index 9ee8b24a..37ab2715 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java
@@ -1,69 +1,41 @@
package me.totalfreedom.totalfreedommod.player;
import com.google.common.collect.Maps;
-import java.io.File;
-import java.util.Collection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
import java.util.Map;
import lombok.Getter;
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.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.config.YamlConfig;
-import net.pravian.aero.util.Ips;
-import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerList extends FreedomService
{
- public static final long AUTO_PURGE_TICKS = 20L * 60L * 5L;
- //
@Getter
public final Map playerMap = Maps.newHashMap(); // ip,dataMap
- @Getter
- public final Map dataMap = Maps.newHashMap(); // ip,dataMap
- @Getter
- private final File configFolder;
- public PlayerList(TotalFreedomMod plugin)
- {
- super(plugin);
-
- this.configFolder = new File(plugin.getDataFolder(), "players");
- }
+ @Getter
+ public final Map dataMap = Maps.newHashMap(); // username, data
@Override
- protected void onStart()
+ public void onStart()
{
- playerMap.clear();
dataMap.clear();
-
- // Preload online players
- for (Player player : server.getOnlinePlayers())
- {
- getPlayer(player);
- }
+ loadMasterBuilders();
}
@Override
- protected void onStop()
+ public void onStop()
{
- save();
- }
-
- public void save()
- {
- for (PlayerData data : dataMap.values())
- {
- YamlConfig config = getConfig(data);
- data.saveTo(config);
- config.save();
- }
}
public FPlayer getPlayerSync(Player player)
@@ -74,11 +46,34 @@ public class PlayerList extends FreedomService
}
}
+ public void loadMasterBuilders()
+ {
+ ResultSet resultSet = plugin.sql.getMasterBuilders();
+
+ if (resultSet == null)
+ {
+ return;
+ }
+
+ try
+ {
+ while (resultSet.next())
+ {
+ PlayerData playerData = load(resultSet);
+ dataMap.put(playerData.getName(), playerData);
+ }
+ }
+ catch (SQLException e)
+ {
+ FLog.severe("Failed to parse master builders: " + e.getMessage());
+ }
+ }
+
public String getIp(OfflinePlayer player)
{
if (player.isOnline())
{
- return Ips.getIp(player.getPlayer());
+ return FUtil.getIp(player.getPlayer());
}
final PlayerData entry = getData(player.getName());
@@ -86,137 +81,244 @@ public class PlayerList extends FreedomService
return (entry == null ? null : entry.getIps().iterator().next());
}
+ public List getMasterBuilderNames()
+ {
+ List masterBuilders = new ArrayList<>();
+ for (PlayerData playerData : plugin.pl.dataMap.values())
+ {
+ if (playerData.isMasterBuilder())
+ {
+ masterBuilders.add(playerData.getName());
+ }
+ }
+ return masterBuilders;
+ }
+
+ public boolean canManageMasterBuilders(String name)
+ {
+ PlayerData data = getData(name);
+
+ if ((!ConfigEntry.HOST_SENDER_NAMES.getStringList().contains(name.toLowerCase()) && data != null && !ConfigEntry.SERVER_OWNERS.getStringList().contains(data.getName()))
+ && !ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(data.getName())
+ && !isTelnetMasterBuilder(data)
+ && !ConfigEntry.HOST_SENDER_NAMES.getStringList().contains(name.toLowerCase()))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean isTelnetMasterBuilder(PlayerData playerData)
+ {
+ Admin admin = plugin.al.getEntryByName(playerData.getName());
+ if (admin != null && admin.getRank().isAtLeast(Rank.TELNET_ADMIN) && playerData.isMasterBuilder())
+ {
+ return true;
+ }
+
+ return false;
+ }
+
// May not return null
public FPlayer getPlayer(Player player)
{
- FPlayer tPlayer = playerMap.get(Ips.getIp(player));
+ FPlayer tPlayer = playerMap.get(FUtil.getIp(player));
if (tPlayer != null)
{
return tPlayer;
}
tPlayer = new FPlayer(plugin, player);
- playerMap.put(Ips.getIp(player), tPlayer);
+ playerMap.put(FUtil.getIp(player), tPlayer);
return tPlayer;
}
- // May not return null
- public PlayerData getData(Player player)
+ public PlayerData loadByName(String name)
{
- // Check already loaded
- PlayerData data = dataMap.get(Ips.getIp(player));
- if (data != null)
- {
- return data;
- }
-
- // Load data
- data = getData(player.getName());
-
- // Create data if nonexistent
- if (data == null)
- {
- FLog.info("Creating new player data entry for " + player.getName());
-
- // Create new player
- final long unix = FUtil.getUnixTime();
- data = new PlayerData(player);
- data.setFirstJoinUnix(unix);
- data.setLastJoinUnix(unix);
- data.addIp(Ips.getIp(player));
-
- // Store player
- dataMap.put(player.getName().toLowerCase(), data);
-
- // Save player
- YamlConfig config = getConfig(data);
- data.saveTo(config);
- config.save();
- }
-
- return data;
+ return load(plugin.sql.getPlayerByName(name));
}
- // May return null
- public PlayerData getData(String username)
+ public PlayerData loadByIp(String ip)
{
- username = username.toLowerCase();
+ return load(plugin.sql.getPlayerByIp(ip));
+ }
- // Check if the player is a known player
- final File configFile = getConfigFile(username);
- if (!configFile.exists())
+ public PlayerData load(ResultSet resultSet)
+ {
+ if (resultSet == null)
{
return null;
}
+ return new PlayerData(resultSet);
+ }
- // Create and load entry
- final PlayerData data = new PlayerData(username);
- data.loadFrom(getConfig(data));
+ public Boolean isPlayerImpostor(Player player)
+ {
+ PlayerData playerData = getData(player);
+ return !plugin.al.isAdmin(player)
+ && (playerData.hasVerification())
+ && !playerData.getIps().contains(FUtil.getIp(player));
+ }
- if (!data.isValid())
+ public boolean isImposter(Player player)
+ {
+ return isPlayerImpostor(player) || plugin.al.isAdminImpostor(player);
+ }
+
+ public void verify(Player player, String backupCode)
+ {
+ PlayerData playerData = getData(player);
+ if (backupCode != null)
{
- FLog.warning("Could not load player data entry: " + username + ". Entry is not valid!");
- configFile.delete();
- return null;
+ playerData.removeBackupCode(backupCode);
}
+ playerData.addIp(FUtil.getIp(player));
+ save(playerData);
- // Only store data if the player is online
- for (String ip : data.getIps())
+ if (plugin.al.isAdminImpostor(player))
{
- for (Player onlinePlayer : Bukkit.getOnlinePlayers())
+ Admin admin = null;
+ for (Admin loopAdmin : plugin.al.getAllAdmins())
{
- if (Ips.getIp(onlinePlayer).equals(ip))
+ if (loopAdmin.getName().equalsIgnoreCase(player.getName()))
{
- dataMap.put(ip, data);
- return data;
+ admin = loopAdmin;
+ break;
+ }
+ }
+ admin.setLastLogin(new Date());
+ admin.addIp(FUtil.getIp(player));
+ plugin.al.updateTables();
+ plugin.al.save(admin);
+ }
+
+ plugin.rm.updateDisplay(player);
+ }
+
+ public void syncIps(Admin admin)
+ {
+ PlayerData playerData = getData(admin.getName());
+ playerData.clearIps();
+ playerData.addIps(admin.getIps());
+ plugin.pl.save(playerData);
+ }
+ public void syncIps(PlayerData playerData)
+ {
+ Admin admin = plugin.al.getEntryByName(playerData.getName());
+
+ if (admin != null && admin.isActive())
+ {
+ admin.clearIPs();
+ admin.addIps(playerData.getIps());
+ plugin.al.updateTables();
+ plugin.al.save(admin);
+ }
+ }
+
+
+ public void save(PlayerData player)
+ {
+ try
+ {
+ ResultSet currentSave = plugin.sql.getPlayerByName(player.getName());
+ for (Map.Entry entry : player.toSQLStorable().entrySet())
+ {
+ Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
+ if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
+ {
+ plugin.sql.setPlayerValue(player, entry.getKey(), entry.getValue());
}
}
}
-
- return data;
- }
-
- @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
- public void onPlayerQuit(PlayerQuitEvent event)
- {
- final Player player = event.getPlayer();
- final String ip = Ips.getIp(player);
- playerMap.remove(ip);
- dataMap.remove(ip);
- }
-
- public Collection getLoadedPlayers()
- {
- return playerMap.values();
- }
-
- public Collection getLoadedData()
- {
- return dataMap.values();
- }
-
- public int purgeAllData()
- {
- int deleted = 0;
- for (File file : getConfigFolder().listFiles())
+ catch (SQLException e)
{
- deleted += file.delete() ? 1 : 0;
+ FLog.severe("Failed to save player: " + e.getMessage());
+ }
+ }
+
+ public PlayerData getData(Player player)
+ {
+ // Check for existing data
+ PlayerData playerData = dataMap.get(player.getName());
+ if (playerData != null)
+ {
+ return playerData;
}
- dataMap.clear();
- return deleted;
+ // Load data
+ playerData = loadByName(player.getName());
+
+ if (playerData == null)
+ {
+ playerData = loadByIp(FUtil.getIp(player));
+ if (playerData != null)
+ {
+ plugin.sql.updatePlayerName(playerData.getName(),player.getName());
+ playerData.setName(player.getName());
+ dataMap.put(player.getName(), playerData);
+ return playerData;
+ }
+ }
+ else
+ {
+ dataMap.put(player.getName(), playerData);
+ return playerData;
+ }
+
+ // Create new data if nonexistent
+ if (playerData == null)
+ {
+ FLog.info("Creating new player verification entry for " + player.getName());
+
+ // Create new player
+ playerData = new PlayerData(player);
+ playerData.addIp(FUtil.getIp(player));
+
+ // Store player
+ dataMap.put(player.getName(), playerData);
+
+ // Save player
+ plugin.sql.addPlayer(playerData);
+ return playerData;
+ }
+
+ return null;
}
- protected File getConfigFile(String name)
+ public PlayerData getData(String username)
{
- return new File(getConfigFolder(), name + ".yml");
+ // Check for existing data
+ PlayerData playerData = dataMap.get(username);
+ if (playerData != null)
+ {
+ return playerData;
+ }
+
+ playerData = loadByName(username);
+
+ if (playerData != null)
+ {
+ dataMap.put(username, playerData);
+ }
+ else
+ {
+ return null;
+ }
+
+ return playerData;
}
- protected YamlConfig getConfig(PlayerData data)
+ public PlayerData getDataByIp(String ip)
{
- final YamlConfig config = new YamlConfig(plugin, getConfigFile(data.getUsername().toLowerCase()), false);
- config.load();
- return config;
+ PlayerData player = loadByIp(ip);
+
+ if (player != null)
+ {
+ dataMap.put(player.getName(), player);
+ }
+
+ return player;
}
+
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/playerverification/PlayerVerification.java b/src/main/java/me/totalfreedom/totalfreedommod/playerverification/PlayerVerification.java
deleted file mode 100644
index 17e290fa..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/playerverification/PlayerVerification.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package me.totalfreedom.totalfreedommod.playerverification;
-
-import com.google.common.collect.Maps;
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import lombok.Getter;
-import me.totalfreedom.totalfreedommod.FreedomService;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import me.totalfreedom.totalfreedommod.util.FLog;
-import net.pravian.aero.config.YamlConfig;
-import net.pravian.aero.util.Ips;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.player.PlayerQuitEvent;
-
-public class PlayerVerification extends FreedomService
-{
-
- @Getter
- public final Map dataMap = Maps.newHashMap(); // username, data
- @Getter
- private final File configFolder;
-
- public PlayerVerification(TotalFreedomMod plugin)
- {
- super(plugin);
-
- this.configFolder = new File(plugin.getDataFolder(), "playerverification");
- }
-
- @Override
- protected void onStart()
- {
- dataMap.clear();
- }
-
- @Override
- protected void onStop()
- {
- save();
- }
-
- public Boolean isPlayerImpostor(Player player)
- {
- VPlayer vPlayer = getVerificationPlayer(player);
- return !plugin.al.isAdmin(player)
- && (vPlayer.getEnabled())
- && !vPlayer.getIps().contains(Ips.getIp(player));
- }
-
- public void verifyPlayer(Player player, String backupCode)
- {
- if (!isPlayerImpostor(player))
- {
- return;
- }
-
- VPlayer vPlayer = getVerificationPlayer(player);
- if (backupCode != null)
- {
- vPlayer.removeBackupCode(backupCode);
- }
- vPlayer.addIp(Ips.getIp(player));
- dataMap.put(player.getName(), vPlayer);
- YamlConfig config = getConfig(vPlayer);
- vPlayer.saveTo(config);
- config.save();
- }
-
- public void saveVerificationData(VPlayer player)
- {
- YamlConfig config = getConfig(player);
- player.saveTo(config);
- config.save();
- dataMap.put(player.getName(), player);
- }
-
- public void removeEntry(String name)
- {
- name = name.toLowerCase(); // Configuration files are saved in lowercase
- if (getVerificationPlayer(name) != null)
- {
- getConfigFile(name).delete();
- dataMap.remove(name);
- }
- }
-
- public void save()
- {
- for (VPlayer vPlayer : dataMap.values())
- {
- YamlConfig config = getConfig(vPlayer);
- vPlayer.saveTo(config);
- config.save();
- }
- }
-
- // May not return null
- public VPlayer getVerificationPlayer(Player player)
- {
- // Check for existing data
- VPlayer vPlayer = dataMap.get(player.getName());
- if (vPlayer != null)
- {
- return vPlayer;
- }
-
- // Load data
- vPlayer = getVerificationPlayer(player.getName());
-
- // Create new data if nonexistent
- if (vPlayer == null)
- {
- FLog.info("Creating new player verification entry for " + player.getName());
-
- // Create new player
- vPlayer = new VPlayer(player);
- vPlayer.addIp(Ips.getIp(player));
-
- // Store player
- dataMap.put(player.getName(), vPlayer);
-
- // Save player
- YamlConfig config = getConfig(vPlayer);
- vPlayer.saveTo(config);
- config.save();
- }
-
- return vPlayer;
- }
-
- // May return null
- public VPlayer getVerificationPlayer(String username)
- {
- username = username.toLowerCase();
-
- final File configFile = getConfigFile(username);
- if (!configFile.exists())
- {
- return null;
- }
-
- final VPlayer vPlayer = new VPlayer(username);
- vPlayer.loadFrom(getConfig(vPlayer));
-
- if (!vPlayer.isValid())
- {
- FLog.warning("Could not load player verification entry for " + username + ". Entry is not valid!");
- configFile.delete();
- return null;
- }
-
- // Only store data in map if the player is online
- for (Player players : Bukkit.getOnlinePlayers())
- {
- if (players.getName().equals(username))
- {
- dataMap.put(username, vPlayer);
- return vPlayer;
- }
- }
-
- return vPlayer;
- }
-
- @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
- public void onPlayerQuit(PlayerQuitEvent event)
- {
- dataMap.remove(event.getPlayer().getName());
- }
-
- protected File getConfigFile(String name)
- {
- return new File(getConfigFolder(), name + ".yml");
- }
-
- protected YamlConfig getConfig(VPlayer player)
- {
- final YamlConfig config = new YamlConfig(plugin, getConfigFile(player.getName().toLowerCase()), false);
- config.load();
-
- // Convert discordEnabled to enabled, and remove forumEnabled.
- if (config.get("discordEnabled") != null)
- {
- config.set("enabled", config.getBoolean("discordEnabled"));
- config.set("discordEnabled", null);
- config.set("forumEnabled", null);
- try
- {
- config.save(getConfigFile(player.getName().toLowerCase()));
- }
- catch (IOException e)
- {
- FLog.warning("Failed to convert player verification entry for " + player.getName());
- }
- }
-
- return config;
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/playerverification/VPlayer.java b/src/main/java/me/totalfreedom/totalfreedommod/playerverification/VPlayer.java
deleted file mode 100644
index 4f1d5535..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/playerverification/VPlayer.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package me.totalfreedom.totalfreedommod.playerverification;
-
-import com.google.common.collect.Lists;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import lombok.Getter;
-import lombok.Setter;
-import me.totalfreedom.totalfreedommod.util.FLog;
-import net.pravian.aero.base.ConfigLoadable;
-import net.pravian.aero.base.ConfigSavable;
-import net.pravian.aero.base.Validatable;
-import org.apache.commons.lang.Validate;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.entity.Player;
-
-public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
-{
-
- private final List ips = Lists.newArrayList();
- private final List