9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-26 18:29:16 +00:00

Remove usage of XMaterial, shadow apache commons

This commit is contained in:
SamB440
2021-07-09 18:53:25 +01:00
parent d660c008ca
commit e9120be874
11 changed files with 50 additions and 2119 deletions

View File

@@ -1,6 +1,6 @@
package net.islandearth.rpgregions.editor.annotate;
import net.islandearth.rpgregions.utils.XMaterial;
import org.bukkit.Material;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -15,7 +15,7 @@ import java.lang.annotation.Target;
@Deprecated
public @interface EditableField {
XMaterial material() default XMaterial.OAK_SIGN;
Material material() default Material.OAK_SIGN;
String name();

View File

@@ -2,8 +2,8 @@ package net.islandearth.rpgregions.editor.field;
import net.islandearth.rpgregions.editor.annotate.EditableField;
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
import net.islandearth.rpgregions.utils.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -16,7 +16,7 @@ public class EditField {
private final ConfiguredRegion clazz;
private final Field field;
private final XMaterial material;
private final Material material;
private final String name;
private final String description;
@@ -34,7 +34,7 @@ public class EditField {
return field;
}
public XMaterial getMaterial() {
public Material getMaterial() {
return material;
}

View File

@@ -11,11 +11,11 @@ import net.islandearth.rpgregions.regenerate.Regenerate;
import net.islandearth.rpgregions.requirements.RegionRequirement;
import net.islandearth.rpgregions.rewards.DiscoveryReward;
import net.islandearth.rpgregions.translation.Translations;
import net.islandearth.rpgregions.utils.XMaterial;
import net.islandearth.rpgregions.utils.XSound;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -41,7 +41,7 @@ public class ConfiguredRegion {
private final UUID world;
private final String id;
@EditableField(material = XMaterial.NAME_TAG, name = "Set name", description = "Set the display name of the region")
@EditableField(material = Material.NAME_TAG, name = "Set name", description = "Set the display name of the region")
private String customName;
private final List<DiscoveryReward> rewards;
private Sound sound;
@@ -50,7 +50,7 @@ public class ConfiguredRegion {
private final List<IconCommand> iconCommand;
@EditableField(description = "Toggle whether the coordinates of the region are shown", name = "Toggle coordinates")
private final boolean showCoords;
@EditableField(material = XMaterial.ENDER_PEARL, name = "Set teleport location", description = "Set the teleport location to your current location")
@EditableField(material = Material.ENDER_PEARL, name = "Set teleport location", description = "Set the teleport location to your current location")
private Location location;
private final List<String> hints;
@EditableField(description = "Toggle whether the hint is shown", name = "Toggle hint")
@@ -71,10 +71,10 @@ public class ConfiguredRegion {
private List<String> discoveredTitle;
private List<String> discoveredSubtitle;
private Regenerate regenerate;
@EditableField(material = XMaterial.NETHER_STAR, name = "Set teleport cooldown", description = "Set the cooldown for teleportation")
@EditableField(material = Material.NETHER_STAR, name = "Set teleport cooldown", description = "Set the cooldown for teleportation")
private int teleportCooldown;
private boolean showActionbar;
@EditableField(material = XMaterial.RED_DYE, name = "Hex display colour", description = "Set the colour of the region. It is a hex colour (e.g 0x42f4f1 for red) and is used in dynmap.")
@EditableField(material = Material.RED_DYE, name = "Hex display colour", description = "Set the colour of the region. It is a hex colour (e.g 0x42f4f1 for red) and is used in dynmap.")
private final String colour;
private final String lineColour;
private final boolean dynmap;
@@ -86,9 +86,9 @@ public class ConfiguredRegion {
this.customName = customName;
this.rewards = rewards;
this.sound = XSound.UI_TOAST_CHALLENGE_COMPLETE.parseSound();
Optional<XMaterial> defaultIcon = XMaterial.matchXMaterial(RPGRegionsAPI.getAPI().getConfig().getString("settings.server.gui.default_region_icon"));
this.icon = defaultIcon.map(Enum::name).orElseGet(XMaterial.TOTEM_OF_UNDYING::name);
this.undiscoveredIcon = defaultIcon.map(Enum::name).orElseGet(XMaterial.TOTEM_OF_UNDYING::name);
Optional<Material> defaultIcon = Optional.of(Material.valueOf(RPGRegionsAPI.getAPI().getConfig().getString("settings.server.gui.default_region_icon")));
this.icon = defaultIcon.map(Enum::name).orElseGet(Material.TOTEM_OF_UNDYING::name);
this.undiscoveredIcon = defaultIcon.map(Enum::name).orElseGet(Material.TOTEM_OF_UNDYING::name);
this.iconCommand = new ArrayList<>();
this.showCoords = false;
this.hints = new ArrayList<>();
@@ -108,7 +108,7 @@ public class ConfiguredRegion {
}
public ConfiguredRegion(@Nullable World world, String id, String customName,
List<DiscoveryReward> rewards, List<RegionEffect> effects, Sound sound, XMaterial icon) {
List<DiscoveryReward> rewards, List<RegionEffect> effects, Sound sound, Material icon) {
this(world, id, customName, rewards, effects);
this.sound = sound;
this.icon = icon.name();
@@ -138,23 +138,23 @@ public class ConfiguredRegion {
@Nullable
public ItemStack getIcon() {
if (icon == null) return new ItemStack(XMaterial.TOTEM_OF_UNDYING.parseMaterial(true));
if (icon == null) return new ItemStack(Material.TOTEM_OF_UNDYING);
if (icon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStack(new HeadDatabaseAPI().getItemHead(icon.replace("hdb-", "")));
return XMaterial.valueOf(icon).parseItem(true);
return new ItemStack(Material.valueOf(icon));
}
public void setIcon(@NotNull XMaterial material) {
public void setIcon(@NotNull Material material) {
this.icon = material.name();
}
@Nullable
public ItemStack getUndiscoveredIcon() {
if (undiscoveredIcon == null) return new ItemStack(XMaterial.TOTEM_OF_UNDYING.parseMaterial(true));
if (undiscoveredIcon == null) return new ItemStack(Material.TOTEM_OF_UNDYING);
if (undiscoveredIcon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStack(new HeadDatabaseAPI().getItemHead(undiscoveredIcon.replace("hdb-", "")));
return XMaterial.valueOf(undiscoveredIcon).parseItem(true);
return new ItemStack(Material.valueOf(undiscoveredIcon));
}
public void setUndiscoveredIcon(@NotNull XMaterial material) {
public void setUndiscoveredIcon(@NotNull Material material) {
this.undiscoveredIcon = material.name();
}

View File

@@ -69,6 +69,7 @@ tasks.shadowJar {
relocate 'org.bstats', 'net.islandearth.rpgregions.libs.bstats'
relocate 'io.papermc.lib', 'net.islandearth.rpgregions.libs.paperlib'
relocate 'net.wesjd', 'net.islandearth.rpgregions.libs.anvilgui'
relocate 'org.apache.commons', 'net.islandearth.libs.commons'
}
tasks.withType(JavaCompile).configureEach {

View File

@@ -56,6 +56,7 @@ dependencies {
implementation 'org.bstats:bstats-bukkit:2.2.1' // plugin stats
implementation 'io.papermc:paperlib:1.0.4' // paperlib - async teleport on Paper
implementation 'com.zaxxer:HikariCP:2.4.1' //todo remove in future in favour of libraries in plugin.yml
implementation 'org.apache.commons:commons-lang3:3.12.0'
compileOnly ('com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT') {
exclude group: 'com.destroystokyo.paper'
@@ -76,7 +77,9 @@ dependencies {
compileOnly name: 'Quests-4.0.1' // quests
compileOnly 'com.github.shynixn.headdatabase:hdb-api:1.0' // head database
compileOnly 'com.github.plan-player-analytics:Plan:5.3.1284' // plan
compileOnly 'io.lumine.xikage:MythicMobs:4.9.1'
compileOnly ('io.lumine.xikage:MythicMobs:4.9.1') {
exclude group: 'org.apache.commons'
}
compileOnly name: 'Dynmap-3.1-spigot' // Dynmap
compileOnly 'org.jetbrains:annotations:20.1.0'

View File

@@ -53,13 +53,13 @@ import net.islandearth.rpgregions.rewards.RegionRewardRegistry;
import net.islandearth.rpgregions.rewards.TeleportReward;
import net.islandearth.rpgregions.tasks.DynmapTask;
import net.islandearth.rpgregions.translation.Translations;
import net.islandearth.rpgregions.utils.XMaterial;
import net.islandearth.rpgregions.utils.XSound;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@@ -183,7 +183,7 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, Lang
config.addDefault("settings.server.discoveries.discovered.sound.pitch", 1);
config.addDefault("settings.server.discoveries.discovered.title.animation_speed", 20);
config.addDefault("settings.server.discoveries.discovered.title.cooldown", 0);
config.addDefault("settings.server.gui.default_region_icon", XMaterial.TOTEM_OF_UNDYING.name());
config.addDefault("settings.server.gui.default_region_icon", Material.TOTEM_OF_UNDYING.name());
config.addDefault("settings.server.gui.general.rows", 6);
config.addDefault("settings.server.gui.back.posX", 0);
config.addDefault("settings.server.gui.back.posY", 5);
@@ -225,11 +225,11 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, Lang
"1111111",
"1111111",
"1111111"));
config.addDefault("settings.server.gui.forward.forward", XMaterial.ARROW.name());
config.addDefault("settings.server.gui.back.back", XMaterial.ARROW.name());
config.addDefault("settings.server.gui.exit.exit", XMaterial.BARRIER.name());
config.addDefault("settings.server.gui.outlinePane.outlinePane", XMaterial.GRAY_STAINED_GLASS_PANE.name());
config.addDefault("settings.server.gui.innerPane.innerPane", XMaterial.WHITE_STAINED_GLASS_PANE.name());
config.addDefault("settings.server.gui.forward.forward", Material.ARROW.name());
config.addDefault("settings.server.gui.back.back", Material.ARROW.name());
config.addDefault("settings.server.gui.exit.exit", Material.BARRIER.name());
config.addDefault("settings.server.gui.outlinePane.outlinePane", Material.GRAY_STAINED_GLASS_PANE.name());
config.addDefault("settings.server.gui.innerPane.innerPane", Material.WHITE_STAINED_GLASS_PANE.name());
config.addDefault("settings.server.worlds.forceload", false);
config.options().copyDefaults(true);
saveConfig();
@@ -329,7 +329,7 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, Lang
@Override
public void onLanguagyHook() {
translator.setDisplay(XMaterial.MAP.parseMaterial());
translator.setDisplay(Material.MAP);
}
@Override

View File

@@ -18,10 +18,10 @@ import net.islandearth.rpgregions.regenerate.Regenerate;
import net.islandearth.rpgregions.rewards.ItemReward;
import net.islandearth.rpgregions.utils.RegenUtils;
import net.islandearth.rpgregions.utils.StringUtils;
import net.islandearth.rpgregions.utils.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -308,7 +308,7 @@ public class RPGRegionsCommand extends BaseCommand {
@Subcommand("forceupdateicons")
@CommandPermission("rpgregions.forceupdate")
public void onForceUpdateIcons(Player player) {
Optional<XMaterial> defaultIcon = XMaterial.matchXMaterial(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 -> {
plugin.getManagers().getRegionsCache().getConfiguredRegions().forEach((name, region) -> {
region.setUndiscoveredIcon(xMaterial);

View File

@@ -18,9 +18,9 @@ import net.islandearth.rpgregions.requirements.RegionRequirement;
import net.islandearth.rpgregions.translation.Translations;
import net.islandearth.rpgregions.utils.ItemStackBuilder;
import net.islandearth.rpgregions.utils.StringUtils;
import net.islandearth.rpgregions.utils.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@@ -58,8 +58,8 @@ public class DiscoveryGUI extends RPGRegionsGUI {
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))
innerPane.addItem(new GuiItem(new ItemStackBuilder(Material.valueOf(
plugin.getConfig().getString("settings.server.gui.innerPane.innerPane")))
.withName(" ")
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
.build()));
@@ -74,8 +74,8 @@ public class DiscoveryGUI extends RPGRegionsGUI {
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))
oPane.addItem(new GuiItem(new ItemStackBuilder(Material.valueOf(
plugin.getConfig().getString("settings.server.gui.outlinePane.outlinePane")))
.withName(" ")
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
.build()));
@@ -93,8 +93,8 @@ public class DiscoveryGUI extends RPGRegionsGUI {
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
.build()
:
new ItemStackBuilder(XMaterial.matchXMaterial(
plugin.getConfig().getString("settings.server.gui.back.back")).get().parseItem(true))
new ItemStackBuilder(Material.valueOf(
plugin.getConfig().getString("settings.server.gui.back.back")))
.withName(Translations.PREVIOUS_PAGE.get(player))
.withLore(Translations.PREVIOUS_PAGE_LORE.getList(player))
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
@@ -120,8 +120,8 @@ public class DiscoveryGUI extends RPGRegionsGUI {
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
.build()
:
new ItemStackBuilder(XMaterial.matchXMaterial(
plugin.getConfig().getString("settings.server.gui.forward.forward")).get().parseItem(true))
new ItemStackBuilder(Material.valueOf(
plugin.getConfig().getString("settings.server.gui.forward.forward")))
.withName(Translations.NEXT_PAGE.get(player))
.withLore(Translations.NEXT_PAGE_LORE.getList(player))
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
@@ -148,8 +148,8 @@ public class DiscoveryGUI extends RPGRegionsGUI {
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
.build()
:
new ItemStackBuilder(XMaterial.matchXMaterial(
plugin.getConfig().getString("settings.server.gui.exit.exit")).get().parseItem(true))
new ItemStackBuilder(Material.valueOf(
plugin.getConfig().getString("settings.server.gui.exit.exit")))
.withName(Translations.EXIT.get(player))
.withLore(Translations.EXIT_LORE.getList(player))
.addFlags(ItemFlag.HIDE_ATTRIBUTES)

View File

@@ -5,9 +5,9 @@ import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
import com.github.stefvanschie.inventoryframework.pane.StaticPane;
import net.islandearth.rpgregions.gui.IGuiEditable;
import net.islandearth.rpgregions.utils.ItemStackBuilder;
import net.islandearth.rpgregions.utils.XMaterial;
import org.apache.commons.lang.reflect.FieldUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -23,7 +23,7 @@ public class ItemStackGuiFieldElement implements IGuiFieldElement {
CompletableFuture<Void> completableFuture = new CompletableFuture<>();
ChestGui gui = new ChestGui(1, "Inventory");
StaticPane pane = new StaticPane(4, 0, 1, 1);
ItemStack info = new ItemStackBuilder(XMaterial.OAK_SIGN.parseMaterial(true))
ItemStack info = new ItemStackBuilder(Material.OAK_SIGN)
.withName("&6Information")
.withLore("&7Click on an item in your inventory below to set the value.",
"&7You are editing: " + field.getName() + ".")

View File

@@ -34,7 +34,6 @@ import net.islandearth.rpgregions.rewards.MessageReward;
import net.islandearth.rpgregions.rewards.PlayerCommandReward;
import net.islandearth.rpgregions.rewards.RegionRewardRegistry;
import net.islandearth.rpgregions.utils.ItemStackBuilder;
import net.islandearth.rpgregions.utils.XMaterial;
import net.islandearth.rpgregions.utils.XSound;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -97,7 +96,7 @@ public class RPGRegionsManagers implements IRPGRegionsManagers {
// Generate an example config
List<DiscoveryReward> rewards = new ArrayList<>();
rewards.add(new ExperienceReward(plugin, 10));
rewards.add(new ItemReward(plugin, new ItemStack(XMaterial.IRON_BARS.parseMaterial())));
rewards.add(new ItemReward(plugin, new ItemStack(Material.IRON_BARS)));
rewards.add(new PlayerCommandReward(plugin, "say I discovered a region!"));
rewards.add(new ConsoleCommandReward(plugin, "say Server sees you discovered a region!"));
rewards.add(new MessageReward(plugin, Collections.singletonList("&aExample message as a reward")));
@@ -109,7 +108,7 @@ public class RPGRegionsManagers implements IRPGRegionsManagers {
ConfiguredRegion configuredRegion = new ConfiguredRegion(null, "exampleconfig", "ExampleConfig", rewards, effects,
XSound.AMBIENT_UNDERWATER_EXIT.parseSound(),
XMaterial.WOODEN_AXE);
Material.WOODEN_AXE);
configuredRegion.setRegenerate(new Regenerate(50000,
false,
Collections.singletonList(