mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-19 14:59:19 +00:00
Update dependencies, update colours and fix discovered lore not supporting minimessage
This commit is contained in:
@@ -6,16 +6,16 @@ dependencies {
|
||||
implementation("com.github.Redempt:Crunch:1.1.2") // used to evaluating mathematical expressions
|
||||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.19:2.141.0")
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.9.0")
|
||||
testImplementation("org.reflections:reflections:0.10.2")
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.ben-manes.caffeine:caffeine:3.1.7") { // IMPLEMENTED VIA LIBRARIES
|
||||
compileOnly("com.github.ben-manes.caffeine:caffeine:3.1.8") { // IMPLEMENTED VIA LIBRARIES
|
||||
exclude("org.checkerframework")
|
||||
}
|
||||
compileOnly("io.papermc:paperlib:1.0.4") // we include paperlib and relocate elsewhere
|
||||
compileOnly("io.papermc:paperlib:1.0.7") // we include paperlib and relocate elsewhere
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") // vault
|
||||
compileOnly("me.clip:placeholderapi:2.10.4") // PAPI
|
||||
compileOnly("me.clip:placeholderapi:2.11.3") // PAPI
|
||||
compileOnly("com.github.shynixn.headdatabase:hdb-api:1.0") // head database
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT") {
|
||||
exclude("com.destroystokyo.paper")
|
||||
|
||||
@@ -38,7 +38,6 @@ 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;
|
||||
|
||||
public class ConfiguredRegion {
|
||||
@@ -138,7 +137,6 @@ public class ConfiguredRegion {
|
||||
this.customName = customName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<DiscoveryReward> getRewards() {
|
||||
return rewards;
|
||||
}
|
||||
@@ -479,8 +477,7 @@ public class ConfiguredRegion {
|
||||
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"))
|
||||
.collect(Collectors.toList());
|
||||
List<Path> valid = files.filter(path -> Files.isRegularFile(path) && path.toFile().getName().equals(this.id + ".json")).toList();
|
||||
files.close();
|
||||
if (valid.isEmpty()) return null;
|
||||
if (valid.size() > 1) {
|
||||
|
||||
@@ -71,7 +71,7 @@ allprojects {
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
|
||||
compileOnly("net.kyori:adventure-api:4.14.0")
|
||||
compileOnly("net.kyori:adventure-platform-bukkit:4.3.0") // IMPLEMENTED VIA LIBRARIES
|
||||
compileOnly("net.kyori:adventure-platform-bukkit:4.3.1") // IMPLEMENTED VIA LIBRARIES
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.14.0") // IMPLEMENTED VIA LIBRARIES
|
||||
}
|
||||
|
||||
@@ -105,6 +105,8 @@ allprojects {
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
|
||||
|
||||
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
|
||||
// See https://openjdk.java.net/jeps/247 for more information.
|
||||
options.release.set(16)
|
||||
|
||||
@@ -8,7 +8,7 @@ dependencies {
|
||||
implementation(project(":folia"))
|
||||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.19:2.141.0")
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.9.0")
|
||||
testImplementation("org.reflections:reflections:0.10.2")
|
||||
|
||||
implementation("cloud.commandframework:cloud-paper:${properties["cloud_version"]}") {
|
||||
@@ -29,7 +29,7 @@ dependencies {
|
||||
implementation("io.papermc:paperlib:1.0.7") // paperlib - async teleport on Paper
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.ben-manes.caffeine:caffeine:3.1.7") { // IMPLEMENTED VIA LIBRARIES
|
||||
compileOnly("com.github.ben-manes.caffeine:caffeine:3.1.8") { // IMPLEMENTED VIA LIBRARIES
|
||||
exclude("org.checkerframework")
|
||||
}
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT") {
|
||||
@@ -62,7 +62,9 @@ dependencies {
|
||||
exclude("org.apache.commons")
|
||||
}
|
||||
compileOnly(":Dynmap-3.5-beta-3-spigot") // Dynmap
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT") {
|
||||
exclude("net.kyori")
|
||||
}
|
||||
compileOnly("com.ryandw11:CustomStructures:1.8.2")
|
||||
}
|
||||
|
||||
@@ -80,6 +82,10 @@ tasks {
|
||||
exclude("net/islandearth/rpgregions/utils/**")
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
minimize()
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ import net.islandearth.rpgregions.gui.RegionCreateGUI;
|
||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||
import net.islandearth.rpgregions.regenerate.Regenerate;
|
||||
import net.islandearth.rpgregions.rewards.ItemReward;
|
||||
import net.islandearth.rpgregions.utils.ChatUtils;
|
||||
import net.islandearth.rpgregions.utils.Colors;
|
||||
import net.islandearth.rpgregions.utils.RegenUtils;
|
||||
import net.islandearth.rpgregions.utils.StringUtils;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -90,10 +92,10 @@ public class RPGRegionsCommand {
|
||||
@CommandDescription("Debug information about the plugin")
|
||||
@CommandMethod("rpgregions|rpgr about")
|
||||
public void onAbout(CommandSender sender) {
|
||||
sender.sendMessage(StringUtils.colour("&eRPGRegions v" + plugin.getDescription().getVersion() + "."));
|
||||
sender.sendMessage(StringUtils.colour("&eOwner: https://www.spigotmc.org/members/%%__USER__%%/"));
|
||||
sender.sendMessage(StringUtils.colour("&eStorage: " + plugin.getManagers().getStorageManager().getClass().getName()));
|
||||
sender.sendMessage(StringUtils.colour("&eIntegration: " + plugin.getManagers().getIntegrationManager().getClass().getName()));
|
||||
sender.sendMessage(Colors.colour("&eRPGRegions v" + plugin.getDescription().getVersion() + "."));
|
||||
sender.sendMessage(Colors.colour("&eOwner: https://www.spigotmc.org/members/%%__USER__%%/"));
|
||||
sender.sendMessage(Colors.colour("&eStorage: " + plugin.getManagers().getStorageManager().getClass().getName()));
|
||||
sender.sendMessage(Colors.colour("&eIntegration: " + plugin.getManagers().getIntegrationManager().getClass().getName()));
|
||||
}
|
||||
|
||||
@CommandDescription("Creates a configured region from a region created in your integration")
|
||||
@@ -102,9 +104,8 @@ public class RPGRegionsCommand {
|
||||
public void onAdd(CommandSender sender,
|
||||
@Argument(value = "region", suggestions = "integration-regions") String region,
|
||||
@Argument("world") @Nullable World world) {
|
||||
|
||||
if (plugin.getManagers().getRegionsCache().getConfiguredRegion(region).isPresent()) {
|
||||
sender.sendMessage(StringUtils.colour("&cThat region is already configured."));
|
||||
Colors.sendColourful(sender, Component.text("That region is already configured.", Colors.BRIGHT_RED));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -124,16 +125,16 @@ public class RPGRegionsCommand {
|
||||
}
|
||||
|
||||
if (!plugin.getManagers().getIntegrationManager().exists(location.getWorld(), region)) {
|
||||
sender.sendMessage(StringUtils.colour("&cThat region does not exist in your protection plugin."));
|
||||
Colors.sendColourful(sender, Component.text("That region does not exist in your protection plugin.", Colors.BRIGHT_RED));
|
||||
return;
|
||||
}
|
||||
|
||||
add(location, region);
|
||||
sender.sendMessage(StringUtils.colour("&aAdded configured region " + region + "!"));
|
||||
sender.sendMessage(StringUtils.colour("&e&oNow use /rpgregions edit "
|
||||
ChatUtils.eventOk(sender, "Added configured region " + region + "!");
|
||||
sender.sendMessage(Colors.colour("&e&oNow use /rpgregions edit "
|
||||
+ region
|
||||
+ " to edit it!"));
|
||||
sender.sendMessage(StringUtils.colour("&e&oUse /rpgregions save to save this to file for editing."));
|
||||
sender.sendMessage(Colors.colour("&e&oUse /rpgregions save to save this to file for editing."));
|
||||
}
|
||||
|
||||
private void add(@NotNull final Location location, final String region) {
|
||||
@@ -150,20 +151,16 @@ public class RPGRegionsCommand {
|
||||
@Argument("region") ConfiguredRegion region,
|
||||
@Argument("name") @Greedy String name) {
|
||||
region.setCustomName(name);
|
||||
sender.sendMessage(StringUtils.colour("&aSet name of region '" + region.getId() + "' to: " + name));
|
||||
Colors.sendColourful(sender, Component.text("Set name of region '" + region.getId() + "' to: " + name, Colors.EREBOR_GREEN));
|
||||
}
|
||||
|
||||
@CommandDescription("Removes a configured region. Does not delete it from your integration.")
|
||||
@CommandPermission("rpgregions.remove")
|
||||
@CommandMethod("rpgregions|rpgr remove <region>")
|
||||
public void onRemove(CommandSender sender, @Argument("region") ConfiguredRegion region) {
|
||||
if (region != null) {
|
||||
region.delete(plugin);
|
||||
plugin.getManagers().getRegionsCache().removeConfiguredRegion(region.getId());
|
||||
sender.sendMessage(StringUtils.colour("&cRemoved configured region " + region.getId() + "!"));
|
||||
} else {
|
||||
sender.sendMessage(StringUtils.colour("&cA region by that name is not yet configured."));
|
||||
}
|
||||
region.delete(plugin);
|
||||
plugin.getManagers().getRegionsCache().removeConfiguredRegion(region.getId());
|
||||
Colors.sendColourful(sender, Component.text("Removed configured region " + region.getId() + "!", Colors.BRIGHT_RED));
|
||||
}
|
||||
|
||||
@CommandDescription("Opens the editor GUI for a region")
|
||||
@@ -184,12 +181,8 @@ public class RPGRegionsCommand {
|
||||
@CommandPermission("rpgregions.additem")
|
||||
@CommandMethod("rpgregions|rpgr additem <region>")
|
||||
public void onAddItem(Player player, @Argument("region") ConfiguredRegion region) {
|
||||
if (region != null) {
|
||||
region.getRewards().add(new ItemReward(plugin, player.getInventory().getItemInMainHand()));
|
||||
player.sendMessage(ChatColor.GREEN + "Item added to configuration!");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "No region exists by that name.");
|
||||
}
|
||||
region.getRewards().add(new ItemReward(plugin, player.getInventory().getItemInMainHand()));
|
||||
Colors.sendColourful(player, Component.text("Item added to configuration!", Colors.EREBOR_GREEN));
|
||||
}
|
||||
|
||||
@CommandDescription("Reloads configured regions from the `/plugins/RPGRegions/regions` folder.")
|
||||
@@ -221,7 +214,7 @@ public class RPGRegionsCommand {
|
||||
Bukkit.getPluginManager().callEvent(new RPGRegionsReloadEvent());
|
||||
long endTime = System.currentTimeMillis();
|
||||
long totalTime = endTime - startTime;
|
||||
sender.sendMessage(ChatColor.GREEN + "Done! (" + totalTime + "ms)");
|
||||
Colors.sendColourful(sender, Component.text("Done! (" + totalTime + "ms)", Colors.EREBOR_GREEN));
|
||||
}
|
||||
|
||||
@CommandDescription("Saves configured regions to the `/plugins/RPGRegions/regions` folder. Also saves user data.")
|
||||
@@ -269,9 +262,9 @@ public class RPGRegionsCommand {
|
||||
plugin.getManagers().getStorageManager().clearDiscovery(player.getUniqueId(), region.getId());
|
||||
if (!player.isOnline())
|
||||
plugin.getManagers().getStorageManager().removeCachedAccount(player.getUniqueId());
|
||||
sender.sendMessage(ChatColor.GREEN + "Discovery cleared.");
|
||||
Colors.sendColourful(sender, Component.text("Discovery cleared.", Colors.EREBOR_GREEN));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Region does not exist or is not configured.");
|
||||
Colors.sendColourful(sender, Component.text("Region does not exist or is not configured.", Colors.BRIGHT_RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +276,7 @@ public class RPGRegionsCommand {
|
||||
public void onDelete(CommandSender sender,
|
||||
@Argument("player") @NotNull OfflinePlayer player) {
|
||||
plugin.getManagers().getStorageManager().deleteAccount(player.getUniqueId());
|
||||
sender.sendMessage(ChatColor.GREEN + "Deleted account of player.");
|
||||
Colors.sendColourful(sender, Component.text("Deleted account of player.", Colors.EREBOR_GREEN));
|
||||
}
|
||||
|
||||
@CommandDescription("Sets the teleport location of a region")
|
||||
@@ -293,7 +286,7 @@ public class RPGRegionsCommand {
|
||||
@Argument("region") ConfiguredRegion region) {
|
||||
Location location = player.getLocation();
|
||||
region.setLocation(location);
|
||||
player.sendMessage(ChatColor.GREEN + "Location has been updated.");
|
||||
Colors.sendColourful(player, Component.text("Location has been updated.", Colors.EREBOR_GREEN));
|
||||
}
|
||||
|
||||
//TODO: use confirmation api
|
||||
|
||||
@@ -17,8 +17,8 @@ import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||
import net.islandearth.rpgregions.requirements.DependencyRequirement;
|
||||
import net.islandearth.rpgregions.requirements.RegionRequirement;
|
||||
import net.islandearth.rpgregions.translation.Translations;
|
||||
import net.islandearth.rpgregions.utils.Colors;
|
||||
import net.islandearth.rpgregions.utils.ItemStackBuilder;
|
||||
import net.islandearth.rpgregions.utils.StringUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -234,14 +234,14 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> translatedDiscoveredLore = new ArrayList<>();
|
||||
List<Component> translatedDiscoveredLore = new ArrayList<>();
|
||||
if (configuredRegion.getDiscoveredLore() != null) {
|
||||
configuredRegion.getDiscoveredLore().forEach(discoveredLore -> translatedDiscoveredLore.add(StringUtils.colour(discoveredLore)));
|
||||
configuredRegion.getDiscoveredLore().forEach(discoveredLore -> translatedDiscoveredLore.add(Colors.colourModern(discoveredLore)));
|
||||
}
|
||||
ItemStack item = hasDiscovered
|
||||
?
|
||||
new ItemStackBuilder(configuredRegion.getIcon())
|
||||
.withLore(translatedDiscoveredLore)
|
||||
.lore(translatedDiscoveredLore)
|
||||
.withModel(configuredRegion.getIconModel())
|
||||
.build()
|
||||
:
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.islandearth.rpgregions.utils;
|
||||
|
||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import static net.kyori.adventure.text.Component.space;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
|
||||
public final class ChatUtils {
|
||||
|
||||
public static final Component ARROW_RIGHT = text("➜", Colors.EREBOR_GREEN);
|
||||
public static final Component PENCIL_RIGHT = text("✎", Colors.EREBOR_GREEN);
|
||||
|
||||
private ChatUtils() {
|
||||
throw new UnsupportedOperationException("This class cannot be instantiated");
|
||||
}
|
||||
|
||||
public static void eventOk(CommandSender sender, String message) {
|
||||
RPGRegionsAPI.getAPI().adventure().sender(sender).sendMessage(text().append(ARROW_RIGHT.append(space()))
|
||||
.append(Colors.colourModern(message)).color(Colors.EREBOR_GREEN));
|
||||
}
|
||||
|
||||
public static void edit(CommandSender sender, ClickEvent event) {
|
||||
RPGRegionsAPI.getAPI().adventure().sender(sender).sendMessage(text().append(text("[")).append(PENCIL_RIGHT.append(space()))
|
||||
.append(text("Edit...]")).color(Colors.HONEY_YELLOW).clickEvent(event));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package net.islandearth.rpgregions.utils;
|
||||
|
||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class Colors {
|
||||
|
||||
public static final TextColor HONEY_YELLOW = TextColor.color(245, 175, 47);
|
||||
public static final TextColor BRIGHT_RED = TextColor.color(244, 61, 61); // ERROR
|
||||
public static final TextColor BRIGHT_RED_HIGHLIGHT = TextColor.color(255, 186, 186);
|
||||
public static final TextColor EREBOR_GREEN = TextColor.color(4, 219, 100); // OK
|
||||
|
||||
private Colors() {
|
||||
throw new UnsupportedOperationException("This class cannot be instantiated");
|
||||
}
|
||||
|
||||
public static void sendColourful(CommandSender sender, Component text) {
|
||||
RPGRegionsAPI.getAPI().adventure().sender(sender).sendMessage(text);
|
||||
}
|
||||
|
||||
public static String colour(final String message) {
|
||||
return ChatColor.translateAlternateColorCodes('&', BukkitComponentSerializer.legacy().serialize(RPGRegionsAPI.getAPI().miniMessage().deserialize(message)));
|
||||
}
|
||||
|
||||
public static Component colourModern(final String message) {
|
||||
return RPGRegionsAPI.getAPI().miniMessage().deserialize(message);
|
||||
}
|
||||
|
||||
public static int getARGB(int red, int green, int blue, int alpha) {
|
||||
int encoded = 0;
|
||||
encoded = encoded | blue;
|
||||
encoded = encoded | (green << 8);
|
||||
encoded = encoded | (red << 16);
|
||||
encoded = encoded | (alpha << 24);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
public static int getARGB(Color color, int alpha) {
|
||||
return getARGB(color.getRed(), color.getGreen(), color.getBlue(), alpha);
|
||||
}
|
||||
|
||||
public static NamedTextColor translateChatColorToNamedTextColor(org.bukkit.ChatColor chatColor) {
|
||||
return NamedTextColor.NAMES.value(chatColor.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public static Color translateChatColorToColor(org.bukkit.ChatColor chatColor) {
|
||||
return switch (chatColor) {
|
||||
case AQUA -> Color.CYAN;
|
||||
case BLACK -> Color.BLACK;
|
||||
case BLUE, DARK_BLUE, DARK_AQUA -> Color.BLUE;
|
||||
case DARK_GRAY, GRAY -> Color.GRAY;
|
||||
case DARK_GREEN, GREEN -> Color.GREEN;
|
||||
case DARK_PURPLE, LIGHT_PURPLE -> Color.MAGENTA;
|
||||
case DARK_RED, RED -> Color.RED;
|
||||
case GOLD, YELLOW -> Color.YELLOW;
|
||||
default -> Color.WHITE;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public class StringUtils {
|
||||
* @param msg the message
|
||||
* @return the coloured message
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String colour(String msg) {
|
||||
return ChatColor.translateAlternateColorCodes('&', msg);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ main: net.islandearth.rpgregions.RPGRegions
|
||||
api-version: '1.16'
|
||||
libraries:
|
||||
- "com.zaxxer:HikariCP:5.0.1" # database
|
||||
- "net.kyori:adventure-platform-bukkit:4.3.0"
|
||||
- "net.kyori:adventure-platform-bukkit:4.3.1"
|
||||
- "net.kyori:adventure-text-minimessage:4.14.0"
|
||||
- "com.github.ben-manes.caffeine:caffeine:3.1.7"
|
||||
- "com.github.ben-manes.caffeine:caffeine:3.1.8"
|
||||
- "org.xerial:sqlite-jdbc:3.30.1"
|
||||
- "org.flywaydb:flyway-core:9.16.2" # db migration
|
||||
- "org.flywaydb:flyway-mysql:9.16.3"
|
||||
|
||||
Reference in New Issue
Block a user