mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2026-01-04 15:31:38 +00:00
Add setting for default icon. Add command to force all regions to update icon to default.
This commit is contained in:
@@ -32,6 +32,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -45,7 +46,7 @@ public class ConfiguredRegion {
|
||||
private final List<DiscoveryReward> rewards;
|
||||
private Sound sound;
|
||||
private String icon;
|
||||
private final String undiscoveredIcon;
|
||||
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;
|
||||
@@ -80,8 +81,9 @@ public class ConfiguredRegion {
|
||||
this.customName = customName;
|
||||
this.rewards = rewards;
|
||||
this.sound = XSound.UI_TOAST_CHALLENGE_COMPLETE.parseSound();
|
||||
this.icon = XMaterial.TOTEM_OF_UNDYING.name();
|
||||
this.undiscoveredIcon = XMaterial.TOTEM_OF_UNDYING.name();
|
||||
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);
|
||||
this.iconCommand = new ArrayList<>();
|
||||
this.showCoords = false;
|
||||
this.hints = new ArrayList<>();
|
||||
@@ -132,6 +134,10 @@ public class ConfiguredRegion {
|
||||
return XMaterial.valueOf(icon).parseItem(true);
|
||||
}
|
||||
|
||||
public void setIcon(@NotNull XMaterial material) {
|
||||
this.icon = material.name();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getUndiscoveredIcon() {
|
||||
if (undiscoveredIcon == null) return new ItemStack(XMaterial.TOTEM_OF_UNDYING.parseMaterial(true));
|
||||
@@ -139,6 +145,10 @@ public class ConfiguredRegion {
|
||||
return XMaterial.valueOf(undiscoveredIcon).parseItem(true);
|
||||
}
|
||||
|
||||
public void setUndiscoveredIcon(@NotNull XMaterial material) {
|
||||
this.undiscoveredIcon = material.name();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<IconCommand> getIconCommand() {
|
||||
return iconCommand == null ? new ArrayList<>() : iconCommand;
|
||||
|
||||
@@ -140,6 +140,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.general.rows", 6);
|
||||
config.addDefault("settings.server.gui.back.posX", 0);
|
||||
config.addDefault("settings.server.gui.back.posY", 5);
|
||||
|
||||
@@ -9,6 +9,7 @@ import co.aikar.commands.annotation.Default;
|
||||
import co.aikar.commands.annotation.HelpCommand;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import net.islandearth.rpgregions.RPGRegions;
|
||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.api.integrations.IntegrationType;
|
||||
import net.islandearth.rpgregions.gui.DiscoveryGUI;
|
||||
import net.islandearth.rpgregions.gui.EditorGUI;
|
||||
@@ -18,6 +19,7 @@ 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;
|
||||
@@ -32,6 +34,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandAlias("rpgregions")
|
||||
@@ -39,7 +42,8 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
|
||||
private final RPGRegions plugin;
|
||||
private final List<UUID> regenerateConfirm = new ArrayList<>();
|
||||
private static final String WARNING_MESSAGE = ChatColor.RED + "" + ChatColor.ITALIC + "" + ChatColor.BOLD + "The regenerate configuration is very dangerous and can delete world sections if used wrongly.";
|
||||
private static final String WARNING_MESSAGE = ChatColor.RED + "" + ChatColor.ITALIC + "" + ChatColor.BOLD
|
||||
+ "The regenerate configuration is very dangerous and can delete world sections if used wrongly.";
|
||||
|
||||
public RPGRegionsCommand(RPGRegions plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -315,4 +319,17 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
player.sendMessage(ChatColor.GREEN + "The player " + target.getName() + " has had the discovery added.");
|
||||
});
|
||||
}
|
||||
|
||||
@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"));
|
||||
defaultIcon.ifPresent(xMaterial -> {
|
||||
plugin.getManagers().getRegionsCache().getConfiguredRegions().forEach((name, region) -> {
|
||||
region.setUndiscoveredIcon(xMaterial);
|
||||
region.setIcon(xMaterial);
|
||||
player.sendMessage(ChatColor.GREEN + "Updated icons for: " + name + ".");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user