mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-19 14:59:19 +00:00
Cloud 2 migration, 1.20.6, bump all deps, refactor project layout
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("maven-publish")
|
id("buildlogic.java-publish-conventions")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -32,31 +32,3 @@ dependencies {
|
|||||||
exclude("com.google")
|
exclude("com.google")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
|
||||||
withSourcesJar()
|
|
||||||
withJavadocJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
repositories {
|
|
||||||
// See Gradle docs for how to provide credentials to PasswordCredentials
|
|
||||||
// https://docs.gradle.org/current/samples/sample_publishing_credentials.html
|
|
||||||
maven {
|
|
||||||
name = "convallyriaSnapshots"
|
|
||||||
url = uri("https://repo.convallyria.com/snapshots/")
|
|
||||||
credentials(PasswordCredentials::class)
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
name = "convallyriaReleases"
|
|
||||||
url = uri("https://repo.convallyria.com/releases/")
|
|
||||||
credentials(PasswordCredentials::class)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configure<PublishingExtension> {
|
|
||||||
publications.create<MavenPublication>("maven") {
|
|
||||||
from(components["java"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -28,7 +28,7 @@ public interface IRPGRegionsAPI {
|
|||||||
IRPGRegionsManagers getManagers();
|
IRPGRegionsManagers getManagers();
|
||||||
|
|
||||||
boolean debug();
|
boolean debug();
|
||||||
|
|
||||||
void debug(String debug);
|
void debug(String debug);
|
||||||
|
|
||||||
boolean hasHeadDatabase();
|
boolean hasHeadDatabase();
|
||||||
|
|||||||
@@ -52,4 +52,4 @@ public class FaunaDiscoverEvent extends Event {
|
|||||||
return HANDLER_LIST;
|
return HANDLER_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ public class RPGRegionsReloadEvent extends Event {
|
|||||||
return HANDLER_LIST;
|
return HANDLER_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class RegionDiscoverEvent extends Event {
|
|||||||
private final RPGRegionsAccount account;
|
private final RPGRegionsAccount account;
|
||||||
private final ConfiguredRegion region;
|
private final ConfiguredRegion region;
|
||||||
private final Discovery discovery;
|
private final Discovery discovery;
|
||||||
|
|
||||||
public RegionDiscoverEvent(Player player, RPGRegionsAccount account, ConfiguredRegion region, Discovery discovery) {
|
public RegionDiscoverEvent(Player player, RPGRegionsAccount account, ConfiguredRegion region, Discovery discovery) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.account = account;
|
this.account = account;
|
||||||
@@ -63,4 +63,4 @@ public class RegionDiscoverEvent extends Event {
|
|||||||
return HANDLER_LIST;
|
return HANDLER_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,4 +63,4 @@ public class RegionsEnterEvent extends Event {
|
|||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return HANDLER_LIST;
|
return HANDLER_LIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,5 @@ public interface IntegrationManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull List<Location> getBoundingBoxPoints(@NotNull ConfiguredRegion region);
|
||||||
List<Location> getBoundingBoxPoints(@NotNull ConfiguredRegion region);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class ClassEditor {
|
public class ClassEditor {
|
||||||
|
|
||||||
private final List<EditField> editable = new ArrayList<>();
|
private final List<EditField> editable = new ArrayList<>();
|
||||||
|
|
||||||
public ClassEditor(ConfiguredRegion clazz) {
|
public ClassEditor(ConfiguredRegion clazz) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class RegionEffect implements IGuiEditable {
|
public abstract class RegionEffect implements IGuiEditable {
|
||||||
|
|
||||||
private final boolean wearingRequired;
|
private final boolean wearingRequired;
|
||||||
private final List<ItemStack> ignoreItems;
|
private final List<ItemStack> ignoreItems;
|
||||||
private final boolean ignorePerm;
|
private final boolean ignorePerm;
|
||||||
@@ -41,8 +41,7 @@ public abstract class RegionEffect implements IGuiEditable {
|
|||||||
* Gets the required Minecraft version for this effect to function.
|
* Gets the required Minecraft version for this effect to function.
|
||||||
* @return minecraft version
|
* @return minecraft version
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable public String getRequiredVersion() {
|
||||||
public String getRequiredVersion() {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +69,7 @@ public abstract class RegionEffect implements IGuiEditable {
|
|||||||
public boolean shouldIgnore(ItemStack item) {
|
public boolean shouldIgnore(ItemStack item) {
|
||||||
return ignoreItems.contains(item);
|
return ignoreItems.contains(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the permission for this effect to apply.
|
* Gets the permission for this effect to apply.
|
||||||
* @return permission the player requires
|
* @return permission the player requires
|
||||||
@@ -78,7 +77,7 @@ public abstract class RegionEffect implements IGuiEditable {
|
|||||||
public String getPermission() {
|
public String getPermission() {
|
||||||
return "rpgregions.effect." + getName();
|
return "rpgregions.effect." + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the permission should be ignored or not.
|
* Whether the permission should be ignored or not.
|
||||||
* @return true if permission is ignored
|
* @return true if permission is ignored
|
||||||
|
|||||||
@@ -77,4 +77,4 @@ public class RPGRegionsAccount {
|
|||||||
ICON_COMMAND,
|
ICON_COMMAND,
|
||||||
TELEPORT
|
TELEPORT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,8 +148,7 @@ public class ConfiguredRegion {
|
|||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public ItemStack getIcon() {
|
||||||
public ItemStack getIcon() {
|
|
||||||
if (icon == null) return new ItemStack(Material.TOTEM_OF_UNDYING);
|
if (icon == null) return new ItemStack(Material.TOTEM_OF_UNDYING);
|
||||||
if (icon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(icon.replace("hdb-", ""))).withModel(iconModel).build();
|
if (icon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(icon.replace("hdb-", ""))).withModel(iconModel).build();
|
||||||
return new ItemStackBuilder(Material.valueOf(icon)).withModel(iconModel).build();
|
return new ItemStackBuilder(Material.valueOf(icon)).withModel(iconModel).build();
|
||||||
@@ -167,8 +166,7 @@ public class ConfiguredRegion {
|
|||||||
this.iconModel = iconModel;
|
this.iconModel = iconModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public ItemStack getUndiscoveredIcon() {
|
||||||
public ItemStack getUndiscoveredIcon() {
|
|
||||||
if (undiscoveredIcon == null) return new ItemStack(Material.TOTEM_OF_UNDYING);
|
if (undiscoveredIcon == null) return new ItemStack(Material.TOTEM_OF_UNDYING);
|
||||||
if (undiscoveredIcon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(undiscoveredIcon.replace("hdb-", ""))).withModel(undiscoveredIconModel).build();
|
if (undiscoveredIcon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(undiscoveredIcon.replace("hdb-", ""))).withModel(undiscoveredIconModel).build();
|
||||||
return new ItemStackBuilder(Material.valueOf(undiscoveredIcon)).withModel(undiscoveredIconModel).build();
|
return new ItemStackBuilder(Material.valueOf(undiscoveredIcon)).withModel(undiscoveredIconModel).build();
|
||||||
@@ -186,8 +184,7 @@ public class ConfiguredRegion {
|
|||||||
this.undiscoveredIconModel = undiscoveredIconModel;
|
this.undiscoveredIconModel = undiscoveredIconModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull public List<IconCommand> getIconCommand() {
|
||||||
public List<IconCommand> getIconCommand() {
|
|
||||||
return iconCommand == null ? new ArrayList<>() : iconCommand;
|
return iconCommand == null ? new ArrayList<>() : iconCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,8 +204,7 @@ public class ConfiguredRegion {
|
|||||||
this.showCoords = showCoords;
|
this.showCoords = showCoords;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public List<String> getHints() {
|
||||||
public List<String> getHints() {
|
|
||||||
return hints;
|
return hints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,8 +224,7 @@ public class ConfiguredRegion {
|
|||||||
this.teleportable = teleportable;
|
this.teleportable = teleportable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public World getWorld() {
|
||||||
public World getWorld() {
|
|
||||||
return Bukkit.getWorld(world);
|
return Bukkit.getWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,18 +249,15 @@ public class ConfiguredRegion {
|
|||||||
this.hidden = hidden;
|
this.hidden = hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public List<RegionEffect> getEffects() {
|
||||||
public List<RegionEffect> getEffects() {
|
|
||||||
return effects;
|
return effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public List<RegionRequirement> getRequirements() {
|
||||||
public List<RegionRequirement> getRequirements() {
|
|
||||||
return requirements;
|
return requirements;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public List<String> getDiscoveredLore() {
|
||||||
public List<String> getDiscoveredLore() {
|
|
||||||
return discoveredLore;
|
return discoveredLore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,8 +270,7 @@ public class ConfiguredRegion {
|
|||||||
* @param player the player
|
* @param player the player
|
||||||
* @return A string list of title
|
* @return A string list of title
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull public List<Component> getTitle(Player player) {
|
||||||
public List<Component> getTitle(Player player) {
|
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
return Translations.DISCOVERED_TITLE.get(player, customName);
|
return Translations.DISCOVERED_TITLE.get(player, customName);
|
||||||
}
|
}
|
||||||
@@ -294,8 +285,7 @@ public class ConfiguredRegion {
|
|||||||
* @param player the player
|
* @param player the player
|
||||||
* @return A string list of subtitles
|
* @return A string list of subtitles
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull public List<Component> getSubtitle(Player player) {
|
||||||
public List<Component> getSubtitle(Player player) {
|
|
||||||
if (subtitle == null) {
|
if (subtitle == null) {
|
||||||
return Translations.DISCOVERED_SUBTITLE.get(player, customName);
|
return Translations.DISCOVERED_SUBTITLE.get(player, customName);
|
||||||
}
|
}
|
||||||
@@ -310,8 +300,7 @@ public class ConfiguredRegion {
|
|||||||
* @param player the player
|
* @param player the player
|
||||||
* @return A string list of title
|
* @return A string list of title
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull public List<Component> getDiscoveredTitle(Player player) {
|
||||||
public List<Component> getDiscoveredTitle(Player player) {
|
|
||||||
if (discoveredTitle == null) {
|
if (discoveredTitle == null) {
|
||||||
return Translations.ALREADY_DISCOVERED_TITLE.get(player, customName);
|
return Translations.ALREADY_DISCOVERED_TITLE.get(player, customName);
|
||||||
}
|
}
|
||||||
@@ -326,8 +315,7 @@ public class ConfiguredRegion {
|
|||||||
* @param player the player
|
* @param player the player
|
||||||
* @return A string list of subtitles
|
* @return A string list of subtitles
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull public List<Component> getDiscoveredSubtitle(Player player) {
|
||||||
public List<Component> getDiscoveredSubtitle(Player player) {
|
|
||||||
if (discoveredSubtitle == null) {
|
if (discoveredSubtitle == null) {
|
||||||
return Translations.ALREADY_DISCOVERED_SUBTITLE.get(player, customName);
|
return Translations.ALREADY_DISCOVERED_SUBTITLE.get(player, customName);
|
||||||
}
|
}
|
||||||
@@ -337,8 +325,7 @@ public class ConfiguredRegion {
|
|||||||
return translatedSubtitle;
|
return translatedSubtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public Regenerate getRegenerate() {
|
||||||
public Regenerate getRegenerate() {
|
|
||||||
return regenerate;
|
return regenerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,8 +368,7 @@ public class ConfiguredRegion {
|
|||||||
this.showActionbar = showActionbar;
|
this.showActionbar = showActionbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public List<Location> getBoundingBox() {
|
||||||
public List<Location> getBoundingBox() {
|
|
||||||
return RPGRegionsAPI.getAPI().getManagers().getIntegrationManager().getBoundingBoxPoints(this);
|
return RPGRegionsAPI.getAPI().getManagers().getIntegrationManager().getBoundingBoxPoints(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,8 +460,7 @@ public class ConfiguredRegion {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable private File findFile(IRPGRegionsAPI plugin) throws IOException {
|
||||||
private File findFile(IRPGRegionsAPI plugin) throws IOException {
|
|
||||||
File folder = new File(plugin.getDataFolder() + "/regions/");
|
File folder = new File(plugin.getDataFolder() + "/regions/");
|
||||||
Stream<Path> files = Files.walk(Paths.get(folder.getPath()));
|
Stream<Path> files = Files.walk(Paths.get(folder.getPath()));
|
||||||
List<Path> valid = files.filter(path -> Files.isRegularFile(path) && path.toFile().getName().equals(this.id + ".json")).toList();
|
List<Path> valid = files.filter(path -> Files.isRegularFile(path) && path.toFile().getName().equals(this.id + ".json")).toList();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.islandearth.rpgregions.managers.data.region;
|
package net.islandearth.rpgregions.managers.data.region;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
public record WorldDiscovery(LocalDateTime date, String region) implements Discovery {
|
public record WorldDiscovery(LocalDateTime date, String region) implements Discovery {
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface IRPGRegionsRegistry<T> {
|
public interface IRPGRegionsRegistry<T> {
|
||||||
|
|
||||||
@NotNull
|
@NotNull ImmutableMap<String, Class<? extends T>> get();
|
||||||
ImmutableMap<String, Class<? extends T>> get();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to register a class.
|
* Attempts to register a class.
|
||||||
@@ -20,11 +19,9 @@ public interface IRPGRegionsRegistry<T> {
|
|||||||
*/
|
*/
|
||||||
void register(Class<? extends T> clazz);
|
void register(Class<? extends T> clazz);
|
||||||
|
|
||||||
@Nullable
|
@Nullable T getNew(String name, IRPGRegionsAPI plugin, Object... data);
|
||||||
T getNew(String name, IRPGRegionsAPI plugin, Object... data);
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable T getNew(Class<? extends T> clazz, IRPGRegionsAPI plugin, Object... data);
|
||||||
T getNew(Class<? extends T> clazz, IRPGRegionsAPI plugin, Object... data);
|
|
||||||
|
|
||||||
String getRegistryName();
|
String getRegistryName();
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,11 @@ public abstract class RPGRegionsRegistry<T> implements IRPGRegionsRegistry<T> {
|
|||||||
this.registeredClasses = new ConcurrentHashMap<>();
|
this.registeredClasses = new ConcurrentHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull protected Map<String, Class<? extends T>> getRegisteredClasses() {
|
||||||
protected Map<String, Class<? extends T>> getRegisteredClasses() {
|
|
||||||
return registeredClasses;
|
return registeredClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull @Override
|
||||||
@Override
|
|
||||||
public ImmutableMap<String, Class<? extends T>> get() {
|
public ImmutableMap<String, Class<? extends T>> get() {
|
||||||
return ImmutableMap.copyOf(registeredClasses);
|
return ImmutableMap.copyOf(registeredClasses);
|
||||||
}
|
}
|
||||||
@@ -36,14 +34,12 @@ public abstract class RPGRegionsRegistry<T> implements IRPGRegionsRegistry<T> {
|
|||||||
registeredClasses.put(clazz.getSimpleName(), clazz);
|
registeredClasses.put(clazz.getSimpleName(), clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable @Override
|
||||||
@Override
|
|
||||||
public T getNew(String name, IRPGRegionsAPI plugin, Object... data) {
|
public T getNew(String name, IRPGRegionsAPI plugin, Object... data) {
|
||||||
return getNew(registeredClasses.get(name), plugin, data);
|
return getNew(registeredClasses.get(name), plugin, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable @Override
|
||||||
@Override
|
|
||||||
public abstract T getNew(Class<? extends T> clazz, IRPGRegionsAPI plugin, Object... data);
|
public abstract T getNew(Class<? extends T> clazz, IRPGRegionsAPI plugin, Object... data);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class DependencyRequirement extends RegionRequirement {
|
|||||||
super(api);
|
super(api);
|
||||||
this.requiredRegions = requiredRegions;
|
this.requiredRegions = requiredRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an immutable list of required regions by their ID.
|
* Returns an immutable list of required regions by their ID.
|
||||||
* @return immutable list of required regions
|
* @return immutable list of required regions
|
||||||
@@ -32,22 +32,22 @@ public class DependencyRequirement extends RegionRequirement {
|
|||||||
public ImmutableList<String> getRequiredRegions() {
|
public ImmutableList<String> getRequiredRegions() {
|
||||||
return ImmutableList.copyOf(requiredRegions);
|
return ImmutableList.copyOf(requiredRegions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean meetsRequirements(List<String> discoveries) {
|
public boolean meetsRequirements(List<String> discoveries) {
|
||||||
return new HashSet<>(discoveries).containsAll(requiredRegions);
|
return new HashSet<>(discoveries).containsAll(requiredRegions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean meetsRequirements(Player player) {
|
public boolean meetsRequirements(Player player) {
|
||||||
return meetsRequirements(Collections.emptyList());
|
return meetsRequirements(Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Dependency";
|
return "Dependency";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Player player) {
|
public String getText(Player player) {
|
||||||
List<String> convertedIds = new ArrayList<>();
|
List<String> convertedIds = new ArrayList<>();
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ public abstract class RegionRequirement implements IGuiEditable, ICustomGuiFeedb
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public String getPreventMessage() {
|
||||||
public String getPreventMessage() {
|
|
||||||
return preventMessage;
|
return preventMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,11 +93,14 @@ public enum Translations {
|
|||||||
File lang = new File(plugin.getDataFolder() + "/lang/");
|
File lang = new File(plugin.getDataFolder() + "/lang/");
|
||||||
lang.mkdirs();
|
lang.mkdirs();
|
||||||
|
|
||||||
|
int validLanguages = 0;
|
||||||
for (Language language : Language.values()) {
|
for (Language language : Language.values()) {
|
||||||
final LanguageKey languageKey = language.getKey();
|
final LanguageKey languageKey = language.getKey();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
plugin.saveResource("lang/" + languageKey.getCode() + ".yml", false);
|
plugin.saveResource("lang/" + languageKey.getCode() + ".yml", false);
|
||||||
plugin.getLogger().info("Generated " + languageKey.getCode() + ".yml");
|
validLanguages++;
|
||||||
|
|
||||||
} catch (IllegalArgumentException ignored) { }
|
} catch (IllegalArgumentException ignored) { }
|
||||||
|
|
||||||
File file = new File(plugin.getDataFolder() + "/lang/" + languageKey.getCode() + ".yml");
|
File file = new File(plugin.getDataFolder() + "/lang/" + languageKey.getCode() + ".yml");
|
||||||
@@ -106,15 +109,17 @@ public enum Translations {
|
|||||||
for (Translations key : values()) {
|
for (Translations key : values()) {
|
||||||
if (config.get(key.toString().toLowerCase()) == null) {
|
if (config.get(key.toString().toLowerCase()) == null) {
|
||||||
plugin.getLogger().warning("No value in translation file for key "
|
plugin.getLogger().warning("No value in translation file for key "
|
||||||
+ key + " was found. Please regenerate or edit your language files with new values!");
|
+ key + " was found. Please regenerate or edit your language files with new values!"
|
||||||
|
+ " Check https://fortitude.islandearth.net/rpgregions/configuration/#default-language-file-en_gb for defaults.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.getLogger().info("Generated " + validLanguages + " valid language(s).");
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull private String setPapi(Player player, String message) {
|
||||||
private String setPapi(Player player, String message) {
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
return PlaceholderAPI.setPlaceholders(player, message);
|
return PlaceholderAPI.setPlaceholders(player, message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package net.islandearth.rpgregions.utils;
|
package net.islandearth.rpgregions.utils;
|
||||||
|
|
||||||
|
import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@@ -48,7 +48,7 @@ public class ItemStackBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackBuilder withName(Component name) {
|
public ItemStackBuilder withName(Component name) {
|
||||||
return withName(LegacyComponentSerializer.legacyAmpersand().serialize(name));
|
return withName(BukkitComponentSerializer.legacy().serialize(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackBuilder withLore(String name) {
|
public ItemStackBuilder withLore(String name) {
|
||||||
@@ -65,7 +65,7 @@ public class ItemStackBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackBuilder withLore(Component name) {
|
public ItemStackBuilder withLore(Component name) {
|
||||||
return withLore(LegacyComponentSerializer.legacyAmpersand().serialize(name));
|
return withLore(BukkitComponentSerializer.legacy().serialize(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackBuilder withLore(@Nullable List<String> name) {
|
public ItemStackBuilder withLore(@Nullable List<String> name) {
|
||||||
@@ -86,7 +86,7 @@ public class ItemStackBuilder {
|
|||||||
if (name == null) return this;
|
if (name == null) return this;
|
||||||
List<String> legacy = new ArrayList<>();
|
List<String> legacy = new ArrayList<>();
|
||||||
for (Component component : name) {
|
for (Component component : name) {
|
||||||
legacy.add(ChatColor.translateAlternateColorCodes('&', LegacyComponentSerializer.legacyAmpersand().serialize(component)));
|
legacy.add(BukkitComponentSerializer.legacy().serialize(component));
|
||||||
}
|
}
|
||||||
return withLore(legacy);
|
return withLore(legacy);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class MessageUtils {
|
public class MessageUtils {
|
||||||
|
|
||||||
@NotNull
|
@NotNull public static String replaceVariables(String message, String... values) {
|
||||||
public static String replaceVariables(String message, String... values) {
|
|
||||||
String modifiedMessage = message;
|
String modifiedMessage = message;
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (values.length > i) modifiedMessage = modifiedMessage.replaceAll("%" + i, values[i]);
|
if (values.length > i) modifiedMessage = modifiedMessage.replaceAll("%" + i, values[i]);
|
||||||
@@ -18,8 +17,7 @@ public class MessageUtils {
|
|||||||
return modifiedMessage;
|
return modifiedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull public static String setPapi(Player player, String message) {
|
||||||
public static String setPapi(Player player, String message) {
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
return PlaceholderAPI.setPlaceholders(player, message);
|
return PlaceholderAPI.setPlaceholders(player, message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.Set;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class TranslationsTest {
|
public class TranslationsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void translationTest() {
|
public void translationTest() {
|
||||||
Reflections reflections = new Reflections("lang/", new ResourcesScanner());
|
Reflections reflections = new Reflections("lang/", new ResourcesScanner());
|
||||||
|
|||||||
23
build-logic/build.gradle.kts
Normal file
23
build-logic/build.gradle.kts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by the Gradle 'init' task.
|
||||||
|
*
|
||||||
|
* This project uses @Incubating APIs which are subject to change.
|
||||||
|
*/
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build.
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
// Use the plugin portal to apply community plugins in convention plugins.
|
||||||
|
gradlePluginPortal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("io.github.goooler.shadow:io.github.goooler.shadow.gradle.plugin:8.1.7")
|
||||||
|
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
|
||||||
|
// implementation("net.kyori:indra-licenser-spotless:3.1.3")
|
||||||
|
implementation("net.kyori:blossom:2.1.0")
|
||||||
|
}
|
||||||
15
build-logic/settings.gradle.kts
Normal file
15
build-logic/settings.gradle.kts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by the Gradle 'init' task.
|
||||||
|
*
|
||||||
|
* This settings file is used to specify which projects to include in your build-logic build.
|
||||||
|
* This project uses @Incubating APIs which are subject to change.
|
||||||
|
*/
|
||||||
|
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
// Reuse version catalog from the main build.
|
||||||
|
versionCatalogs {
|
||||||
|
create("libs", { from(files("../gradle/libs.versions.toml")) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "build-logic"
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
plugins {
|
||||||
|
// Apply the java Plugin to add support for Java.
|
||||||
|
java
|
||||||
|
id("io.github.goooler.shadow")
|
||||||
|
id("com.diffplug.spotless")
|
||||||
|
// id("net.kyori.indra.licenser.spotless")
|
||||||
|
}
|
||||||
|
|
||||||
|
spotless {
|
||||||
|
java {
|
||||||
|
toggleOffOn("@formatter:off", "@formatter:on")
|
||||||
|
trimTrailingWhitespace()
|
||||||
|
formatAnnotations()
|
||||||
|
removeUnusedImports()
|
||||||
|
endWithNewline()
|
||||||
|
toggleOffOn()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinGradle {
|
||||||
|
endWithNewline()
|
||||||
|
indentWithSpaces(4)
|
||||||
|
trimTrailingWhitespace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
|
||||||
|
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||||
|
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||||
|
maven("https://repo.codemc.io/repository/maven-snapshots/")
|
||||||
|
maven("https://jitpack.io")
|
||||||
|
maven("https://repo.convallyria.com/releases")
|
||||||
|
maven("https://repo.convallyria.com/snapshots")
|
||||||
|
maven("https://papermc.io/repo/repository/maven-public/")
|
||||||
|
maven("https://oss.sonatype.org/content/groups/public/")
|
||||||
|
maven("https://repo.aikar.co/content/groups/aikar/")
|
||||||
|
|
||||||
|
// worldguard
|
||||||
|
maven("https://maven.enginehub.org/repo/")
|
||||||
|
|
||||||
|
// PAPI
|
||||||
|
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||||
|
|
||||||
|
// MythicMobs
|
||||||
|
maven("https://mvn.lumine.io/repository/maven-public/")
|
||||||
|
|
||||||
|
// Dynmap
|
||||||
|
maven("https://repo.mikeprimm.com")
|
||||||
|
|
||||||
|
// GriefDefender
|
||||||
|
maven("https://repo.glaremasters.me/repository/bloodshot")
|
||||||
|
|
||||||
|
// Crunch
|
||||||
|
maven("https://redempt.dev")
|
||||||
|
|
||||||
|
flatDir { dir("../libraries") }
|
||||||
|
}
|
||||||
|
|
||||||
|
project.group = "net.islandearth.rpgregions"
|
||||||
|
project.version = "1.4.7-SNAPSHOT"
|
||||||
|
|
||||||
|
group = project.group
|
||||||
|
version = project.version
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
constraints {
|
||||||
|
// Define dependency versions as constraints
|
||||||
|
compileOnly("net.kyori:adventure-api:4.17.0")
|
||||||
|
implementation("net.kyori:adventure-api:4.17.0")
|
||||||
|
testImplementation("net.kyori:adventure-api:4.17.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
implementation("com.convallyria.languagy:api:3.0.3-SNAPSHOT")
|
||||||
|
implementation("com.google.code.gson:gson:2.10.1")
|
||||||
|
|
||||||
|
implementation("net.kyori:adventure-api:4.17.0")
|
||||||
|
implementation("net.kyori:adventure-text-serializer-plain:4.17.0")
|
||||||
|
implementation("net.kyori:adventure-platform-bukkit:4.3.3-SNAPSHOT") // IMPLEMENTED VIA LIBRARIES
|
||||||
|
// implementation("net.kyori:adventure-platform-api:4.3.3-SNAPSHOT")
|
||||||
|
implementation("net.kyori:adventure-text-minimessage:4.17.0") // IMPLEMENTED VIA LIBRARIES
|
||||||
|
}
|
||||||
|
|
||||||
|
testing {
|
||||||
|
suites {
|
||||||
|
// Configure the built-in test suite
|
||||||
|
val test by getting(JvmTestSuite::class) {
|
||||||
|
// Use JUnit Jupiter test framework
|
||||||
|
useJUnitJupiter("5.10.1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply a specific Java toolchain to ease working on different environments.
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(21)
|
||||||
|
}
|
||||||
|
disableAutoTargetJvm()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
processResources {
|
||||||
|
filesMatching("plugin.yml") {
|
||||||
|
expand("version" to project.version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
options.release.set(16)
|
||||||
|
}
|
||||||
|
|
||||||
|
build {
|
||||||
|
dependsOn(shadowJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
archiveBaseName.set("rpgregions-2-${project.name}")
|
||||||
|
archiveClassifier.set("")
|
||||||
|
relocate("net.kyori", "rpgregions-libs.adventure")
|
||||||
|
relocate("com.google.gson", "rpgregions-libs.gson")
|
||||||
|
relocate("org.incendo.cloud", "rpgregions-libs.commandframework")
|
||||||
|
relocate("io.leangen.geantyref", "rpgregions-libs.typetoken")
|
||||||
|
relocate("com.convallyria.languagy", "rpgregions-libs.languagy")
|
||||||
|
relocate("io.papermc.lib", "rpgregions-libs.paperlib")
|
||||||
|
relocate("redempt.crunch", "rpgregions-libs.crunch")
|
||||||
|
relocate("co.aikar.idb", "rpgregions-libs.idb")
|
||||||
|
relocate("com.github.stefvanschie.inventoryframework", "rpgregions-libs.inventoryframework")
|
||||||
|
relocate("org.bstats", "rpgregions-libs.bstats")
|
||||||
|
relocate("me.lucko.helper", "rpgregions-libs.helper")
|
||||||
|
relocate("net.wesjd", "rpgregions-libs.anvilgui")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by the Gradle 'init' task.
|
||||||
|
*
|
||||||
|
* This project uses @Incubating APIs which are subject to change.
|
||||||
|
*/
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
// Apply the common convention plugin for shared build configuration between library and application projects.
|
||||||
|
id("buildlogic.java-common-conventions")
|
||||||
|
|
||||||
|
// Apply the java-library plugin for API and implementation separation.
|
||||||
|
`java-library`
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by the Gradle 'init' task.
|
||||||
|
*
|
||||||
|
* This project uses @Incubating APIs which are subject to change.
|
||||||
|
*/
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
// Apply the common convention plugin for shared build configuration between library and application projects.
|
||||||
|
id("buildlogic.java-library-conventions")
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
withSourcesJar()
|
||||||
|
withJavadocJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("maven") {
|
||||||
|
groupId = "net.islandearth.rpgregions"
|
||||||
|
artifactId = project.name
|
||||||
|
version = project.version.toString()
|
||||||
|
from(components["java"])
|
||||||
|
|
||||||
|
// skip shadow jar from publishing. Workaround for https://github.com/johnrengelman/shadow/issues/651
|
||||||
|
val javaComponent = components["java"] as AdhocComponentWithVariants
|
||||||
|
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { skip() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
// See Gradle docs for how to provide credentials to PasswordCredentials
|
||||||
|
// https://docs.gradle.org/current/samples/sample_publishing_credentials.html
|
||||||
|
maven {
|
||||||
|
val snapshotUrl = "https://repo.convallyria.com/snapshots/"
|
||||||
|
val releaseUrl = "https://repo.convallyria.com/releases/"
|
||||||
|
|
||||||
|
// Check which URL should be used
|
||||||
|
url = if (project.version.toString().endsWith("SNAPSHOT")) {
|
||||||
|
uri(snapshotUrl)
|
||||||
|
} else {
|
||||||
|
uri(releaseUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
name = "convallyria"
|
||||||
|
credentials {
|
||||||
|
credentials(PasswordCredentials::class)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
122
build.gradle.kts
122
build.gradle.kts
@@ -1,122 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id("com.github.johnrengelman.shadow") version("8.1.1")
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testImplementation("junit:junit:4.13.2")
|
|
||||||
implementation(project(":rpgregions", "shadow"))
|
|
||||||
implementation(project(":modern", "shadow"))
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
group = "net.islandearth.rpgregions"
|
|
||||||
version = "1.4.6"
|
|
||||||
|
|
||||||
//tasks.withType(JavaCompile).configureEach {
|
|
||||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
|
||||||
// this fixes some edge cases with special characters not displaying correctly
|
|
||||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
|
||||||
// If Javadoc is generated, this must be specified in that task too.
|
|
||||||
//it.options.encoding = "UTF-8"
|
|
||||||
|
|
||||||
// Force warnings
|
|
||||||
//options.compilerArgs << '-Xlint:all'
|
|
||||||
//options.deprecation = true
|
|
||||||
//}
|
|
||||||
|
|
||||||
apply(plugin = "com.github.johnrengelman.shadow")
|
|
||||||
apply(plugin = "java")
|
|
||||||
|
|
||||||
java {
|
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
|
||||||
disableAutoTargetJvm()
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
mavenLocal()
|
|
||||||
|
|
||||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
|
||||||
maven("https://repo.codemc.io/repository/maven-snapshots/")
|
|
||||||
maven("https://jitpack.io")
|
|
||||||
maven("https://repo.convallyria.com/releases")
|
|
||||||
maven("https://repo.convallyria.com/snapshots")
|
|
||||||
maven("https://papermc.io/repo/repository/maven-public/")
|
|
||||||
maven("https://oss.sonatype.org/content/groups/public/")
|
|
||||||
maven("https://repo.aikar.co/content/groups/aikar/")
|
|
||||||
|
|
||||||
// worldguard
|
|
||||||
maven("https://maven.enginehub.org/repo/")
|
|
||||||
|
|
||||||
// PAPI
|
|
||||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
|
||||||
|
|
||||||
// MythicMobs
|
|
||||||
maven("https://mvn.lumine.io/repository/maven-public/")
|
|
||||||
|
|
||||||
// Dynmap
|
|
||||||
maven("https://repo.mikeprimm.com")
|
|
||||||
|
|
||||||
// GriefDefender
|
|
||||||
maven("https://repo.glaremasters.me/repository/bloodshot")
|
|
||||||
|
|
||||||
// Crunch
|
|
||||||
maven("https://redempt.dev")
|
|
||||||
|
|
||||||
flatDir { dir("../libraries") }
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation("com.convallyria.languagy:api:3.0.3-SNAPSHOT")
|
|
||||||
implementation("com.google.code.gson:gson:2.10.1")
|
|
||||||
|
|
||||||
compileOnly("net.kyori:adventure-api:4.14.0")
|
|
||||||
compileOnly("net.kyori:adventure-platform-bukkit:4.3.2") // IMPLEMENTED VIA LIBRARIES
|
|
||||||
compileOnly("net.kyori:adventure-text-minimessage:4.14.0") // IMPLEMENTED VIA LIBRARIES
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
|
|
||||||
testLogging {
|
|
||||||
events("passed", "skipped", "failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
archiveClassifier.set("")
|
|
||||||
|
|
||||||
relocate("com.google.gson", "net.islandearth.rpgregions.libs.gson")
|
|
||||||
relocate("cloud.commandframework", "net.islandearth.rpgregions.libs.commandframework")
|
|
||||||
relocate("io.leangen.geantyref", "net.islandearth.rpgregions.libs.typetoken")
|
|
||||||
relocate("com.convallyria.languagy", "net.islandearth.rpgregions.libs.languagy")
|
|
||||||
relocate("io.papermc.lib", "net.islandearth.rpgregions.libs.paperlib")
|
|
||||||
relocate("redempt.crunch", "net.islandearth.rpgregions.libs.crunch")
|
|
||||||
relocate("co.aikar.idb", "net.islandearth.rpgregions.libs.idb")
|
|
||||||
relocate("com.github.stefvanschie.inventoryframework", "net.islandearth.rpgregions.libs.inventoryframework")
|
|
||||||
relocate("org.bstats", "net.islandearth.rpgregions.libs.bstats")
|
|
||||||
relocate("me.lucko.helper", "net.islandearth.rpgregions.libs.helper")
|
|
||||||
relocate("net.wesjd", "net.islandearth.rpgregions.libs.anvilgui")
|
|
||||||
}
|
|
||||||
|
|
||||||
build {
|
|
||||||
dependsOn(shadowJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
compileJava {
|
|
||||||
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
|
|
||||||
|
|
||||||
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
|
|
||||||
// See https://openjdk.java.net/jeps/247 for more information.
|
|
||||||
options.release.set(16)
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
filesMatching("plugin.yml") {
|
|
||||||
expand("version" to project.version)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
java {
|
plugins {
|
||||||
disableAutoTargetJvm()
|
id("buildlogic.java-common-conventions")
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
java {
|
||||||
maven {
|
disableAutoTargetJvm()
|
||||||
name = "papermc"
|
|
||||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
pluginGroup=net.islandearth
|
pluginGroup=net.islandearth
|
||||||
pluginVersion=1.4.5
|
pluginVersion=1.4.7
|
||||||
# Set to false if you don't have access to the UltraRegions API jar to make the plugin compilable. The purchased plugin has support for it.
|
# Set to false if you don't have access to the UltraRegions API jar to make the plugin compilable. The purchased plugin has support for it.
|
||||||
ultraRegionsSupport=true
|
ultraRegionsSupport=true
|
||||||
|
|
||||||
# Dependency management
|
# Dependency management
|
||||||
spigot_version = 1.20.4-R0.1-SNAPSHOT
|
spigot_version = 1.20.6-R0.1-SNAPSHOT
|
||||||
folia_version = 1.20.4-R0.1-SNAPSHOT
|
folia_version = 1.20.4-R0.1-SNAPSHOT
|
||||||
worldguard_version = 7.0.9
|
worldguard_version = 7.0.9
|
||||||
worldedit_version = 7.2.18-SNAPSHOT
|
worldedit_version = 7.2.18-SNAPSHOT
|
||||||
cloud_version = 1.8.3
|
cloud_version = 2.0.0-beta.7
|
||||||
|
|||||||
2
gradle/libs.versions.toml
Normal file
2
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# This file was generated by the Gradle 'init' task.
|
||||||
|
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
22
gradlew
vendored
22
gradlew
vendored
@@ -83,7 +83,8 @@ done
|
|||||||
# This is normally unused
|
# This is normally unused
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -130,10 +131,13 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
@@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@@ -198,11 +202,11 @@ fi
|
|||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# Collect all arguments for the java command:
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
# and any embedded shellness will be escaped.
|
||||||
# double quotes to make sure that they get re-expanded; and
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
|||||||
20
gradlew.bat
vendored
20
gradlew.bat
vendored
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
|||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
|||||||
17
license_header.txt
Normal file
17
license_header.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
This file is part of RPGRegions, licensed under the GNU GPL v3 License.
|
||||||
|
|
||||||
|
Copyright (C) $YEAR Convallyria
|
||||||
|
Copyright (C) contributors
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
plugins {
|
||||||
|
id("buildlogic.java-common-conventions")
|
||||||
|
}
|
||||||
|
|
||||||
val ultraRegionsSupport = (properties.getValue("ultraRegionsSupport") as String).toBoolean()
|
val ultraRegionsSupport = (properties.getValue("ultraRegionsSupport") as String).toBoolean()
|
||||||
|
|
||||||
tasks.compileJava {
|
tasks.compileJava {
|
||||||
@@ -8,9 +12,6 @@ tasks.compileJava {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":api"))
|
implementation(project(":api"))
|
||||||
implementation(project(":rpgregions"))
|
|
||||||
|
|
||||||
testImplementation("junit:junit:4.13.2")
|
|
||||||
|
|
||||||
compileOnly("org.spigotmc:spigot-api:${properties["spigot_version"]}")
|
compileOnly("org.spigotmc:spigot-api:${properties["spigot_version"]}")
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:${properties["worldguard_version"]}") {
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:${properties["worldguard_version"]}") {
|
||||||
@@ -23,4 +24,4 @@ dependencies {
|
|||||||
compileOnly("com.griefdefender:api:2.1.0-SNAPSHOT") // GriefDefender
|
compileOnly("com.griefdefender:api:2.1.0-SNAPSHOT") // GriefDefender
|
||||||
if (ultraRegionsSupport) compileOnly(":UltraRegions") // ultraregions
|
if (ultraRegionsSupport) compileOnly(":UltraRegions") // ultraregions
|
||||||
compileOnly("org.empirewar.orbis:paper-api:1.0.0-SNAPSHOT")
|
compileOnly("org.empirewar.orbis:paper-api:1.0.0-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
|||||||
import net.islandearth.rpgregions.api.events.RegionsEnterEvent;
|
import net.islandearth.rpgregions.api.events.RegionsEnterEvent;
|
||||||
import net.islandearth.rpgregions.api.integrations.IntegrationManager;
|
import net.islandearth.rpgregions.api.integrations.IntegrationManager;
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -15,7 +16,7 @@ import org.empirewar.orbis.query.RegionQuery;
|
|||||||
import org.empirewar.orbis.region.Region;
|
import org.empirewar.orbis.region.Region;
|
||||||
import org.empirewar.orbis.world.RegionisedWorld;
|
import org.empirewar.orbis.world.RegionisedWorld;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.joml.Vector3i;
|
import org.joml.Vector3ic;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -91,32 +92,35 @@ public class OrbisIntegration implements IntegrationManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean exists(World world, String region) {
|
public boolean exists(World world, String region) {
|
||||||
final RegionisedWorld regionisedWorld = OrbisAPI.get().getRegionisedWorld(world.getUID());
|
final RegionisedWorld regionisedWorld = OrbisAPI.get().getRegionisedWorld(worldToKey(world));
|
||||||
return regionisedWorld.getByName(region).isPresent();
|
return regionisedWorld.getByName(region).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getAllRegionNames(World world) {
|
public Set<String> getAllRegionNames(World world) {
|
||||||
final RegionisedWorld regionisedWorld = OrbisAPI.get().getRegionisedWorld(world.getUID());
|
final RegionisedWorld regionisedWorld = OrbisAPI.get().getRegionisedWorld(worldToKey(world));
|
||||||
return regionisedWorld.regions().stream().map(Region::name).collect(Collectors.toSet());
|
return regionisedWorld.regions().stream().map(Region::name).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull public List<Location> getBoundingBoxPoints(@NotNull ConfiguredRegion region) {
|
||||||
public List<Location> getBoundingBoxPoints(@NotNull ConfiguredRegion region) {
|
|
||||||
List<Location> points = new ArrayList<>();
|
List<Location> points = new ArrayList<>();
|
||||||
final RegionisedWorld world = OrbisAPI.get().getRegionisedWorld(region.getWorld().getUID());
|
final RegionisedWorld world = OrbisAPI.get().getRegionisedWorld(worldToKey(region.getWorld()));
|
||||||
final Region protectedRegion = world.getByName(region.getId()).orElseThrow();
|
final Region protectedRegion = world.getByName(region.getId()).orElseThrow();
|
||||||
for (Vector3i point : protectedRegion.area().points()) {
|
for (Vector3ic point : protectedRegion.area().points()) {
|
||||||
points.add(new Location(region.getWorld(), point.x(), region.getLocation().getY(), point.z()));
|
points.add(new Location(region.getWorld(), point.x(), region.getLocation().getY(), point.z()));
|
||||||
}
|
}
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Region> getRegions(Location location) {
|
private Set<Region> getRegions(Location location) {
|
||||||
final RegionisedWorld world = OrbisAPI.get().getRegionisedWorld(location.getWorld().getUID());
|
final RegionisedWorld world = OrbisAPI.get().getRegionisedWorld(worldToKey(location.getWorld()));
|
||||||
return world.query(RegionQuery.Position.builder()
|
return world.query(RegionQuery.Position.builder()
|
||||||
.position(location.getX(), location.getY(), location.getZ()).build())
|
.position(location.getX(), location.getY(), location.getZ()).build())
|
||||||
.result();
|
.result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Key worldToKey(World world) {
|
||||||
|
return Key.key(world.getKey().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,8 +107,7 @@ public class WorldGuardIntegration implements IntegrationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull public List<Location> getBoundingBoxPoints(@NotNull ConfiguredRegion region) {
|
||||||
public List<Location> getBoundingBoxPoints(@NotNull ConfiguredRegion region) {
|
|
||||||
List<Location> points = new ArrayList<>();
|
List<Location> points = new ArrayList<>();
|
||||||
final Map<String, ProtectedRegion> regions = WorldGuard.getInstance()
|
final Map<String, ProtectedRegion> regions = WorldGuard.getInstance()
|
||||||
.getPlatform()
|
.getPlatform()
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
plugins {
|
||||||
|
id("buildlogic.java-common-conventions")
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven("https://nexus.betonquest.org/repository/betonquest/")
|
maven("https://nexus.betonquest.org/repository/betonquest/")
|
||||||
maven("https://repo.codemc.io/repository/maven-public/")
|
maven("https://repo.codemc.io/repository/maven-public/")
|
||||||
@@ -7,23 +11,28 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":api"))
|
implementation(project(":api"))
|
||||||
implementation(project(":folia"))
|
implementation(project(":folia"))
|
||||||
|
implementation(project(":modern"))
|
||||||
|
|
||||||
testImplementation("junit:junit:4.13.2")
|
|
||||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.9.0")
|
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.9.0")
|
||||||
testImplementation("org.reflections:reflections:0.10.2")
|
testImplementation("org.reflections:reflections:0.10.2")
|
||||||
|
|
||||||
implementation("cloud.commandframework:cloud-paper:${properties["cloud_version"]}") {
|
implementation("org.incendo:cloud-paper:${properties["cloud_version"]}") {
|
||||||
|
exclude("org.checkerframework")
|
||||||
|
exclude("net.kyori")
|
||||||
|
}
|
||||||
|
implementation("org.incendo:cloud-annotations:2.0.0-rc.1") {
|
||||||
exclude("org.checkerframework")
|
exclude("org.checkerframework")
|
||||||
}
|
}
|
||||||
implementation("cloud.commandframework:cloud-annotations:${properties["cloud_version"]}") {
|
implementation("org.incendo:cloud-minecraft-extras:${properties["cloud_version"]}") {
|
||||||
exclude("org.checkerframework")
|
exclude("org.checkerframework")
|
||||||
|
exclude("net.kyori")
|
||||||
}
|
}
|
||||||
implementation("cloud.commandframework:cloud-minecraft-extras:${properties["cloud_version"]}") {
|
implementation("org.incendo:cloud-processors-confirmation:1.0.0-SNAPSHOT") {
|
||||||
exclude("org.checkerframework")
|
exclude("org.checkerframework")
|
||||||
exclude("net.kyori")
|
exclude("net.kyori")
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation("net.wesjd:anvilgui:1.9.3-SNAPSHOT") // anvilgui
|
implementation("net.wesjd:anvilgui:1.9.4-SNAPSHOT") // anvilgui
|
||||||
implementation("com.github.stefvanschie.inventoryframework:IF:0.10.13") // inventory framework
|
implementation("com.github.stefvanschie.inventoryframework:IF:0.10.13") // inventory framework
|
||||||
implementation("co.aikar:idb-core:1.0.0-SNAPSHOT") // database
|
implementation("co.aikar:idb-core:1.0.0-SNAPSHOT") // database
|
||||||
implementation("org.bstats:bstats-bukkit:3.0.2") // plugin stats
|
implementation("org.bstats:bstats-bukkit:3.0.2") // plugin stats
|
||||||
@@ -43,8 +52,8 @@ dependencies {
|
|||||||
exclude("org.bukkit")
|
exclude("org.bukkit")
|
||||||
exclude("org.spigotmc")
|
exclude("org.spigotmc")
|
||||||
}
|
}
|
||||||
compileOnly("org.flywaydb:flyway-core:9.16.2") // IMPLEMENTED VIA LIBRARIES - db migration
|
compileOnly("org.flywaydb:flyway-core:10.12.0") // IMPLEMENTED VIA LIBRARIES - db migration
|
||||||
compileOnly("org.flywaydb:flyway-mysql:9.16.3") // IMPLEMENTED VIA LIBRARIES
|
compileOnly("org.flywaydb:flyway-mysql:10.12.0") // IMPLEMENTED VIA LIBRARIES
|
||||||
//compileOnly 'com.zaxxer:HikariCP:2.4.1' // IMPLEMENTED VIA LIBRARIES - database
|
//compileOnly 'com.zaxxer:HikariCP:2.4.1' // IMPLEMENTED VIA LIBRARIES - database
|
||||||
compileOnly("me.clip:placeholderapi:2.11.3") // PAPI
|
compileOnly("me.clip:placeholderapi:2.11.3") // PAPI
|
||||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") { // vault
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7") { // vault
|
||||||
@@ -90,6 +99,9 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
minimize()
|
archiveBaseName.set("rpgregions-2")
|
||||||
|
minimize {
|
||||||
|
exclude(project(":modern"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,8 +85,7 @@ public interface GsonSerializable {
|
|||||||
* @param clazz the class
|
* @param clazz the class
|
||||||
* @return the deserialization method, if the class has one
|
* @return the deserialization method, if the class has one
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable static Method getDeserializeMethod(@Nonnull Class<?> clazz) {
|
||||||
static Method getDeserializeMethod(@Nonnull Class<?> clazz) {
|
|
||||||
if (!GsonSerializable.class.isAssignableFrom(clazz)) {
|
if (!GsonSerializable.class.isAssignableFrom(clazz)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,9 +77,11 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -359,6 +361,23 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
|||||||
this.formatter = null;
|
this.formatter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveResource(@NotNull String resourcePath, boolean replace) {
|
||||||
|
// Override to avoid "could not save resource" warning if already exists.
|
||||||
|
if (!resourcePath.isEmpty()) {
|
||||||
|
resourcePath = resourcePath.replace('\\', '/');
|
||||||
|
InputStream in = this.getResource(resourcePath);
|
||||||
|
if (in == null) {
|
||||||
|
// Let super error this
|
||||||
|
super.saveResource(resourcePath, replace);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
File outFile = new File(this.getDataFolder(), resourcePath);
|
||||||
|
if (outFile.exists()) return;
|
||||||
|
}
|
||||||
|
super.saveResource(resourcePath, replace);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean debug() {
|
public boolean debug() {
|
||||||
// This part of the code is called very often, caching the boolean gives a big performance boost at high player counts
|
// This part of the code is called very often, caching the boolean gives a big performance boost at high player counts
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
|||||||
import net.islandearth.rpgregions.thread.Blocking;
|
import net.islandearth.rpgregions.thread.Blocking;
|
||||||
import net.islandearth.rpgregions.translation.Translations;
|
import net.islandearth.rpgregions.translation.Translations;
|
||||||
import net.islandearth.rpgregions.utils.TimeEntry;
|
import net.islandearth.rpgregions.utils.TimeEntry;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -70,7 +70,7 @@ public class PlaceholderRegionHook extends PlaceholderExpansion implements Block
|
|||||||
if (plugin.getManagers().getIntegrationManager().getPrioritisedRegion(player.getLocation()).isPresent())
|
if (plugin.getManagers().getIntegrationManager().getPrioritisedRegion(player.getLocation()).isPresent())
|
||||||
return plugin.getManagers().getIntegrationManager().getPrioritisedRegion(player.getLocation()).get().getCustomName();
|
return plugin.getManagers().getIntegrationManager().getPrioritisedRegion(player.getLocation()).get().getCustomName();
|
||||||
else
|
else
|
||||||
return LegacyComponentSerializer.legacyAmpersand().serialize(Translations.UNKNOWN_REGION.get(player).get(0));
|
return BukkitComponentSerializer.legacy().serialize(Translations.UNKNOWN_REGION.get(player).get(0));
|
||||||
case "discovered_count":
|
case "discovered_count":
|
||||||
// We have to do a blocking operation :(
|
// We have to do a blocking operation :(
|
||||||
try {
|
try {
|
||||||
@@ -93,7 +93,7 @@ public class PlaceholderRegionHook extends PlaceholderExpansion implements Block
|
|||||||
case "region_timed": {
|
case "region_timed": {
|
||||||
final Optional<ConfiguredRegion> region = plugin.getManagers().getIntegrationManager().getPrioritisedRegion(player.getLocation());
|
final Optional<ConfiguredRegion> region = plugin.getManagers().getIntegrationManager().getPrioritisedRegion(player.getLocation());
|
||||||
if (region.isEmpty()) {
|
if (region.isEmpty()) {
|
||||||
return LegacyComponentSerializer.legacyAmpersand().serialize(Translations.UNKNOWN_REGION.get(player).get(0));
|
return BukkitComponentSerializer.legacy().serialize(Translations.UNKNOWN_REGION.get(player).get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
final ConfiguredRegion configuredRegion = region.get();
|
final ConfiguredRegion configuredRegion = region.get();
|
||||||
@@ -113,7 +113,7 @@ public class PlaceholderRegionHook extends PlaceholderExpansion implements Block
|
|||||||
final double time = TimeUnit.MILLISECONDS.toSeconds((long) (timeEntry.get().getLatestEntry() - entry));
|
final double time = TimeUnit.MILLISECONDS.toSeconds((long) (timeEntry.get().getLatestEntry() - entry));
|
||||||
final double secondsInsideToDiscover = configuredRegion.getSecondsInsideToDiscover();
|
final double secondsInsideToDiscover = configuredRegion.getSecondsInsideToDiscover();
|
||||||
final double percent = (time / secondsInsideToDiscover) * 100;
|
final double percent = (time / secondsInsideToDiscover) * 100;
|
||||||
return LegacyComponentSerializer.legacyAmpersand().serialize(Translations.DISCOVERING_AREA_PLACEHOLDER.get(player, (int) percent, region.get().getId()).get(0));
|
return BukkitComponentSerializer.legacy().serialize(Translations.DISCOVERING_AREA_PLACEHOLDER.get(player, (int) percent, region.get().getId()).get(0));
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,11 @@ public class CuboidRegion extends RPGRegionsRegion {
|
|||||||
super(name, world);
|
super(name, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public Location getFirstCorner() {
|
||||||
public Location getFirstCorner() {
|
|
||||||
return getPoints().isEmpty() ? null : getPoints().get(0);
|
return getPoints().isEmpty() ? null : getPoints().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public Location getSecondCorner() {
|
||||||
public Location getSecondCorner() {
|
|
||||||
return getPoints().size() < 2 ? null : getPoints().get(1);
|
return getPoints().size() < 2 ? null : getPoints().get(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class RPGRegionsConversationPrefix implements ConversationPrefix {
|
public class RPGRegionsConversationPrefix implements ConversationPrefix {
|
||||||
|
|
||||||
@NotNull
|
@NotNull @Override
|
||||||
@Override
|
|
||||||
public String getPrefix(@NotNull ConversationContext context) {
|
public String getPrefix(@NotNull ConversationContext context) {
|
||||||
return ChatColor.GOLD + "RPGRegions > " + ChatColor.AQUA;
|
return ChatColor.GOLD + "RPGRegions > " + ChatColor.AQUA;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,14 +14,12 @@ public class RPGRegionsStringPrompt extends StringPrompt {
|
|||||||
this.promptText = promptText;
|
this.promptText = promptText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull @Override
|
||||||
@Override
|
|
||||||
public String getPromptText(@NotNull ConversationContext context) {
|
public String getPromptText(@NotNull ConversationContext context) {
|
||||||
return promptText;
|
return promptText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable @Override
|
||||||
@Override
|
|
||||||
public Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) {
|
public Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) {
|
||||||
context.setSessionData("input", input);
|
context.setSessionData("input", input);
|
||||||
return Prompt.END_OF_CONVERSATION;
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
|||||||
@@ -1,52 +1,54 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import cloud.commandframework.annotations.AnnotationParser;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
import cloud.commandframework.arguments.parser.ParserParameters;
|
|
||||||
import cloud.commandframework.arguments.parser.ParserRegistry;
|
|
||||||
import cloud.commandframework.arguments.parser.StandardParameters;
|
|
||||||
import cloud.commandframework.bukkit.CloudBukkitCapabilities;
|
|
||||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
|
||||||
import cloud.commandframework.extra.confirmation.CommandConfirmationManager;
|
|
||||||
import cloud.commandframework.meta.CommandMeta;
|
|
||||||
import cloud.commandframework.minecraft.extras.MinecraftExceptionHandler;
|
|
||||||
import cloud.commandframework.paper.PaperCommandManager;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import io.leangen.geantyref.TypeFactory;
|
import io.leangen.geantyref.TypeFactory;
|
||||||
import io.leangen.geantyref.TypeToken;
|
import io.leangen.geantyref.TypeToken;
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.region.RPGRegionsRegion;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.region.RPGRegionsRegion;
|
||||||
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionRegistry;
|
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionProvider;
|
||||||
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionRegistryFactory;
|
|
||||||
import net.islandearth.rpgregions.commands.parser.ConfiguredRegionArgument;
|
import net.islandearth.rpgregions.commands.parser.ConfiguredRegionArgument;
|
||||||
import net.islandearth.rpgregions.commands.parser.FaunaArgument;
|
import net.islandearth.rpgregions.commands.parser.FaunaArgument;
|
||||||
import net.islandearth.rpgregions.commands.parser.IntegrationRegionArgument;
|
import net.islandearth.rpgregions.commands.parser.IntegrationRegionArgument;
|
||||||
import net.islandearth.rpgregions.fauna.FaunaInstance;
|
import net.islandearth.rpgregions.fauna.FaunaInstance;
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
import org.bukkit.ChatColor;
|
import net.islandearth.rpgregions.utils.Colors;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.incendo.cloud.SenderMapper;
|
||||||
|
import org.incendo.cloud.annotations.AnnotationParser;
|
||||||
|
import org.incendo.cloud.bukkit.CloudBukkitCapabilities;
|
||||||
|
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||||
|
import org.incendo.cloud.minecraft.extras.MinecraftExceptionHandler;
|
||||||
|
import org.incendo.cloud.paper.PaperCommandManager;
|
||||||
|
import org.incendo.cloud.parser.ParserRegistry;
|
||||||
|
import org.incendo.cloud.processors.cache.CaffeineCache;
|
||||||
|
import org.incendo.cloud.processors.confirmation.ConfirmationConfiguration;
|
||||||
|
import org.incendo.cloud.processors.confirmation.ConfirmationManager;
|
||||||
|
import org.incendo.cloud.suggestion.Suggestion;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Function;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
public class Commands {
|
public class Commands {
|
||||||
|
|
||||||
public Commands(RPGRegions plugin) {
|
private ConfirmationManager<CommandSender> confirmationManager;
|
||||||
|
|
||||||
// This function maps the command sender type of our choice to the bukkit command sender.
|
public Commands(RPGRegions plugin) {
|
||||||
final Function<CommandSender, CommandSender> mapperFunction = Function.identity();
|
|
||||||
|
|
||||||
final PaperCommandManager<CommandSender> manager;
|
final PaperCommandManager<CommandSender> manager;
|
||||||
try {
|
try {
|
||||||
manager = new PaperCommandManager<>(
|
manager = new PaperCommandManager<>(
|
||||||
plugin,
|
plugin,
|
||||||
CommandExecutionCoordinator.simpleCoordinator(),
|
ExecutionCoordinator.asyncCoordinator(),
|
||||||
mapperFunction,
|
SenderMapper.identity()
|
||||||
mapperFunction
|
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.getLogger().severe("Failed to initialize the command manager");
|
plugin.getLogger().severe("Failed to initialize the command manager");
|
||||||
@@ -54,13 +56,10 @@ public class Commands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register Brigadier mappings
|
// Register Brigadier mappings or asynchronous completions
|
||||||
if (manager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
|
if (manager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
|
||||||
manager.registerBrigadier();
|
manager.registerBrigadier();
|
||||||
}
|
} else if (manager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
|
||||||
|
|
||||||
// Register asynchronous completions
|
|
||||||
if (manager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
|
|
||||||
manager.registerAsynchronousCompletions();
|
manager.registerAsynchronousCompletions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,78 +67,82 @@ public class Commands {
|
|||||||
* Create the confirmation manager. This allows us to require certain commands to be
|
* Create the confirmation manager. This allows us to require certain commands to be
|
||||||
* confirmed before they can be executed
|
* confirmed before they can be executed
|
||||||
*/
|
*/
|
||||||
final CommandConfirmationManager<CommandSender> confirmationManager = new CommandConfirmationManager<>(30L, TimeUnit.SECONDS,
|
ConfirmationConfiguration<CommandSender> confirmationConfig = ConfirmationConfiguration.<CommandSender>builder()
|
||||||
/* Action when confirmation is required */
|
.cache(CaffeineCache.of(Caffeine.newBuilder().expireAfterWrite(Duration.ofSeconds(30)).build()))
|
||||||
context -> {
|
.noPendingCommandNotifier(sender -> {
|
||||||
final String name = context.getCommand().getArguments().get(0).getName();
|
final Audience audience = plugin.adventure().sender(sender);
|
||||||
context.getCommandContext().getSender().sendMessage(
|
audience.sendMessage(text("You don't have any pending confirmations.", Colors.BRIGHT_RED));
|
||||||
ChatColor.RED + "Confirmation required. Confirm using " + ChatColor.YELLOW + "/" + name + " confirm" + ChatColor.RED + ".");
|
})
|
||||||
},
|
.confirmationRequiredNotifier((sender, context) -> {
|
||||||
/* Action when no confirmation is pending */ sender -> sender.sendMessage(
|
final Audience audience = plugin.adventure().sender(sender);
|
||||||
ChatColor.RED + "You don't have any pending commands.")
|
audience.sendMessage(text("Confirmation required. Confirm using", Colors.BRIGHT_RED).append(text(" /rpgregions confirm", Colors.HONEY_YELLOW).append(text(".", Colors.BRIGHT_RED))));
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
confirmationManager = ConfirmationManager.confirmationManager(confirmationConfig);
|
||||||
|
|
||||||
|
// Register the confirmation command.
|
||||||
|
manager.command(
|
||||||
|
manager.commandBuilder("rpgregions")
|
||||||
|
.literal("confirm")
|
||||||
|
.handler(confirmationManager.createExecutionHandler())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Register the confirmation processor. This will enable confirmations for commands that require it
|
// Register the confirmation processor. This will enable confirmations for commands that require it
|
||||||
confirmationManager.registerConfirmationProcessor(manager);
|
manager.registerCommandPostProcessor(confirmationManager.createPostprocessor());
|
||||||
|
|
||||||
// This will allow you to decorate commands with descriptions
|
|
||||||
final Function<ParserParameters, CommandMeta> commandMetaFunction = parserParameters ->
|
|
||||||
CommandMeta.simple()
|
|
||||||
.with(CommandMeta.DESCRIPTION, parserParameters.get(StandardParameters.DESCRIPTION, "No description"))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Override the default exception handlers
|
// Override the default exception handlers
|
||||||
// todo: change some stuff lmao
|
// todo: change some stuff lmao
|
||||||
new MinecraftExceptionHandler<CommandSender>()
|
MinecraftExceptionHandler.<CommandSender>create(sender -> plugin.adventure().sender(sender))
|
||||||
.withInvalidSyntaxHandler()
|
.defaultInvalidSyntaxHandler()
|
||||||
.withInvalidSenderHandler()
|
.defaultInvalidSenderHandler()
|
||||||
.withNoPermissionHandler()
|
.defaultNoPermissionHandler()
|
||||||
.withArgumentParsingHandler()
|
.defaultArgumentParsingHandler()
|
||||||
.apply(manager, player -> plugin.adventure().sender(player));
|
.defaultCommandExecutionHandler()
|
||||||
|
.registerTo(manager);
|
||||||
|
|
||||||
// Register our custom caption registry so we can define exception messages for parsers
|
// Register our custom caption registry so we can define exception messages for parsers
|
||||||
final RPGRegionsCaptionRegistry<CommandSender> captionRegistry = new RPGRegionsCaptionRegistryFactory<CommandSender>().create();
|
manager.captionRegistry().registerProvider(new RPGRegionsCaptionProvider<>());
|
||||||
manager.captionRegistry(captionRegistry);
|
|
||||||
|
|
||||||
// Register custom parsers
|
// Register custom parsers
|
||||||
final ParserRegistry<CommandSender> parserRegistry = manager.parserRegistry();
|
final ParserRegistry<CommandSender> parserRegistry = manager.parserRegistry();
|
||||||
parserRegistry.registerParserSupplier(TypeToken.get(ConfiguredRegion.class), parserParameters ->
|
parserRegistry.registerParserSupplier(TypeToken.get(ConfiguredRegion.class), parserParameters -> new ConfiguredRegionArgument<>());
|
||||||
new ConfiguredRegionArgument.ConfiguredRegionParser<>());
|
|
||||||
parserRegistry.registerParserSupplier(TypeToken.get(TypeFactory.parameterizedClass(FaunaInstance.class, TypeFactory.unboundWildcard())), parserParameters ->
|
parserRegistry.registerParserSupplier(TypeToken.get(TypeFactory.parameterizedClass(FaunaInstance.class, TypeFactory.unboundWildcard())), parserParameters ->
|
||||||
new FaunaArgument.FaunaParser<>());
|
new FaunaArgument<>());
|
||||||
parserRegistry.registerParserSupplier(TypeToken.get(RPGRegionsRegion.class), parserParameters ->
|
parserRegistry.registerParserSupplier(TypeToken.get(RPGRegionsRegion.class), parserParameters ->
|
||||||
new IntegrationRegionArgument.IntegrationRegionParser<>());
|
new IntegrationRegionArgument<>());
|
||||||
|
|
||||||
parserRegistry.registerSuggestionProvider("region-types", (context, arg) -> ImmutableList.of("Cuboid", "Poly"));
|
parserRegistry.registerSuggestionProvider("region-types", (context, arg) -> CompletableFuture.completedFuture(Stream.of("Cuboid", "Poly").map(Suggestion::suggestion).toList()));
|
||||||
|
|
||||||
parserRegistry.registerSuggestionProvider("integration-regions", (context, arg) -> {
|
parserRegistry.registerSuggestionProvider("integration-regions", (context, arg) -> {
|
||||||
if (context.getSender() instanceof Player player) {
|
if (context.sender() instanceof Player player) {
|
||||||
return ImmutableList.copyOf(plugin.getManagers().getIntegrationManager().getAllRegionNames(player.getWorld()));
|
return CompletableFuture.completedFuture(plugin.getManagers().getIntegrationManager()
|
||||||
|
.getAllRegionNames(player.getWorld()).stream().map(Suggestion::suggestion).toList());
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return CompletableFuture.completedFuture(List.of());
|
||||||
});
|
});
|
||||||
|
|
||||||
parserRegistry.registerSuggestionProvider("templates", (context, arg) -> {
|
parserRegistry.registerSuggestionProvider("templates", (context, arg) -> {
|
||||||
File templates = new File(plugin.getDataFolder() + File.separator + "templates");
|
File templates = new File(plugin.getDataFolder() + File.separator + "templates");
|
||||||
List<String> files = new ArrayList<>();
|
List<Suggestion> files = new ArrayList<>();
|
||||||
for (File file : templates.listFiles()) {
|
for (File file : templates.listFiles()) {
|
||||||
files.add(file.getName());
|
files.add(Suggestion.suggestion(file.getName()));
|
||||||
}
|
}
|
||||||
return files;
|
return CompletableFuture.completedFuture(files);
|
||||||
});
|
});
|
||||||
|
|
||||||
parserRegistry.registerSuggestionProvider("schematics", (context, arg) -> {
|
parserRegistry.registerSuggestionProvider("schematics", (context, arg) -> {
|
||||||
File schematicFolder = new File("plugins/WorldEdit/schematics/");
|
File schematicFolder = new File("plugins/WorldEdit/schematics/");
|
||||||
List<String> files = new ArrayList<>();
|
List<Suggestion> files = new ArrayList<>();
|
||||||
for (File file : schematicFolder.listFiles()) {
|
for (File file : schematicFolder.listFiles()) {
|
||||||
files.add(file.getName());
|
files.add(Suggestion.suggestion(file.getName()));
|
||||||
}
|
}
|
||||||
return files;
|
return CompletableFuture.completedFuture(files);
|
||||||
});
|
});
|
||||||
|
|
||||||
parserRegistry.registerSuggestionProvider("async", (context, arg) -> List.of("--async"));
|
parserRegistry.registerSuggestionProvider("async", (context, arg) -> CompletableFuture.completedFuture(List.of(Suggestion.suggestion("--async"))));
|
||||||
|
|
||||||
final AnnotationParser<CommandSender> annotationParser = new AnnotationParser<>(manager, CommandSender.class, commandMetaFunction);
|
final AnnotationParser<CommandSender> annotationParser = new AnnotationParser<>(manager, CommandSender.class);
|
||||||
annotationParser.parse(new DiscoveriesCommand(plugin));
|
annotationParser.parse(new DiscoveriesCommand(plugin));
|
||||||
annotationParser.parse(new RPGRegionsCommand(plugin, manager));
|
annotationParser.parse(new RPGRegionsCommand(plugin, manager));
|
||||||
annotationParser.parse(new RPGRegionsDebugCommand(plugin));
|
annotationParser.parse(new RPGRegionsDebugCommand(plugin));
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import cloud.commandframework.annotations.Argument;
|
|
||||||
import cloud.commandframework.annotations.CommandDescription;
|
|
||||||
import cloud.commandframework.annotations.CommandMethod;
|
|
||||||
import cloud.commandframework.annotations.CommandPermission;
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||||
@@ -30,6 +26,10 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.incendo.cloud.annotations.Argument;
|
||||||
|
import org.incendo.cloud.annotations.Command;
|
||||||
|
import org.incendo.cloud.annotations.CommandDescription;
|
||||||
|
import org.incendo.cloud.annotations.Permission;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -44,24 +44,24 @@ public class DiscoveriesCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Opens the discovery GUI")
|
@CommandDescription("Opens the discovery GUI")
|
||||||
@CommandPermission("rpgregions.list")
|
@Permission("rpgregions.list")
|
||||||
@CommandMethod("discoveries|discovery")
|
@Command("discoveries|discovery")
|
||||||
public void onDefault(Player player) {
|
public void onDefault(Player player) {
|
||||||
new DiscoveryGUI(plugin, player).open();
|
plugin.getScheduler().executeOnMain(() -> new DiscoveryGUI(plugin, player).open());
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Opens the bestiary book")
|
@CommandDescription("Opens the bestiary book")
|
||||||
@CommandPermission("rpgregions.bestiary")
|
@Permission("rpgregions.bestiary")
|
||||||
@CommandMethod("bestiary|flora|fauna")
|
@Command("bestiary|flora|fauna")
|
||||||
public void onBestiary(Player player) {
|
public void onBestiary(Player player) {
|
||||||
openBestiary(player);
|
openBestiary(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Shows a specific bestiary entry")
|
@CommandDescription("Shows a specific bestiary entry")
|
||||||
@CommandPermission("rpgregions.bestiary")
|
@Permission("rpgregions.bestiary")
|
||||||
@CommandMethod("bestiary|flora|fauna show <fauna>")
|
@Command("bestiary|flora|fauna show <fauna>")
|
||||||
public void onBestiaryShow(Player player,
|
public void onBestiaryShow(Player player,
|
||||||
@Argument(value = "fauna") FaunaInstance<?> fauna) {
|
@Argument(value = "fauna") FaunaInstance<?> fauna) {
|
||||||
fauna.openDescription(player);
|
fauna.openDescription(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +109,8 @@ public class DiscoveriesCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Discovers a region for a player")
|
@CommandDescription("Discovers a region for a player")
|
||||||
@CommandPermission("rpgregions.discover")
|
@Permission("rpgregions.discover")
|
||||||
@CommandMethod("discoveries|discovery discover region <region> <player>")
|
@Command("discoveries|discovery discover region <region> <player>")
|
||||||
public void onDiscover(CommandSender sender,
|
public void onDiscover(CommandSender sender,
|
||||||
@Argument("region") ConfiguredRegion configuredRegion,
|
@Argument("region") ConfiguredRegion configuredRegion,
|
||||||
@Argument("player") OfflinePlayer target) {
|
@Argument("player") OfflinePlayer target) {
|
||||||
@@ -130,8 +130,8 @@ public class DiscoveriesCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Discovers fauna for a player")
|
@CommandDescription("Discovers fauna for a player")
|
||||||
@CommandPermission("rpgregions.discover")
|
@Permission("rpgregions.discover")
|
||||||
@CommandMethod("discoveries|discovery discover fauna <fauna> <player>")
|
@Command("discoveries|discovery discover fauna <fauna> <player>")
|
||||||
public void onDiscover(CommandSender sender,
|
public void onDiscover(CommandSender sender,
|
||||||
@Argument("fauna") FaunaInstance<?> fauna,
|
@Argument("fauna") FaunaInstance<?> fauna,
|
||||||
@Argument("player") OfflinePlayer target) {
|
@Argument("player") OfflinePlayer target) {
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import cloud.commandframework.annotations.Argument;
|
|
||||||
import cloud.commandframework.annotations.CommandDescription;
|
|
||||||
import cloud.commandframework.annotations.CommandMethod;
|
|
||||||
import cloud.commandframework.annotations.CommandPermission;
|
|
||||||
import cloud.commandframework.annotations.Hidden;
|
|
||||||
import cloud.commandframework.annotations.specifier.Greedy;
|
|
||||||
import cloud.commandframework.annotations.suggestions.Suggestions;
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
|
||||||
import cloud.commandframework.minecraft.extras.MinecraftHelp;
|
|
||||||
import cloud.commandframework.paper.PaperCommandManager;
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||||
import net.islandearth.rpgregions.api.events.RPGRegionsReloadEvent;
|
import net.islandearth.rpgregions.api.events.RPGRegionsReloadEvent;
|
||||||
@@ -35,6 +25,15 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.incendo.cloud.annotation.specifier.Greedy;
|
||||||
|
import org.incendo.cloud.annotations.Argument;
|
||||||
|
import org.incendo.cloud.annotations.Command;
|
||||||
|
import org.incendo.cloud.annotations.CommandDescription;
|
||||||
|
import org.incendo.cloud.annotations.Permission;
|
||||||
|
import org.incendo.cloud.annotations.suggestion.Suggestions;
|
||||||
|
import org.incendo.cloud.context.CommandContext;
|
||||||
|
import org.incendo.cloud.minecraft.extras.MinecraftHelp;
|
||||||
|
import org.incendo.cloud.paper.PaperCommandManager;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -59,15 +58,11 @@ public class RPGRegionsCommand {
|
|||||||
|
|
||||||
public RPGRegionsCommand(RPGRegions plugin, PaperCommandManager<CommandSender> manager) {
|
public RPGRegionsCommand(RPGRegions plugin, PaperCommandManager<CommandSender> manager) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.help = new MinecraftHelp<>(
|
this.help = MinecraftHelp.create("/rpgregions help", manager, sender -> plugin.adventure().sender(sender));
|
||||||
"/rpgregions help",
|
|
||||||
player -> plugin.adventure().sender(player),
|
|
||||||
manager
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("The default RPGRegions command")
|
@CommandDescription("The default RPGRegions command")
|
||||||
@CommandMethod("rpgregions|rpgr")
|
@Command("rpgregions|rpgr")
|
||||||
public void onDefault(CommandSender sender) {
|
public void onDefault(CommandSender sender) {
|
||||||
if (sender.hasPermission("rpgregions.noview") && !sender.isOp()) return;
|
if (sender.hasPermission("rpgregions.noview") && !sender.isOp()) return;
|
||||||
|
|
||||||
@@ -91,14 +86,13 @@ public class RPGRegionsCommand {
|
|||||||
"<light_purple>" + plugin.getManagers().getFaunaCache().getFauna().size() + " <dark_purple>fauna is loaded."));
|
"<light_purple>" + plugin.getManagers().getFaunaCache().getFauna().size() + " <dark_purple>fauna is loaded."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandMethod("rpgregions|rpgr help [query]")
|
@Command("rpgregions|rpgr help [query]")
|
||||||
public void onHelp(final CommandSender sender, @Argument("query") @Greedy @Nullable String query) {
|
public void onHelp(final CommandSender sender, @Argument("query") @Greedy @Nullable String query) {
|
||||||
help.queryCommands(query == null ? "" : query, sender);
|
help.queryCommands(query == null ? "" : query, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Debug information about the plugin")
|
@CommandDescription("Debug information about the plugin")
|
||||||
@CommandMethod("rpgregions|rpgr about")
|
@Command("rpgregions|rpgr about")
|
||||||
@Hidden
|
|
||||||
public void onAbout(CommandSender sender) {
|
public void onAbout(CommandSender sender) {
|
||||||
sender.sendMessage(Colors.colour("&eRPGRegions v" + plugin.getDescription().getVersion() + "."));
|
sender.sendMessage(Colors.colour("&eRPGRegions v" + plugin.getDescription().getVersion() + "."));
|
||||||
sender.sendMessage(Colors.colour("&eOwner: https://www.spigotmc.org/members/%%__USER__%%/"));
|
sender.sendMessage(Colors.colour("&eOwner: https://www.spigotmc.org/members/%%__USER__%%/"));
|
||||||
@@ -107,8 +101,8 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Creates a configured region from a region created in your integration")
|
@CommandDescription("Creates a configured region from a region created in your integration")
|
||||||
@CommandPermission("rpgregions.add")
|
@Permission("rpgregions.add")
|
||||||
@CommandMethod("rpgregions|rpgr add <region> [world]")
|
@Command("rpgregions|rpgr add <region> [world]")
|
||||||
public void onAdd(CommandSender sender,
|
public void onAdd(CommandSender sender,
|
||||||
@Argument(value = "region", suggestions = "integration-regions") String region,
|
@Argument(value = "region", suggestions = "integration-regions") String region,
|
||||||
@Argument("world") @Nullable World world) {
|
@Argument("world") @Nullable World world) {
|
||||||
@@ -153,8 +147,8 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Sets the display name of a region")
|
@CommandDescription("Sets the display name of a region")
|
||||||
@CommandPermission("rpgregions.setname")
|
@Permission("rpgregions.setname")
|
||||||
@CommandMethod("rpgregions|rpgr setname <region> <name>")
|
@Command("rpgregions|rpgr setname <region> <name>")
|
||||||
public void onSetName(CommandSender sender,
|
public void onSetName(CommandSender sender,
|
||||||
@Argument("region") ConfiguredRegion region,
|
@Argument("region") ConfiguredRegion region,
|
||||||
@Argument("name") @Greedy String name) {
|
@Argument("name") @Greedy String name) {
|
||||||
@@ -163,8 +157,8 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Removes a configured region. Does not delete it from your integration.")
|
@CommandDescription("Removes a configured region. Does not delete it from your integration.")
|
||||||
@CommandPermission("rpgregions.remove")
|
@Permission("rpgregions.remove")
|
||||||
@CommandMethod("rpgregions|rpgr remove <region>")
|
@Command("rpgregions|rpgr remove <region>")
|
||||||
public void onRemove(CommandSender sender, @Argument("region") ConfiguredRegion region) {
|
public void onRemove(CommandSender sender, @Argument("region") ConfiguredRegion region) {
|
||||||
region.delete(plugin);
|
region.delete(plugin);
|
||||||
plugin.getManagers().getRegionsCache().removeConfiguredRegion(region.getId());
|
plugin.getManagers().getRegionsCache().removeConfiguredRegion(region.getId());
|
||||||
@@ -172,30 +166,30 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Opens the editor GUI for a region")
|
@CommandDescription("Opens the editor GUI for a region")
|
||||||
@CommandPermission("rpgregions.edit")
|
@Permission("rpgregions.edit")
|
||||||
@CommandMethod("rpgregions|rpgr edit <region>")
|
@Command("rpgregions|rpgr edit <region>")
|
||||||
public void onEdit(Player player, @Argument("region") ConfiguredRegion region) {
|
public void onEdit(Player player, @Argument("region") ConfiguredRegion region) {
|
||||||
new RegionCreateGUI(plugin, player, region).open();
|
plugin.getScheduler().executeOnMain(() -> new RegionCreateGUI(plugin, player, region).open());
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Opens the /discovery GUI")
|
@CommandDescription("Opens the /discovery GUI")
|
||||||
@CommandPermission("rpgregions.list")
|
@Permission("rpgregions.list")
|
||||||
@CommandMethod("rpgregions|rpgr list|discoveries")
|
@Command("rpgregions|rpgr list|discoveries")
|
||||||
public void onList(Player player) {
|
public void onList(Player player) {
|
||||||
new DiscoveryGUI(plugin, player).open();
|
plugin.getScheduler().executeOnMain(() -> new DiscoveryGUI(plugin, player).open());
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Adds an item reward to a region (util command)")
|
@CommandDescription("Adds an item reward to a region (util command)")
|
||||||
@CommandPermission("rpgregions.additem")
|
@Permission("rpgregions.additem")
|
||||||
@CommandMethod("rpgregions|rpgr additem <region>")
|
@Command("rpgregions|rpgr additem <region>")
|
||||||
public void onAddItem(Player player, @Argument("region") ConfiguredRegion region) {
|
public void onAddItem(Player player, @Argument("region") ConfiguredRegion region) {
|
||||||
region.getRewards().add(new ItemReward(plugin, player.getInventory().getItemInMainHand()));
|
region.getRewards().add(new ItemReward(plugin, player.getInventory().getItemInMainHand()));
|
||||||
Colors.sendColourful(player, Component.text("Item added to configuration!", Colors.EREBOR_GREEN));
|
Colors.sendColourful(player, Component.text("Item added to configuration!", Colors.EREBOR_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Reloads configured regions from the `/plugins/RPGRegions/regions` folder.")
|
@CommandDescription("Reloads configured regions from the `/plugins/RPGRegions/regions` folder.")
|
||||||
@CommandPermission("rpgregions.reload")
|
@Permission("rpgregions.reload")
|
||||||
@CommandMethod("rpgregions|rpgr reload")
|
@Command("rpgregions|rpgr reload")
|
||||||
public void onReload(CommandSender sender) {
|
public void onReload(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Reloading region files...");
|
sender.sendMessage(ChatColor.GREEN + "Reloading region files...");
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
@@ -226,8 +220,8 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Saves configured regions to the `/plugins/RPGRegions/regions` folder. Also saves user data.")
|
@CommandDescription("Saves configured regions to the `/plugins/RPGRegions/regions` folder. Also saves user data.")
|
||||||
@CommandPermission("rpgregions.save")
|
@Permission("rpgregions.save")
|
||||||
@CommandMethod("rpgregions|rpgr save [async]")
|
@Command("rpgregions|rpgr save [async]")
|
||||||
public void onSave(CommandSender sender,
|
public void onSave(CommandSender sender,
|
||||||
@Argument(value = "async", suggestions = "async") @Nullable String asyncArg) {
|
@Argument(value = "async", suggestions = "async") @Nullable String asyncArg) {
|
||||||
boolean async = asyncArg != null && asyncArg.equals("--async");
|
boolean async = asyncArg != null && asyncArg.equals("--async");
|
||||||
@@ -255,8 +249,8 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Resets the data of a player")
|
@CommandDescription("Resets the data of a player")
|
||||||
@CommandPermission("rpgregions.reset")
|
@Permission("rpgregions.reset")
|
||||||
@CommandMethod("rpgregions|rpgr reset <player> [region]")
|
@Command("rpgregions|rpgr reset <player> [region]")
|
||||||
public void onReset(CommandSender sender,
|
public void onReset(CommandSender sender,
|
||||||
@Argument("player") @NonNull OfflinePlayer player,
|
@Argument("player") @NonNull OfflinePlayer player,
|
||||||
@Argument("region") @Nullable ConfiguredRegion region) {
|
@Argument("region") @Nullable ConfiguredRegion region) {
|
||||||
@@ -279,8 +273,8 @@ public class RPGRegionsCommand {
|
|||||||
|
|
||||||
|
|
||||||
@CommandDescription("Deletes user accounts from the database")
|
@CommandDescription("Deletes user accounts from the database")
|
||||||
@CommandPermission("rpgregions.delete")
|
@Permission("rpgregions.delete")
|
||||||
@CommandMethod("rpgregions|rpgr delete <player>")
|
@Command("rpgregions|rpgr delete <player>")
|
||||||
public void onDelete(CommandSender sender,
|
public void onDelete(CommandSender sender,
|
||||||
@Argument("player") @NotNull OfflinePlayer player) {
|
@Argument("player") @NotNull OfflinePlayer player) {
|
||||||
plugin.getManagers().getStorageManager().deleteAccount(player.getUniqueId());
|
plugin.getManagers().getStorageManager().deleteAccount(player.getUniqueId());
|
||||||
@@ -288,8 +282,8 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Sets the teleport location of a region")
|
@CommandDescription("Sets the teleport location of a region")
|
||||||
@CommandPermission("rpgregions.setlocation")
|
@Permission("rpgregions.setlocation")
|
||||||
@CommandMethod("rpgregions|rpgr setlocation <region>")
|
@Command("rpgregions|rpgr setlocation <region>")
|
||||||
public void onSetLocation(Player player,
|
public void onSetLocation(Player player,
|
||||||
@Argument("region") ConfiguredRegion region) {
|
@Argument("region") ConfiguredRegion region) {
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
@@ -298,8 +292,8 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Sets or removes the sound of a region when it is discovered")
|
@CommandDescription("Sets or removes the sound of a region when it is discovered")
|
||||||
@CommandPermission("rpgregions.edit")
|
@Permission("rpgregions.edit")
|
||||||
@CommandMethod("rpgregions|rpgr setsound <region> [sound]")
|
@Command("rpgregions|rpgr setsound <region> [sound]")
|
||||||
public void onSetSound(CommandSender sender,
|
public void onSetSound(CommandSender sender,
|
||||||
@Argument("region") ConfiguredRegion region,
|
@Argument("region") ConfiguredRegion region,
|
||||||
@Argument(value = "sound", suggestions = "sound_names") @Nullable String soundName) {
|
@Argument(value = "sound", suggestions = "sound_names") @Nullable String soundName) {
|
||||||
@@ -314,8 +308,8 @@ public class RPGRegionsCommand {
|
|||||||
|
|
||||||
//TODO: use confirmation api
|
//TODO: use confirmation api
|
||||||
@CommandDescription("If configured, regenerates a region to the set schematic")
|
@CommandDescription("If configured, regenerates a region to the set schematic")
|
||||||
@CommandPermission("rpgregions.regenerate")
|
@Permission("rpgregions.regenerate")
|
||||||
@CommandMethod("rpgregions|rpgr regenerate <region>")
|
@Command("rpgregions|rpgr regenerate <region>")
|
||||||
public void onRegenerate(Player player,
|
public void onRegenerate(Player player,
|
||||||
@Argument("region") ConfiguredRegion region) {
|
@Argument("region") ConfiguredRegion region) {
|
||||||
IntegrationType integrationType = IntegrationType.valueOf(plugin.getConfig().getString("settings.integration.name").toUpperCase());
|
IntegrationType integrationType = IntegrationType.valueOf(plugin.getConfig().getString("settings.integration.name").toUpperCase());
|
||||||
@@ -343,8 +337,8 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Sets the regeneration schematic for a region")
|
@CommandDescription("Sets the regeneration schematic for a region")
|
||||||
@CommandPermission("rpgregions.setschematic")
|
@Permission("rpgregions.setschematic")
|
||||||
@CommandMethod("rpgregions|rpgr setschematic <region> <schematicName>")
|
@Command("rpgregions|rpgr setschematic <region> <schematicName>")
|
||||||
public void onAddSchematic(Player player,
|
public void onAddSchematic(Player player,
|
||||||
@Argument("region") ConfiguredRegion region,
|
@Argument("region") ConfiguredRegion region,
|
||||||
@Argument("schematicName") @Greedy String schematicName) {
|
@Argument("schematicName") @Greedy String schematicName) {
|
||||||
@@ -374,8 +368,8 @@ public class RPGRegionsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Resets the icons of all configured regions to the config default")
|
@CommandDescription("Resets the icons of all configured regions to the config default")
|
||||||
@CommandPermission("rpgregions.forceupdate")
|
@Permission("rpgregions.forceupdate")
|
||||||
@CommandMethod("rpgregions|rpgr forceupdateicons")
|
@Command("rpgregions|rpgr forceupdateicons")
|
||||||
public void onForceUpdateIcons(Player player) {
|
public void onForceUpdateIcons(Player player) {
|
||||||
Optional<Material> defaultIcon = Optional.of(Material.valueOf(RPGRegionsAPI.getAPI().getConfig().getString("settings.server.gui.default_region_icon")));
|
Optional<Material> defaultIcon = Optional.of(Material.valueOf(RPGRegionsAPI.getAPI().getConfig().getString("settings.server.gui.default_region_icon")));
|
||||||
defaultIcon.ifPresent(xMaterial -> {
|
defaultIcon.ifPresent(xMaterial -> {
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import cloud.commandframework.annotations.Argument;
|
|
||||||
import cloud.commandframework.annotations.CommandMethod;
|
|
||||||
import cloud.commandframework.annotations.CommandPermission;
|
|
||||||
import co.aikar.idb.DB;
|
import co.aikar.idb.DB;
|
||||||
import co.aikar.idb.Database;
|
import co.aikar.idb.Database;
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
@@ -11,16 +8,19 @@ import net.islandearth.rpgregions.managers.data.IStorageManager;
|
|||||||
import net.islandearth.rpgregions.requirements.RegionRequirement;
|
import net.islandearth.rpgregions.requirements.RegionRequirement;
|
||||||
import net.islandearth.rpgregions.rewards.DiscoveryReward;
|
import net.islandearth.rpgregions.rewards.DiscoveryReward;
|
||||||
import net.islandearth.rpgregions.thread.Blocking;
|
import net.islandearth.rpgregions.thread.Blocking;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.incendo.cloud.annotations.Argument;
|
||||||
|
import org.incendo.cloud.annotations.Command;
|
||||||
|
import org.incendo.cloud.annotations.Permission;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermission("rpgregions.debug")
|
@Permission("rpgregions.debug")
|
||||||
public class RPGRegionsDebugCommand {
|
public class RPGRegionsDebugCommand {
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
private final RPGRegions plugin;
|
||||||
@@ -29,15 +29,16 @@ public class RPGRegionsDebugCommand {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandMethod("rpgregionsdebug|rpgrd")
|
@Command("rpgregionsdebug|rpgrd")
|
||||||
public void onDefault(CommandSender sender) throws SQLException {
|
public void onDefault(CommandSender sender) throws SQLException {
|
||||||
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
||||||
sender.sendMessage(ChatColor.GOLD + "Database status:");
|
sender.sendMessage(ChatColor.GOLD + "Database status:");
|
||||||
sender.sendMessage(ChatColor.GRAY + "Storage implementation " + storageManager.getClass().getSimpleName() + ".");
|
sender.sendMessage(ChatColor.GRAY + "Storage implementation " + storageManager.getClass().getSimpleName() + ".");
|
||||||
sender.sendMessage(ChatColor.GRAY + "" + storageManager.getCachedAccounts().synchronous().asMap().size()
|
sender.sendMessage(ChatColor.GRAY + "" + storageManager.getCachedAccounts().synchronous().asMap().size()
|
||||||
+ " cached players.");
|
+ " cached players.");
|
||||||
|
final List<Long> timings = storageManager.getTimings();
|
||||||
sender.sendMessage(ChatColor.GRAY + "Performance (" + storageManager.getTimingsAverage() + " avg. ms)" +
|
sender.sendMessage(ChatColor.GRAY + "Performance (" + storageManager.getTimingsAverage() + " avg. ms)" +
|
||||||
" (last 3 retrievals): " + StringUtils.join(storageManager.getTimings(), "ms, ") + "ms");
|
" (last 3 retrievals): " + timings.get(0) + " ms, " + timings.get(1) + " ms, " + timings.get(2) + " ms");
|
||||||
Database database = DB.getGlobalDatabase();
|
Database database = DB.getGlobalDatabase();
|
||||||
if (database != null) {
|
if (database != null) {
|
||||||
Connection connection = database.getConnection();
|
Connection connection = database.getConnection();
|
||||||
@@ -67,7 +68,7 @@ public class RPGRegionsDebugCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandMethod("rpgregionsdebug|rpgrd enable|disable|toggle")
|
@Command("rpgregionsdebug|rpgrd enable|disable|toggle")
|
||||||
public void onEnable(CommandSender sender) {
|
public void onEnable(CommandSender sender) {
|
||||||
final boolean newValue = !plugin.debug();
|
final boolean newValue = !plugin.debug();
|
||||||
plugin.getConfig().set("settings.dev.debug", newValue);
|
plugin.getConfig().set("settings.dev.debug", newValue);
|
||||||
@@ -76,7 +77,7 @@ public class RPGRegionsDebugCommand {
|
|||||||
else sender.sendMessage(ChatColor.RED + "Debug disabled.");
|
else sender.sendMessage(ChatColor.RED + "Debug disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandMethod("rpgregionsdebug|rpgrd cache")
|
@Command("rpgregionsdebug|rpgrd cache")
|
||||||
public void onCache(CommandSender sender) {
|
public void onCache(CommandSender sender) {
|
||||||
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
||||||
sender.sendMessage(ChatColor.GOLD + "Database cache:");
|
sender.sendMessage(ChatColor.GOLD + "Database cache:");
|
||||||
@@ -85,7 +86,7 @@ public class RPGRegionsDebugCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandMethod("rpgregionsdebug|rpgrd removecached <player>")
|
@Command("rpgregionsdebug|rpgrd removecached <player>")
|
||||||
public void onRemoveCached(CommandSender sender, @Argument("player") OfflinePlayer player) {
|
public void onRemoveCached(CommandSender sender, @Argument("player") OfflinePlayer player) {
|
||||||
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
||||||
sender.sendMessage(ChatColor.GREEN + "Removing from cache...");
|
sender.sendMessage(ChatColor.GREEN + "Removing from cache...");
|
||||||
@@ -94,7 +95,7 @@ public class RPGRegionsDebugCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandMethod("rpgregionsdebug|rpgrd worldid <world>")
|
@Command("rpgregionsdebug|rpgrd worldid <world>")
|
||||||
public void onGetWorldId(CommandSender sender, @Argument("world") World world) {
|
public void onGetWorldId(CommandSender sender, @Argument("world") World world) {
|
||||||
sender.sendMessage(ChatColor.GREEN + String.valueOf(world.getUID()));
|
sender.sendMessage(ChatColor.GREEN + String.valueOf(world.getUID()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import cloud.commandframework.annotations.Argument;
|
|
||||||
import cloud.commandframework.annotations.CommandDescription;
|
|
||||||
import cloud.commandframework.annotations.CommandMethod;
|
|
||||||
import cloud.commandframework.annotations.specifier.Greedy;
|
|
||||||
import cloud.commandframework.minecraft.extras.MinecraftHelp;
|
|
||||||
import cloud.commandframework.paper.PaperCommandManager;
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.effects.RegionEffect;
|
import net.islandearth.rpgregions.effects.RegionEffect;
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
@@ -13,6 +7,12 @@ import net.islandearth.rpgregions.requirements.RegionRequirement;
|
|||||||
import net.islandearth.rpgregions.rewards.DiscoveryReward;
|
import net.islandearth.rpgregions.rewards.DiscoveryReward;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.incendo.cloud.annotation.specifier.Greedy;
|
||||||
|
import org.incendo.cloud.annotations.Argument;
|
||||||
|
import org.incendo.cloud.annotations.Command;
|
||||||
|
import org.incendo.cloud.annotations.CommandDescription;
|
||||||
|
import org.incendo.cloud.minecraft.extras.MinecraftHelp;
|
||||||
|
import org.incendo.cloud.paper.PaperCommandManager;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -27,26 +27,22 @@ public class RPGRegionsExportCommand {
|
|||||||
|
|
||||||
public RPGRegionsExportCommand(RPGRegions plugin, PaperCommandManager<CommandSender> manager) {
|
public RPGRegionsExportCommand(RPGRegions plugin, PaperCommandManager<CommandSender> manager) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.help = new MinecraftHelp<>(
|
this.help = MinecraftHelp.create("/rpgre help", manager, sender -> plugin.adventure().sender(sender));
|
||||||
"/rpgre help",
|
|
||||||
player -> plugin.adventure().sender(player),
|
|
||||||
manager
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("The default RPGRegions export command.")
|
@CommandDescription("The default RPGRegions export command.")
|
||||||
@CommandMethod("rpgre")
|
@Command("rpgre")
|
||||||
public void onDefault(CommandSender sender) {
|
public void onDefault(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Use this command to export/import a region template.");
|
sender.sendMessage(ChatColor.GREEN + "Use this command to export/import a region template.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandMethod("rpgre help [query]")
|
@Command("rpgre help [query]")
|
||||||
public void onHelp(final CommandSender sender, @Argument("query") @Greedy @Nullable String query) {
|
public void onHelp(final CommandSender sender, @Argument("query") @Greedy @Nullable String query) {
|
||||||
help.queryCommands(query == null ? "" : query, sender);
|
help.queryCommands(query == null ? "" : query, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Exports a region to a template file (`plugins/RPGRegions/templates`).")
|
@CommandDescription("Exports a region to a template file (`plugins/RPGRegions/templates`).")
|
||||||
@CommandMethod("rpgre export <region>")
|
@Command("rpgre export <region>")
|
||||||
public void onExport(CommandSender sender,
|
public void onExport(CommandSender sender,
|
||||||
@Argument("region") ConfiguredRegion region) {
|
@Argument("region") ConfiguredRegion region) {
|
||||||
File templates = new File(plugin.getDataFolder() + File.separator + "templates");
|
File templates = new File(plugin.getDataFolder() + File.separator + "templates");
|
||||||
@@ -58,7 +54,7 @@ public class RPGRegionsExportCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Imports a template region into an existing configured region")
|
@CommandDescription("Imports a template region into an existing configured region")
|
||||||
@CommandMethod("rpgre import <template> <region>")
|
@Command("rpgre import <template> <region>")
|
||||||
public void onImport(CommandSender sender,
|
public void onImport(CommandSender sender,
|
||||||
@Argument(value = "template",
|
@Argument(value = "template",
|
||||||
suggestions = "templates",
|
suggestions = "templates",
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import cloud.commandframework.annotations.Argument;
|
|
||||||
import cloud.commandframework.annotations.CommandDescription;
|
|
||||||
import cloud.commandframework.annotations.CommandMethod;
|
|
||||||
import cloud.commandframework.annotations.CommandPermission;
|
|
||||||
import cloud.commandframework.annotations.specifier.Greedy;
|
|
||||||
import cloud.commandframework.minecraft.extras.MinecraftHelp;
|
|
||||||
import cloud.commandframework.paper.PaperCommandManager;
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.region.CuboidRegion;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.region.CuboidRegion;
|
||||||
@@ -18,13 +11,20 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.incendo.cloud.annotation.specifier.Greedy;
|
||||||
|
import org.incendo.cloud.annotations.Argument;
|
||||||
|
import org.incendo.cloud.annotations.Command;
|
||||||
|
import org.incendo.cloud.annotations.CommandDescription;
|
||||||
|
import org.incendo.cloud.annotations.Permission;
|
||||||
|
import org.incendo.cloud.minecraft.extras.MinecraftHelp;
|
||||||
|
import org.incendo.cloud.paper.PaperCommandManager;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@CommandPermission("rpgregions.integration")
|
@Permission("rpgregions.integration")
|
||||||
public class RPGRegionsIntegrationCommand {
|
public class RPGRegionsIntegrationCommand {
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
private final RPGRegions plugin;
|
||||||
@@ -32,33 +32,29 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
|
|
||||||
public RPGRegionsIntegrationCommand(final RPGRegions plugin, PaperCommandManager<CommandSender> manager) {
|
public RPGRegionsIntegrationCommand(final RPGRegions plugin, PaperCommandManager<CommandSender> manager) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.help = new MinecraftHelp<>(
|
this.help = MinecraftHelp.create("/rpgri help", manager, sender -> plugin.adventure().sender(sender));
|
||||||
"/rpgri help",
|
|
||||||
player -> plugin.adventure().sender(player),
|
|
||||||
manager
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("The default RPGRegions integration command.")
|
@CommandDescription("The default RPGRegions integration command.")
|
||||||
@CommandMethod("rpgri|rpgrintegration")
|
@Command("rpgri|rpgrintegration")
|
||||||
public void onDefault(CommandSender sender) {
|
public void onDefault(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "RPGRegions region integration is enabled. Type /rpgri help for help.");
|
sender.sendMessage(ChatColor.GREEN + "RPGRegions region integration is enabled. Type /rpgri help for help.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandMethod("rpgri|rpgrintegration help [query]")
|
@Command("rpgri|rpgrintegration help [query]")
|
||||||
public void onHelp(final CommandSender sender, @Argument("query") @Greedy @Nullable String query) {
|
public void onHelp(final CommandSender sender, @Argument("query") @Greedy @Nullable String query) {
|
||||||
help.queryCommands(query == null ? "" : query, sender);
|
help.queryCommands(query == null ? "" : query, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Lists all existing regions in the integration")
|
@CommandDescription("Lists all existing regions in the integration")
|
||||||
@CommandMethod("rpgri|rpgrintegration list")
|
@Command("rpgri|rpgrintegration list")
|
||||||
public void onList(final CommandSender sender) {
|
public void onList(final CommandSender sender) {
|
||||||
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
integration.getAllRegionNames(null).forEach(name -> sender.sendMessage(ChatColor.GREEN + "- " + name));
|
integration.getAllRegionNames(null).forEach(name -> sender.sendMessage(ChatColor.GREEN + "- " + name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Shows information about a region")
|
@CommandDescription("Shows information about a region")
|
||||||
@CommandMethod("rpgri|rpgrintegration info <region>")
|
@Command("rpgri|rpgrintegration info <region>")
|
||||||
public void onInfo(final CommandSender sender,
|
public void onInfo(final CommandSender sender,
|
||||||
@Argument(value = "region") final RPGRegionsRegion region) {
|
@Argument(value = "region") final RPGRegionsRegion region) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Name: " + ChatColor.WHITE + region.getName());
|
sender.sendMessage(ChatColor.GREEN + "Name: " + ChatColor.WHITE + region.getName());
|
||||||
@@ -68,7 +64,7 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Saves all regions")
|
@CommandDescription("Saves all regions")
|
||||||
@CommandMethod("rpgri|rpgrintegration save")
|
@Command("rpgri|rpgrintegration save")
|
||||||
public void onSave(final CommandSender sender) {
|
public void onSave(final CommandSender sender) {
|
||||||
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
integration.save();
|
integration.save();
|
||||||
@@ -76,7 +72,7 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Creates a region of the specified name, type, and optionally the world it is in.")
|
@CommandDescription("Creates a region of the specified name, type, and optionally the world it is in.")
|
||||||
@CommandMethod("rpgri|rpgrintegration create <name> <type> <world>")
|
@Command("rpgri|rpgrintegration create <name> <type> <world>")
|
||||||
public void onCreate(final CommandSender sender,
|
public void onCreate(final CommandSender sender,
|
||||||
@Argument("name") final String name,
|
@Argument("name") final String name,
|
||||||
@Argument(value = "type", suggestions = "region-types") final String regionType,
|
@Argument(value = "type", suggestions = "region-types") final String regionType,
|
||||||
@@ -104,7 +100,7 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Deletes a region.")
|
@CommandDescription("Deletes a region.")
|
||||||
@CommandMethod("rpgri|rpgrintegration delete <region>")
|
@Command("rpgri|rpgrintegration delete <region>")
|
||||||
public void onDelete(final CommandSender sender,
|
public void onDelete(final CommandSender sender,
|
||||||
@Argument("region") final RPGRegionsRegion region) {
|
@Argument("region") final RPGRegionsRegion region) {
|
||||||
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
@@ -113,7 +109,7 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Adds a position to a region. Cuboid regions require 2 points to form a cuboid. Poly regions may have any number.")
|
@CommandDescription("Adds a position to a region. Cuboid regions require 2 points to form a cuboid. Poly regions may have any number.")
|
||||||
@CommandMethod("rpgri|rpgrintegration addpos <region> [location]")
|
@Command("rpgri|rpgrintegration addpos <region> [location]")
|
||||||
public void onAddPos(final CommandSender sender,
|
public void onAddPos(final CommandSender sender,
|
||||||
@Argument("region") final RPGRegionsRegion region,
|
@Argument("region") final RPGRegionsRegion region,
|
||||||
@Argument("location") @Nullable Location location) {
|
@Argument("location") @Nullable Location location) {
|
||||||
@@ -138,7 +134,7 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Removes a position from a region.")
|
@CommandDescription("Removes a position from a region.")
|
||||||
@CommandMethod("rpgri|rpgrintegration removepos <region> [location]")
|
@Command("rpgri|rpgrintegration removepos <region> [location]")
|
||||||
public void onRemovePos(final CommandSender sender,
|
public void onRemovePos(final CommandSender sender,
|
||||||
@Argument("region") final RPGRegionsRegion region,
|
@Argument("region") final RPGRegionsRegion region,
|
||||||
@Argument("location") @Nullable Location location) {
|
@Argument("location") @Nullable Location location) {
|
||||||
@@ -165,7 +161,7 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Sets the priority of a region. Higher priority regions override lower priority ones in the same location.")
|
@CommandDescription("Sets the priority of a region. Higher priority regions override lower priority ones in the same location.")
|
||||||
@CommandMethod("rpgri|rpgrintegration setpriority <region> <priority>")
|
@Command("rpgri|rpgrintegration setpriority <region> <priority>")
|
||||||
public void onSetPriority(final Player player,
|
public void onSetPriority(final Player player,
|
||||||
@Argument("region") final RPGRegionsRegion region,
|
@Argument("region") final RPGRegionsRegion region,
|
||||||
@Argument("priority") final int priority) {
|
@Argument("priority") final int priority) {
|
||||||
@@ -174,7 +170,7 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Sets the world a region is in.")
|
@CommandDescription("Sets the world a region is in.")
|
||||||
@CommandMethod("rpgri|rpgrintegration setworld <region> <world>")
|
@Command("rpgri|rpgrintegration setworld <region> <world>")
|
||||||
public void onSetWorld(final CommandSender sender,
|
public void onSetWorld(final CommandSender sender,
|
||||||
@Argument("region") final RPGRegionsRegion region,
|
@Argument("region") final RPGRegionsRegion region,
|
||||||
@Argument("world") final World world) {
|
@Argument("world") final World world) {
|
||||||
@@ -183,13 +179,13 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Visualises the boundaries of a region.")
|
@CommandDescription("Visualises the boundaries of a region.")
|
||||||
@CommandMethod("rpgri|rpgrintegration visualise <region>")
|
@Command("rpgri|rpgrintegration visualise <region>")
|
||||||
public void onVisualise(final Player sender, @Argument("region") final RPGRegionsRegion region) {
|
public void onVisualise(final Player sender, @Argument("region") final RPGRegionsRegion region) {
|
||||||
region.visualise(sender);
|
region.visualise(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Tells you what region you are in.")
|
@CommandDescription("Tells you what region you are in.")
|
||||||
@CommandMethod("rpgri|rpgrintegration whereami")
|
@Command("rpgri|rpgrintegration whereami")
|
||||||
public void onWhereAmI(final Player sender) {
|
public void onWhereAmI(final Player sender) {
|
||||||
final RPGRegionsIntegration manager = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
final RPGRegionsIntegration manager = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
List<RPGRegionsRegion> regions = new ArrayList<>();
|
List<RPGRegionsRegion> regions = new ArrayList<>();
|
||||||
@@ -210,7 +206,7 @@ public class RPGRegionsIntegrationCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CommandDescription("Migrates all regions to a world.")
|
@CommandDescription("Migrates all regions to a world.")
|
||||||
@CommandMethod("rpgri|rpgrintegration migrate <world>")
|
@Command("rpgri|rpgrintegration migrate <world>")
|
||||||
public void onMigrate(final CommandSender sender,
|
public void onMigrate(final CommandSender sender,
|
||||||
@Argument("world") final World world) {
|
@Argument("world") final World world) {
|
||||||
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package net.islandearth.rpgregions.commands.caption;
|
package net.islandearth.rpgregions.commands.caption;
|
||||||
|
|
||||||
import cloud.commandframework.captions.Caption;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.incendo.cloud.caption.Caption;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package net.islandearth.rpgregions.commands.caption;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.incendo.cloud.caption.CaptionProvider;
|
||||||
|
import org.incendo.cloud.caption.DelegatingCaptionProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caption registry that uses bi-functions to produce messages
|
||||||
|
*
|
||||||
|
* @param <C> Command sender type
|
||||||
|
*/
|
||||||
|
public class RPGRegionsCaptionProvider<C> extends DelegatingCaptionProvider<C> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default caption for {@link RPGRegionsCaptionKeys#ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND}.
|
||||||
|
*/
|
||||||
|
public static final String ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND = "Could not find region '{input}'";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default caption for {@link RPGRegionsCaptionKeys#ARGUMENT_PARSE_FAILURE_FAUNA_NOT_FOUND}.
|
||||||
|
*/
|
||||||
|
public static final String ARGUMENT_PARSE_FAILURE_FAUNA_NOT_FOUND = "Could not find fauna '{input}'";
|
||||||
|
|
||||||
|
private static final CaptionProvider<?> PROVIDER = CaptionProvider.constantProvider()
|
||||||
|
.putCaption(
|
||||||
|
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_FAUNA_NOT_FOUND,
|
||||||
|
ARGUMENT_PARSE_FAILURE_FAUNA_NOT_FOUND
|
||||||
|
).putCaption(
|
||||||
|
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND,
|
||||||
|
ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull CaptionProvider<C> delegate() {
|
||||||
|
return (CaptionProvider<C>) PROVIDER;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package net.islandearth.rpgregions.commands.caption;
|
|
||||||
|
|
||||||
import cloud.commandframework.bukkit.BukkitCaptionRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Caption registry that uses bi-functions to produce messages
|
|
||||||
*
|
|
||||||
* @param <C> Command sender type
|
|
||||||
*/
|
|
||||||
public class RPGRegionsCaptionRegistry<C> extends BukkitCaptionRegistry<C> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default caption for {@link RPGRegionsCaptionKeys#ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND}.
|
|
||||||
*/
|
|
||||||
public static final String ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND = "Could not find region '{input}'";
|
|
||||||
|
|
||||||
protected RPGRegionsCaptionRegistry() {
|
|
||||||
super();
|
|
||||||
this.registerMessageFactory(
|
|
||||||
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND,
|
|
||||||
(caption, sender) -> ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,8 +9,8 @@ public final class RPGRegionsCaptionRegistryFactory<C> {
|
|||||||
*
|
*
|
||||||
* @return Created instance
|
* @return Created instance
|
||||||
*/
|
*/
|
||||||
public @NonNull RPGRegionsCaptionRegistry<C> create() {
|
public @NonNull RPGRegionsCaptionProvider<C> create() {
|
||||||
return new RPGRegionsCaptionRegistry<>();
|
return new RPGRegionsCaptionProvider<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,80 +1,37 @@
|
|||||||
package net.islandearth.rpgregions.commands.parser;
|
package net.islandearth.rpgregions.commands.parser;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
|
||||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
|
||||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
|
||||||
import cloud.commandframework.captions.CaptionVariable;
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
|
||||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
|
||||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||||
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionKeys;
|
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionKeys;
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.incendo.cloud.caption.CaptionVariable;
|
||||||
|
import org.incendo.cloud.context.CommandContext;
|
||||||
|
import org.incendo.cloud.context.CommandInput;
|
||||||
|
import org.incendo.cloud.exception.parsing.ParserException;
|
||||||
|
import org.incendo.cloud.parser.ArgumentParseResult;
|
||||||
|
import org.incendo.cloud.parser.ArgumentParser;
|
||||||
|
import org.incendo.cloud.suggestion.BlockingSuggestionProvider;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
|
|
||||||
public final class ConfiguredRegionArgument<C> extends CommandArgument<C, ConfiguredRegion> {
|
public final class ConfiguredRegionArgument<C> implements ArgumentParser<C, ConfiguredRegion>, BlockingSuggestionProvider.Strings<C> {
|
||||||
|
|
||||||
public ConfiguredRegionArgument(
|
@Override
|
||||||
final boolean required,
|
public @NonNull ArgumentParseResult<@NonNull ConfiguredRegion> parse(@NonNull CommandContext<@NonNull C> commandContext, @NonNull CommandInput commandInput) {
|
||||||
final @NonNull String name,
|
final String input = commandInput.peekString();
|
||||||
final @NonNull String defaultValue,
|
|
||||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<@NonNull String>> suggestionsProvider) {
|
final Optional<ConfiguredRegion> configuredRegion = RPGRegionsAPI.getAPI().getManagers().getRegionsCache().getConfiguredRegion(input);
|
||||||
super(required, name, new ConfiguredRegionArgument.ConfiguredRegionParser<>(), defaultValue, ConfiguredRegion.class, suggestionsProvider);
|
if (configuredRegion.isPresent()) {
|
||||||
|
commandInput.readString();
|
||||||
|
return ArgumentParseResult.success(configuredRegion.get());
|
||||||
|
}
|
||||||
|
return ArgumentParseResult.failure(new ConfiguredRegionParserException(input, commandContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <C> ConfiguredRegionArgument.Builder<C> newBuilder(final @NonNull String name) {
|
@Override
|
||||||
return new ConfiguredRegionArgument.Builder<>(name);
|
public @NonNull Iterable<@NonNull String> stringSuggestions(@NonNull CommandContext<C> commandContext, @NonNull CommandInput input) {
|
||||||
}
|
return ImmutableList.copyOf(RPGRegionsAPI.getAPI().getManagers().getRegionsCache().getConfiguredRegions().keySet());
|
||||||
|
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, ConfiguredRegion> {
|
|
||||||
|
|
||||||
private Builder(final @NonNull String name) {
|
|
||||||
super(ConfiguredRegion.class, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull CommandArgument<C, ConfiguredRegion> build() {
|
|
||||||
return new ConfiguredRegionArgument<>(
|
|
||||||
this.isRequired(),
|
|
||||||
this.getName(),
|
|
||||||
this.getDefaultValue(),
|
|
||||||
this.getSuggestionsProvider()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class ConfiguredRegionParser<C> implements ArgumentParser<C, ConfiguredRegion> {
|
|
||||||
@Override
|
|
||||||
public @NonNull ArgumentParseResult<ConfiguredRegion> parse(
|
|
||||||
@NonNull CommandContext<@NonNull C> commandContext,
|
|
||||||
@NonNull Queue<@NonNull String> inputQueue) {
|
|
||||||
final String input = inputQueue.peek();
|
|
||||||
if (input == null) {
|
|
||||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
|
||||||
ConfiguredRegionArgument.class,
|
|
||||||
commandContext
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
final Optional<ConfiguredRegion> configuredRegion = RPGRegionsAPI.getAPI().getManagers().getRegionsCache().getConfiguredRegion(input);
|
|
||||||
if (configuredRegion.isPresent()) {
|
|
||||||
inputQueue.remove();
|
|
||||||
return ArgumentParseResult.success(configuredRegion.get());
|
|
||||||
}
|
|
||||||
return ArgumentParseResult.failure(new ConfiguredRegionParserException(input, commandContext));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull List<@NonNull String> suggestions(@NonNull CommandContext<C> commandContext, @NonNull String input) {
|
|
||||||
return ImmutableList.copyOf(RPGRegionsAPI.getAPI().getManagers().getRegionsCache().getConfiguredRegions().keySet());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class ConfiguredRegionParserException extends ParserException {
|
public static final class ConfiguredRegionParserException extends ParserException {
|
||||||
@@ -84,7 +41,7 @@ public final class ConfiguredRegionArgument<C> extends CommandArgument<C, Config
|
|||||||
final @NonNull CommandContext<?> context
|
final @NonNull CommandContext<?> context
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
ConfiguredRegionParser.class,
|
ConfiguredRegionArgument.class,
|
||||||
context,
|
context,
|
||||||
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND,
|
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND,
|
||||||
CaptionVariable.of("input", input)
|
CaptionVariable.of("input", input)
|
||||||
|
|||||||
@@ -1,82 +1,38 @@
|
|||||||
package net.islandearth.rpgregions.commands.parser;
|
package net.islandearth.rpgregions.commands.parser;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
|
||||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
|
||||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
|
||||||
import cloud.commandframework.captions.CaptionVariable;
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
|
||||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
|
||||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||||
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionKeys;
|
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionKeys;
|
||||||
import net.islandearth.rpgregions.fauna.FaunaInstance;
|
import net.islandearth.rpgregions.fauna.FaunaInstance;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.incendo.cloud.caption.CaptionVariable;
|
||||||
|
import org.incendo.cloud.context.CommandContext;
|
||||||
|
import org.incendo.cloud.context.CommandInput;
|
||||||
|
import org.incendo.cloud.exception.parsing.ParserException;
|
||||||
|
import org.incendo.cloud.parser.ArgumentParseResult;
|
||||||
|
import org.incendo.cloud.parser.ArgumentParser;
|
||||||
|
import org.incendo.cloud.suggestion.BlockingSuggestionProvider;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class FaunaArgument<C> extends CommandArgument<C, FaunaInstance> {
|
public final class FaunaArgument<C> implements ArgumentParser<C, FaunaInstance<?>>, BlockingSuggestionProvider.Strings<C> {
|
||||||
|
|
||||||
public FaunaArgument(
|
@Override
|
||||||
final boolean required,
|
public @NonNull ArgumentParseResult<@NonNull FaunaInstance<?>> parse(@NonNull CommandContext<@NonNull C> commandContext, @NonNull CommandInput commandInput) {
|
||||||
final @NonNull String name,
|
final String input = commandInput.peekString();
|
||||||
final @NonNull String defaultValue,
|
|
||||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<@NonNull String>> suggestionsProvider) {
|
final Optional<FaunaInstance<?>> fauna = RPGRegionsAPI.getAPI().getManagers().getFaunaCache().getFauna(input);
|
||||||
super(required, name, new FaunaArgument.FaunaParser<>(), defaultValue, FaunaInstance.class, suggestionsProvider);
|
if (fauna.isPresent()) {
|
||||||
|
commandInput.readString();
|
||||||
|
return ArgumentParseResult.success(fauna.get());
|
||||||
|
}
|
||||||
|
return ArgumentParseResult.failure(new FaunaParserException(input, commandContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <C> FaunaArgument.Builder<C> newBuilder(final @NonNull String name) {
|
@Override
|
||||||
return new FaunaArgument.Builder<>(name);
|
public @NonNull Iterable<@NonNull String> stringSuggestions(@NonNull CommandContext<C> commandContext, @NonNull CommandInput input) {
|
||||||
}
|
return ImmutableList.copyOf(RPGRegionsAPI.getAPI().getManagers().getFaunaCache().getFauna().stream().map(FaunaInstance::getIdentifier).collect(Collectors.toList()));
|
||||||
|
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, FaunaInstance> {
|
|
||||||
|
|
||||||
private Builder(final @NonNull String name) {
|
|
||||||
super(FaunaInstance.class, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull CommandArgument<C, FaunaInstance> build() {
|
|
||||||
return new FaunaArgument<>(
|
|
||||||
this.isRequired(),
|
|
||||||
this.getName(),
|
|
||||||
this.getDefaultValue(),
|
|
||||||
this.getSuggestionsProvider()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FaunaParser<C> implements ArgumentParser<C, FaunaInstance> {
|
|
||||||
@Override
|
|
||||||
public @NonNull ArgumentParseResult<FaunaInstance> parse(
|
|
||||||
@NonNull CommandContext<@NonNull C> commandContext,
|
|
||||||
@NonNull Queue<@NonNull String> inputQueue) {
|
|
||||||
final String input = inputQueue.peek();
|
|
||||||
if (input == null) {
|
|
||||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
|
||||||
FaunaArgument.class,
|
|
||||||
commandContext
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
final Optional<FaunaInstance<?>> fauna = RPGRegionsAPI.getAPI().getManagers().getFaunaCache().getFauna(input);
|
|
||||||
if (fauna.isPresent()) {
|
|
||||||
inputQueue.remove();
|
|
||||||
return ArgumentParseResult.success(fauna.get());
|
|
||||||
}
|
|
||||||
return ArgumentParseResult.failure(new FaunaParserException(input, commandContext));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull List<@NonNull String> suggestions(@NonNull CommandContext<C> commandContext, @NonNull String input) {
|
|
||||||
return ImmutableList.copyOf(RPGRegionsAPI.getAPI().getManagers().getFaunaCache().getFauna().stream().map(FaunaInstance::getIdentifier).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class FaunaParserException extends ParserException {
|
public static final class FaunaParserException extends ParserException {
|
||||||
@@ -86,7 +42,7 @@ public final class FaunaArgument<C> extends CommandArgument<C, FaunaInstance> {
|
|||||||
final @NonNull CommandContext<?> context
|
final @NonNull CommandContext<?> context
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
FaunaParser.class,
|
FaunaArgument.class,
|
||||||
context,
|
context,
|
||||||
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_FAUNA_NOT_FOUND,
|
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_FAUNA_NOT_FOUND,
|
||||||
CaptionVariable.of("input", input)
|
CaptionVariable.of("input", input)
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
package net.islandearth.rpgregions.commands.parser;
|
package net.islandearth.rpgregions.commands.parser;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
|
||||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
|
||||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
|
||||||
import cloud.commandframework.captions.CaptionVariable;
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
|
||||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
|
||||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
||||||
@@ -14,76 +7,40 @@ import net.islandearth.rpgregions.api.integrations.rpgregions.region.RPGRegionsR
|
|||||||
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionKeys;
|
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionKeys;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.incendo.cloud.caption.CaptionVariable;
|
||||||
|
import org.incendo.cloud.context.CommandContext;
|
||||||
|
import org.incendo.cloud.context.CommandInput;
|
||||||
|
import org.incendo.cloud.exception.parsing.ParserException;
|
||||||
|
import org.incendo.cloud.parser.ArgumentParseResult;
|
||||||
|
import org.incendo.cloud.parser.ArgumentParser;
|
||||||
|
import org.incendo.cloud.suggestion.BlockingSuggestionProvider;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
|
|
||||||
public final class IntegrationRegionArgument<C> extends CommandArgument<C, RPGRegionsRegion> {
|
public final class IntegrationRegionArgument<C> implements ArgumentParser<C, RPGRegionsRegion>, BlockingSuggestionProvider.Strings<C> {
|
||||||
|
|
||||||
public IntegrationRegionArgument(
|
@Override
|
||||||
final boolean required,
|
public @NonNull ArgumentParseResult<@NonNull RPGRegionsRegion> parse(@NonNull CommandContext<@NonNull C> commandContext, @NonNull CommandInput commandInput) {
|
||||||
final @NonNull String name,
|
final String input = commandInput.peekString();
|
||||||
final @NonNull String defaultValue,
|
|
||||||
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<@NonNull String>> suggestionsProvider) {
|
if (RPGRegionsAPI.getAPI().getManagers().getIntegrationManager() instanceof RPGRegionsIntegration rpgRegionsIntegration) {
|
||||||
super(required, name, new IntegrationRegionArgument.IntegrationRegionParser<>(), defaultValue, RPGRegionsRegion.class, suggestionsProvider);
|
Optional<RPGRegionsRegion> region = rpgRegionsIntegration.getRegion(input);
|
||||||
|
if (region.isPresent()) {
|
||||||
|
commandInput.readString();
|
||||||
|
return ArgumentParseResult.success(region.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ArgumentParseResult.failure(new IntegrationRegionParserException(input, commandContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <C> IntegrationRegionArgument.Builder<C> newBuilder(final @NonNull String name) {
|
@Override
|
||||||
return new IntegrationRegionArgument.Builder<>(name);
|
public @NonNull Iterable<@NonNull String> stringSuggestions(@NonNull CommandContext<C> commandContext, @NonNull CommandInput input) {
|
||||||
}
|
if (commandContext.sender() instanceof Player player) {
|
||||||
|
return ImmutableList.copyOf(RPGRegionsAPI.getAPI().getManagers().getIntegrationManager().getAllRegionNames(player.getWorld()));
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, RPGRegionsRegion> {
|
|
||||||
|
|
||||||
private Builder(final @NonNull String name) {
|
|
||||||
super(RPGRegionsRegion.class, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull CommandArgument<C, RPGRegionsRegion> build() {
|
|
||||||
return new IntegrationRegionArgument<>(
|
|
||||||
this.isRequired(),
|
|
||||||
this.getName(),
|
|
||||||
this.getDefaultValue(),
|
|
||||||
this.getSuggestionsProvider()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class IntegrationRegionParser<C> implements ArgumentParser<C, RPGRegionsRegion> {
|
|
||||||
@Override
|
|
||||||
public @NonNull ArgumentParseResult<RPGRegionsRegion> parse(
|
|
||||||
@NonNull CommandContext<@NonNull C> commandContext,
|
|
||||||
@NonNull Queue<@NonNull String> inputQueue) {
|
|
||||||
final String input = inputQueue.peek();
|
|
||||||
if (input == null) {
|
|
||||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
|
||||||
IntegrationRegionArgument.class,
|
|
||||||
commandContext
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RPGRegionsAPI.getAPI().getManagers().getIntegrationManager() instanceof RPGRegionsIntegration rpgRegionsIntegration) {
|
|
||||||
Optional<RPGRegionsRegion> region = rpgRegionsIntegration.getRegion(input);
|
|
||||||
if (region.isPresent()) {
|
|
||||||
inputQueue.remove();
|
|
||||||
return ArgumentParseResult.success(region.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ArgumentParseResult.failure(new IntegrationRegionParserException(input, commandContext));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull List<@NonNull String> suggestions(@NonNull CommandContext<C> commandContext, @NonNull String input) {
|
|
||||||
if (commandContext.getSender() instanceof Player player) {
|
|
||||||
return ImmutableList.copyOf(RPGRegionsAPI.getAPI().getManagers().getIntegrationManager().getAllRegionNames(player.getWorld()));
|
|
||||||
}
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class IntegrationRegionParserException extends ParserException {
|
public static final class IntegrationRegionParserException extends ParserException {
|
||||||
|
|||||||
@@ -54,4 +54,4 @@ public class AbstractAdapter<T> implements JsonSerializer<T>, JsonDeserializer<T
|
|||||||
throw new JsonParseException("Unknown element type: " + type, cnfe);
|
throw new JsonParseException("Unknown element type: " + type, cnfe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,4 +38,4 @@ public class ItemStackAdapter implements JsonSerializer<ItemStack>, JsonDeserial
|
|||||||
public JsonElement serialize(ItemStack itemStack, Type type, JsonSerializationContext context) {
|
public JsonElement serialize(ItemStack itemStack, Type type, JsonSerializationContext context) {
|
||||||
return Serializers.serializeItemstack(itemStack);
|
return Serializers.serializeItemstack(itemStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,4 @@ public class PotionEffectAdapter implements JsonSerializer<PotionEffect>, JsonDe
|
|||||||
boolean icon = (boolean) map.get("icon");
|
boolean icon = (boolean) map.get("icon");
|
||||||
return new PotionEffect(type, (int) duration, (int) amplifier, ambient, particles, icon);
|
return new PotionEffect(type, (int) duration, (int) amplifier, ambient, particles, icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.islandearth.rpgregions.gui.element;
|
package net.islandearth.rpgregions.gui.element;
|
||||||
|
|
||||||
import net.islandearth.rpgregions.gui.IGuiEditable;
|
import net.islandearth.rpgregions.gui.IGuiEditable;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -15,7 +14,8 @@ public class BooleanGuiFieldElement implements IGuiFieldElement {
|
|||||||
public CompletableFuture<Void> set(Player player, IGuiEditable guiEditable, Field field, Object value) {
|
public CompletableFuture<Void> set(Player player, IGuiEditable guiEditable, Field field, Object value) {
|
||||||
try {
|
try {
|
||||||
Object currentValue = field.get(guiEditable);
|
Object currentValue = field.get(guiEditable);
|
||||||
FieldUtils.writeField(field, guiEditable, !(Boolean) currentValue);
|
field.setAccessible(true);
|
||||||
|
field.set(guiEditable, !(Boolean) currentValue);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.google.common.base.Optional;
|
|||||||
import net.islandearth.rpgregions.chat.preset.ReturnValueConversationPreset;
|
import net.islandearth.rpgregions.chat.preset.ReturnValueConversationPreset;
|
||||||
import net.islandearth.rpgregions.gui.IGuiEditable;
|
import net.islandearth.rpgregions.gui.IGuiEditable;
|
||||||
import net.islandearth.rpgregions.utils.PlaceholderCompareType;
|
import net.islandearth.rpgregions.utils.PlaceholderCompareType;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -24,7 +23,8 @@ public class CompareTypeGuiFieldElement implements IGuiFieldElement {
|
|||||||
Optional<PlaceholderCompareType> compareType = Enums.getIfPresent(PlaceholderCompareType.class,input.toUpperCase());
|
Optional<PlaceholderCompareType> compareType = Enums.getIfPresent(PlaceholderCompareType.class,input.toUpperCase());
|
||||||
if (compareType.isPresent()) {
|
if (compareType.isPresent()) {
|
||||||
try {
|
try {
|
||||||
FieldUtils.writeField(field, guiEditable, PlaceholderCompareType.valueOf(input.toUpperCase()));
|
field.setAccessible(true);
|
||||||
|
field.set(guiEditable, PlaceholderCompareType.valueOf(input.toUpperCase()));
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.islandearth.rpgregions.gui.element;
|
package net.islandearth.rpgregions.gui.element;
|
||||||
|
|
||||||
import net.islandearth.rpgregions.gui.IGuiEditable;
|
import net.islandearth.rpgregions.gui.IGuiEditable;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -15,7 +14,8 @@ public class DefaultGuiFieldElement implements IGuiFieldElement {
|
|||||||
public CompletableFuture<Void> set(Player player, IGuiEditable guiEditable, Field field, Object value) {
|
public CompletableFuture<Void> set(Player player, IGuiEditable guiEditable, Field field, Object value) {
|
||||||
Object casted = field.getType().cast(value);
|
Object casted = field.getType().cast(value);
|
||||||
try {
|
try {
|
||||||
FieldUtils.writeField(field, guiEditable, casted);
|
field.setAccessible(true);
|
||||||
|
field.set(guiEditable, casted);
|
||||||
} catch (IllegalAccessException e2) {
|
} catch (IllegalAccessException e2) {
|
||||||
e2.printStackTrace();
|
e2.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.islandearth.rpgregions.gui.element;
|
package net.islandearth.rpgregions.gui.element;
|
||||||
|
|
||||||
import net.islandearth.rpgregions.gui.IGuiEditable;
|
import net.islandearth.rpgregions.gui.IGuiEditable;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -14,7 +13,8 @@ public class IntegerGuiFieldElement implements IGuiFieldElement {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> set(Player player, IGuiEditable guiEditable, Field field, Object value) {
|
public CompletableFuture<Void> set(Player player, IGuiEditable guiEditable, Field field, Object value) {
|
||||||
try {
|
try {
|
||||||
FieldUtils.writeField(field, guiEditable, Integer.parseInt(String.valueOf(value)));
|
field.setAccessible(true);
|
||||||
|
field.set(guiEditable, Integer.parseInt(String.valueOf(value)));
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
|||||||
import com.github.stefvanschie.inventoryframework.pane.StaticPane;
|
import com.github.stefvanschie.inventoryframework.pane.StaticPane;
|
||||||
import net.islandearth.rpgregions.gui.IGuiEditable;
|
import net.islandearth.rpgregions.gui.IGuiEditable;
|
||||||
import net.islandearth.rpgregions.utils.ItemStackBuilder;
|
import net.islandearth.rpgregions.utils.ItemStackBuilder;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -33,7 +32,8 @@ public class ItemStackGuiFieldElement implements IGuiFieldElement {
|
|||||||
gui.setOnGlobalClick(click -> {
|
gui.setOnGlobalClick(click -> {
|
||||||
click.setCancelled(true);
|
click.setCancelled(true);
|
||||||
try {
|
try {
|
||||||
FieldUtils.writeField(field, guiEditable, click.getCurrentItem());
|
field.setAccessible(true);
|
||||||
|
field.set(guiEditable, click.getCurrentItem());
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.islandearth.rpgregions.gui.element;
|
package net.islandearth.rpgregions.gui.element;
|
||||||
|
|
||||||
import net.islandearth.rpgregions.gui.IGuiEditable;
|
import net.islandearth.rpgregions.gui.IGuiEditable;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -15,7 +14,8 @@ public class LocationGuiFieldElement implements IGuiFieldElement {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> set(Player player, IGuiEditable guiEditable, Field field, Object value) {
|
public CompletableFuture<Void> set(Player player, IGuiEditable guiEditable, Field field, Object value) {
|
||||||
try {
|
try {
|
||||||
FieldUtils.writeField(field, guiEditable, player.getLocation());
|
field.setAccessible(true);
|
||||||
|
field.set(guiEditable, player.getLocation());
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.islandearth.rpgregions.gui.element;
|
|||||||
|
|
||||||
import net.islandearth.rpgregions.chat.preset.ReturnValueConversationPreset;
|
import net.islandearth.rpgregions.chat.preset.ReturnValueConversationPreset;
|
||||||
import net.islandearth.rpgregions.gui.IGuiEditable;
|
import net.islandearth.rpgregions.gui.IGuiEditable;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
@@ -35,7 +34,8 @@ public class PotionEffectGuiFieldElement implements IGuiFieldElement {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (field.getType().isAssignableFrom(PotionEffectType.class)) {
|
if (field.getType().isAssignableFrom(PotionEffectType.class)) {
|
||||||
FieldUtils.writeField(field, guiEditable, validType);
|
field.setAccessible(true);
|
||||||
|
field.set(guiEditable, validType);
|
||||||
} else {
|
} else {
|
||||||
PotionEffect potionEffect = (PotionEffect) field.get(guiEditable);
|
PotionEffect potionEffect = (PotionEffect) field.get(guiEditable);
|
||||||
int duration = potionEffect.getDuration();
|
int duration = potionEffect.getDuration();
|
||||||
@@ -48,7 +48,8 @@ public class PotionEffectGuiFieldElement implements IGuiFieldElement {
|
|||||||
}
|
}
|
||||||
PotionEffect newPotionEffect = new PotionEffect(validType, duration, amplifier,
|
PotionEffect newPotionEffect = new PotionEffect(validType, duration, amplifier,
|
||||||
potionEffect.isAmbient(), potionEffect.hasParticles(), potionEffect.hasIcon());
|
potionEffect.isAmbient(), potionEffect.hasParticles(), potionEffect.hasIcon());
|
||||||
FieldUtils.writeField(field, guiEditable, newPotionEffect);
|
field.setAccessible(true);
|
||||||
|
field.set(guiEditable, newPotionEffect);
|
||||||
}
|
}
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -49,4 +49,4 @@ public record MoveListener(RPGRegions plugin) implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class RegionListener implements Listener {
|
|||||||
plugin.debug("Player is on title cooldown");
|
plugin.debug("Player is on title cooldown");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.debug("Added to title cooldown");
|
plugin.debug("Added to title cooldown");
|
||||||
titleCooldown.add(player.getUniqueId());
|
titleCooldown.add(player.getUniqueId());
|
||||||
plugin.getScheduler().executeDelayed(() -> {
|
plugin.getScheduler().executeDelayed(() -> {
|
||||||
|
|||||||
@@ -180,8 +180,7 @@ public class RPGRegionsManagers implements IRPGRegionsManagers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull private static ConfiguredRegion createExampleRegion(List<DiscoveryReward> rewards, List<RegionEffect> effects) {
|
||||||
private static ConfiguredRegion createExampleRegion(List<DiscoveryReward> rewards, List<RegionEffect> effects) {
|
|
||||||
ConfiguredRegion configuredRegion = new ConfiguredRegion(null, "exampleconfig", "ExampleConfig", rewards, effects,
|
ConfiguredRegion configuredRegion = new ConfiguredRegion(null, "exampleconfig", "ExampleConfig", rewards, effects,
|
||||||
Sound.AMBIENT_UNDERWATER_EXIT,
|
Sound.AMBIENT_UNDERWATER_EXIT,
|
||||||
Material.WOODEN_AXE);
|
Material.WOODEN_AXE);
|
||||||
@@ -250,8 +249,7 @@ public class RPGRegionsManagers implements IRPGRegionsManagers {
|
|||||||
return registry;
|
return registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable @Override
|
||||||
@Override
|
|
||||||
public <T> IRPGRegionsRegistry<T> getRegistry(Class<? extends IRPGRegionsRegistry<T>> clazz) {
|
public <T> IRPGRegionsRegistry<T> getRegistry(Class<? extends IRPGRegionsRegistry<T>> clazz) {
|
||||||
return (IRPGRegionsRegistry<T>) registry.get(clazz);
|
return (IRPGRegionsRegistry<T>) registry.get(clazz);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,26 +21,26 @@ public class MoneyRequirement extends RegionRequirement {
|
|||||||
super(api);
|
super(api);
|
||||||
this.money = money;
|
this.money = money;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean meetsRequirements(Player player) {
|
public boolean meetsRequirements(Player player) {
|
||||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisteredServiceProvider<Economy> economy = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> economy = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
if (economy == null) {
|
if (economy == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return economy.getProvider().getBalance(player) >= money;
|
return economy.getProvider().getBalance(player) >= money;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Money";
|
return "Money";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Player player) {
|
public String getText(Player player) {
|
||||||
return "Money " + money;
|
return "Money " + money;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class PlaceholderRequirement extends RegionRequirement {
|
|||||||
this.placeholderName = placeholder;
|
this.placeholderName = placeholder;
|
||||||
this.equal = equal;
|
this.equal = equal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean meetsRequirements(Player player) {
|
public boolean meetsRequirements(Player player) {
|
||||||
try {
|
try {
|
||||||
@@ -83,16 +83,16 @@ public class PlaceholderRequirement extends RegionRequirement {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return "Placeholder";
|
return "Placeholder";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Player player) {
|
public String getText(Player player) {
|
||||||
return placeholderName == null ? "(null)" : placeholderName;
|
return placeholderName == null ? "(null)" : placeholderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlaceholder() {
|
public String getPlaceholder() {
|
||||||
return placeholder;
|
return placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEqual() {
|
public String getEqual() {
|
||||||
return equal;
|
return equal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,4 @@ public class ConsoleCommandReward extends DiscoveryReward {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return "Console Command";
|
return "Console Command";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class ExperienceReward extends DiscoveryReward {
|
|||||||
super(api);
|
super(api);
|
||||||
this.xp = xp;
|
this.xp = xp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void award(Player player, RPGRegionsAccount account) {
|
public void award(Player player, RPGRegionsAccount account) {
|
||||||
player.giveExp(xp);
|
player.giveExp(xp);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class ItemReward extends DiscoveryReward {
|
|||||||
super(api);
|
super(api);
|
||||||
this.item = item;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void award(Player player, RPGRegionsAccount account) {
|
public void award(Player player, RPGRegionsAccount account) {
|
||||||
player.getInventory().addItem(item).forEach((pos, item) -> {
|
player.getInventory().addItem(item).forEach((pos, item) -> {
|
||||||
|
|||||||
@@ -37,4 +37,4 @@ public class PlayerCommandReward extends DiscoveryReward {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return "Player Command";
|
return "Player Command";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package net.islandearth.rpgregions.tasks;
|
package net.islandearth.rpgregions.tasks;
|
||||||
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.dynmap.DynmapAPI;
|
import org.dynmap.DynmapCommonAPI;
|
||||||
import org.dynmap.bukkit.DynmapPlugin;
|
|
||||||
import org.dynmap.markers.AreaMarker;
|
import org.dynmap.markers.AreaMarker;
|
||||||
import org.dynmap.markers.MarkerSet;
|
import org.dynmap.markers.MarkerSet;
|
||||||
|
|
||||||
@@ -14,13 +14,13 @@ import java.util.Map;
|
|||||||
public class DynmapTask implements Runnable {
|
public class DynmapTask implements Runnable {
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
private final RPGRegions plugin;
|
||||||
private final DynmapAPI dynmapAPI;
|
private final DynmapCommonAPI dynmapAPI;
|
||||||
private final Map<String, AreaMarker> markers;
|
private final Map<String, AreaMarker> markers;
|
||||||
private final MarkerSet markerSet;
|
private final MarkerSet markerSet;
|
||||||
|
|
||||||
public DynmapTask(final RPGRegions plugin) {
|
public DynmapTask(final RPGRegions plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.dynmapAPI = DynmapPlugin.plugin;
|
this.dynmapAPI = (DynmapCommonAPI) Bukkit.getPluginManager().getPlugin("Dynmap");
|
||||||
this.markers = new HashMap<>();
|
this.markers = new HashMap<>();
|
||||||
this.markerSet = dynmapAPI.getMarkerAPI().createMarkerSet("rpgregions.regions", "Regions", dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
this.markerSet = dynmapAPI.getMarkerAPI().createMarkerSet("rpgregions.regions", "Regions", dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ public enum PlaceholderCompareType {
|
|||||||
LESS_THAN,
|
LESS_THAN,
|
||||||
LESS_THAN_OR_EQUAL_TO,
|
LESS_THAN_OR_EQUAL_TO,
|
||||||
RANGE
|
RANGE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ main: net.islandearth.rpgregions.RPGRegions
|
|||||||
api-version: '1.16'
|
api-version: '1.16'
|
||||||
libraries:
|
libraries:
|
||||||
- "com.zaxxer:HikariCP:5.0.1" # database
|
- "com.zaxxer:HikariCP:5.0.1" # database
|
||||||
- "net.kyori:adventure-platform-bukkit:4.3.2"
|
|
||||||
- "net.kyori:adventure-text-minimessage:4.14.0"
|
|
||||||
- "com.github.ben-manes.caffeine:caffeine:3.1.8"
|
- "com.github.ben-manes.caffeine:caffeine:3.1.8"
|
||||||
- "org.xerial:sqlite-jdbc:3.30.1"
|
- "org.xerial:sqlite-jdbc:3.30.1"
|
||||||
- "org.flywaydb:flyway-core:9.16.2" # db migration
|
- "org.flywaydb:flyway-core:10.12.0" # db migration
|
||||||
- "org.flywaydb:flyway-mysql:9.16.3"
|
- "org.flywaydb:flyway-mysql:10.12.0"
|
||||||
softdepend: [Hyperverse, Multiverse-Core, UltraRegions, WorldGuard, PlaceholderAPI, HeadDatabase, Residence, Plan, GriefPrevention, GriefDefender, Vault, MythicMobs, AlonsoLevels, dynmap, ProtocolLib, Quests, BetonQuest, Lands, MMOCore, CustomStructures]
|
softdepend: [Hyperverse, Multiverse-Core, UltraRegions, WorldGuard, PlaceholderAPI, HeadDatabase, Residence, Plan, GriefPrevention, GriefDefender, Vault, MythicMobs, AlonsoLevels, dynmap, ProtocolLib, Quests, BetonQuest, Lands, MMOCore, CustomStructures]
|
||||||
authors: [SamB440]
|
authors: [SamB440]
|
||||||
description: Discoverable regions
|
description: Utilise your protection plugin to create discoverable regions
|
||||||
website: https://fortitude.islandearth.net
|
website: https://fortitude.islandearth.net
|
||||||
folia-supported: true
|
folia-supported: true
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
include("rpgregions")
|
pluginManagement {
|
||||||
include("modern")
|
// Include 'plugins build' to define convention plugins.
|
||||||
include("api")
|
includeBuild("build-logic")
|
||||||
include("folia")
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
// Apply the foojay-resolver plugin to allow automatic download of JDKs
|
||||||
|
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "rpgregions-2"
|
||||||
|
include("rpgregions", "modern", "api", "folia")
|
||||||
|
|||||||
Reference in New Issue
Block a user