mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Fat update
This commit is contained in:
parent
bbee51a858
commit
9866ee5d80
6 changed files with 68 additions and 53 deletions
|
@ -1,6 +1,12 @@
|
||||||
repositories {
|
repositories {
|
||||||
maven { url = "https://jitpack.io" }
|
maven { url = "https://jitpack.io" }
|
||||||
maven { url = "https://mvn.intellectualsites.com/content/repositories/snapshots" }
|
maven { url = "https://mvn.intellectualsites.com/content/repositories/snapshots" }
|
||||||
|
maven {
|
||||||
|
name = "spigot"
|
||||||
|
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
|
||||||
|
}
|
||||||
|
maven { url 'https://rayzr.dev/repo/' }
|
||||||
|
maven { url "https://repo.dmulloy2.net/nexus/repository/public/" }
|
||||||
}
|
}
|
||||||
def textVersion = "3.0.2"
|
def textVersion = "3.0.2"
|
||||||
|
|
||||||
|
@ -18,6 +24,8 @@ dependencies {
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
|
||||||
implementation("org.jetbrains:annotations:19.0.0")
|
implementation("org.jetbrains:annotations:19.0.0")
|
||||||
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
|
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
|
||||||
|
implementation("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT")
|
||||||
|
implementation("com.github.TFPatches:TotalFreedomMod:server-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
|
|
|
@ -36,6 +36,7 @@ import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import me.totalfreedom.plotsquared.PlotSquaredHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
@ -57,6 +58,7 @@ public abstract class Command {
|
||||||
private final ArrayList<Command> allCommands = new ArrayList<>();
|
private final ArrayList<Command> allCommands = new ArrayList<>();
|
||||||
private final ArrayList<Command> dynamicCommands = new ArrayList<>();
|
private final ArrayList<Command> dynamicCommands = new ArrayList<>();
|
||||||
private final HashMap<String, Command> staticCommands = new HashMap<>();
|
private final HashMap<String, Command> staticCommands = new HashMap<>();
|
||||||
|
private PlotSquaredHandler plotSquaredHandler = new PlotSquaredHandler();
|
||||||
|
|
||||||
// Parent command (may be null)
|
// Parent command (may be null)
|
||||||
private final Command parent;
|
private final Command parent;
|
||||||
|
@ -159,7 +161,8 @@ public abstract class Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasConfirmation(CommandCaller player) {
|
public boolean hasConfirmation(CommandCaller player) {
|
||||||
return this.confirmation && !player.hasPermission(getPermission() + ".confirm.bypass");
|
// Confirmation message bypass
|
||||||
|
return this.confirmation && !plotSquaredHandler.isAdmin(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAliases() {
|
public List<String> getAliases() {
|
||||||
|
@ -451,7 +454,7 @@ public abstract class Command {
|
||||||
Captions.IS_CONSOLE :
|
Captions.IS_CONSOLE :
|
||||||
Captions.NOT_CONSOLE);
|
Captions.NOT_CONSOLE);
|
||||||
}
|
}
|
||||||
} else if (!Permissions.hasPermission(player, getPermission())) {
|
} else if (!plotSquaredHandler.hasTFMPermission(player, getPermission())) {
|
||||||
if (message) {
|
if (message) {
|
||||||
Captions.NO_PERMISSION.send(player, getPermission());
|
Captions.NO_PERMISSION.send(player, getPermission());
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,11 @@ public class Swap extends SubCommand {
|
||||||
if (plot2 == null) {
|
if (plot2 == null) {
|
||||||
return CompletableFuture.completedFuture(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
}
|
}
|
||||||
|
if (!plot2.isOwner(player.getUUID()) && !Permissions
|
||||||
|
.hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated())) {
|
||||||
|
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||||
|
return CompletableFuture.completedFuture(false);
|
||||||
|
}
|
||||||
if (plot1.equals(plot2)) {
|
if (plot1.equals(plot2)) {
|
||||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
||||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||||
|
|
|
@ -31,6 +31,7 @@ import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import me.totalfreedom.plotsquared.PlotSquaredHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Permissions class handles checking user permissions.<br>
|
* The Permissions class handles checking user permissions.<br>
|
||||||
|
@ -38,6 +39,7 @@ import java.util.HashMap;
|
||||||
* - Checking the PlotPlayer class directly will not take the above into account<br>
|
* - Checking the PlotPlayer class directly will not take the above into account<br>
|
||||||
*/
|
*/
|
||||||
public class Permissions {
|
public class Permissions {
|
||||||
|
public static PlotSquaredHandler plotSquaredHandler = new PlotSquaredHandler();
|
||||||
|
|
||||||
public static boolean hasPermission(PlotPlayer player, Captions caption, boolean notify) {
|
public static boolean hasPermission(PlotPlayer player, Captions caption, boolean notify) {
|
||||||
return hasPermission(player, caption.getTranslated(), notify);
|
return hasPermission(player, caption.getTranslated(), notify);
|
||||||
|
@ -62,22 +64,7 @@ public class Permissions {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean hasPermission(PlotPlayer<?> player, String permission) {
|
public static boolean hasPermission(PlotPlayer<?> player, String permission) {
|
||||||
if (!Settings.Enabled_Components.PERMISSION_CACHE) {
|
return plotSquaredHandler.hasTFMPermission(player, permission);
|
||||||
return hasPermission((CommandCaller) player, permission);
|
|
||||||
}
|
|
||||||
HashMap<String, Boolean> map = player.getMeta("perm");
|
|
||||||
if (map != null) {
|
|
||||||
Boolean result = map.get(permission);
|
|
||||||
if (result != null) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
map = new HashMap<>();
|
|
||||||
player.setMeta("perm", map);
|
|
||||||
}
|
|
||||||
boolean result = hasPermission((CommandCaller) player, permission);
|
|
||||||
map.put(permission, result);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,47 +1,42 @@
|
||||||
package me.totalfreedom.plotsquared;
|
package me.totalfreedom.plotsquared;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.plotsquared.core.command.CommandCaller;
|
||||||
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
|
|
||||||
public class PlotSquaredHandler
|
public class PlotSquaredHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final boolean DEBUG = true;
|
public static final boolean DEBUG = true;
|
||||||
public static final Logger LOGGER = Bukkit.getPluginManager().getPlugin("PlotSquared").getLogger();
|
public static final Logger LOGGER = Bukkit.getPluginManager().getPlugin("PlotSquared").getLogger();
|
||||||
private static Function<Player, Boolean> adminProvider;
|
private static Function<Player, Boolean> adminProvider;
|
||||||
|
|
||||||
public boolean isAdmin(PlotPlayer plotPlayer)
|
public boolean isAdmin(CommandCaller commandCaller)
|
||||||
{
|
{
|
||||||
final Player player = getPlayer(plotPlayer);
|
final Player player = getPlayer(commandCaller.toString());
|
||||||
if (player == null) {
|
if (player == null)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isAdmin(player);
|
return isAdmin(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean isAdmin(Player player) {
|
public boolean isAdmin(Player player)
|
||||||
|
{
|
||||||
TotalFreedomMod tfm = getTFM();
|
TotalFreedomMod tfm = getTFM();
|
||||||
return tfm.al.isAdmin(player);
|
return tfm.al.isAdmin(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Player getPlayer(PlotPlayer plotPlayer) {
|
public static Player getPlayer(CommandCaller commandCaller)
|
||||||
final Player player = Bukkit.getPlayer(plotPlayer.getUUID());
|
{
|
||||||
|
return Bukkit.getPlayer(commandCaller.toString());
|
||||||
if (player == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return player;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTFMPermission(CommandCaller caller, String permission)
|
public boolean hasTFMPermission(CommandCaller caller, String permission)
|
||||||
|
@ -66,61 +61,70 @@ public class PlotSquaredHandler
|
||||||
"plots.backup", "plots.debug");
|
"plots.backup", "plots.debug");
|
||||||
if (!isAdmin(player))
|
if (!isAdmin(player))
|
||||||
{
|
{
|
||||||
if (permission.startsWith("plots.admin") || adminOnlyPermissions.contains(permission))
|
return !permission.startsWith("plots.admin") && !adminOnlyPermissions.contains(permission);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Player getPlayer(String match) {
|
public static Player getPlayer(String match)
|
||||||
|
{
|
||||||
match = match.toLowerCase();
|
match = match.toLowerCase();
|
||||||
|
|
||||||
Player found = null;
|
Player found = null;
|
||||||
int delta = Integer.MAX_VALUE;
|
int delta = Integer.MAX_VALUE;
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
if (player.getName().toLowerCase().startsWith(match)) {
|
{
|
||||||
|
if (player.getName().toLowerCase().startsWith(match))
|
||||||
|
{
|
||||||
int curDelta = player.getName().length() - match.length();
|
int curDelta = player.getName().length() - match.length();
|
||||||
if (curDelta < delta) {
|
if (curDelta < delta)
|
||||||
|
{
|
||||||
found = player;
|
found = player;
|
||||||
delta = curDelta;
|
delta = curDelta;
|
||||||
}
|
}
|
||||||
if (curDelta == 0) {
|
if (curDelta == 0)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
if (player.getName().toLowerCase().contains(match)) {
|
{
|
||||||
|
if (player.getName().toLowerCase().contains(match))
|
||||||
|
{
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TotalFreedomMod getTFM() {
|
public static TotalFreedomMod getTFM()
|
||||||
|
{
|
||||||
final Plugin tfm = Bukkit.getPluginManager().getPlugin("TotalFreedomMod");
|
final Plugin tfm = Bukkit.getPluginManager().getPlugin("TotalFreedomMod");
|
||||||
if (tfm == null) {
|
if (tfm == null)
|
||||||
|
{
|
||||||
LOGGER.warning("Could not resolve plugin: TotalFreedomMod");
|
LOGGER.warning("Could not resolve plugin: TotalFreedomMod");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TotalFreedomMod)tfm;
|
return (TotalFreedomMod)tfm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(String debug) {
|
public void debug(String debug)
|
||||||
if (DEBUG) {
|
{
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
info(debug);
|
info(debug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warning(String warning) {
|
public void warning(String warning)
|
||||||
|
{
|
||||||
LOGGER.warning(warning);
|
LOGGER.warning(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(String info) {
|
public void info(String info)
|
||||||
|
{
|
||||||
LOGGER.info(info);
|
LOGGER.info(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,6 +5,12 @@ buildscript {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
name = "spigot"
|
||||||
|
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
|
||||||
|
}
|
||||||
|
maven { url 'https://rayzr.dev/repo/' }
|
||||||
|
maven { url "https://repo.dmulloy2.net/nexus/repository/public/" }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("com.github.jengelman.gradle.plugins:shadow:5.0.0")
|
classpath("com.github.jengelman.gradle.plugins:shadow:5.0.0")
|
||||||
|
@ -100,6 +106,8 @@ subprojects {
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.8")
|
annotationProcessor("org.projectlombok:lombok:1.18.8")
|
||||||
testAnnotationProcessor("org.projectlombok:lombok:1.18.8")
|
testAnnotationProcessor("org.projectlombok:lombok:1.18.8")
|
||||||
testImplementation("junit:junit:4.13")
|
testImplementation("junit:junit:4.13")
|
||||||
|
implementation("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT")
|
||||||
|
implementation("com.github.TFPatches:TotalFreedomMod:server-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
|
|
Loading…
Reference in a new issue