mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-21 15:59:18 +00:00
Update to 1.17, improvements to error handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module external.linked.project.id="RPGRegions" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="net.islandearth" external.system.module.version="1.3.8" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id="RPGRegions" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="net.islandearth" external.system.module.version="1.3.9" type="JAVA_MODULE" version="4">
|
||||||
<component name="ExternalSystem" externalSystem="GRADLE" externalSystemModuleGroup="net.islandearth" externalSystemModuleVersion="1.3.3" linkedProjectId="RPGRegions" linkedProjectPath="$MODULE_DIR$" rootProjectPath="$MODULE_DIR$" />
|
<component name="ExternalSystem" externalSystem="GRADLE" externalSystemModuleGroup="net.islandearth" externalSystemModuleVersion="1.3.3" linkedProjectId="RPGRegions" linkedProjectPath="$MODULE_DIR$" rootProjectPath="$MODULE_DIR$" />
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_16" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ dependencies {
|
|||||||
implementation 'com.gitlab.samb440:languagy:2.0.3-RELEASE' // languagy
|
implementation 'com.gitlab.samb440:languagy:2.0.3-RELEASE' // languagy
|
||||||
implementation 'io.papermc:paperlib:1.0.4' // paperlib - async teleport on Paper
|
implementation 'io.papermc:paperlib:1.0.4' // paperlib - async teleport on Paper
|
||||||
|
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT' // spigot
|
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT' // spigot
|
||||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7' // vault
|
compileOnly 'com.github.MilkBowl:VaultAPI:1.7' // vault
|
||||||
compileOnly 'me.clip:placeholderapi:2.10.4' // PAPI
|
compileOnly 'me.clip:placeholderapi:2.10.4' // PAPI
|
||||||
compileOnly name: 'AlonsoLevels_v2.0-BETA' // alonsolevels
|
compileOnly name: 'AlonsoLevels_v2.0-BETA' // alonsolevels
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ public enum IntegrationType {
|
|||||||
if (plugin.getManagers() != null && plugin.getManagers().getIntegrationManager() != null) throw new UnsupportedOperationException("IntegrationManager already loaded");
|
if (plugin.getManagers() != null && plugin.getManagers().getIntegrationManager() != null) throw new UnsupportedOperationException("IntegrationManager already loaded");
|
||||||
plugin.getLogger().info("Loading IntegrationManager implementation...");
|
plugin.getLogger().info("Loading IntegrationManager implementation...");
|
||||||
if (Bukkit.getPluginManager().getPlugin(this.plugin) == null) {
|
if (Bukkit.getPluginManager().getPlugin(this.plugin) == null) {
|
||||||
plugin.getLogger().severe("Unable to load IntegrationManager. The requested plugin is not enabled.");
|
|
||||||
Bukkit.getPluginManager().disablePlugin((JavaPlugin) plugin);
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ plugins {
|
|||||||
group = pluginGroup
|
group = pluginGroup
|
||||||
version = pluginVersion
|
version = pluginVersion
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
java.sourceCompatibility = JavaVersion.VERSION_16
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
java.targetCompatibility = JavaVersion.VERSION_16
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
pluginGroup=net.islandearth
|
pluginGroup=net.islandearth
|
||||||
pluginVersion=1.3.8
|
pluginVersion=1.3.9
|
||||||
# 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
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ dependencies {
|
|||||||
exclude group: 'com.destroystokyo.paper'
|
exclude group: 'com.destroystokyo.paper'
|
||||||
exclude group: 'org.spigotmc'
|
exclude group: 'org.spigotmc'
|
||||||
}
|
}
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT' // spigot
|
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT' // spigot
|
||||||
compileOnly name: 'Residence4.9.2.2' // residence
|
compileOnly name: 'Residence4.9.2.2' // residence
|
||||||
compileOnly name: 'GriefPrevention' // griefprevention
|
compileOnly name: 'GriefPrevention' // griefprevention
|
||||||
if (ultraRegionsSupport) compileOnly name: 'UltraRegions' // ultraregions
|
if (ultraRegionsSupport) compileOnly name: 'UltraRegions' // ultraregions
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ plugins {
|
|||||||
id 'java'
|
id 'java'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group = pluginGroup
|
||||||
|
version = pluginVersion
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
@@ -47,7 +50,7 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation group: 'junit', name: 'junit', version: '4.5'
|
testImplementation group: 'junit', name: 'junit', version: '4.5'
|
||||||
testImplementation 'com.github.seeseemelk:MockBukkit-v1.15:0.3.0-SNAPSHOT'
|
testImplementation 'com.github.seeseemelk:MockBukkit-v1.16:1.0.0'
|
||||||
testImplementation 'org.reflections:reflections:0.9.12'
|
testImplementation 'org.reflections:reflections:0.9.12'
|
||||||
|
|
||||||
implementation 'com.github.WesJD.AnvilGUI:anvilgui:bb60945f7a' // anvilgui
|
implementation 'com.github.WesJD.AnvilGUI:anvilgui:bb60945f7a' // anvilgui
|
||||||
@@ -69,7 +72,7 @@ dependencies {
|
|||||||
exclude group: 'org.bukkit'
|
exclude group: 'org.bukkit'
|
||||||
exclude group: 'org.spigotmc'
|
exclude group: 'org.spigotmc'
|
||||||
}
|
}
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT' // spigot
|
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT' // spigot
|
||||||
compileOnly 'me.clip:placeholderapi:2.10.4' // PAPI
|
compileOnly 'me.clip:placeholderapi:2.10.4' // PAPI
|
||||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7' // vault
|
compileOnly 'com.github.MilkBowl:VaultAPI:1.7' // vault
|
||||||
compileOnly name: 'AlonsoLevels_v2.0-BETA' // alonsolevels
|
compileOnly name: 'AlonsoLevels_v2.0-BETA' // alonsolevels
|
||||||
@@ -90,3 +93,10 @@ javadoc {
|
|||||||
exclude 'net/islandearth/rpgregions/commands/**'
|
exclude 'net/islandearth/rpgregions/commands/**'
|
||||||
exclude 'net/islandearth/rpgregions/utils/**'
|
exclude 'net/islandearth/rpgregions/utils/**'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import org.apache.tools.ant.filters.ReplaceTokens
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
filter ReplaceTokens, tokens: [version: version]
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import net.islandearth.rpgregions.commands.RPGRegionsDebugCommand;
|
|||||||
import net.islandearth.rpgregions.effects.PotionRegionEffect;
|
import net.islandearth.rpgregions.effects.PotionRegionEffect;
|
||||||
import net.islandearth.rpgregions.effects.RegionEffect;
|
import net.islandearth.rpgregions.effects.RegionEffect;
|
||||||
import net.islandearth.rpgregions.effects.RegionEffectRegistry;
|
import net.islandearth.rpgregions.effects.RegionEffectRegistry;
|
||||||
|
import net.islandearth.rpgregions.exception.CouldNotStartException;
|
||||||
import net.islandearth.rpgregions.gson.AbstractAdapter;
|
import net.islandearth.rpgregions.gson.AbstractAdapter;
|
||||||
import net.islandearth.rpgregions.gson.ItemStackAdapter;
|
import net.islandearth.rpgregions.gson.ItemStackAdapter;
|
||||||
import net.islandearth.rpgregions.gson.LocationAdapter;
|
import net.islandearth.rpgregions.gson.LocationAdapter;
|
||||||
@@ -98,9 +99,8 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, Lang
|
|||||||
this.generateLang();
|
this.generateLang();
|
||||||
try {
|
try {
|
||||||
this.managers = new RPGRegionsManagers(this);
|
this.managers = new RPGRegionsManagers(this);
|
||||||
} catch (ReflectiveOperationException | IOException e) {
|
} catch (ReflectiveOperationException | IOException | CouldNotStartException e) {
|
||||||
getLogger().severe("Error starting managers: ");
|
getLogger().log(Level.SEVERE, "Error starting managers, please report this!", e);
|
||||||
e.printStackTrace();
|
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package net.islandearth.rpgregions.exception;
|
||||||
|
|
||||||
|
public class CouldNotStartException extends Exception {
|
||||||
|
|
||||||
|
public CouldNotStartException(final String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,248 +0,0 @@
|
|||||||
package net.islandearth.rpgregions.gui;
|
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
|
||||||
import com.github.stefvanschie.inventoryframework.pane.OutlinePane;
|
|
||||||
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
|
||||||
import com.github.stefvanschie.inventoryframework.pane.StaticPane;
|
|
||||||
import com.github.stefvanschie.inventoryframework.pane.util.Mask;
|
|
||||||
import me.arcaniax.hdb.api.HeadDatabaseAPI;
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
|
||||||
import net.islandearth.rpgregions.editor.ClassEditor;
|
|
||||||
import net.islandearth.rpgregions.editor.field.EditField;
|
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
|
||||||
import net.islandearth.rpgregions.translation.Translations;
|
|
||||||
import net.islandearth.rpgregions.utils.ItemStackBuilder;
|
|
||||||
import net.islandearth.rpgregions.utils.XMaterial;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.wesjd.anvilgui.AnvilGUI;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated It is preferable to use the new RegionCreateGUI class.
|
|
||||||
* This will be removed in version 1.3.6.
|
|
||||||
* @see net.islandearth.rpgregions.gui.RegionCreateGUI
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class EditorGUI extends RPGRegionsGUI {
|
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
|
||||||
private final Player player;
|
|
||||||
private final ConfiguredRegion region;
|
|
||||||
private final ChestGui gui;
|
|
||||||
|
|
||||||
public EditorGUI(RPGRegions plugin, Player player, ConfiguredRegion region) {
|
|
||||||
super(plugin, player);
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.player = player;
|
|
||||||
this.region = region;
|
|
||||||
this.gui = new ChestGui(6, region.getCustomName());
|
|
||||||
gui.setOnGlobalClick(click -> click.setCancelled(true));
|
|
||||||
|
|
||||||
ClassEditor classEditor = new ClassEditor(region);
|
|
||||||
PaginatedPane pane = new PaginatedPane(paneX, paneY, paneL, paneH);
|
|
||||||
OutlinePane oPane = new OutlinePane(oPaneX, oPaneY, oPaneL, oPaneH);
|
|
||||||
OutlinePane innerPane = new OutlinePane(iPaneX, iPaneY, iPaneL, iPaneH);
|
|
||||||
StaticPane back = new StaticPane(backX, backY, backL, backH);
|
|
||||||
StaticPane forward = new StaticPane(forwardX, forwardY, forwardL, forwardH);
|
|
||||||
StaticPane exit = new StaticPane(exitX, exitY, exitL, exitH);
|
|
||||||
|
|
||||||
// Inner pane
|
|
||||||
if (plugin.getConfig().getBoolean("settings.server.gui.innerPane.show")) {
|
|
||||||
innerPane.setRepeat(true);
|
|
||||||
List<String> mask = plugin.getConfig().getStringList("settings.server.gui.innerPane.mask");
|
|
||||||
innerPane.applyMask(new Mask(mask.toArray(new String[]{})));
|
|
||||||
innerPane.setOnClick(inventoryClickEvent -> inventoryClickEvent.setCancelled(true));
|
|
||||||
|
|
||||||
innerPane.addItem(new GuiItem(new ItemStackBuilder(XMaterial.matchXMaterial(
|
|
||||||
plugin.getConfig().getString("settings.server.gui.innerPane.innerPane")).get().parseItem(true))
|
|
||||||
.withName(" ")
|
|
||||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
|
||||||
.build()));
|
|
||||||
|
|
||||||
gui.addPane(innerPane);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Outline pane
|
|
||||||
if (plugin.getConfig().getBoolean("settings.server.gui.outlinePane.show")) {
|
|
||||||
oPane.setRepeat(true);
|
|
||||||
List<String> mask = plugin.getConfig().getStringList("settings.server.gui.outlinePane.mask");
|
|
||||||
oPane.applyMask(new Mask(mask.toArray(new String[]{})));
|
|
||||||
oPane.setOnClick(inventoryClickEvent -> inventoryClickEvent.setCancelled(true));
|
|
||||||
|
|
||||||
oPane.addItem(new GuiItem(new ItemStackBuilder(XMaterial.matchXMaterial(
|
|
||||||
plugin.getConfig().getString("settings.server.gui.outlinePane.outlinePane")).get().parseItem(true))
|
|
||||||
.withName(" ")
|
|
||||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
|
||||||
.build()));
|
|
||||||
|
|
||||||
gui.addPane(oPane);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Back item
|
|
||||||
String bm = plugin.getConfig().getString("settings.server.gui.back.back");
|
|
||||||
ItemStack backItem = bm.startsWith("hdb-") && plugin.hasHeadDatabase()
|
|
||||||
?
|
|
||||||
new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(bm.replace("hdb-", "")))
|
|
||||||
.withName(Translations.PREVIOUS_PAGE.get(player))
|
|
||||||
.withLore(Translations.PREVIOUS_PAGE_LORE.getList(player))
|
|
||||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
|
||||||
.build()
|
|
||||||
:
|
|
||||||
new ItemStackBuilder(XMaterial.matchXMaterial(
|
|
||||||
plugin.getConfig().getString("settings.server.gui.back.back")).get().parseItem(true))
|
|
||||||
.withName(Translations.PREVIOUS_PAGE.get(player))
|
|
||||||
.withLore(Translations.PREVIOUS_PAGE_LORE.getList(player))
|
|
||||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
back.addItem(new GuiItem(backItem, event -> {
|
|
||||||
event.setCancelled(true);
|
|
||||||
if (pane.getPages() == 0 || pane.getPages() == 1) return;
|
|
||||||
|
|
||||||
pane.setPage(pane.getPage() - 1);
|
|
||||||
|
|
||||||
forward.setVisible(true);
|
|
||||||
gui.update();
|
|
||||||
}), 0, 0);
|
|
||||||
|
|
||||||
// Forward item
|
|
||||||
String fm = plugin.getConfig().getString("settings.server.gui.forward.forward");
|
|
||||||
ItemStack forwardItem = fm.startsWith("hdb-") && plugin.hasHeadDatabase()
|
|
||||||
?
|
|
||||||
new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(fm.replace("hdb-", "")))
|
|
||||||
.withName(Translations.NEXT_PAGE.get(player))
|
|
||||||
.withLore(Translations.NEXT_PAGE_LORE.getList(player))
|
|
||||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
|
||||||
.build()
|
|
||||||
:
|
|
||||||
new ItemStackBuilder(XMaterial.matchXMaterial(
|
|
||||||
plugin.getConfig().getString("settings.server.gui.forward.forward")).get().parseItem(true))
|
|
||||||
.withName(Translations.NEXT_PAGE.get(player))
|
|
||||||
.withLore(Translations.NEXT_PAGE_LORE.getList(player))
|
|
||||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
forward.addItem(new GuiItem(forwardItem, event -> {
|
|
||||||
event.setCancelled(true);
|
|
||||||
if (pane.getPages() == 0 || pane.getPages() == 1) return;
|
|
||||||
|
|
||||||
pane.setPage(pane.getPage() + 1);
|
|
||||||
|
|
||||||
back.setVisible(true);
|
|
||||||
gui.update();
|
|
||||||
}), 0, 0);
|
|
||||||
|
|
||||||
// Exit item
|
|
||||||
if (plugin.getConfig().getBoolean("settings.server.gui.exit.show")) {
|
|
||||||
String em = plugin.getConfig().getString("settings.server.gui.exit.exit");
|
|
||||||
ItemStack item = em.startsWith("hdb-") && plugin.hasHeadDatabase()
|
|
||||||
?
|
|
||||||
new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(em.replace("hdb-", "")))
|
|
||||||
.withName(Translations.EXIT.get(player))
|
|
||||||
.withLore(Translations.EXIT_LORE.getList(player))
|
|
||||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
|
||||||
.build()
|
|
||||||
:
|
|
||||||
new ItemStackBuilder(XMaterial.matchXMaterial(
|
|
||||||
plugin.getConfig().getString("settings.server.gui.exit.exit")).get().parseItem(true))
|
|
||||||
.withName(Translations.EXIT.get(player))
|
|
||||||
.withLore(Translations.EXIT_LORE.getList(player))
|
|
||||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
|
||||||
.build();
|
|
||||||
exit.addItem(new GuiItem(item, event -> {
|
|
||||||
event.setCancelled(true);
|
|
||||||
gui.update();
|
|
||||||
player.closeInventory();
|
|
||||||
String command = plugin.getConfig().getString("settings.server.gui.exit.command");
|
|
||||||
if (!command.isEmpty()) player.performCommand(command
|
|
||||||
.replace("%player%", player.getName()));
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Saving data...");
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
region.save(plugin);
|
|
||||||
long endTime = System.currentTimeMillis();
|
|
||||||
long totalTime = endTime - startTime;
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Done! (" + totalTime + "ms)");
|
|
||||||
}), 0, 0);
|
|
||||||
|
|
||||||
gui.addPane(exit);
|
|
||||||
}
|
|
||||||
|
|
||||||
gui.addPane(back);
|
|
||||||
gui.addPane(forward);
|
|
||||||
|
|
||||||
List<GuiItem> guiItems = new ArrayList<>();
|
|
||||||
for (EditField editField : classEditor.getEditable()) {
|
|
||||||
ItemStack itemStack = new ItemStackBuilder(editField.getMaterial().parseMaterial(true))
|
|
||||||
.withName(ChatColor.GREEN + editField.getName())
|
|
||||||
.withLore(Arrays.asList(ChatColor.WHITE + editField.getDescription(),
|
|
||||||
ChatColor.GRAY + editField.getValue().getClass().getSimpleName().toLowerCase()))
|
|
||||||
.build();
|
|
||||||
if (editField.getValue() instanceof Boolean) {
|
|
||||||
Boolean bool = (Boolean) editField.getValue();
|
|
||||||
if (bool) {
|
|
||||||
itemStack.setType(XMaterial.LIME_DYE.parseMaterial(true));
|
|
||||||
} else {
|
|
||||||
itemStack.setType(XMaterial.GRAY_DYE.parseMaterial(true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (editField.getField().get(region) instanceof Location) {
|
|
||||||
guiItems.add(new GuiItem(itemStack, event -> {
|
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(editField.setValue(player.getLocation())));
|
|
||||||
this.open();
|
|
||||||
}));
|
|
||||||
} else if (editField.getField().get(region) instanceof Boolean) {
|
|
||||||
Boolean bool = (Boolean) editField.getField().get(region);
|
|
||||||
guiItems.add(new GuiItem(itemStack, event -> {
|
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(editField.setValue(!bool)));
|
|
||||||
player.closeInventory();
|
|
||||||
new EditorGUI(plugin, player, region).open();
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
guiItems.add(new GuiItem(itemStack, event -> {
|
|
||||||
new AnvilGUI.Builder()
|
|
||||||
.onComplete((responder, text) -> {
|
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(editField.setValue(text)));
|
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, this::open, 20L);
|
|
||||||
return AnvilGUI.Response.close();
|
|
||||||
})
|
|
||||||
.preventClose()
|
|
||||||
.text(region.getCustomName())
|
|
||||||
.itemLeft(new ItemStack(Material.NAME_TAG))
|
|
||||||
.title("Set display name") // only works in 1.14+
|
|
||||||
.plugin(plugin)
|
|
||||||
.open(player);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pane.populateWithGuiItems(guiItems);
|
|
||||||
gui.addPane(pane);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChestGui getGui() {
|
|
||||||
return gui;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,6 +8,7 @@ import net.islandearth.rpgregions.command.IconCommand;
|
|||||||
import net.islandearth.rpgregions.effects.PotionRegionEffect;
|
import net.islandearth.rpgregions.effects.PotionRegionEffect;
|
||||||
import net.islandearth.rpgregions.effects.RegionEffect;
|
import net.islandearth.rpgregions.effects.RegionEffect;
|
||||||
import net.islandearth.rpgregions.effects.RegionEffectRegistry;
|
import net.islandearth.rpgregions.effects.RegionEffectRegistry;
|
||||||
|
import net.islandearth.rpgregions.exception.CouldNotStartException;
|
||||||
import net.islandearth.rpgregions.gui.element.BooleanGuiFieldElement;
|
import net.islandearth.rpgregions.gui.element.BooleanGuiFieldElement;
|
||||||
import net.islandearth.rpgregions.gui.element.GuiFieldElementRegistry;
|
import net.islandearth.rpgregions.gui.element.GuiFieldElementRegistry;
|
||||||
import net.islandearth.rpgregions.gui.element.IGuiFieldElementRegistry;
|
import net.islandearth.rpgregions.gui.element.IGuiFieldElementRegistry;
|
||||||
@@ -55,28 +56,34 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class RPGRegionsManagers implements IRPGRegionsManagers {
|
public class RPGRegionsManagers implements IRPGRegionsManagers {
|
||||||
|
|
||||||
private IStorageManager storageManager;
|
private IStorageManager storageManager;
|
||||||
private IntegrationManager integrationManager;
|
private final IntegrationManager integrationManager;
|
||||||
private final IRPGRegionsCache regionsCache;
|
private final IRPGRegionsCache regionsCache;
|
||||||
private final IRegenerationManager regenerationManager;
|
private final IRegenerationManager regenerationManager;
|
||||||
private final Map<Class<? extends RPGRegionsRegistry<?>>, RPGRegionsRegistry<?>> registry;
|
private final Map<Class<? extends RPGRegionsRegistry<?>>, RPGRegionsRegistry<?>> registry;
|
||||||
private final IGuiFieldElementRegistry guiFieldElementRegistry;
|
private final IGuiFieldElementRegistry guiFieldElementRegistry;
|
||||||
|
|
||||||
public RPGRegionsManagers(RPGRegions plugin) throws ReflectiveOperationException, IllegalStateException, IOException {
|
public RPGRegionsManagers(RPGRegions plugin) throws ReflectiveOperationException, CouldNotStartException, IOException {
|
||||||
StorageType.valueOf(plugin.getConfig().getString("settings.storage.mode").toUpperCase())
|
StorageType.valueOf(plugin.getConfig().getString("settings.storage.mode").toUpperCase())
|
||||||
.get()
|
.get()
|
||||||
.ifPresent(storageManager1 -> storageManager = storageManager1);
|
.ifPresent(storageManager1 -> storageManager = storageManager1);
|
||||||
if (storageManager == null) throw new IllegalStateException("Could not find StorageManager!");
|
if (storageManager == null) throw new CouldNotStartException("Could not find StorageManager!");
|
||||||
|
|
||||||
IntegrationType.valueOf(plugin.getConfig().getString("settings.integration.name").toUpperCase())
|
Optional<IntegrationManager> integrationManager = IntegrationType.valueOf(plugin.getConfig().getString("settings.integration.name").toUpperCase())
|
||||||
.get(plugin)
|
.get(plugin);
|
||||||
.ifPresent(integrationManager1 -> integrationManager = integrationManager1);
|
if (integrationManager.isPresent()) {
|
||||||
|
this.integrationManager = integrationManager.get();
|
||||||
|
} else {
|
||||||
|
throw new CouldNotStartException("Unable to load IntegrationManager. The requested plugin is not enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
this.regionsCache = new RPGRegionsCache(plugin);
|
this.regionsCache = new RPGRegionsCache(plugin);
|
||||||
this.registry = new ConcurrentHashMap<>();
|
this.registry = new ConcurrentHashMap<>();
|
||||||
@@ -121,9 +128,11 @@ public class RPGRegionsManagers implements IRPGRegionsManagers {
|
|||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
.forEach(path -> {
|
.forEach(path -> {
|
||||||
File file = path.toFile();
|
File file = path.toFile();
|
||||||
|
plugin.debug("Walking file tree: " + file);
|
||||||
if (regionsCache.getConfiguredRegions().containsKey(file.getName().replace(".json", ""))) {
|
if (regionsCache.getConfiguredRegions().containsKey(file.getName().replace(".json", ""))) {
|
||||||
plugin.getLogger().severe("Duplicate region files have been found for " + file.getName() + ". " +
|
plugin.getLogger().severe("Duplicate region files have been found for " + file.getName() + ". " +
|
||||||
"In order to protect your data, the plugin will NOT load the duplicate region config.");
|
"In order to protect your data, the plugin will NOT load the duplicate region config " +
|
||||||
|
"(which is " + file + ").");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Exclude non-json files
|
// Exclude non-json files
|
||||||
@@ -132,8 +141,7 @@ public class RPGRegionsManagers implements IRPGRegionsManagers {
|
|||||||
ConfiguredRegion region = plugin.getGson().fromJson(reader, ConfiguredRegion.class);
|
ConfiguredRegion region = plugin.getGson().fromJson(reader, ConfiguredRegion.class);
|
||||||
if (!region.getId().equals("exampleconfig")) regionsCache.addConfiguredRegion(region);
|
if (!region.getId().equals("exampleconfig")) regionsCache.addConfiguredRegion(region);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.getLogger().severe("Error loading region config " + file.getName() + ":");
|
plugin.getLogger().log(Level.SEVERE, "Error loading region config " + file.getName() + ".", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ public abstract class SQLCommonStorage implements IStorageManager {
|
|||||||
|
|
||||||
public SQLCommonStorage(RPGRegions plugin) {
|
public SQLCommonStorage(RPGRegions plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
include 'rpgregions'
|
include 'rpgregions'
|
||||||
include 'modern'
|
include 'modern'
|
||||||
include 'api'
|
include 'api'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user