mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-29 19:59:11 +00:00
Cloud 2 migration, 1.20.6, bump all deps, refactor project layout
This commit is contained in:
@@ -28,7 +28,7 @@ public interface IRPGRegionsAPI {
|
||||
IRPGRegionsManagers getManagers();
|
||||
|
||||
boolean debug();
|
||||
|
||||
|
||||
void debug(String debug);
|
||||
|
||||
boolean hasHeadDatabase();
|
||||
|
||||
@@ -52,4 +52,4 @@ public class FaunaDiscoverEvent extends Event {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ public class RPGRegionsReloadEvent extends Event {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class RegionDiscoverEvent extends Event {
|
||||
private final RPGRegionsAccount account;
|
||||
private final ConfiguredRegion region;
|
||||
private final Discovery discovery;
|
||||
|
||||
|
||||
public RegionDiscoverEvent(Player player, RPGRegionsAccount account, ConfiguredRegion region, Discovery discovery) {
|
||||
this.player = player;
|
||||
this.account = account;
|
||||
@@ -63,4 +63,4 @@ public class RegionDiscoverEvent extends Event {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,4 +63,4 @@ public class RegionsEnterEvent extends Event {
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,5 @@ public interface IntegrationManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
List<Location> getBoundingBoxPoints(@NotNull ConfiguredRegion region);
|
||||
@NotNull List<Location> getBoundingBoxPoints(@NotNull ConfiguredRegion region);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
*/
|
||||
@Deprecated
|
||||
public class ClassEditor {
|
||||
|
||||
|
||||
private final List<EditField> editable = new ArrayList<>();
|
||||
|
||||
public ClassEditor(ConfiguredRegion clazz) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class RegionEffect implements IGuiEditable {
|
||||
|
||||
|
||||
private final boolean wearingRequired;
|
||||
private final List<ItemStack> ignoreItems;
|
||||
private final boolean ignorePerm;
|
||||
@@ -41,8 +41,7 @@ public abstract class RegionEffect implements IGuiEditable {
|
||||
* Gets the required Minecraft version for this effect to function.
|
||||
* @return minecraft version
|
||||
*/
|
||||
@Nullable
|
||||
public String getRequiredVersion() {
|
||||
@Nullable public String getRequiredVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -70,7 +69,7 @@ public abstract class RegionEffect implements IGuiEditable {
|
||||
public boolean shouldIgnore(ItemStack item) {
|
||||
return ignoreItems.contains(item);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the permission for this effect to apply.
|
||||
* @return permission the player requires
|
||||
@@ -78,7 +77,7 @@ public abstract class RegionEffect implements IGuiEditable {
|
||||
public String getPermission() {
|
||||
return "rpgregions.effect." + getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the permission should be ignored or not.
|
||||
* @return true if permission is ignored
|
||||
|
||||
@@ -77,4 +77,4 @@ public class RPGRegionsAccount {
|
||||
ICON_COMMAND,
|
||||
TELEPORT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,8 +148,7 @@ public class ConfiguredRegion {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getIcon() {
|
||||
@Nullable public ItemStack getIcon() {
|
||||
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();
|
||||
return new ItemStackBuilder(Material.valueOf(icon)).withModel(iconModel).build();
|
||||
@@ -167,8 +166,7 @@ public class ConfiguredRegion {
|
||||
this.iconModel = iconModel;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getUndiscoveredIcon() {
|
||||
@Nullable public ItemStack getUndiscoveredIcon() {
|
||||
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();
|
||||
return new ItemStackBuilder(Material.valueOf(undiscoveredIcon)).withModel(undiscoveredIconModel).build();
|
||||
@@ -186,8 +184,7 @@ public class ConfiguredRegion {
|
||||
this.undiscoveredIconModel = undiscoveredIconModel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<IconCommand> getIconCommand() {
|
||||
@NotNull public List<IconCommand> getIconCommand() {
|
||||
return iconCommand == null ? new ArrayList<>() : iconCommand;
|
||||
}
|
||||
|
||||
@@ -207,8 +204,7 @@ public class ConfiguredRegion {
|
||||
this.showCoords = showCoords;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getHints() {
|
||||
@Nullable public List<String> getHints() {
|
||||
return hints;
|
||||
}
|
||||
|
||||
@@ -228,8 +224,7 @@ public class ConfiguredRegion {
|
||||
this.teleportable = teleportable;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public World getWorld() {
|
||||
@Nullable public World getWorld() {
|
||||
return Bukkit.getWorld(world);
|
||||
}
|
||||
|
||||
@@ -254,18 +249,15 @@ public class ConfiguredRegion {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<RegionEffect> getEffects() {
|
||||
@Nullable public List<RegionEffect> getEffects() {
|
||||
return effects;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<RegionRequirement> getRequirements() {
|
||||
@Nullable public List<RegionRequirement> getRequirements() {
|
||||
return requirements;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getDiscoveredLore() {
|
||||
@Nullable public List<String> getDiscoveredLore() {
|
||||
return discoveredLore;
|
||||
}
|
||||
|
||||
@@ -278,8 +270,7 @@ public class ConfiguredRegion {
|
||||
* @param player the player
|
||||
* @return A string list of title
|
||||
*/
|
||||
@NotNull
|
||||
public List<Component> getTitle(Player player) {
|
||||
@NotNull public List<Component> getTitle(Player player) {
|
||||
if (title == null) {
|
||||
return Translations.DISCOVERED_TITLE.get(player, customName);
|
||||
}
|
||||
@@ -294,8 +285,7 @@ public class ConfiguredRegion {
|
||||
* @param player the player
|
||||
* @return A string list of subtitles
|
||||
*/
|
||||
@NotNull
|
||||
public List<Component> getSubtitle(Player player) {
|
||||
@NotNull public List<Component> getSubtitle(Player player) {
|
||||
if (subtitle == null) {
|
||||
return Translations.DISCOVERED_SUBTITLE.get(player, customName);
|
||||
}
|
||||
@@ -310,8 +300,7 @@ public class ConfiguredRegion {
|
||||
* @param player the player
|
||||
* @return A string list of title
|
||||
*/
|
||||
@NotNull
|
||||
public List<Component> getDiscoveredTitle(Player player) {
|
||||
@NotNull public List<Component> getDiscoveredTitle(Player player) {
|
||||
if (discoveredTitle == null) {
|
||||
return Translations.ALREADY_DISCOVERED_TITLE.get(player, customName);
|
||||
}
|
||||
@@ -326,8 +315,7 @@ public class ConfiguredRegion {
|
||||
* @param player the player
|
||||
* @return A string list of subtitles
|
||||
*/
|
||||
@NotNull
|
||||
public List<Component> getDiscoveredSubtitle(Player player) {
|
||||
@NotNull public List<Component> getDiscoveredSubtitle(Player player) {
|
||||
if (discoveredSubtitle == null) {
|
||||
return Translations.ALREADY_DISCOVERED_SUBTITLE.get(player, customName);
|
||||
}
|
||||
@@ -337,8 +325,7 @@ public class ConfiguredRegion {
|
||||
return translatedSubtitle;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Regenerate getRegenerate() {
|
||||
@Nullable public Regenerate getRegenerate() {
|
||||
return regenerate;
|
||||
}
|
||||
|
||||
@@ -381,8 +368,7 @@ public class ConfiguredRegion {
|
||||
this.showActionbar = showActionbar;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Location> getBoundingBox() {
|
||||
@Nullable public List<Location> getBoundingBox() {
|
||||
return RPGRegionsAPI.getAPI().getManagers().getIntegrationManager().getBoundingBoxPoints(this);
|
||||
}
|
||||
|
||||
@@ -474,8 +460,7 @@ public class ConfiguredRegion {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private File findFile(IRPGRegionsAPI plugin) throws IOException {
|
||||
@Nullable private File findFile(IRPGRegionsAPI plugin) throws IOException {
|
||||
File folder = new File(plugin.getDataFolder() + "/regions/");
|
||||
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();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.islandearth.rpgregions.managers.data.region;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public record WorldDiscovery(LocalDateTime date, String region) implements Discovery {
|
||||
|
||||
@@ -10,8 +10,7 @@ import java.util.List;
|
||||
|
||||
public interface IRPGRegionsRegistry<T> {
|
||||
|
||||
@NotNull
|
||||
ImmutableMap<String, Class<? extends T>> get();
|
||||
@NotNull ImmutableMap<String, Class<? extends T>> get();
|
||||
|
||||
/**
|
||||
* Attempts to register a class.
|
||||
@@ -20,11 +19,9 @@ public interface IRPGRegionsRegistry<T> {
|
||||
*/
|
||||
void register(Class<? extends T> clazz);
|
||||
|
||||
@Nullable
|
||||
T getNew(String name, IRPGRegionsAPI plugin, Object... data);
|
||||
@Nullable T getNew(String name, IRPGRegionsAPI plugin, Object... data);
|
||||
|
||||
@Nullable
|
||||
T getNew(Class<? extends T> clazz, IRPGRegionsAPI plugin, Object... data);
|
||||
@Nullable T getNew(Class<? extends T> clazz, IRPGRegionsAPI plugin, Object... data);
|
||||
|
||||
String getRegistryName();
|
||||
|
||||
|
||||
@@ -18,13 +18,11 @@ public abstract class RPGRegionsRegistry<T> implements IRPGRegionsRegistry<T> {
|
||||
this.registeredClasses = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected Map<String, Class<? extends T>> getRegisteredClasses() {
|
||||
@NotNull protected Map<String, Class<? extends T>> getRegisteredClasses() {
|
||||
return registeredClasses;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public ImmutableMap<String, Class<? extends T>> get() {
|
||||
return ImmutableMap.copyOf(registeredClasses);
|
||||
}
|
||||
@@ -36,14 +34,12 @@ public abstract class RPGRegionsRegistry<T> implements IRPGRegionsRegistry<T> {
|
||||
registeredClasses.put(clazz.getSimpleName(), clazz);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@Nullable @Override
|
||||
public T getNew(String name, IRPGRegionsAPI plugin, Object... data) {
|
||||
return getNew(registeredClasses.get(name), plugin, data);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@Nullable @Override
|
||||
public abstract T getNew(Class<? extends T> clazz, IRPGRegionsAPI plugin, Object... data);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DependencyRequirement extends RegionRequirement {
|
||||
super(api);
|
||||
this.requiredRegions = requiredRegions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an immutable list of required regions by their ID.
|
||||
* @return immutable list of required regions
|
||||
@@ -32,22 +32,22 @@ public class DependencyRequirement extends RegionRequirement {
|
||||
public ImmutableList<String> getRequiredRegions() {
|
||||
return ImmutableList.copyOf(requiredRegions);
|
||||
}
|
||||
|
||||
|
||||
public boolean meetsRequirements(List<String> discoveries) {
|
||||
return new HashSet<>(discoveries).containsAll(requiredRegions);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean meetsRequirements(Player player) {
|
||||
return meetsRequirements(Collections.emptyList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Dependency";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getText(Player player) {
|
||||
List<String> convertedIds = new ArrayList<>();
|
||||
|
||||
@@ -57,8 +57,7 @@ public abstract class RegionRequirement implements IGuiEditable, ICustomGuiFeedb
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPreventMessage() {
|
||||
@Nullable public String getPreventMessage() {
|
||||
return preventMessage;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,11 +93,14 @@ public enum Translations {
|
||||
File lang = new File(plugin.getDataFolder() + "/lang/");
|
||||
lang.mkdirs();
|
||||
|
||||
int validLanguages = 0;
|
||||
for (Language language : Language.values()) {
|
||||
final LanguageKey languageKey = language.getKey();
|
||||
|
||||
try {
|
||||
plugin.saveResource("lang/" + languageKey.getCode() + ".yml", false);
|
||||
plugin.getLogger().info("Generated " + languageKey.getCode() + ".yml");
|
||||
validLanguages++;
|
||||
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
|
||||
File file = new File(plugin.getDataFolder() + "/lang/" + languageKey.getCode() + ".yml");
|
||||
@@ -106,15 +109,17 @@ public enum Translations {
|
||||
for (Translations key : values()) {
|
||||
if (config.get(key.toString().toLowerCase()) == null) {
|
||||
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
|
||||
private String setPapi(Player player, String message) {
|
||||
@NotNull private String setPapi(Player player, String message) {
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
return PlaceholderAPI.setPlaceholders(player, message);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.islandearth.rpgregions.utils;
|
||||
|
||||
import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
@@ -48,7 +48,7 @@ public class ItemStackBuilder {
|
||||
}
|
||||
|
||||
public ItemStackBuilder withName(Component name) {
|
||||
return withName(LegacyComponentSerializer.legacyAmpersand().serialize(name));
|
||||
return withName(BukkitComponentSerializer.legacy().serialize(name));
|
||||
}
|
||||
|
||||
public ItemStackBuilder withLore(String name) {
|
||||
@@ -65,7 +65,7 @@ public class ItemStackBuilder {
|
||||
}
|
||||
|
||||
public ItemStackBuilder withLore(Component name) {
|
||||
return withLore(LegacyComponentSerializer.legacyAmpersand().serialize(name));
|
||||
return withLore(BukkitComponentSerializer.legacy().serialize(name));
|
||||
}
|
||||
|
||||
public ItemStackBuilder withLore(@Nullable List<String> name) {
|
||||
@@ -86,7 +86,7 @@ public class ItemStackBuilder {
|
||||
if (name == null) return this;
|
||||
List<String> legacy = new ArrayList<>();
|
||||
for (Component component : name) {
|
||||
legacy.add(ChatColor.translateAlternateColorCodes('&', LegacyComponentSerializer.legacyAmpersand().serialize(component)));
|
||||
legacy.add(BukkitComponentSerializer.legacy().serialize(component));
|
||||
}
|
||||
return withLore(legacy);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MessageUtils {
|
||||
|
||||
@NotNull
|
||||
public static String replaceVariables(String message, String... values) {
|
||||
@NotNull public static String replaceVariables(String message, String... values) {
|
||||
String modifiedMessage = message;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (values.length > i) modifiedMessage = modifiedMessage.replaceAll("%" + i, values[i]);
|
||||
@@ -18,8 +17,7 @@ public class MessageUtils {
|
||||
return modifiedMessage;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String setPapi(Player player, String message) {
|
||||
@NotNull public static String setPapi(Player player, String message) {
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
return PlaceholderAPI.setPlaceholders(player, message);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class TranslationsTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void translationTest() {
|
||||
Reflections reflections = new Reflections("lang/", new ResourcesScanner());
|
||||
|
||||
Reference in New Issue
Block a user