mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 20:46:41 +00:00
Compare commits
4 Commits
dependabot
...
FS-200
Author | SHA1 | Date | |
---|---|---|---|
f63362a9fb | |||
54b803e09b | |||
9fba895088 | |||
feba260744 |
2
.github/workflows/downstream.yml
vendored
2
.github/workflows/downstream.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
# Step 2: run this sync action - specify the upstream repo, upstream branch to sync with, and target sync branch
|
# Step 2: run this sync action - specify the upstream repo, upstream branch to sync with, and target sync branch
|
||||||
- name: Pull (Fast-Forward) upstream changes
|
- name: Pull (Fast-Forward) upstream changes
|
||||||
id: sync
|
id: sync
|
||||||
uses: aormsby/Fork-Sync-With-Upstream-action@v2.1
|
uses: aormsby/Fork-Sync-With-Upstream-action@v3.3
|
||||||
with:
|
with:
|
||||||
upstream_repository: AtlasMediaGroup/TotalFreedomMod
|
upstream_repository: AtlasMediaGroup/TotalFreedomMod
|
||||||
upstream_branch: main
|
upstream_branch: main
|
||||||
|
53
pom.xml
53
pom.xml
@ -39,7 +39,17 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>networkmanager-repo</id>
|
||||||
|
<url>https://repo.networkmanager.xyz/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>atlas-nexus-01-totalfreedom-development</id>
|
<id>atlas-nexus-01-totalfreedom-development</id>
|
||||||
<url>https://nexus-01.core.atlas-media.co.uk/repository/totalfreedom-development/</url>
|
<url>https://nexus-01.core.atlas-media.co.uk/repository/totalfreedom-development/</url>
|
||||||
@ -100,8 +110,8 @@
|
|||||||
<id>esentialsx-repo</id>
|
<id>esentialsx-repo</id>
|
||||||
<url>https://repo.essentialsx.net/releases/</url>
|
<url>https://repo.essentialsx.net/releases/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -189,7 +199,7 @@
|
|||||||
<version>v1.9</version>
|
<version>v1.9</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.essentialsx</groupId>
|
<groupId>net.essentialsx</groupId>
|
||||||
<artifactId>EssentialsX</artifactId>
|
<artifactId>EssentialsX</artifactId>
|
||||||
@ -231,19 +241,50 @@
|
|||||||
<version>3.1.2</version>
|
<version>3.1.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
<version>5.8.0</version>
|
<version>5.8.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.sisu</groupId>
|
<groupId>org.eclipse.sisu</groupId>
|
||||||
<artifactId>org.eclipse.sisu.inject</artifactId>
|
<artifactId>org.eclipse.sisu.inject</artifactId>
|
||||||
<version>0.3.4</version>
|
<version>0.3.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.chimpgamer.networkmanager</groupId>
|
||||||
|
<artifactId>api</artifactId>
|
||||||
|
<version>2.11.4</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.github.slimjar</groupId>
|
||||||
|
<artifactId>slimjar</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20220320</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
@ -35,6 +36,10 @@ import me.totalfreedom.totalfreedommod.fun.Trailer;
|
|||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||||
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.handler.DefaultPermissionHandler;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.handler.IPermissionHandler;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.handler.NMPermissionHandler;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.handler.VaultPermissionHandler;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||||
@ -132,6 +137,8 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public WorldEditBridge web;
|
public WorldEditBridge web;
|
||||||
public WorldGuardBridge wgb;
|
public WorldGuardBridge wgb;
|
||||||
|
|
||||||
|
public IPermissionHandler permissionHandler;
|
||||||
|
|
||||||
public static TotalFreedomMod getPlugin()
|
public static TotalFreedomMod getPlugin()
|
||||||
{
|
{
|
||||||
return plugin;
|
return plugin;
|
||||||
@ -143,7 +150,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
{
|
{
|
||||||
if (plugin.getName().equalsIgnoreCase(pluginName))
|
if (plugin.getName().equalsIgnoreCase(pluginName))
|
||||||
{
|
{
|
||||||
return (TotalFreedomMod)plugin;
|
return (TotalFreedomMod) plugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -208,6 +215,20 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
|
|
||||||
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod/2966
|
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod/2966
|
||||||
new Metrics(this, 2966);
|
new Metrics(this, 2966);
|
||||||
|
|
||||||
|
if (getServer().getPluginManager().isPluginEnabled("NetworkManager"))
|
||||||
|
{
|
||||||
|
FLog.info("Using NetworkManager's permission handling");
|
||||||
|
this.permissionHandler = new NMPermissionHandler(this);
|
||||||
|
} else if (getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||||
|
{
|
||||||
|
FLog.info("Using Vault's permission handling");
|
||||||
|
this.permissionHandler = new VaultPermissionHandler(this);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
FLog.info("Using Bukkit's native permission handling");
|
||||||
|
this.permissionHandler = new DefaultPermissionHandler();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -255,8 +276,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
date = props.getProperty("buildDate", "unknown");
|
date = props.getProperty("buildDate", "unknown");
|
||||||
// Need to do this or it will display ${git.commit.id.abbrev}
|
// Need to do this or it will display ${git.commit.id.abbrev}
|
||||||
head = props.getProperty("buildHead", "unknown").replace("${git.commit.id.abbrev}", "unknown");
|
head = props.getProperty("buildHead", "unknown").replace("${git.commit.id.abbrev}", "unknown");
|
||||||
}
|
} catch (Exception ex)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
FLog.severe("Could not load build properties! Did you compile with NetBeans/Maven?");
|
FLog.severe("Could not load build properties! Did you compile with NetBeans/Maven?");
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
|
@ -2,17 +2,22 @@ package me.totalfreedom.totalfreedommod.admin;
|
|||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.handler.NMPermissionHandler;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.handler.VaultPermissionHandler;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class AdminList extends FreedomService
|
public class AdminList extends FreedomService
|
||||||
@ -55,8 +60,7 @@ public class AdminList extends FreedomService
|
|||||||
allAdmins.add(admin);
|
allAdmins.add(admin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (SQLException e)
|
||||||
catch (SQLException e)
|
|
||||||
{
|
{
|
||||||
FLog.severe("Failed to load admin list: " + e.getMessage());
|
FLog.severe("Failed to load admin list: " + e.getMessage());
|
||||||
}
|
}
|
||||||
@ -110,7 +114,7 @@ public class AdminList extends FreedomService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = getAdmin((Player)sender);
|
Admin admin = getAdmin((Player) sender);
|
||||||
|
|
||||||
return admin != null && admin.isActive();
|
return admin != null && admin.isActive();
|
||||||
}
|
}
|
||||||
@ -121,28 +125,48 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (plugin.permissionHandler instanceof NMPermissionHandler || plugin.permissionHandler instanceof VaultPermissionHandler)
|
||||||
|
{
|
||||||
|
// FLog.debug("Using " + plugin.permissionHandler.getClass().getSimpleName() + " for AdminList#isAdmin");
|
||||||
|
return plugin.permissionHandler.inGroup(player, ConfigEntry.PERMISSIONS_GROUPS_ADMIN.getString());
|
||||||
|
}
|
||||||
|
// FLog.debug("AdminList#isAdmin: Returning false because there is no permissions plugin that supports groups on the server");
|
||||||
|
return false;
|
||||||
|
|
||||||
Admin admin = getAdmin(player);
|
/*Admin admin = getAdmin(player);
|
||||||
|
|
||||||
return admin != null && admin.isActive();
|
return admin != null && admin.isActive();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSeniorAdmin(CommandSender sender)
|
public boolean isSeniorAdmin(CommandSender sender)
|
||||||
{
|
{
|
||||||
Admin admin = getAdmin(sender);
|
//TODO: BukkitTelnet checks, but fuck that plugin
|
||||||
|
if (sender instanceof ConsoleCommandSender)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (sender instanceof Player player && (plugin.permissionHandler instanceof NMPermissionHandler || plugin.permissionHandler instanceof VaultPermissionHandler))
|
||||||
|
{
|
||||||
|
// FLog.debug("Using " + plugin.permissionHandler.getClass().getSimpleName() + " for AdminList#isSeniorAdmin");
|
||||||
|
return plugin.permissionHandler.inGroup(player, ConfigEntry.PERMISSIONS_GROUPS_SENIOR.getString());
|
||||||
|
}
|
||||||
|
// FLog.debug("AdminList#isSeniorAdmin: Returning false because there is no permissions plugin that supports groups on the server");
|
||||||
|
return false;
|
||||||
|
// return plugin.permissionHandler.hasPermission(sender, "totalfreedommod.admin");
|
||||||
|
/*Admin admin = getAdmin(sender);
|
||||||
if (admin == null)
|
if (admin == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return admin.getRank().ordinal() >= Rank.SENIOR_ADMIN.ordinal();
|
return admin.getRank().ordinal() >= Rank.SENIOR_ADMIN.ordinal();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public Admin getAdmin(CommandSender sender)
|
public Admin getAdmin(CommandSender sender)
|
||||||
{
|
{
|
||||||
if (sender instanceof Player)
|
if (sender instanceof Player)
|
||||||
{
|
{
|
||||||
return getAdmin((Player)sender);
|
return getAdmin((Player) sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getEntryByName(sender.getName());
|
return getEntryByName(sender.getName());
|
||||||
@ -271,13 +295,13 @@ public class AdminList extends FreedomService
|
|||||||
ResultSet currentSave = plugin.sql.getAdminByUuid(admin.getUuid());
|
ResultSet currentSave = plugin.sql.getAdminByUuid(admin.getUuid());
|
||||||
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
for (Map.Entry<String, Object> 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 || entry.getValue() == null)
|
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.setAdminValue(admin, entry.getKey(), entry.getValue());
|
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (SQLException e)
|
||||||
catch (SQLException e)
|
|
||||||
{
|
{
|
||||||
FLog.severe("Failed to save admin: " + e.getMessage());
|
FLog.severe("Failed to save admin: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,12 @@ public @interface CommandPermissions
|
|||||||
|
|
||||||
Rank level() default Rank.NON_OP;
|
Rank level() default Rank.NON_OP;
|
||||||
|
|
||||||
|
String permission() default "";
|
||||||
|
|
||||||
SourceType source() default SourceType.BOTH;
|
SourceType source() default SourceType.BOTH;
|
||||||
|
|
||||||
boolean blockHostConsole() default false;
|
boolean blockHostConsole() default false;
|
||||||
|
|
||||||
int cooldown() default 0;
|
int cooldown() default 0;
|
||||||
|
|
||||||
}
|
}
|
@ -43,6 +43,8 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||||||
private final String usage;
|
private final String usage;
|
||||||
private final String aliases;
|
private final String aliases;
|
||||||
private final Rank level;
|
private final Rank level;
|
||||||
|
|
||||||
|
private final String permission;
|
||||||
private final SourceType source;
|
private final SourceType source;
|
||||||
private final boolean blockHostConsole;
|
private final boolean blockHostConsole;
|
||||||
private final int cooldown;
|
private final int cooldown;
|
||||||
@ -59,6 +61,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||||||
this.usage = params.usage();
|
this.usage = params.usage();
|
||||||
this.aliases = params.aliases();
|
this.aliases = params.aliases();
|
||||||
this.level = perms.level();
|
this.level = perms.level();
|
||||||
|
this.permission = perms.permission().isEmpty() ? "totalfreedommod." + this.name.toLowerCase() : perms.permission();
|
||||||
this.source = perms.source();
|
this.source = perms.source();
|
||||||
this.blockHostConsole = perms.blockHostConsole();
|
this.blockHostConsole = perms.blockHostConsole();
|
||||||
this.cooldown = perms.cooldown();
|
this.cooldown = perms.cooldown();
|
||||||
@ -162,8 +165,65 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
protected void checkRank(@Deprecated Rank rank, String permission)
|
||||||
|
{
|
||||||
|
//TODO: Not bothering with BukkitTelnet now.
|
||||||
|
if (sender instanceof Player player)
|
||||||
|
{
|
||||||
|
if (!plugin.permissionHandler.hasPermission(player, permission))
|
||||||
|
{
|
||||||
|
noPerms();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!plugin.rm.getRank(sender).isAtLeast(rank))
|
||||||
|
{
|
||||||
|
noPerms();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected void checkPermissions(String permission)
|
||||||
|
{
|
||||||
|
//TODO: Not bothering with BukkitTelnet now.
|
||||||
|
if (sender instanceof Player player)
|
||||||
|
{
|
||||||
|
if (!plugin.permissionHandler.hasPermission(player, permission))
|
||||||
|
{
|
||||||
|
noPerms();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean checkPermissionsSilent(String permission)
|
||||||
|
{
|
||||||
|
//TODO: Not bothering with BukkitTelnet now.
|
||||||
|
// FLog.debug("Using checkPermissionsSilent");
|
||||||
|
if (sender instanceof ConsoleCommandSender)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (sender instanceof Player player)
|
||||||
|
{
|
||||||
|
// FLog.debug("Checking player permission for " + player.getUniqueId() + " - " + permission);
|
||||||
|
return plugin.permissionHandler.hasPermission(player, permission);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
protected void checkRank(Rank rank)
|
protected void checkRank(Rank rank)
|
||||||
{
|
{
|
||||||
|
// FLog.debug("Using checkRank");
|
||||||
|
//TODO: Not bothering with BukkitTelnet now.
|
||||||
|
if (sender instanceof Player player)
|
||||||
|
{
|
||||||
|
// FLog.debug("Checking player permission for " + player.getUniqueId() + " - " + this.permission);
|
||||||
|
if (!plugin.permissionHandler.hasPermission(player, this.permission))
|
||||||
|
{
|
||||||
|
noPerms();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!plugin.rm.getRank(sender).isAtLeast(rank))
|
if (!plugin.rm.getRank(sender).isAtLeast(rank))
|
||||||
{
|
{
|
||||||
noPerms();
|
noPerms();
|
||||||
@ -365,7 +425,15 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||||||
|
|
||||||
public boolean func2()
|
public boolean func2()
|
||||||
{
|
{
|
||||||
if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
|
/*if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
|
||||||
|
{
|
||||||
|
msg(NO_PERMISSION);
|
||||||
|
return true;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
FLog.debug("Result of check perms: " + (!checkPermissionsSilent(cmd.permission)));
|
||||||
|
|
||||||
|
if (!checkPermissionsSilent(cmd.permission))
|
||||||
{
|
{
|
||||||
msg(NO_PERMISSION);
|
msg(NO_PERMISSION);
|
||||||
return true;
|
return true;
|
||||||
|
@ -73,6 +73,10 @@ public enum ConfigEntry
|
|||||||
SERVER_WHITELIST_MOTD(String.class, "server.motds.whitelist"),
|
SERVER_WHITELIST_MOTD(String.class, "server.motds.whitelist"),
|
||||||
SERVER_FULL_MOTD(String.class, "server.motds.full"),
|
SERVER_FULL_MOTD(String.class, "server.motds.full"),
|
||||||
//
|
//
|
||||||
|
|
||||||
|
PERMISSIONS_GROUPS_ADMIN(String.class, "permissions.groups.admin"),
|
||||||
|
PERMISSIONS_GROUPS_SENIOR(String.class, "permissions.groups.senior_admin"),
|
||||||
|
PERMISSIONS_GROUPS_DEFAULT(String.class, "permissions.groups.default"),
|
||||||
DISCORD_TOKEN(String.class, "discord.token"),
|
DISCORD_TOKEN(String.class, "discord.token"),
|
||||||
DISCORD_REPORT_CHANNEL_ID(String.class, "discord.report_channel_id"),
|
DISCORD_REPORT_CHANNEL_ID(String.class, "discord.report_channel_id"),
|
||||||
DISCORD_CHAT_CHANNEL_ID(String.class, "discord.chat_channel_id"),
|
DISCORD_CHAT_CHANNEL_ID(String.class, "discord.chat_channel_id"),
|
||||||
|
@ -4,12 +4,16 @@ import me.totalfreedom.totalfreedommod.admin.Admin;
|
|||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.handler.DefaultPermissionHandler;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.handler.IPermissionHandler;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class Module_list extends HTTPDModule
|
public class Module_list extends HTTPDModule
|
||||||
@ -25,7 +29,32 @@ public class Module_list extends HTTPDModule
|
|||||||
{
|
{
|
||||||
if (params.get("json") != null && params.get("json").equals("true"))
|
if (params.get("json") != null && params.get("json").equals("true"))
|
||||||
{
|
{
|
||||||
|
FLog.debug("Swapping to JSON View!");
|
||||||
final JSONObject responseObject = new JSONObject();
|
final JSONObject responseObject = new JSONObject();
|
||||||
|
if (!(plugin.permissionHandler instanceof DefaultPermissionHandler))
|
||||||
|
{
|
||||||
|
FLog.debug("Displaying custom list on HTTPD!");
|
||||||
|
IPermissionHandler handler = plugin.permissionHandler;
|
||||||
|
final JSONObject players = new JSONObject();
|
||||||
|
|
||||||
|
Arrays.stream(handler.getGroups()).forEach(s ->
|
||||||
|
{
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
Bukkit.getOnlinePlayers().stream().filter(player -> !plugin.al.isVanished(player.getName())).filter(player -> handler.getPrimaryGroup(player).equalsIgnoreCase(s)).forEach(player ->
|
||||||
|
{
|
||||||
|
array.put(player.getName());
|
||||||
|
});
|
||||||
|
players.put(s.toLowerCase(), array);
|
||||||
|
});
|
||||||
|
|
||||||
|
responseObject.put("players", players);
|
||||||
|
responseObject.put("online", Bukkit.getOnlinePlayers().stream().filter(player -> !plugin.al.isVanished(player.getName())).count());
|
||||||
|
responseObject.put("max", Bukkit.getMaxPlayers());
|
||||||
|
|
||||||
|
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString(4));
|
||||||
|
response.addHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
final JSONArray owners = new JSONArray();
|
final JSONArray owners = new JSONArray();
|
||||||
final JSONArray executives = new JSONArray();
|
final JSONArray executives = new JSONArray();
|
||||||
@ -44,27 +73,27 @@ public class Module_list extends HTTPDModule
|
|||||||
|
|
||||||
if (plugin.pl.getData(player).isMasterBuilder())
|
if (plugin.pl.getData(player).isMasterBuilder())
|
||||||
{
|
{
|
||||||
masterbuilders.add(player.getName());
|
masterbuilders.put(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FUtil.DEVELOPER_NAMES.contains(player.getName()))
|
if (FUtil.DEVELOPER_NAMES.contains(player.getName()))
|
||||||
{
|
{
|
||||||
developers.add(player.getName());
|
developers.put(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.SERVER_EXECUTIVES.getList().contains(player.getName()) && !FUtil.DEVELOPERS.contains(player.getName()))
|
if (ConfigEntry.SERVER_EXECUTIVES.getList().contains(player.getName()) && !FUtil.DEVELOPERS.contains(player.getName()))
|
||||||
{
|
{
|
||||||
executives.add(player.getName());
|
executives.put(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.SERVER_OWNERS.getList().contains(player.getName()))
|
if (ConfigEntry.SERVER_OWNERS.getList().contains(player.getName()))
|
||||||
{
|
{
|
||||||
owners.add(player.getName());
|
owners.put(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player) && hasSpecialTitle(player))
|
if (!plugin.al.isAdmin(player) && hasSpecialTitle(player))
|
||||||
{
|
{
|
||||||
operators.add(player.getName());
|
operators.put(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasSpecialTitle(player) && plugin.al.isAdmin(player) && !plugin.al.isVanished(player.getName()))
|
if (hasSpecialTitle(player) && plugin.al.isAdmin(player) && !plugin.al.isVanished(player.getName()))
|
||||||
@ -74,12 +103,12 @@ public class Module_list extends HTTPDModule
|
|||||||
{
|
{
|
||||||
case ADMIN:
|
case ADMIN:
|
||||||
{
|
{
|
||||||
admins.add(player.getName());
|
admins.put(player.getName());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SENIOR_ADMIN:
|
case SENIOR_ADMIN:
|
||||||
{
|
{
|
||||||
senioradmins.add(player.getName());
|
senioradmins.put(player.getName());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -102,11 +131,11 @@ public class Module_list extends HTTPDModule
|
|||||||
responseObject.put("online", FUtil.getFakePlayerCount());
|
responseObject.put("online", FUtil.getFakePlayerCount());
|
||||||
responseObject.put("max", server.getMaxPlayers());
|
responseObject.put("max", server.getMaxPlayers());
|
||||||
|
|
||||||
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString());
|
|
||||||
|
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString(4));
|
||||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
response.addHeader("Access-Control-Allow-Origin", "*");
|
||||||
return response;
|
return response;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
final StringBuilder body = new StringBuilder();
|
final StringBuilder body = new StringBuilder();
|
||||||
|
|
||||||
@ -144,4 +173,5 @@ public class Module_list extends HTTPDModule
|
|||||||
{
|
{
|
||||||
return "TotalFreedom - Online Players";
|
return "TotalFreedom - Online Players";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.permissions.handler;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @project TotalFreedomMod
|
||||||
|
* @since 9:10 PM [23-05-2022]
|
||||||
|
*/
|
||||||
|
public class DefaultPermissionHandler implements IPermissionHandler
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(@NotNull OfflinePlayer player, @Nullable String permission)
|
||||||
|
{
|
||||||
|
if (permission == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
throw new UnsupportedOperationException("Unable to use Bukkit's native permission system for permissions!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(@NotNull Player player, @Nullable String permission)
|
||||||
|
{
|
||||||
|
return permission == null || player.hasPermission(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inGroup(@NotNull OfflinePlayer player, @Nullable String groupName)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Unable to use Bukkit's native permission system for groups!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inGroup(@NotNull Player player, @Nullable String groupName)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Unable to use Bukkit's native permission system for groups!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrimaryGroup(@NotNull Player player)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Unable to use Bukkit's native permission system for groups!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrefix(@NotNull Player player)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Unable to use Bukkit's native permission system for groups!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getGroups()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Unable to use Bukkit's native permission system for groups!");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.permissions.handler;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @project TotalFreedomMod
|
||||||
|
* @since 9:05 PM [23-05-2022]
|
||||||
|
*/
|
||||||
|
public interface IPermissionHandler
|
||||||
|
{
|
||||||
|
boolean hasPermission(@NotNull OfflinePlayer player, @Nullable String permission);
|
||||||
|
boolean hasPermission(@NotNull Player player, @Nullable String permission);
|
||||||
|
|
||||||
|
boolean inGroup(@NotNull OfflinePlayer player, @Nullable String groupName);
|
||||||
|
boolean inGroup(@NotNull Player player, @Nullable String groupName);
|
||||||
|
|
||||||
|
String getPrimaryGroup(@NotNull Player player);
|
||||||
|
|
||||||
|
String getPrefix(@NotNull Player player);
|
||||||
|
|
||||||
|
String[] getGroups();
|
||||||
|
}
|
@ -0,0 +1,150 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.permissions.handler;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import nl.chimpgamer.networkmanager.api.NetworkManagerPlugin;
|
||||||
|
import nl.chimpgamer.networkmanager.api.NetworkManagerProvider;
|
||||||
|
import nl.chimpgamer.networkmanager.api.models.permissions.Group;
|
||||||
|
import nl.chimpgamer.networkmanager.api.models.permissions.PermissionPlayer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @project TotalFreedomMod
|
||||||
|
* @since 9:10 PM [23-05-2022]
|
||||||
|
*/
|
||||||
|
public class NMPermissionHandler implements IPermissionHandler
|
||||||
|
{
|
||||||
|
private NetworkManagerPlugin plugin;
|
||||||
|
|
||||||
|
public NMPermissionHandler(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
if (plugin.permissionHandler != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Bukkit.getPluginManager().isPluginEnabled("NetworkManager"))
|
||||||
|
{
|
||||||
|
plugin.permissionHandler = new DefaultPermissionHandler();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.plugin = NetworkManagerProvider.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(@NotNull OfflinePlayer player, @Nullable String permission)
|
||||||
|
{
|
||||||
|
if (permission == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Permission was null!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PermissionPlayer permissionPlayer = this.plugin.getPermissionManager().getPermissionPlayer(player.getUniqueId());
|
||||||
|
if (permissionPlayer == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Unable to find permissions player in NetworkManager. Returning false.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (permissionPlayer.getAllPermissions() == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Screw you NetworkManager for telling me all the permissions for player is null.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Boolean has = permissionPlayer.hasPermission(permission);
|
||||||
|
if (has == null)
|
||||||
|
{
|
||||||
|
// FLog.debug("NetworkManager is idiotic and has a chance of returning null on a Boolean object. Returning false.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// FLog.debug("Player has perm? " + has);
|
||||||
|
// FLog.debug("Player permissions for: " + permissionPlayer.getUuid() + "\n" + new GsonBuilder().setPrettyPrinting().create().toJson(permissionPlayer.getAllPermissions()));
|
||||||
|
// permissionPlayer.getPermissions().forEach(permission1 -> FLog.debug(String.format("%s:%s", permission1.getPermissionString(), permission1.hasExpired())));
|
||||||
|
return has;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(@NotNull Player player, @Nullable String permission)
|
||||||
|
{
|
||||||
|
return hasPermission((OfflinePlayer) player, permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inGroup(@NotNull OfflinePlayer player, @Nullable String groupName)
|
||||||
|
{
|
||||||
|
if (groupName == null)
|
||||||
|
{
|
||||||
|
FLog.debug("NM Perms: Setting permission access to false, group is null");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PermissionPlayer permissionPlayer = this.plugin.getPermissionManager().getPermissionPlayer(player.getUniqueId());
|
||||||
|
if (permissionPlayer == null)
|
||||||
|
{
|
||||||
|
FLog.debug("NM Perms: Setting permission access to false, player not found in NM for '" + player.getUniqueId() + "'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (permissionPlayer.getGroups().isEmpty())
|
||||||
|
{
|
||||||
|
FLog.debug("NM Perms: Setting permission access to false, player groups are empty for '" + player.getUniqueId() + "'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// FLog.debug("Group Name requested for: " + player.getUniqueId() + " - " + groupName);
|
||||||
|
// FLog.debug("Player has? " + (permissionPlayer.getGroups().stream().anyMatch(group -> group.getName().equals(groupName))));
|
||||||
|
// permissionPlayer.getGroups().forEach(group -> FLog.debug("Player group: " + group.getName()));
|
||||||
|
return permissionPlayer.getGroups().stream().anyMatch(group -> group.getName().equals(groupName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inGroup(@NotNull Player player, @Nullable String groupName)
|
||||||
|
{
|
||||||
|
return this.inGroup((OfflinePlayer) player, groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getGroups()
|
||||||
|
{
|
||||||
|
return this.plugin.getPermissionManager().getGroups().values().stream().map(Group::getName).toArray(String[]::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrimaryGroup(@NotNull Player player)
|
||||||
|
{
|
||||||
|
PermissionPlayer permissionPlayer = this.plugin.getPermissionManager().getPermissionPlayer(player.getUniqueId());
|
||||||
|
if (permissionPlayer == null || permissionPlayer.getPrimaryGroup() == null)
|
||||||
|
{
|
||||||
|
FLog.warning("NM Perms: Couldn't find player's primary group due to them not be found our list");
|
||||||
|
return ConfigEntry.PERMISSIONS_GROUPS_DEFAULT.getString();
|
||||||
|
}
|
||||||
|
// permissionPlayer.getGroups().forEach(group -> FLog.debug(String.format("Group for %s: %s", permissionPlayer.getUuid(), group.getName())));
|
||||||
|
// FLog.debug(String.format("%s Primary Group: %s", permissionPlayer.getUuid(), permissionPlayer.getGroups().stream().sorted(Comparator.comparingInt(Group::getRank)).map(Group::getName).findFirst().orElse(ConfigEntry.PERMISSIONS_GROUPS_DEFAULT.getString())));
|
||||||
|
return permissionPlayer.getGroups().stream().sorted((o1, o2) -> o1.getRank() - o2.getRank()).map(Group::getName).findFirst().orElse(ConfigEntry.PERMISSIONS_GROUPS_DEFAULT.getString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrefix(@NotNull Player player)
|
||||||
|
{
|
||||||
|
PermissionPlayer permissionPlayer = this.plugin.getPermissionManager().getPermissionPlayer(player.getUniqueId());
|
||||||
|
if (permissionPlayer == null)
|
||||||
|
{
|
||||||
|
FLog.warning("NM Perms: Couldn't find player's primary group due to them not be found our list");
|
||||||
|
return "[Error Loading Player]";
|
||||||
|
}
|
||||||
|
Group group = this.plugin.getPermissionManager().getGroup(getPrimaryGroup(player));
|
||||||
|
if (group == null)
|
||||||
|
{
|
||||||
|
return "[Error Finding Group]";
|
||||||
|
}
|
||||||
|
return group.getPrefix(null);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,152 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.permissions.handler;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.milkbowl.vault.chat.Chat;
|
||||||
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @project TotalFreedomMod
|
||||||
|
* @since 9:10 PM [23-05-2022]
|
||||||
|
*/
|
||||||
|
public class VaultPermissionHandler implements IPermissionHandler
|
||||||
|
{
|
||||||
|
private Permission permissions;
|
||||||
|
private Chat chat;
|
||||||
|
|
||||||
|
public VaultPermissionHandler(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
if (plugin.permissionHandler != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Bukkit.getPluginManager().isPluginEnabled("Vault"))
|
||||||
|
{
|
||||||
|
plugin.permissionHandler = new DefaultPermissionHandler();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.permissions = setupPerms(plugin);
|
||||||
|
this.chat = setupChat(plugin);
|
||||||
|
|
||||||
|
plugin.permissionHandler = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(@NotNull OfflinePlayer player, @Nullable String permission)
|
||||||
|
{
|
||||||
|
if (this.permissions == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Can't use Vault permissions system, there is no plugin using Vault permissions.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return permission == null || this.permissions.playerHas(null, player, permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(@NotNull Player player, @Nullable String permission)
|
||||||
|
{
|
||||||
|
if (this.permissions == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Can't use Vault permissions system, there is no plugin using Vault permissions.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return permission == null || this.permissions.playerHas(player, permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inGroup(@NotNull OfflinePlayer player, @Nullable String groupName)
|
||||||
|
{
|
||||||
|
if (this.permissions == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Can't use Vault permissions system for groups, there is no plugin using Vault permissions.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (groupName == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Vault Perms: Group name is null, returning false for group check");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.permissions.playerInGroup(null, player, groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inGroup(@NotNull Player player, @Nullable String groupName)
|
||||||
|
{
|
||||||
|
if (this.permissions == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Can't use Vault permissions system for groups, there is no plugin using Vault permissions.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (groupName == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Vault Perms: Group name is null, returning false for group check");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.permissions.playerInGroup(player, groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getGroups()
|
||||||
|
{
|
||||||
|
if (this.permissions == null)
|
||||||
|
{
|
||||||
|
FLog.debug("Can't use Vault permissions system for group listing, there is no plugin using Vault permissions.");
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
return this.permissions.getGroups();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrimaryGroup(@NotNull Player player)
|
||||||
|
{
|
||||||
|
return this.permissions.getPrimaryGroup(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrefix(@NotNull Player player)
|
||||||
|
{
|
||||||
|
if (this.chat == null)
|
||||||
|
{
|
||||||
|
return "[No Chat Plugin]";
|
||||||
|
}
|
||||||
|
return this.chat.getPlayerPrefix(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Permission getPermissions()
|
||||||
|
{
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Permission setupPerms(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class);
|
||||||
|
if (rsp == null)
|
||||||
|
{
|
||||||
|
FLog.warning("Switching back to Bukkit's default permissions from Vault's due to no permission system found.");
|
||||||
|
plugin.permissionHandler = new DefaultPermissionHandler();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return rsp.getProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Chat setupChat(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
RegisteredServiceProvider<Chat> rsp = Bukkit.getServicesManager().getRegistration(Chat.class);
|
||||||
|
if (rsp == null)
|
||||||
|
{
|
||||||
|
// FLog.warning("Switching back to Bukkit's default permissions from Vault's due to no permission system found.");
|
||||||
|
// plugin.permissionHandler = new DefaultPermissionHandler();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return rsp.getProvider();
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import java.util.Objects;
|
|||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.handler.DefaultPermissionHandler;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -168,7 +169,12 @@ public class RankManager extends FreedomService
|
|||||||
fPlayer.setTag(null);
|
fPlayer.setTag(null);
|
||||||
player.setPlayerListName(null);
|
player.setPlayerListName(null);
|
||||||
}
|
}
|
||||||
fPlayer.setTag(getTag(player, display.getColoredTag()));
|
if (!(plugin.permissionHandler instanceof DefaultPermissionHandler))
|
||||||
|
{
|
||||||
|
fPlayer.setTag(getTag(player, plugin.permissionHandler.getPrefix(player)));
|
||||||
|
} else {
|
||||||
|
fPlayer.setTag(getTag(player, display.getColoredTag()));
|
||||||
|
}
|
||||||
updatePlayerTeam(player);
|
updatePlayerTeam(player);
|
||||||
plugin.pem.setPermissions(player);
|
plugin.pem.setPermissions(player);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,13 @@ server:
|
|||||||
# What to display at the bottom of the tab list
|
# What to display at the bottom of the tab list
|
||||||
tablist_footer: ''
|
tablist_footer: ''
|
||||||
|
|
||||||
|
# Permissions System
|
||||||
|
permissions:
|
||||||
|
groups:
|
||||||
|
admin: "Administrator"
|
||||||
|
senior_admin: "Senior-Administrator"
|
||||||
|
default: "Guest"
|
||||||
|
|
||||||
# Discord
|
# Discord
|
||||||
discord:
|
discord:
|
||||||
# If you do not have a token, make a bot account and get one at https://discordapp.com/developers/applications/me
|
# If you do not have a token, make a bot account and get one at https://discordapp.com/developers/applications/me
|
||||||
|
Reference in New Issue
Block a user