mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Tweak permission registration
This commit is contained in:
19 files changed
+84
-253
No files matched your search
@@ -7,23 +7,22 @@ import net.william278.desertwell.UpdateChecker;
|
||||
import net.william278.desertwell.Version;
|
||||
import net.william278.huskhomes.command.Command;
|
||||
import net.william278.huskhomes.config.Locales;
|
||||
import net.william278.huskhomes.config.Server;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.config.Spawn;
|
||||
import net.william278.huskhomes.database.Database;
|
||||
import net.william278.huskhomes.event.EventDispatcher;
|
||||
import net.william278.huskhomes.hook.EconomyHook;
|
||||
import net.william278.huskhomes.hook.MapHook;
|
||||
import net.william278.huskhomes.hook.Hook;
|
||||
import net.william278.huskhomes.hook.MapHook;
|
||||
import net.william278.huskhomes.manager.Manager;
|
||||
import net.william278.huskhomes.network.Broker;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.config.Server;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import net.william278.huskhomes.random.RandomTeleportEngine;
|
||||
import net.william278.huskhomes.user.ConsoleUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import net.william278.huskhomes.util.TaskRunner;
|
||||
import net.william278.huskhomes.util.Validator;
|
||||
import org.intellij.lang.annotations.Subst;
|
||||
@@ -193,7 +192,7 @@ public interface HuskHomes extends TaskRunner, EventDispatcher {
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
default boolean validateEconomyCheck(@NotNull OnlineUser player, @NotNull EconomyHook.Action action) {
|
||||
final Optional<Double> cost = getSettings().getEconomyCost(action).map(Math::abs);
|
||||
if (cost.isPresent() && !player.hasPermission(Permission.BYPASS_ECONOMY_CHECKS.node)) {
|
||||
if (cost.isPresent() && !player.hasPermission(EconomyHook.BYPASS_PERMISSION)) {
|
||||
final Optional<EconomyHook> hook = getEconomyHook();
|
||||
if (hook.isPresent()) {
|
||||
if (cost.get() > hook.get().getPlayerBalance(player)) {
|
||||
@@ -216,7 +215,7 @@ public interface HuskHomes extends TaskRunner, EventDispatcher {
|
||||
if (!getSettings().doEconomy()) return;
|
||||
final Optional<Double> cost = getSettings().getEconomyCost(action).map(Math::abs);
|
||||
|
||||
if (cost.isPresent() && !player.hasPermission(Permission.BYPASS_ECONOMY_CHECKS.node)) {
|
||||
if (cost.isPresent() && !player.hasPermission(EconomyHook.BYPASS_PERMISSION)) {
|
||||
final Optional<EconomyHook> hook = getEconomyHook();
|
||||
if (hook.isPresent()) {
|
||||
hook.get().changePlayerBalance(player, -cost.get());
|
||||
|
||||
@@ -4,16 +4,19 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class Command extends Node {
|
||||
|
||||
private final String usage;
|
||||
private final Map<String, Boolean> additionalPermissions;
|
||||
|
||||
protected Command(@NotNull String name, @NotNull List<String> aliases, @NotNull String usage, @NotNull HuskHomes plugin) {
|
||||
super(name, aliases, plugin);
|
||||
this.usage = usage;
|
||||
this.additionalPermissions = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,6 +43,15 @@ public abstract class Command extends Node {
|
||||
return "/" + getName() + " " + usage;
|
||||
}
|
||||
|
||||
public final void addAdditionalPermissions(@NotNull Map<String, Boolean> additionalPermissions) {
|
||||
additionalPermissions.forEach((permission, value) -> this.additionalPermissions.put(getPermission(permission), value));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Map<String, Boolean> getAdditionalPermissions() {
|
||||
return additionalPermissions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDescription() {
|
||||
return plugin.getLocales().getRawLocale(getName() + "_command_description")
|
||||
@@ -47,11 +59,6 @@ public abstract class Command extends Node {
|
||||
.orElse(getUsage());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<String, Boolean> getAdditionalPermissions() {
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final HuskHomes getPlugin() {
|
||||
return plugin;
|
||||
|
||||
@@ -12,15 +12,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
|
||||
public EditHomeCommand(@NotNull HuskHomes plugin) {
|
||||
super("edithome", List.of(), Home.class, List.of("rename", "description", "relocate", "privacy"), plugin);
|
||||
addAdditionalPermissions(arguments.stream()
|
||||
.collect(HashMap::new, (m, e) -> m.put(getPermission(e), false), HashMap::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -19,6 +20,8 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
|
||||
public EditWarpCommand(@NotNull HuskHomes plugin) {
|
||||
super("editwarp", List.of(), Warp.class, List.of("rename", "description", "relocate"), plugin);
|
||||
addAdditionalPermissions(arguments.stream()
|
||||
.collect(HashMap::new, (m, e) -> m.put(getPermission(e), false), HashMap::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,18 +10,24 @@ import net.william278.paginedown.PaginatedList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class HuskHomesCommand extends Command implements TabProvider {
|
||||
|
||||
private static final List<String> SUB_COMMANDS = List.of("about", "help", "reload", "update");
|
||||
private static final Map<String, Boolean> SUB_COMMANDS = Map.of(
|
||||
"about", false,
|
||||
"help", false,
|
||||
"reload", true,
|
||||
"update", true
|
||||
);
|
||||
|
||||
private final UpdateChecker updateChecker;
|
||||
private final AboutMenu aboutMenu;
|
||||
|
||||
protected HuskHomesCommand(@NotNull HuskHomes plugin) {
|
||||
super("huskhomes", List.of(), "[" + String.join("|", SUB_COMMANDS) + "]", plugin);
|
||||
setOperatorCommand(true);
|
||||
super("huskhomes", List.of(), "[" + String.join("|", SUB_COMMANDS.keySet()) + "]", plugin);
|
||||
addAdditionalPermissions(SUB_COMMANDS);
|
||||
|
||||
this.updateChecker = plugin.getUpdateChecker();
|
||||
this.aboutMenu = AboutMenu.create("HuskHomes")
|
||||
@@ -52,7 +58,7 @@ public class HuskHomesCommand extends Command implements TabProvider {
|
||||
@Override
|
||||
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
|
||||
final String action = parseStringArg(args, 0).orElse("about");
|
||||
if (SUB_COMMANDS.contains(action) && !executor.hasPermission(getPermission(action))) {
|
||||
if (SUB_COMMANDS.containsKey(action) && !executor.hasPermission(getPermission(action))) {
|
||||
plugin.getLocales().getLocale("error_no_permission")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
@@ -105,7 +111,7 @@ public class HuskHomesCommand extends Command implements TabProvider {
|
||||
@Override
|
||||
@NotNull
|
||||
public List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
|
||||
return args.length < 2 ? SUB_COMMANDS : List.of();
|
||||
return args.length < 2 ? SUB_COMMANDS.keySet().stream().sorted().toList() : List.of();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import net.william278.paginedown.PaginatedList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -18,6 +19,7 @@ public class PrivateHomeListCommand extends ListCommand {
|
||||
|
||||
protected PrivateHomeListCommand(@NotNull HuskHomes plugin) {
|
||||
super("homelist", List.of("homes"), "[player] [page]", plugin);
|
||||
addAdditionalPermissions(Map.of("other", true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,12 +14,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class RtpCommand extends Command {
|
||||
|
||||
protected RtpCommand(@NotNull HuskHomes plugin) {
|
||||
super("rtp", List.of(), "[player]", plugin);
|
||||
addAdditionalPermissions(Map.of(
|
||||
"other", true,
|
||||
"bypass_cooldown", true
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +69,7 @@ public class RtpCommand extends Command {
|
||||
.orElseThrow(() -> new IllegalStateException("No user data found for " + teleporter.getUsername()));
|
||||
final Instant currentTime = Instant.now();
|
||||
if (executor.equals(teleporter) && !currentTime.isAfter(user.getRtpCooldown()) &&
|
||||
!executor.hasPermission(getPermission("bypass_cooldown"))) {
|
||||
!executor.hasPermission(getPermission("bypass_cooldown"))) {
|
||||
plugin.getLocales().getLocale("error_rtp_cooldown",
|
||||
Long.toString(currentTime.until(user.getRtpCooldown(), ChronoUnit.MINUTES) + 1))
|
||||
.ifPresent(executor::sendMessage);
|
||||
|
||||
@@ -25,6 +25,8 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
|
||||
super(name, aliases, "<name>" + ((arguments.size() > 0) ? " [" + String.join("|", arguments) + "]" : ""), plugin);
|
||||
this.positionType = positionType;
|
||||
this.arguments = arguments;
|
||||
|
||||
addAdditionalPermissions(Map.of("other", false));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -114,12 +116,6 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<String, Boolean> getAdditionalPermissions() {
|
||||
return Map.of(getOtherPermission(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<String> suggest(@NotNull CommandUser executor, @NotNull String[] args) {
|
||||
|
||||
@@ -10,12 +10,14 @@ import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SpawnCommand extends Command {
|
||||
|
||||
protected SpawnCommand(@NotNull HuskHomes plugin) {
|
||||
super("spawn", List.of(), "[player]", plugin);
|
||||
addAdditionalPermissions(Map.of("other", true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -16,6 +17,7 @@ public class TpCommand extends Command implements TabProvider {
|
||||
|
||||
protected TpCommand(@NotNull HuskHomes plugin) {
|
||||
super("tp", List.of("tpo"), "[<player|position>] [target]", plugin);
|
||||
addAdditionalPermissions(Map.of("coordinates", true));
|
||||
setOperatorCommand(true);
|
||||
}
|
||||
|
||||
@@ -31,10 +33,11 @@ public class TpCommand extends Command implements TabProvider {
|
||||
|
||||
this.execute(executor, user, Target.username(args[0]), args);
|
||||
}
|
||||
case 2 -> execute(executor, Teleportable.username(args[0]), Target.username(args[1]), args);
|
||||
case 2 -> this.execute(executor, Teleportable.username(args[0]), Target.username(args[1]), args);
|
||||
default -> {
|
||||
final Position basePosition = getBasePosition(executor);
|
||||
Optional<Position> target = parsePositionArgs(basePosition, args, 0);
|
||||
Optional<Position> target = executor.hasPermission(getPermission("coordinates"))
|
||||
? parsePositionArgs(basePosition, args, 0) : Optional.empty();
|
||||
if (target.isPresent()) {
|
||||
if (!(executor instanceof OnlineUser user)) {
|
||||
plugin.getLocales().getLocale("error_in_game_only")
|
||||
@@ -46,7 +49,8 @@ public class TpCommand extends Command implements TabProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
target = parsePositionArgs(basePosition, args, 1);
|
||||
target = executor.hasPermission(getPermission("coordinates"))
|
||||
? parsePositionArgs(basePosition, args, 0) : Optional.empty();
|
||||
if (target.isPresent() && args.length >= 1) {
|
||||
this.execute(executor, Teleportable.username(args[0]), target.get(), args);
|
||||
return;
|
||||
|
||||
@@ -2,7 +2,10 @@ package net.william278.huskhomes.database;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Server;
|
||||
import net.william278.huskhomes.position.*;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.position.SavedPosition;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.teleport.Teleport;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.user.SavedUser;
|
||||
|
||||
@@ -13,7 +13,10 @@ import org.sqlite.SQLiteConfig;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public abstract class EconomyHook extends Hook {
|
||||
|
||||
public static final String BYPASS_PERMISSION = "huskhomes.bypass_economy_checks";
|
||||
|
||||
protected EconomyHook(@NotNull HuskHomes plugin, @NotNull String hookName) {
|
||||
super(plugin, hookName);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@ package net.william278.huskhomes.listener;
|
||||
|
||||
import de.themoep.minedown.adventure.MineDown;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.command.BackCommand;
|
||||
import net.william278.huskhomes.command.Command;
|
||||
import net.william278.huskhomes.network.Message;
|
||||
import net.william278.huskhomes.network.Payload;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.teleport.Teleport;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -148,9 +149,8 @@ public class EventListener {
|
||||
* @param onlineUser the {@link OnlineUser} who died
|
||||
*/
|
||||
protected final void handlePlayerDeath(@NotNull OnlineUser onlineUser) {
|
||||
// Set the player's last position to where they died
|
||||
if (plugin.getSettings().isBackCommandReturnByDeath()
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK_RETURN_BY_DEATH.node)) {
|
||||
if (plugin.getSettings().isBackCommandReturnByDeath() && plugin.getCommand(BackCommand.class)
|
||||
.map(Command::getPermission).map(onlineUser::hasPermission).orElse(false)) {
|
||||
plugin.getDatabase().setLastPosition(onlineUser, onlineUser.getPosition());
|
||||
}
|
||||
}
|
||||
@@ -163,9 +163,11 @@ public class EventListener {
|
||||
protected final void handlePlayerRespawn(@NotNull OnlineUser onlineUser) {
|
||||
plugin.runAsync(() -> {
|
||||
// Display the return by death via /back notification
|
||||
if (plugin.getSettings().isBackCommandReturnByDeath()
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK.node)
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK_RETURN_BY_DEATH.node)) {
|
||||
final boolean canReturnByDeath = plugin.getCommand(BackCommand.class)
|
||||
.map(command -> onlineUser.hasPermission(command.getPermission())
|
||||
&& onlineUser.hasPermission(command.getPermission("death")))
|
||||
.orElse(false);
|
||||
if (plugin.getSettings().isBackCommandReturnByDeath() && canReturnByDeath) {
|
||||
plugin.getLocales().getLocale("return_by_death_notification")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.william278.huskhomes.teleport;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.command.BackCommand;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.event.ITeleportEvent;
|
||||
import net.william278.huskhomes.hook.EconomyHook;
|
||||
@@ -22,21 +23,23 @@ public class Teleport {
|
||||
protected final Teleportable teleporter;
|
||||
protected final Target target;
|
||||
protected final Type type;
|
||||
protected final boolean updateLastPosition;
|
||||
protected final List<EconomyHook.Action> economyActions;
|
||||
private final boolean async;
|
||||
protected final boolean updateLastPosition;
|
||||
|
||||
protected Teleport(@NotNull OnlineUser executor, @NotNull Teleportable teleporter, @NotNull Target target,
|
||||
@NotNull Type type, boolean updateLastPosition, @NotNull List<EconomyHook.Action> actions,
|
||||
@NotNull HuskHomes plugin) {
|
||||
this.plugin = plugin;
|
||||
this.executor = executor;
|
||||
this.teleporter = teleporter;
|
||||
this.target = target;
|
||||
this.type = type;
|
||||
this.updateLastPosition = updateLastPosition;
|
||||
this.economyActions = actions;
|
||||
this.async = plugin.getSettings().isAsynchronousTeleports();
|
||||
this.plugin = plugin;
|
||||
this.updateLastPosition = updateLastPosition && plugin.getCommand(BackCommand.class)
|
||||
.map(command -> executor.hasPermission(command.getPermission()))
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -6,7 +6,6 @@ import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.hook.EconomyHook;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,6 +13,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class TimedTeleport extends Teleport {
|
||||
|
||||
public static final String BYPASS_PERMISSION = "huskhomes.bypass_teleport_warmup";
|
||||
private final OnlineUser teleporter;
|
||||
private final Position startLocation;
|
||||
private final double startHealth;
|
||||
@@ -32,7 +32,7 @@ public class TimedTeleport extends Teleport {
|
||||
@Override
|
||||
public void execute() throws TeleportationException {
|
||||
// Check if the teleporter can bypass warmup
|
||||
if (timeLeft == 0 || teleporter.hasPermission(Permission.BYPASS_TELEPORT_WARMUP.node)) {
|
||||
if (timeLeft == 0 || teleporter.hasPermission(BYPASS_PERMISSION)) {
|
||||
super.execute();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
package net.william278.huskhomes.util;
|
||||
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
import org.intellij.lang.annotations.Subst;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Static plugin permission nodes required to perform actions or execute commands
|
||||
*/
|
||||
public enum Permission {
|
||||
|
||||
/*
|
||||
* Bypass permission nodes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lets the user bypass the warmup time when a player must stand still before teleportation
|
||||
*/
|
||||
BYPASS_TELEPORT_WARMUP("huskhomes.bypass.teleport_warmup", DefaultAccess.NOBODY),
|
||||
/**
|
||||
* Lets the user bypass the cooldown on the {@code /rtp} command
|
||||
*/
|
||||
BYPASS_RTP_COOLDOWN("huskhomes.bypass.rtp_cooldown", DefaultAccess.NOBODY),
|
||||
/**
|
||||
* Lets the user bypass economy costs when teleporting
|
||||
*/
|
||||
BYPASS_ECONOMY_CHECKS("huskhomes.bypass.economy", DefaultAccess.NOBODY),
|
||||
|
||||
/*
|
||||
* Command permission nodes
|
||||
*/
|
||||
/**
|
||||
* Lets the user view the "disabled command" message for disabled commands
|
||||
*/
|
||||
COMMAND_DISABLED_MESSAGE("huskhomes.disabled_command_message", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user teleport to their homes ({@code /home [home_name]})
|
||||
*/
|
||||
COMMAND_HOME("huskhomes.command.home", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user teleport to other users' homes ({@code /home [player_name.home_name]})
|
||||
*/
|
||||
COMMAND_HOME_OTHER("huskhomes.command.home.other", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user set a home ({@code /sethome [home_name]})
|
||||
*/
|
||||
COMMAND_SET_HOME("huskhomes.command.sethome", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user delete a home ({@code /delhome [home_name]})
|
||||
*/
|
||||
COMMAND_DELETE_HOME("huskhomes.command.delhome", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user delete other users' homes ({@code /delhome [player_name.home_name]})
|
||||
*/
|
||||
COMMAND_DELETE_HOME_OTHER("huskhomes.command.delhome.other", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user edit their homes ({@code /edithome [home_name]})
|
||||
*/
|
||||
COMMAND_EDIT_HOME("huskhomes.command.edithome", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user edit other users' homes ({@code /edithome [player_name.home_name]})
|
||||
*/
|
||||
COMMAND_EDIT_HOME_OTHER("huskhomes.command.edithome.other", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user edit the privacy of their home ({@code /edithome [home_name] [public/private]})
|
||||
*/
|
||||
COMMAND_EDIT_HOME_PRIVACY("huskhomes.command.edithome.privacy", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user teleport to a public home ({@code /phome [player_name.home_name]})
|
||||
*/
|
||||
COMMAND_PUBLIC_HOME("huskhomes.command.phome", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user teleport to a warp ({@code /warp [warp_name]})
|
||||
*/
|
||||
COMMAND_WARP("huskhomes.command.warp", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user set a warp ({@code /setwarp [warp_name]})
|
||||
*/
|
||||
COMMAND_SET_WARP("huskhomes.command.setwarp", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user delete a warp ({@code /delwarp [warp_name]})
|
||||
*/
|
||||
COMMAND_DELETE_WARP("huskhomes.command.delwarp", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user edit a warp ({@code /editwarp [warp_name]})
|
||||
*/
|
||||
COMMAND_EDIT_WARP("huskhomes.command.editwarp", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user instantly tp to another player ({@code /tp [player_name]})
|
||||
*/
|
||||
COMMAND_TP("huskhomes.command.tp", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user instantly tp to a set of coordinates ({@code /tp [x] [y] [z] [world] [server]})
|
||||
*/
|
||||
COMMAND_TP_TO_COORDINATES("huskhomes.command.tp.coordinates", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user instantly tp another user to a player (and, if they have the {@link Permission#COMMAND_TP_TO_COORDINATES}
|
||||
* permission, to a set of coordinates) ({@code /tp [player_to_teleport] [target]})
|
||||
*/
|
||||
COMMAND_TP_OTHER("huskhomes.command.tp.other", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user instantly tp another player to them ({@code /tphere [player_name]})
|
||||
*/
|
||||
COMMAND_TPHERE("huskhomes.command.tphere", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user request to tp to another player ({@code /tpa [player_name]})
|
||||
*/
|
||||
COMMAND_TPA("huskhomes.command.tpa", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user request another player to tp to them ({@code /tpahere [player_name]})
|
||||
*/
|
||||
COMMAND_TPAHERE("huskhomes.command.tpahere", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user accept a tp request ({@code /tpaccept})
|
||||
*/
|
||||
COMMAND_TPACCEPT("huskhomes.command.tpaccept", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user deny a tp request ({@code /tpdeny})
|
||||
*/
|
||||
COMMAND_TPDECLINE("huskhomes.command.tpdecline", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user ignore incoming tp requests ({@code /tpignore})
|
||||
*/
|
||||
COMMAND_TPIGNORE("huskhomes.command.tpignore", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user tp to where a user logged out ({@code /tpoffline [player_name]})
|
||||
*/
|
||||
COMMAND_TPOFFLINE("huskhomes.command.tpoffline", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user teleport everyone to their position ({@code /tpall})
|
||||
*/
|
||||
COMMAND_TPALL("huskhomes.command.tpall", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user send a teleport request asking everyone to teleport to them ({@code /tpaall})
|
||||
*/
|
||||
COMMAND_TPA_ALL("huskhomes.command.tpaall", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user randomly teleport in the world they are in ({@code /rtp})
|
||||
*/
|
||||
COMMAND_RTP("huskhomes.command.rtp", DefaultAccess.EVERYONE),
|
||||
COMMAND_RTP_OTHER("huskhomes.command.rtp.other", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user teleport to the defined spawn position ({@code /spawn})
|
||||
*/
|
||||
COMMAND_SPAWN("huskhomes.command.spawn", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user set the spawn position ({@code /setspawn})
|
||||
*/
|
||||
COMMAND_SET_SPAWN("huskhomes.command.setspawn", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user return to where they last teleported from ({@code /back})
|
||||
*/
|
||||
COMMAND_BACK("huskhomes.command.back", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user use {@code /back} to return to where they died
|
||||
*/
|
||||
COMMAND_BACK_RETURN_BY_DEATH("huskhomes.command.back.death", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user access /huskhomes subcommands
|
||||
*/
|
||||
COMMAND_HUSKHOMES("huskhomes.command.huskhomes", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user view the command list
|
||||
*/
|
||||
COMMAND_HUSKHOMES_HELP("huskhomes.command.huskhomes.help", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user view plugin information
|
||||
*/
|
||||
COMMAND_HUSKHOMES_ABOUT("huskhomes.command.huskhomes.about", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user reload the plugin config and message files
|
||||
*/
|
||||
COMMAND_HUSKHOMES_RELOAD("huskhomes.command.huskhomes.reload", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user check for plugin updates
|
||||
*/
|
||||
COMMAND_HUSKHOMES_UPDATE("huskhomes.command.huskhomes.update", DefaultAccess.OPERATORS);
|
||||
|
||||
public static final String PERMISSION_PATTERN = "(huskhomes\\.)?[a-z0-9_\\-*.]+";
|
||||
|
||||
@Pattern(Permission.PERMISSION_PATTERN)
|
||||
@NotNull
|
||||
public final String node;
|
||||
@NotNull
|
||||
public final DefaultAccess defaultAccess;
|
||||
|
||||
Permission(@Subst("huskhomes.*") @NotNull String node, @NotNull DefaultAccess defaultAccess) {
|
||||
this.node = node;
|
||||
this.defaultAccess = defaultAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies who gets what permissions by default
|
||||
*/
|
||||
public enum DefaultAccess {
|
||||
/**
|
||||
* Everyone gets this permission node by default
|
||||
*/
|
||||
EVERYONE,
|
||||
/**
|
||||
* Nobody gets this permission node by default
|
||||
*/
|
||||
NOBODY,
|
||||
/**
|
||||
* Server operators ({@code /op}) get this permission node by default
|
||||
*/
|
||||
OPERATORS
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user