mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-28 19:29:16 +00:00
Reduce repetitive GUI code
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package net.islandearth.rpgregions.editor.annotate;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Specifies that a field needs GUI implementation
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface NeedsGUI { }
|
||||
@@ -6,6 +6,8 @@ import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public final class RegionEffectRegistry extends RPGRegionsRegistry<RegionEffect> {
|
||||
|
||||
@@ -22,7 +24,7 @@ public final class RegionEffectRegistry extends RPGRegionsRegistry<RegionEffect>
|
||||
|
||||
@Override
|
||||
public String getRegistryName() {
|
||||
return "effects";
|
||||
return "Effects";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,6 +34,11 @@ public final class RegionEffectRegistry extends RPGRegionsRegistry<RegionEffect>
|
||||
|
||||
@Override
|
||||
public Material getIcon() {
|
||||
return Material.POTION;
|
||||
return Material.WRITABLE_BOOK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDescription() {
|
||||
return Arrays.asList("&7Effects that are present within a region.", "&e&lClick &7to edit region effects.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.command.IconCommand;
|
||||
import net.islandearth.rpgregions.editor.annotate.EditableField;
|
||||
import net.islandearth.rpgregions.editor.annotate.NeedsGUI;
|
||||
import net.islandearth.rpgregions.effects.RegionEffect;
|
||||
import net.islandearth.rpgregions.regenerate.Regenerate;
|
||||
import net.islandearth.rpgregions.requirements.RegionRequirement;
|
||||
@@ -40,31 +41,27 @@ public class ConfiguredRegion {
|
||||
|
||||
private final UUID world;
|
||||
private final String id;
|
||||
@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;
|
||||
private String icon;
|
||||
private String undiscoveredIcon;
|
||||
@NeedsGUI private Sound sound;
|
||||
@NeedsGUI private String icon;
|
||||
@NeedsGUI private String undiscoveredIcon;
|
||||
private final List<IconCommand> iconCommand;
|
||||
@EditableField(description = "Toggle whether the coordinates of the region are shown", name = "Toggle coordinates")
|
||||
private final boolean showCoords;
|
||||
@NeedsGUI private final boolean showCoords;
|
||||
@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;
|
||||
@NeedsGUI private Location location;
|
||||
@NeedsGUI private final List<String> hints;
|
||||
@EditableField(description = "Toggle whether the hint is shown", name = "Toggle hint")
|
||||
private final boolean showHint;
|
||||
@EditableField(description = "Toggle whether this region can be teleported to", name = "Toggle teleportable")
|
||||
@NeedsGUI private final boolean showHint;
|
||||
private boolean teleportable;
|
||||
@EditableField(name = "Toggle hidden", description = "Toggle whether this region is hidden")
|
||||
private boolean hidden;
|
||||
@EditableField(name = "Toggle discoverable", description = "Toggle whether this region can be discovered")
|
||||
private boolean discoverable;
|
||||
private final List<RegionEffect> effects;
|
||||
private final List<RegionRequirement> requirements;
|
||||
private final List<String> discoveredLore;
|
||||
@EditableField(description = "Toggle whether the title is always shown on entry after discovery", name = "Toggle always showing titles")
|
||||
private final boolean alwaysShowTitles;
|
||||
@NeedsGUI private final boolean alwaysShowTitles;
|
||||
private List<String> title;
|
||||
private List<String> subtitle;
|
||||
private List<String> discoveredTitle;
|
||||
@@ -72,11 +69,11 @@ public class ConfiguredRegion {
|
||||
private Regenerate regenerate;
|
||||
@EditableField(material = Material.NETHER_STAR, name = "Set teleport cooldown", description = "Set the cooldown for teleportation")
|
||||
private int teleportCooldown;
|
||||
private boolean showActionbar;
|
||||
@NeedsGUI private boolean showActionbar;
|
||||
@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;
|
||||
@NeedsGUI private final boolean dynmap;
|
||||
|
||||
public ConfiguredRegion(@Nullable World world, String id, String customName,
|
||||
List<DiscoveryReward> rewards, List<RegionEffect> effects) {
|
||||
|
||||
@@ -6,6 +6,8 @@ import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IRPGRegionsRegistry<T> {
|
||||
|
||||
@NotNull
|
||||
@@ -29,4 +31,6 @@ public interface IRPGRegionsRegistry<T> {
|
||||
Class<T> getImplementation();
|
||||
|
||||
Material getIcon();
|
||||
|
||||
List<String> getDescription();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -53,4 +54,9 @@ public abstract class RPGRegionsRegistry<T> implements IRPGRegionsRegistry<T> {
|
||||
|
||||
@Override
|
||||
public abstract Material getIcon();
|
||||
|
||||
@Override
|
||||
public List<String> getDescription() {
|
||||
return List.of("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public final class RegionRequirementRegistry extends RPGRegionsRegistry<RegionRequirement> {
|
||||
|
||||
@@ -28,7 +30,7 @@ public final class RegionRequirementRegistry extends RPGRegionsRegistry<RegionRe
|
||||
|
||||
@Override
|
||||
public String getRegistryName() {
|
||||
return "requirements";
|
||||
return "Requirements";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,6 +40,11 @@ public final class RegionRequirementRegistry extends RPGRegionsRegistry<RegionRe
|
||||
|
||||
@Override
|
||||
public Material getIcon() {
|
||||
return Material.REDSTONE;
|
||||
return Material.COMPARATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDescription() {
|
||||
return Arrays.asList("&7Requirements before a region can", "&7be entered by a player", "&e&lClick &7to edit region requirements.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public final class RegionRewardRegistry extends RPGRegionsRegistry<DiscoveryReward> {
|
||||
|
||||
@@ -28,7 +30,7 @@ public final class RegionRewardRegistry extends RPGRegionsRegistry<DiscoveryRewa
|
||||
|
||||
@Override
|
||||
public String getRegistryName() {
|
||||
return "rewards";
|
||||
return "Rewards";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,6 +40,11 @@ public final class RegionRewardRegistry extends RPGRegionsRegistry<DiscoveryRewa
|
||||
|
||||
@Override
|
||||
public Material getIcon() {
|
||||
return Material.GOLD_NUGGET;
|
||||
return Material.CHEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDescription() {
|
||||
return Arrays.asList("&7Rewards are granted upon region discovery", "&e&lClick &7to edit region rewards.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user