From bc8ff3cd7fe945773329df69f7d084050b34bf8c Mon Sep 17 00:00:00 2001
From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com>
Date: Mon, 13 Apr 2020 23:40:22 -0700
Subject: [PATCH] permission system
---
TotalFreedomMod.iml | 65 +------
pom.xml | 19 +-
.../totalfreedommod/LoginProcess.java | 2 +-
.../totalfreedommod/TotalFreedomMod.java | 9 +
.../totalfreedommod/admin/AdminList.java | 1 +
.../bridge/EssentialsBridge.java | 6 -
.../bridge/WorldEditBridge.java | 4 -
.../bridge/WorldEditListener.java | 63 ------
.../bridge/WorldGuardBridge.java | 34 +---
.../command/Command_cartsit.java | 2 +-
.../totalfreedommod/command/Command_deop.java | 49 +++--
.../command/Command_invis.java | 2 +-
.../command/Command_invsee.java | 2 +-
.../totalfreedommod/command/Command_list.java | 8 +-
.../command/Command_makeopregion.java | 25 ++-
.../command/Command_nickfilter.java | 4 +-
.../totalfreedommod/command/Command_op.java | 53 +++--
.../command/Command_permissions.java | 52 +++++
.../command/Command_potion.java | 4 +-
.../command/Command_qdeop.java | 61 ------
.../totalfreedommod/command/Command_qop.java | 61 ------
.../totalfreedommod/command/Command_rank.java | 2 +-
.../command/Command_reactionbar.java | 25 +++
.../command/Command_report.java | 2 +-
.../totalfreedommod/command/Command_ride.java | 2 +-
.../totalfreedommod/command/Command_tag.java | 2 +-
.../command/Command_vanish.java | 7 +-
.../command/Command_whohas.java | 2 +-
.../httpd/module/Module_permbans.java | 7 +-
.../permissions/PermissionConfig.java | 184 ++++++++++++++++++
.../permissions/PermissionEntry.java | 44 +++++
.../permissions/PermissionManager.java | 138 +++++++++++++
.../totalfreedommod/rank/RankManager.java | 1 +
.../totalfreedommod/util/FUtil.java | 2 +-
src/main/resources/activitylog.yml | 2 +-
src/main/resources/admins.yml | 2 +-
src/main/resources/bans.yml | 2 +-
src/main/resources/config.yml | 2 +-
src/main/resources/masterbuilders.yml | 2 +-
src/main/resources/permbans.yml | 2 +-
src/main/resources/permissions.yml | 78 ++++++++
src/main/resources/plugin.yml | 2 +-
src/main/resources/punishments.yml | 2 +-
src/main/resources/vpnbans.yml | 2 +-
44 files changed, 662 insertions(+), 378 deletions(-)
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditListener.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_qdeop.java
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_qop.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionEntry.java
create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java
create mode 100644 src/main/resources/permissions.yml
diff --git a/TotalFreedomMod.iml b/TotalFreedomMod.iml
index 869f5898..72d4af32 100644
--- a/TotalFreedomMod.iml
+++ b/TotalFreedomMod.iml
@@ -61,58 +61,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -142,14 +91,16 @@
+
-
-
-
-
-
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 03dd2704..48a3b06f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
me.totalfreedom
TotalFreedomMod
- 5.4
+ 5.5
jar
@@ -49,6 +49,11 @@
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+ enginehub
+ https://maven.enginehub.org/repo/
+
+
elmakers-repo
http://maven.elmakers.com/repository/
@@ -159,9 +164,9 @@
- com.github.TFPatches
- TF-WorldEdit
- fd3f56f015
+ com.sk89q.worldedit
+ worldedit-bukkit
+ 7.1.0
provided
@@ -187,9 +192,9 @@
- com.github.TFPatches
- TF-WorldGuard
- bb12813214
+ com.sk89q.worldguard
+ worldguard-bukkit
+ 7.0.2
provided
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
index 13404a57..327af295 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
@@ -227,7 +227,7 @@ public class LoginProcess extends FreedomService
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
}
- for (Player p : Command_vanish.VANISHED)
+ for (Player p : plugin.al.vanished)
{
if (!plugin.al.isAdmin(player))
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java
index 333bcd18..ccb3f8d0 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java
@@ -41,6 +41,8 @@ import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderList;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderWorldRestrictions;
+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;
@@ -72,6 +74,7 @@ public class TotalFreedomMod extends AeroPlugin
public static String pluginVersion;
//
public MainConfig config;
+ public PermissionConfig permissions;
//
// Services
public ServiceManager services;
@@ -100,6 +103,7 @@ public class TotalFreedomMod extends AeroPlugin
public PunishmentList pul;
public BanManager bm;
public PermbanList pm;
+ public PermissionManager pem;
public VPNBanList vn;
public ProtectArea pa;
public GameRuleHandler gr;
@@ -176,6 +180,7 @@ public class TotalFreedomMod extends AeroPlugin
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
backups.createBackups(AdminList.CONFIG_FILENAME);
backups.createBackups(PermbanList.CONFIG_FILENAME);
+ backups.createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
backups.createBackups(VPNBanList.CONFIG_FILENAME);
backups.createBackups(MasterBuilder.CONFIG_FILENAME);
backups.createBackups(PunishmentList.CONFIG_FILENAME);
@@ -183,6 +188,9 @@ public class TotalFreedomMod extends AeroPlugin
config = new MainConfig(this);
config.load();
+ permissions = new PermissionConfig(this);
+ permissions.load();
+
// Start services
services = new ServiceManager<>(plugin);
si = services.registerService(ServerInterface.class);
@@ -213,6 +221,7 @@ public class TotalFreedomMod extends AeroPlugin
pul = services.registerService(PunishmentList.class);
bm = services.registerService(BanManager.class);
pm = services.registerService(PermbanList.class);
+ pem = services.registerService(PermissionManager.class);
vn = services.registerService(VPNBanList.class);
pa = services.registerService(ProtectArea.class);
gr = services.registerService(GameRuleHandler.class);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java
index b1ca3003..24c06e90 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java
@@ -38,6 +38,7 @@ public class AdminList extends FreedomService
private final Map ipTable = Maps.newHashMap();
public final List verifiedNoAdmins = new ArrayList<>();
public final Map> verifiedNoAdminIps = Maps.newHashMap();
+ public static ArrayList vanished = new ArrayList<>();
//
private final YamlConfig config;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java
index 7009be95..324c05f2 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java
@@ -4,7 +4,6 @@ import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import me.totalfreedom.totalfreedommod.command.Command_vanish;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
@@ -40,7 +39,6 @@ public class EssentialsBridge extends FreedomService
@Override
protected void onStop()
{
- Command_vanish.VANISHED.clear();
}
public Essentials getEssentialsPlugin()
@@ -215,10 +213,6 @@ public class EssentialsBridge extends FreedomService
public void onPlayerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
- if (Command_vanish.VANISHED.contains(player))
- {
- Command_vanish.VANISHED.remove(player);
- }
}
public boolean isEnabled()
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java
index 60489b73..7e33051b 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java
@@ -12,26 +12,22 @@ import org.bukkit.plugin.Plugin;
public class WorldEditBridge extends FreedomService
{
- private final WorldEditListener listener;
//
private WorldEditPlugin worldeditPlugin = null;
public WorldEditBridge(TotalFreedomMod plugin)
{
super(plugin);
- listener = new WorldEditListener(plugin);
}
@Override
protected void onStart()
{
- listener.register();
}
@Override
protected void onStop()
{
- listener.unregister();
}
public WorldEditPlugin getWorldEditPlugin()
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditListener.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditListener.java
deleted file mode 100644
index 62a8790d..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditListener.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package me.totalfreedom.totalfreedommod.bridge;
-
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import me.totalfreedom.worldedit.LimitChangedEvent;
-import me.totalfreedom.worldedit.SelectionChangedEvent;
-import net.pravian.aero.component.PluginListener;
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-
-public class WorldEditListener extends PluginListener
-{
-
- public WorldEditListener(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
- @EventHandler
- public void onSelectionChange(final SelectionChangedEvent event)
- {
- final Player player = event.getPlayer();
-
- if (plugin.al.isAdmin(player))
- {
- return;
- }
-
- if (plugin.pa.isInProtectedArea(
- event.getMinVector(),
- event.getMaxVector(),
- event.getWorld().getName()))
- {
- player.sendMessage(ChatColor.RED + "The region that you selected contained a protected area. Selection cleared.");
- event.setCancelled(true);
- }
- }
-
- @EventHandler
- public void onLimitChanged(LimitChangedEvent event)
- {
- final Player player = event.getPlayer();
-
- if (plugin.al.isAdmin(player))
- {
- return;
- }
-
- if (!event.getPlayer().equals(event.getTarget()))
- {
- player.sendMessage(ChatColor.RED + "Only admins can change the limit for other players!");
- event.setCancelled(true);
- }
-
- if (event.getLimit() < 0 || event.getLimit() > 200000)
- {
- event.setCancelled(true);
- player.sendMessage(ChatColor.RED + "You cannot set your limit higher than 200000 or to -1!");
- }
- }
-
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java
index 22ba8e7f..afb7f4be 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java
@@ -1,20 +1,19 @@
package me.totalfreedom.totalfreedommod.bridge;
-import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.managers.RegionManager;
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 me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.World;
import org.bukkit.plugin.Plugin;
public class WorldGuardBridge extends FreedomService
{
- private WorldGuardPlugin worldGuardPlugin;
-
public WorldGuardBridge(TotalFreedomMod plugin)
{
super(plugin);
@@ -30,31 +29,16 @@ public class WorldGuardBridge extends FreedomService
{
}
- public WorldGuardPlugin getWorldGuardPlugin()
+ public RegionManager getRegionManager(World world)
{
- if (worldGuardPlugin == null)
- {
- try
- {
- final Plugin worldGuard = server.getPluginManager().getPlugin("WorldGuard");
- if (worldGuard != null && worldGuard instanceof WorldGuardPlugin)
- {
- worldGuardPlugin = (WorldGuardPlugin)worldGuard;
- }
- }
- catch (Exception ex)
- {
- FLog.severe(ex);
- }
- }
-
- return worldGuardPlugin;
+ RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
+ return container.get(BukkitAdapter.adapt(world));
}
public int wipeRegions(World world)
{
int count = 0;
- RegionManager regionManager = getWorldGuardPlugin().getRegionManager(world);
+ RegionManager regionManager = getRegionManager(world);
if (regionManager != null)
{
Map regions = regionManager.getRegions();
@@ -69,8 +53,8 @@ public class WorldGuardBridge extends FreedomService
public boolean isEnabled()
{
- final WorldGuardPlugin wg = getWorldGuardPlugin();
+ Plugin plugin = server.getPluginManager().getPlugin("WorldGuard");
- return wg != null && wg.isEnabled();
+ return plugin != null && plugin.isEnabled();
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java
index f18dbbcd..61122b87 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java
@@ -21,7 +21,7 @@ public class Command_cartsit extends FreedomCommand
targetPlayer = getPlayer(args[0]);
- if (targetPlayer == null || Command_vanish.VANISHED.contains(targetPlayer) && !plugin.al.isAdmin(sender))
+ if (targetPlayer == null || plugin.al.vanished.contains(targetPlayer) && !plugin.al.isAdmin(sender))
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java
index a9f29d15..a7448b37 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java
@@ -1,50 +1,59 @@
package me.totalfreedom.totalfreedommod.command;
+import java.util.ArrayList;
+import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.OfflinePlayer;
+import org.apache.commons.lang.StringUtils;
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 = "Deop a player.", usage = "/ ")
+@CommandParameters(description = "Deop a player", usage = "/ ")
public class Command_deop extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (args.length != 1)
+ if (args.length < 1)
{
return false;
}
- OfflinePlayer player = null;
-
- for (Player onlinePlayer : server.getOnlinePlayers())
+ boolean silent = false;
+ if (args.length == 2)
{
- if (args[0].equalsIgnoreCase(onlinePlayer.getName()))
+ silent = args[1].equalsIgnoreCase("-s");
+ }
+
+ final String targetName = args[0].toLowerCase();
+
+ final List matchedPlayerNames = new ArrayList<>();
+ for (final Player player : server.getOnlinePlayers())
+ {
+ if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName))
{
- player = onlinePlayer;
+ if (player.isOp() && !plugin.al.vanished.contains(player))
+ {
+ matchedPlayerNames.add(player.getName());
+ player.setOp(false);
+ player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
+ }
}
}
- // if the player is not online
- if (player == null)
+ if (!matchedPlayerNames.isEmpty())
{
- player = DepreciationAggregator.getOfflinePlayer(server, args[0]);
+ if (!silent)
+ {
+ FUtil.adminAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false);
+ }
}
-
- FUtil.adminAction(sender.getName(), "De-opping " + player.getName(), false);
-
- player.setOp(false);
-
- if (player.isOnline())
+ else
{
- Player p = (Player)player;
- p.sendMessage(YOU_ARE_NOT_OP);
+ msg("No targets matched.");
}
return true;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java
index 19320e07..b2156e87 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java
@@ -42,7 +42,7 @@ public class Command_invis extends FreedomCommand
for (Player player : server.getOnlinePlayers())
{
- if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !Command_vanish.VANISHED.contains(player))
+ if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !plugin.al.vanished.contains(player))
{
players.add(player.getName());
if (clear && !plugin.al.isAdmin(player))
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invsee.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invsee.java
index 6e892c80..538a07d5 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invsee.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invsee.java
@@ -23,7 +23,7 @@ public class Command_invsee extends FreedomCommand
Player player = getPlayer(args[0]);
- if (player == null || Command_vanish.VANISHED.contains(player) && !plugin.al.isAdmin(sender))
+ if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
{
msg("This player is not online.");
return false;
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 e5513150..0350c5b9 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java
@@ -71,7 +71,7 @@ public class Command_list extends FreedomCommand
}
StringBuilder onlineStats = new StringBuilder();
StringBuilder onlineUsers = new StringBuilder();
- onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - Command_vanish.VANISHED.size())
+ onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - plugin.al.vanished.size())
.append(ChatColor.BLUE)
.append(" out of a maximum ")
.append(ChatColor.RED)
@@ -85,11 +85,11 @@ public class Command_list extends FreedomCommand
{
continue;
}
- if (listFilter == ListFilter.ADMINS && Command_vanish.VANISHED.contains(p))
+ if (listFilter == ListFilter.ADMINS && plugin.al.vanished.contains(p))
{
continue;
}
- if (listFilter == ListFilter.VANISHED_ADMINS && !Command_vanish.VANISHED.contains(p))
+ if (listFilter == ListFilter.VANISHED_ADMINS && !plugin.al.vanished.contains(p))
{
continue;
}
@@ -101,7 +101,7 @@ public class Command_list extends FreedomCommand
{
continue;
}
- if (listFilter == ListFilter.PLAYERS && Command_vanish.VANISHED.contains(p))
+ if (listFilter == ListFilter.PLAYERS && plugin.al.vanished.contains(p))
{
continue;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_makeopregion.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_makeopregion.java
index 4d2a6f49..21aea054 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_makeopregion.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_makeopregion.java
@@ -6,6 +6,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.Flags;
+import com.sk89q.worldguard.protection.flags.RegionGroup;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
@@ -23,14 +24,15 @@ import org.bukkit.entity.Player;
public class Command_makeopregion extends FreedomCommand
{
- final Map, Object> flags = new HashMap, Object>() {{
- put(Flags.BLOCK_PLACE, StateFlag.State.DENY);
- put(Flags.BLOCK_BREAK, StateFlag.State.DENY);
- put(Flags.BUILD, StateFlag.State.DENY);
- put(Flags.PLACE_VEHICLE, StateFlag.State.DENY);
- put(Flags.DESTROY_VEHICLE, StateFlag.State.DENY);
- put(Flags.ENTITY_ITEM_FRAME_DESTROY, StateFlag.State.DENY);
- put(Flags.ENTITY_PAINTING_DESTROY, StateFlag.State.DENY);
+ final Map, Object> flags = new HashMap, Object>()
+ {{
+ put(Flags.BLOCK_PLACE, StateFlag.State.ALLOW);
+ put(Flags.BLOCK_BREAK, StateFlag.State.ALLOW);
+ put(Flags.BUILD, StateFlag.State.ALLOW);
+ put(Flags.PLACE_VEHICLE, StateFlag.State.ALLOW);
+ put(Flags.DESTROY_VEHICLE, StateFlag.State.ALLOW);
+ put(Flags.ENTITY_ITEM_FRAME_DESTROY, StateFlag.State.ALLOW);
+ put(Flags.ENTITY_PAINTING_DESTROY, StateFlag.State.ALLOW);
}};
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
@@ -78,7 +80,12 @@ public class Command_makeopregion extends FreedomCommand
region.setOwners(owners);
region.setFlags(flags);
- RegionManager regionManager = plugin.wgb.getWorldGuardPlugin().getRegionManager(playerSender.getWorld());
+ for (Flag flag : flags.keySet())
+ {
+ region.setFlag(flag.getRegionGroupFlag(), RegionGroup.MEMBERS);
+ }
+
+ RegionManager regionManager = plugin.wgb.getRegionManager(playerSender.getWorld());
regionManager.addRegion(region);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java
index 2a06d943..a2e9b021 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java
@@ -41,11 +41,11 @@ public class Command_nickfilter extends FreedomCommand
player = getPlayerByDisplayName(displayName);
- if (player == null || Command_vanish.VANISHED.contains(player) && !plugin.al.isAdmin(sender))
+ if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
{
player = getPlayerByDisplayNameAlt(displayName);
- if (player == null || Command_vanish.VANISHED.contains(player) && !plugin.al.isAdmin(sender))
+ if (player == null || !plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
{
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName);
return true;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java
index 52789638..d7c9550b 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java
@@ -1,64 +1,59 @@
package me.totalfreedom.totalfreedommod.command;
+import java.util.ArrayList;
+import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.ChatColor;
-import org.bukkit.OfflinePlayer;
+import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH, cooldown = 5)
-@CommandParameters(description = "OPs the specified player.", usage = "/ ")
+@CommandParameters(description = "OP a player", usage = "/ ")
public class Command_op extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
- if (args.length != 1)
+ if (args.length < 1)
{
return false;
}
- if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("everyone"))
+ boolean silent = false;
+ if (args.length == 2)
{
- msg("Correct usage: /opall");
- return true;
+ silent = args[1].equalsIgnoreCase("-s");
}
- OfflinePlayer player = null;
- for (Player onlinePlayer : server.getOnlinePlayers())
+ final String targetName = args[0].toLowerCase();
+
+ final List matchedPlayerNames = new ArrayList<>();
+ for (final Player player : server.getOnlinePlayers())
{
- if (args[0].equalsIgnoreCase(onlinePlayer.getName()))
+ if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName))
{
- player = onlinePlayer;
+ if (!player.isOp() && !plugin.al.vanished.contains(player))
+ {
+ matchedPlayerNames.add(player.getName());
+ player.setOp(true);
+ player.sendMessage(FreedomCommand.YOU_ARE_OP);
+ }
}
}
- // if the player is not online or is vanished
- if (player == null || Command_vanish.VANISHED.contains(player) && !plugin.al.isAdmin(sender))
+ if (!matchedPlayerNames.isEmpty())
{
- if (plugin.al.isAdmin(sender) || senderIsConsole)
+ if (!silent)
{
- player = DepreciationAggregator.getOfflinePlayer(server, args[0]);
- }
- else
- {
- msg("That player is not online.");
- msg("You don't have permissions to OP offline players.", ChatColor.RED);
- return true;
+ FUtil.adminAction(sender.getName(), "Opping " + StringUtils.join(matchedPlayerNames, ", "), false);
}
}
-
- FUtil.adminAction(sender.getName(), "Opping " + player.getName(), false);
- player.setOp(true);
-
- if (player.isOnline())
+ else
{
- Player p = (Player)player;
- p.sendMessage(YOU_ARE_OP);
+ msg("No targets matched.");
}
return true;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java
new file mode 100644
index 00000000..d328cc6b
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java
@@ -0,0 +1,52 @@
+package me.totalfreedom.totalfreedommod.command;
+
+import java.util.ArrayList;
+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;
+import org.bukkit.permissions.PermissionAttachmentInfo;
+
+@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
+@CommandParameters(description = "Check your permissions", usage = "/ [prefix | reload]")
+public class Command_permissions extends FreedomCommand
+{
+
+ @Override
+ public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
+ {
+ if (args.length > 0 && args[0].equals("reload") && plugin.al.isAdmin(sender))
+ {
+ plugin.permissions.load();
+ plugin.pem.loadPermissionNodes();
+ plugin.pem.updatePlayers();
+ msg("Reloaded permissions");
+ }
+ else
+ {
+ String prefix = "";
+ if (args.length > 0)
+ {
+ prefix = args[0];
+ }
+ checkPlayer();
+ List permissions = new ArrayList<>();
+ for (PermissionAttachmentInfo attachmentInfo : playerSender.getEffectivePermissions())
+ {
+ if (attachmentInfo.getValue())
+ {
+ String permission = attachmentInfo.getPermission();
+ if (!prefix.isEmpty() && !permission.startsWith(prefix))
+ {
+ continue;
+ }
+ permissions.add(permission);
+ }
+ }
+ msg(String.join(", ", permissions));
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java
index bf7e1b7f..df13a1e5 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java
@@ -62,7 +62,7 @@ public class Command_potion extends FreedomCommand
{
target = getPlayer(args[1]);
- if (target == null || Command_vanish.VANISHED.contains(target) && !plugin.al.isAdmin(sender))
+ if (target == null || plugin.al.vanished.contains(target) && !plugin.al.isAdmin(sender))
{
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
@@ -105,7 +105,7 @@ public class Command_potion extends FreedomCommand
{
target = getPlayer(args[4]);
- if (target == null || Command_vanish.VANISHED.contains(target) && !plugin.al.isAdmin(sender))
+ if (target == null || plugin.al.vanished.contains(target) && !plugin.al.isAdmin(sender))
{
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_qdeop.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_qdeop.java
deleted file mode 100644
index 58b6215e..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_qdeop.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package me.totalfreedom.totalfreedommod.command;
-
-import java.util.ArrayList;
-import java.util.List;
-import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.apache.commons.lang.StringUtils;
-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 = "Quickly deop someone based on only their partial name.", usage = "/ ")
-public class Command_qdeop extends FreedomCommand
-{
-
- @Override
- public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (args.length < 1)
- {
- return false;
- }
-
- boolean silent = false;
- if (args.length == 2)
- {
- silent = args[1].equalsIgnoreCase("-s");
- }
-
- final String targetName = args[0].toLowerCase();
-
- final List matchedPlayerNames = new ArrayList<>();
- for (final Player player : server.getOnlinePlayers())
- {
- if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName))
- {
- if (player.isOp() && !Command_vanish.VANISHED.contains(player))
- {
- matchedPlayerNames.add(player.getName());
- player.setOp(false);
- player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
- }
- }
- }
-
- if (!matchedPlayerNames.isEmpty())
- {
- if (!silent)
- {
- FUtil.adminAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false);
- }
- }
- else
- {
- msg("No targets matched.");
- }
-
- return true;
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_qop.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_qop.java
deleted file mode 100644
index 17384996..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_qop.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package me.totalfreedom.totalfreedommod.command;
-
-import java.util.ArrayList;
-import java.util.List;
-import me.totalfreedom.totalfreedommod.rank.Rank;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.apache.commons.lang.StringUtils;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-@CommandPermissions(level = Rank.OP, source = SourceType.BOTH, cooldown = 5)
-@CommandParameters(description = "Quickly OP someone based on only their partial name.", usage = "/ ")
-public class Command_qop extends FreedomCommand
-{
-
- @Override
- public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (args.length < 1)
- {
- return false;
- }
-
- boolean silent = false;
- if (args.length == 2)
- {
- silent = args[1].equalsIgnoreCase("-s");
- }
-
- final String targetName = args[0].toLowerCase();
-
- final List matchedPlayerNames = new ArrayList<>();
- for (final Player player : server.getOnlinePlayers())
- {
- if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName))
- {
- if (!player.isOp() && !Command_vanish.VANISHED.contains(player))
- {
- matchedPlayerNames.add(player.getName());
- player.setOp(true);
- player.sendMessage(FreedomCommand.YOU_ARE_OP);
- }
- }
- }
-
- if (!matchedPlayerNames.isEmpty())
- {
- if (!silent)
- {
- FUtil.adminAction(sender.getName(), "Opping " + StringUtils.join(matchedPlayerNames, ", "), false);
- }
- }
- else
- {
- msg("No targets matched.");
- }
-
- return true;
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java
index db9ad280..ed480ea3 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java
@@ -37,7 +37,7 @@ public class Command_rank extends FreedomCommand
final Player player = getPlayer(args[0]);
- if (player == null || Command_vanish.VANISHED.contains(player) && !plugin.al.isAdmin(sender))
+ if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java
new file mode 100644
index 00000000..aa434656
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java
@@ -0,0 +1,25 @@
+package me.totalfreedom.totalfreedommod.command;
+
+import com.connorlinfoot.actionbarapi.ActionBarAPI;
+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;
+
+@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
+@CommandParameters(description = "Brings the current reaction string up on your action bar", 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())
+ {
+ ActionBarAPI.sendActionBar(playerSender, ChatColor.BOLD + plugin.sh.reactionString, 15 * 20);
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java
index acfaa32d..5896e101 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java
@@ -23,7 +23,7 @@ public class Command_report extends FreedomCommand
Player player = getPlayer(args[0]);
- if (player == null || Command_vanish.VANISHED.contains(player) && !plugin.al.isAdmin(sender))
+ if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
{
msg(PLAYER_NOT_FOUND);
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 1cba5af2..e072af17 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java
@@ -84,7 +84,7 @@ public class Command_ride extends FreedomCommand
}
final Player player = getPlayer(args[0]);
- if (player == null || Command_vanish.VANISHED.contains(player) && !plugin.al.isAdmin(sender))
+ if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
{
msg(PLAYER_NOT_FOUND);
return true;
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 4f696fee..d97434a7 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java
@@ -53,7 +53,7 @@ public class Command_tag extends FreedomCommand
for (final Player player : server.getOnlinePlayers())
{
- if (Command_vanish.VANISHED.contains(player) && !plugin.al.isAdmin(sender))
+ if (plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
{
continue;
}
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 ac913dbe..ef315aa9 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java
@@ -19,7 +19,6 @@ import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
@CommandParameters(description = "Vanish/unvanish yourself.", usage = "/ [-s[ilent]]", aliases = "v")
public class Command_vanish extends FreedomCommand
{
- public static ArrayList VANISHED = new ArrayList<>();
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{
@@ -36,7 +35,7 @@ public class Command_vanish extends FreedomCommand
silent = true;
}
}
- if (VANISHED.contains(playerSender))
+ if (plugin.al.vanished.contains(playerSender))
{
msg(ChatColor.GOLD + "You have been unvanished.");
if (admin.hasLoginMessage())
@@ -68,7 +67,7 @@ public class Command_vanish extends FreedomCommand
}
plugin.esb.setVanished(playerSender.getName(), false);
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
- VANISHED.remove(playerSender);
+ plugin.al.vanished.remove(playerSender);
}
else
{
@@ -89,7 +88,7 @@ public class Command_vanish extends FreedomCommand
}
}
plugin.esb.setVanished(playerSender.getName(), true);
- VANISHED.add(playerSender);
+ plugin.al.vanished.add(playerSender);
}
return true;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java
index e60a4ecb..c0f5e599 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java
@@ -40,7 +40,7 @@ public class Command_whohas extends FreedomCommand
for (final Player player : server.getOnlinePlayers())
{
- if (!plugin.al.isAdmin(sender) && Command_vanish.VANISHED.contains(player))
+ if (!plugin.al.isAdmin(sender) && plugin.al.vanished.contains(player))
{
continue;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_permbans.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_permbans.java
index 6310182c..a26c3d05 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_permbans.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_permbans.java
@@ -20,15 +20,12 @@ public class Module_permbans extends HTTPDModule
{
File permbanFile = new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME);
- // if people get mad that opening the permban list to the public causes a mass DDoS attack on the server due to ip
- // leaks, it wasnt my idea
-
- /*final String remoteAddress = socket.getInetAddress().getHostAddress();
+ final String remoteAddress = socket.getInetAddress().getHostAddress();
if (!isAuthorized(remoteAddress))
{
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
"You may not view the permban list. Your IP, " + remoteAddress + ", is not registered to an admin on the server.");
- }*/
+ }
if (permbanFile.exists())
{
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java
new file mode 100644
index 00000000..bdcf3f9f
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java
@@ -0,0 +1,184 @@
+package me.totalfreedom.totalfreedommod.permissions;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.EnumMap;
+import java.util.List;
+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 static final String PERMISSIONS_FILENAME = "permissions.yml";
+ //
+ private final EnumMap entries;
+ private final PermissionDefaults defaults;
+ public YamlConfiguration configuration;
+
+ public PermissionConfig(TotalFreedomMod plugin)
+ {
+ super(plugin);
+
+ entries = new EnumMap<>(PermissionEntry.class);
+
+ PermissionDefaults tempDefaults = null;
+ try
+ {
+ try
+ {
+ try (InputStream defaultConfig = getDefaultConfig())
+ {
+ tempDefaults = new PermissionDefaults(defaultConfig);
+ for (PermissionEntry entry : PermissionEntry.values())
+ {
+ entries.put(entry, tempDefaults.get(entry.getConfigName()));
+ }
+ }
+ }
+ catch (IOException ex)
+ {
+ FLog.severe(ex);
+ }
+
+ copyDefaultConfig(getConfigFile());
+
+ load();
+ }
+ catch (Exception ex)
+ {
+ FLog.severe(ex);
+ }
+
+ defaults = tempDefaults;
+ }
+
+ public void load()
+ {
+ try
+ {
+ YamlConfiguration config = new YamlConfiguration();
+
+ config.load(getConfigFile());
+
+ configuration = config;
+
+ for (PermissionEntry entry : PermissionEntry.values())
+ {
+ String path = entry.getConfigName();
+ if (config.contains(path))
+ {
+ Object value = config.get(path);
+ if (value != null)
+ {
+ entries.put(entry, value);
+ }
+ }
+ else
+ {
+ FLog.warning("Missing permission entry " + entry.getConfigName() + ". Using default value.");
+ }
+ }
+ }
+ catch (IOException | InvalidConfigurationException ex)
+ {
+ FLog.severe(ex);
+ }
+ }
+
+ private File getConfigFile()
+ {
+ return new File(plugin.getDataFolder(), PERMISSIONS_FILENAME);
+ }
+
+ public List getList(PermissionEntry entry)
+ {
+ try
+ {
+ return get(entry, List.class);
+ }
+ catch (IllegalArgumentException ex)
+ {
+ FLog.severe(ex);
+ }
+ return null;
+ }
+
+ public T get(PermissionEntry entry, Class type) throws IllegalArgumentException
+ {
+ Object value = entries.get(entry);
+ try
+ {
+ return type.cast(value);
+ }
+ catch (ClassCastException ex)
+ {
+ throw new IllegalArgumentException(entry.name() + " is not of type " + type.getSimpleName());
+ }
+ }
+
+ public void set(PermissionEntry entry, T value)
+ {
+ entries.put(entry, value);
+ }
+
+ private void copyDefaultConfig(File targetFile)
+ {
+ if (targetFile.exists())
+ {
+ return;
+ }
+
+ FLog.info("Installing default permission file template: " + targetFile.getPath());
+
+ try
+ {
+ try (InputStream defaultConfig = getDefaultConfig())
+ {
+ FileUtils.copyInputStreamToFile(defaultConfig, targetFile);
+ }
+ }
+ catch (IOException ex)
+ {
+ FLog.severe(ex);
+ }
+ }
+
+ private InputStream getDefaultConfig()
+ {
+ return plugin.getResource(PERMISSIONS_FILENAME);
+ }
+
+ public static class PermissionDefaults
+ {
+
+ private YamlConfiguration defaults = null;
+
+ private PermissionDefaults(InputStream defaultConfig)
+ {
+ try
+ {
+ defaults = new YamlConfiguration();
+ final InputStreamReader isr = new InputStreamReader(defaultConfig);
+ defaults.load(isr);
+ isr.close();
+ }
+ catch (IOException | InvalidConfigurationException ex)
+ {
+ FLog.severe(ex);
+ }
+ }
+
+ public Object get(String path)
+ {
+ return defaults.get(path);
+ }
+ }
+
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionEntry.java b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionEntry.java
new file mode 100644
index 00000000..0baad2a6
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionEntry.java
@@ -0,0 +1,44 @@
+package me.totalfreedom.totalfreedommod.permissions;
+
+import java.util.List;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+
+
+public enum PermissionEntry
+{
+ REMOVE("remove"),
+ OPERATORS("operators"),
+ MASTER_BUILDERS("master_builders"),
+ SUPER_ADMINS("super_admins"),
+ TELNET_ADMINS("telnet_admins"),
+ SENIOR_ADMINS("senior_admins");
+
+
+ private final String configName;
+
+ PermissionEntry(String configName)
+ {
+ this.configName = configName;
+ }
+
+ public String getConfigName()
+ {
+ return configName;
+ }
+
+ public List> getList()
+ {
+ return getConfig().getList(this);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List getEntry()
+ {
+ return (List)getList();
+ }
+
+ private PermissionConfig getConfig()
+ {
+ return TotalFreedomMod.plugin().permissions;
+ }
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java
new file mode 100644
index 00000000..5b2b4607
--- /dev/null
+++ b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java
@@ -0,0 +1,138 @@
+package me.totalfreedom.totalfreedommod.permissions;
+
+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;
+import me.totalfreedom.totalfreedommod.util.FLog;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.permissions.PermissionAttachment;
+import org.bukkit.permissions.PermissionAttachmentInfo;
+
+public class PermissionManager extends FreedomService
+{
+
+ public Map> permissions = Maps.newHashMap();
+
+ public Map attachments = Maps.newHashMap();
+
+ public PermissionManager(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ loadPermissionNodes();
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ public void loadPermissionNodes()
+ {
+
+ FLog.info("Loading permission nodes...");
+
+ permissions.clear();
+
+ List operatorPermissions;
+ List masterBuilderPermissions;
+ List superAdminPermissions;
+ List telnetAdminPermissions;
+ List seniorAdminPermissions;
+
+ operatorPermissions = PermissionEntry.OPERATORS.getEntry();
+ permissions.put(Rank.OP, operatorPermissions);
+
+ masterBuilderPermissions = PermissionEntry.MASTER_BUILDERS.getEntry();
+ masterBuilderPermissions.addAll(operatorPermissions);
+ permissions.put(Title.MASTER_BUILDER, masterBuilderPermissions);
+
+
+ superAdminPermissions = PermissionEntry.SUPER_ADMINS.getEntry();
+ superAdminPermissions.addAll(masterBuilderPermissions);
+ permissions.put(Rank.SUPER_ADMIN, superAdminPermissions);
+
+ telnetAdminPermissions = PermissionEntry.TELNET_ADMINS.getEntry();
+ telnetAdminPermissions.addAll(superAdminPermissions);
+ permissions.put(Rank.TELNET_ADMIN, superAdminPermissions);
+
+ seniorAdminPermissions = PermissionEntry.SENIOR_ADMINS.getEntry();
+ seniorAdminPermissions.addAll(telnetAdminPermissions);
+ permissions.put(Rank.SENIOR_ADMIN, seniorAdminPermissions);
+
+ FLog.info("Loaded " + permissions.values().size() + " permission nodes");
+ }
+
+ public void setPermissions(Player player)
+ {
+ PermissionAttachment attachment = attachments.get(player);
+
+ if (attachment != null)
+ {
+ player.removeAttachment(attachment);
+ }
+
+ attachment = player.addAttachment(plugin);
+
+ for (PermissionAttachmentInfo attachmentInfo : player.getEffectivePermissions())
+ {
+ for (String rootNode : PermissionEntry.REMOVE.getEntry())
+ {
+ String permission = attachmentInfo.getPermission();
+ if (permission.startsWith(rootNode))
+ {
+ attachment.setPermission(attachmentInfo.getPermission(), false);
+ }
+ }
+ }
+ List nodes = permissions.get(plugin.rm.getRank(player));
+ if (nodes != null)
+ {
+ for (String node : nodes)
+ {
+ attachment.setPermission(node, true);
+ }
+ }
+
+ if (plugin.mbl.isMasterBuilder(player) && !plugin.al.isAdmin(player))
+ {
+ if (nodes != null)
+ {
+ for (String node : permissions.get(Title.MASTER_BUILDER))
+ {
+ attachment.setPermission(node, true);
+ }
+ }
+ }
+
+ attachments.put(player, attachment);
+
+ player.recalculatePermissions();
+ }
+
+ public void updatePlayers()
+ {
+ for (Player player : server.getOnlinePlayers())
+ {
+ setPermissions(player);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onPlayerJoin(PlayerJoinEvent event)
+ {
+ setPermissions(event.getPlayer());
+ }
+}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java
index 6ddb455a..61d77155 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java
@@ -175,6 +175,7 @@ public class RankManager extends FreedomService
fPlayer.setTag(null);
player.setPlayerListName(null);
}
+ plugin.pem.setPermissions(player);
}
@EventHandler(priority = EventPriority.MONITOR)
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java
index d929ee0e..63e73846 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java
@@ -51,7 +51,7 @@ public class FUtil
//
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
// See https://github.com/TotalFreedom/License - None of the listed names may be removed.
- public static final List DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "Demonic_Mario", "RobinGall2910", "smartnt");
+ public static final List DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "Demonic_Mario", "OxLemonxO");
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
public static final Map CHAT_COLOR_NAMES = new HashMap<>();
public static final List CHAT_COLOR_POOL = Arrays.asList(
diff --git a/src/main/resources/activitylog.yml b/src/main/resources/activitylog.yml
index 152b15e6..e32ef42a 100644
--- a/src/main/resources/activitylog.yml
+++ b/src/main/resources/activitylog.yml
@@ -1,3 +1,3 @@
#
-# TotalFreedomMod 5.2 Activity Log
+# TotalFreedomMod 5.5 Activity Log
#
diff --git a/src/main/resources/admins.yml b/src/main/resources/admins.yml
index 2957e245..ba27d643 100644
--- a/src/main/resources/admins.yml
+++ b/src/main/resources/admins.yml
@@ -1,5 +1,5 @@
#
-# TotalFreedomMod 5.2 Admin List
+# TotalFreedomMod 5.5 Admin List
#
prozza:
diff --git a/src/main/resources/bans.yml b/src/main/resources/bans.yml
index 63c8af98..6a4a0e2f 100644
--- a/src/main/resources/bans.yml
+++ b/src/main/resources/bans.yml
@@ -1,3 +1,3 @@
#
-# TotalFreedomMod 5.2 Player Bans
+# TotalFreedomMod 5.5 Player Bans
#
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 892cea5b..f1308871 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,5 +1,5 @@
#
-# TotalFreedomMod 5.2 Configuration
+# TotalFreedomMod 5.5 Configuration
# by Madgeek1450 and Prozza
#
diff --git a/src/main/resources/masterbuilders.yml b/src/main/resources/masterbuilders.yml
index fb615f2c..90f42696 100644
--- a/src/main/resources/masterbuilders.yml
+++ b/src/main/resources/masterbuilders.yml
@@ -1,3 +1,3 @@
#
-# TotalFreedomMod 5.2 Master Builder List
+# TotalFreedomMod 5.5 Master Builder List
#
diff --git a/src/main/resources/permbans.yml b/src/main/resources/permbans.yml
index b6421acf..0df32bba 100644
--- a/src/main/resources/permbans.yml
+++ b/src/main/resources/permbans.yml
@@ -1,5 +1,5 @@
#
-# TotalFreedomMod 5.2 Permanent Bans
+# TotalFreedomMod 5.5 Permanent Bans
#
badplayer1:
diff --git a/src/main/resources/permissions.yml b/src/main/resources/permissions.yml
new file mode 100644
index 00000000..f1a62529
--- /dev/null
+++ b/src/main/resources/permissions.yml
@@ -0,0 +1,78 @@
+#
+# TotalFreedomMod 5.5 Permissions
+# by ZeroEpoch1969
+#
+
+# Note that every group inherits the previous groups' permissions
+# Meaning Telnet Admins have the permissions of Operators and Super Admins, and etc
+
+# This is used to remove all permission begging with the root node
+# This is useful when a plugin gives all permissions to a player because they are opped
+remove:
+ - "coreprotect"
+
+# Operator permission nodes
+operators:
+ # WorldEdit
+ - "worldedit.help"
+ - "worldedit.history.undo.self"
+ - "worldedit.history.redo.self"
+ - "worldedit.history.clear"
+ - "worldedit.limit"
+ - "worldedit.reorder"
+ - "worldedit.drawsel"
+ - "worldedit.searchitem"
+ - "worldedit.navigation.*"
+ - "worldedit.selection.*"
+ - "worldedit.wand"
+ - "worldedit.wand.*"
+ - "worldedit.region.*"
+ - "worldedit.generation.*"
+ - "worldedit.clipboard.*"
+ - "worldedit.tool.info"
+ - "worldedit.biome.*"
+ - "worldedit.removeabove"
+ - "worldedit.removebelow"
+ - "worldedit.removenear"
+ - "worldedit.replacenear"
+
+ # CoreProtect
+ - "coreprotect.inspect"
+ - "coreprotect.lookup"
+ - "coreprotect.help"
+ - "coreprotect.status"
+ - "coreprotect.lookup.block"
+ - "coreprotect.lookup.click"
+ - "coreprotect.lookup.container"
+ - "coreprotect.container"
+ - "coreprotect.core"
+ - "coreprotect.coreprotect"
+ - "coreprotect.co"
+
+ # WorldGuard
+ - "worldgyardregion.list.own"
+ - "worldguard.region.addmember.own.*"
+ - "worldguard.region.removemember.own.*"
+ - "worldguard.region.info.*"
+
+# Master Builder permission nodes
+master_builders:
+ - "worldedit.tool.*"
+ - "worldedit.brush.*"
+ - "worldedit.snow"
+ - "worldedit.green"
+ - "worldedit.extinguish"
+ - "worldedit.thaw"
+
+# Super Admin permission nodes
+super_admins:
+ - "coreprotect.*"
+ - "worldedit.*"
+ - "worldguard.*"
+
+# Telnet Admin permission nodes
+telnet_admins: []
+
+# Senior Admin permission nodes
+senior_admins: []
+
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 7dfa6193..77bb4df0 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -5,4 +5,4 @@ description: Plugin for the Total Freedom server.
depend: [Aero]
softdepend: [BukkitTelnet, Essentials, LibsDisguises, WorldEdit]
authors: [Madgeek1450, Prozza]
-api-version: 1.14
+api-version: 1.15
diff --git a/src/main/resources/punishments.yml b/src/main/resources/punishments.yml
index 29ae71ef..74b68c48 100644
--- a/src/main/resources/punishments.yml
+++ b/src/main/resources/punishments.yml
@@ -1,3 +1,3 @@
#
-# TotalFreedomMod 5.2 Player Punishments
+# TotalFreedomMod 5.5 Player Punishments
#
diff --git a/src/main/resources/vpnbans.yml b/src/main/resources/vpnbans.yml
index c642975b..a1c40cb1 100644
--- a/src/main/resources/vpnbans.yml
+++ b/src/main/resources/vpnbans.yml
@@ -1,5 +1,5 @@
#
-# TotalFreedomMod 5.2 VPN Bans
+# TotalFreedomMod 5.5 VPN Bans
#
badnetwork1: