mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-28 19:29:16 +00:00
Remove legacy support
This commit is contained in:
@@ -350,14 +350,6 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, Lang
|
||||
.serializeNulls().create();
|
||||
}
|
||||
|
||||
public boolean isLegacyServer() {
|
||||
return Bukkit.getVersion().contains("1.12")
|
||||
|| Bukkit.getVersion().contains("1.11")
|
||||
|| Bukkit.getVersion().contains("1.10")
|
||||
|| Bukkit.getVersion().contains("1.9")
|
||||
|| Bukkit.getVersion().contains("1.8");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasHeadDatabase() {
|
||||
return Bukkit.getPluginManager().getPlugin("HeadDatabase") != null;
|
||||
@@ -366,7 +358,7 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, Lang
|
||||
@NotNull
|
||||
private String getIntegration() {
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
return isLegacyServer() ? "WorldGuard_Legacy" : "WorldGuard";
|
||||
return "WorldGuard";
|
||||
} else if (Bukkit.getPluginManager().getPlugin("Residence") != null) {
|
||||
return "Residence";
|
||||
} else if (Bukkit.getPluginManager().getPlugin("GriefPrevention") != null) {
|
||||
|
||||
@@ -202,28 +202,24 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1: {
|
||||
case 1 -> {
|
||||
plugin.getManagers().getStorageManager().clearDiscoveries(player.getUniqueId());
|
||||
if (!player.isOnline()) plugin.getManagers().getStorageManager().removeCachedAccount(player.getUniqueId());
|
||||
if (!player.isOnline())
|
||||
plugin.getManagers().getStorageManager().removeCachedAccount(player.getUniqueId());
|
||||
sender.sendMessage(ChatColor.GREEN + "Players discoveries has been cleared.");
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: {
|
||||
case 2 -> {
|
||||
String regionId = args[1];
|
||||
if (plugin.getManagers().getRegionsCache().getConfiguredRegions().containsKey(regionId)) {
|
||||
plugin.getManagers().getStorageManager().clearDiscovery(player.getUniqueId(), regionId);
|
||||
if (!player.isOnline()) plugin.getManagers().getStorageManager().removeCachedAccount(player.getUniqueId());
|
||||
if (!player.isOnline())
|
||||
plugin.getManagers().getStorageManager().removeCachedAccount(player.getUniqueId());
|
||||
sender.sendMessage(ChatColor.GREEN + "Discovery cleared.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Region does not exist or is not configured.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /rpgregions reset <player> [region_id]");
|
||||
break;
|
||||
default -> sender.sendMessage(ChatColor.RED + "Usage: /rpgregions reset <player> [region_id]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,17 +304,6 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("discover")
|
||||
@CommandPermission("rpgregions.discover")
|
||||
@CommandCompletion("@regions @players")
|
||||
@Deprecated
|
||||
public void onDiscover(Player player, ConfiguredRegion configuredRegion, Player target) {
|
||||
player.sendMessage(ChatColor.RED + "Use of this command format is deprecated/discouraged. " +
|
||||
"Please switch to the /discoveries command to handle this. " +
|
||||
"The new format also supports console and offline player usage.");
|
||||
player.performCommand("discoveries discover " + configuredRegion.getId() + " " + target.getName());
|
||||
}
|
||||
|
||||
@Subcommand("forceupdateicons")
|
||||
@CommandPermission("rpgregions.forceupdate")
|
||||
public void onForceUpdateIcons(Player player) {
|
||||
|
||||
@@ -35,23 +35,14 @@ public class PotionEffectAdapter implements JsonSerializer<PotionEffect>, JsonDe
|
||||
@Override
|
||||
public JsonElement serialize(PotionEffect potionEffect, Type type, JsonSerializationContext context) {
|
||||
// Our own serialisation - use type name instead of id
|
||||
if (!plugin.isLegacyServer())
|
||||
return gson.toJsonTree(ImmutableMap.<String, Object>builder()
|
||||
.put("type", potionEffect.getType().getName())
|
||||
.put("duration", potionEffect.getDuration())
|
||||
.put("amplifier", potionEffect.getAmplifier())
|
||||
.put("ambient", potionEffect.isAmbient())
|
||||
.put("particles", potionEffect.hasParticles())
|
||||
.put("icon", potionEffect.hasIcon())
|
||||
.build());
|
||||
else
|
||||
return gson.toJsonTree(ImmutableMap.<String, Object>builder()
|
||||
.put("type", potionEffect.getType().getName())
|
||||
.put("duration", potionEffect.getDuration())
|
||||
.put("amplifier", potionEffect.getAmplifier())
|
||||
.put("ambient", potionEffect.isAmbient())
|
||||
.put("particles", potionEffect.hasParticles())
|
||||
.build());
|
||||
return gson.toJsonTree(ImmutableMap.<String, Object>builder()
|
||||
.put("type", potionEffect.getType().getName())
|
||||
.put("duration", potionEffect.getDuration())
|
||||
.put("amplifier", potionEffect.getAmplifier())
|
||||
.put("ambient", potionEffect.isAmbient())
|
||||
.put("particles", potionEffect.hasParticles())
|
||||
.put("icon", potionEffect.hasIcon())
|
||||
.build());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -63,9 +54,7 @@ public class PotionEffectAdapter implements JsonSerializer<PotionEffect>, JsonDe
|
||||
double amplifier = (double) map.get("amplifier");
|
||||
boolean ambient = (boolean) map.get("ambient");
|
||||
boolean particles = (boolean) map.get("particles");
|
||||
if (!plugin.isLegacyServer()) {
|
||||
boolean icon = (boolean) map.get("icon");
|
||||
return new PotionEffect(type, (int) duration, (int) amplifier, ambient, particles, icon);
|
||||
} else return new PotionEffect(type, (int) duration, (int) amplifier, ambient, particles);
|
||||
boolean icon = (boolean) map.get("icon");
|
||||
return new PotionEffect(type, (int) duration, (int) amplifier, ambient, particles, icon);
|
||||
}
|
||||
}
|
||||
@@ -102,14 +102,10 @@ public class RPGRegionsManagers implements IRPGRegionsManagers {
|
||||
rewards.add(new ConsoleCommandReward(plugin, "say Server sees you discovered a region!"));
|
||||
rewards.add(new MessageReward(plugin, Collections.singletonList("&aExample message as a reward")));
|
||||
List<RegionEffect> effects = new ArrayList<>();
|
||||
if (!plugin.isLegacyServer()) effects.add(new PotionRegionEffect(plugin,
|
||||
effects.add(new PotionRegionEffect(plugin,
|
||||
new PotionEffect(PotionEffectType.GLOWING, 100, 1, true, true, true),
|
||||
true,
|
||||
Collections.singletonList(new ItemStackBuilder(Material.IRON_CHESTPLATE).build())));
|
||||
else effects.add(new PotionRegionEffect(plugin,
|
||||
new PotionEffect(PotionEffectType.GLOWING, 100, 1, true, true),
|
||||
true,
|
||||
Collections.singletonList(new ItemStackBuilder(Material.IRON_CHESTPLATE).build())));
|
||||
|
||||
ConfiguredRegion configuredRegion = new ConfiguredRegion(null, "exampleconfig", "ExampleConfig", rewards, effects,
|
||||
XSound.AMBIENT_UNDERWATER_EXIT.parseSound(),
|
||||
|
||||
Reference in New Issue
Block a user