mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-30 04:09:15 +00:00
Update to Languagy 3, temporarily disable fog effects
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("java")
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -7,15 +7,12 @@ dependencies {
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.17:1.13.0")
|
||||
testImplementation("org.reflections:reflections:0.10.2")
|
||||
|
||||
implementation("net.islandearth:languagy:2.0.4-SNAPSHOT") // languagy
|
||||
implementation("io.papermc:paperlib:1.0.4") // paperlib - async teleport on Paper
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT") // spigot
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") // vault
|
||||
compileOnly("me.clip:placeholderapi:2.10.4") // PAPI
|
||||
compileOnly(":AlonsoLevels_v2.0-BETA") // alonsolevels
|
||||
compileOnly("com.github.shynixn.headdatabase:hdb-api:1.0") // head database
|
||||
compileOnly("org.jetbrains:annotations:22.0.0")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT") {
|
||||
exclude("com.destroystokyo.paper")
|
||||
exclude("org.spigotmc")
|
||||
@@ -29,3 +26,31 @@ dependencies {
|
||||
exclude("org.apache.commons")
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
// See Gradle docs for how to provide credentials to PasswordCredentials
|
||||
// https://docs.gradle.org/current/samples/sample_publishing_credentials.html
|
||||
maven {
|
||||
name = "convallyriaSnapshots"
|
||||
url = uri("https://repo.convallyria.com/snapshots/")
|
||||
credentials(PasswordCredentials::class)
|
||||
}
|
||||
maven {
|
||||
name = "convallyriaReleases"
|
||||
url = uri("https://repo.convallyria.com/releases/")
|
||||
credentials(PasswordCredentials::class)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configure<PublishingExtension> {
|
||||
publications.create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.islandearth.rpgregions.api;
|
||||
|
||||
import com.convallyria.languagy.api.language.Translator;
|
||||
import com.google.gson.Gson;
|
||||
import net.islandearth.languagy.api.language.Translator;
|
||||
import net.islandearth.rpgregions.managers.IRPGRegionsManagers;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ public class ConfiguredRegion {
|
||||
@NotNull
|
||||
public List<String> getTitle(Player player) {
|
||||
if (title == null) {
|
||||
return Translations.DISCOVERED_TITLE.getList(player, customName);
|
||||
return Translations.DISCOVERED_TITLE.get(player, customName);
|
||||
}
|
||||
|
||||
List<String> translatedTitle = new ArrayList<>();
|
||||
@@ -252,7 +252,7 @@ public class ConfiguredRegion {
|
||||
@NotNull
|
||||
public List<String> getSubtitle(Player player) {
|
||||
if (subtitle == null) {
|
||||
return Translations.DISCOVERED_SUBTITLE.getList(player, customName);
|
||||
return Translations.DISCOVERED_SUBTITLE.get(player, customName);
|
||||
}
|
||||
|
||||
List<String> translatedSubtitle = new ArrayList<>();
|
||||
@@ -268,7 +268,7 @@ public class ConfiguredRegion {
|
||||
@NotNull
|
||||
public List<String> getDiscoveredTitle(Player player) {
|
||||
if (discoveredTitle == null) {
|
||||
return Translations.ALREADY_DISCOVERED_TITLE.getList(player, customName);
|
||||
return Translations.ALREADY_DISCOVERED_TITLE.get(player, customName);
|
||||
}
|
||||
|
||||
List<String> translatedTitle = new ArrayList<>();
|
||||
@@ -284,7 +284,7 @@ public class ConfiguredRegion {
|
||||
@NotNull
|
||||
public List<String> getDiscoveredSubtitle(Player player) {
|
||||
if (discoveredSubtitle == null) {
|
||||
return Translations.ALREADY_DISCOVERED_SUBTITLE.getList(player, customName);
|
||||
return Translations.ALREADY_DISCOVERED_SUBTITLE.get(player, customName);
|
||||
}
|
||||
|
||||
List<String> translatedSubtitle = new ArrayList<>();
|
||||
|
||||
@@ -22,9 +22,9 @@ public enum PreventType {
|
||||
}
|
||||
|
||||
if (getVersionNumber() <= 17) {
|
||||
player.spawnParticle(Particle.BARRIER, event.getTo().getBlock().getLocation().add(0.5, 0.5, 0.5), 1);
|
||||
player.spawnParticle(Particle.valueOf("BARRIER"), event.getTo().getBlock().getLocation().add(0.5, 0.5, 0.5), 1);
|
||||
} else {
|
||||
player.spawnParticle(Particle.valueOf("BLOCK_MARKER"), event.getTo().getBlock().getLocation().add(0.5, 0.5, 0.5), 1, Material.BARRIER.createBlockData());
|
||||
player.spawnParticle(Particle.BLOCK_MARKER, event.getTo().getBlock().getLocation().add(0.5, 0.5, 0.5), 1, Material.BARRIER.createBlockData());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package net.islandearth.rpgregions.translation;
|
||||
|
||||
import com.convallyria.languagy.api.language.Language;
|
||||
import com.convallyria.languagy.api.language.key.LanguageKey;
|
||||
import com.convallyria.languagy.api.language.key.TranslationKey;
|
||||
import com.convallyria.languagy.api.language.translation.Translation;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.islandearth.languagy.api.language.Language;
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -11,47 +14,37 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum Translations {
|
||||
NEXT_PAGE("&aNext Page"),
|
||||
NEXT_PAGE_LORE("&fGo to the next page", true),
|
||||
PREVIOUS_PAGE("&cPrevious Page"),
|
||||
PREVIOUS_PAGE_LORE("&fGo to the previous page", true),
|
||||
REGIONS("Regions"),
|
||||
DISCOVERED_ON("&7Discovered on: %0"),
|
||||
DISCOVERED_TITLE("&d%0 discovered!", true),
|
||||
DISCOVERED_SUBTITLE("&fKeep exploring to discover more!", true),
|
||||
ALREADY_DISCOVERED_TITLE("&d%0 entered!", true),
|
||||
ALREADY_DISCOVERED_SUBTITLE("&fAlready discovered!", true),
|
||||
TELEPORT("&aClick to teleport"),
|
||||
CANNOT_TELEPORT("&cWe can't teleport you because that world doesn't exist!"),
|
||||
UNKNOWN_REGION("Unknown Realm"),
|
||||
EXIT("&cExit"),
|
||||
EXIT_LORE("&fExit the GUI", true),
|
||||
CANNOT_ENTER("&cYou require %0 to enter this area."),
|
||||
COOLDOWN("&cThat is currently on cooldown."),
|
||||
REGION_ENTER_ACTIONBAR("&a%0");
|
||||
NEXT_PAGE(TranslationKey.of("next_page")),
|
||||
NEXT_PAGE_LORE(TranslationKey.of("next_page_lore")),
|
||||
PREVIOUS_PAGE(TranslationKey.of("previous_page")),
|
||||
PREVIOUS_PAGE_LORE(TranslationKey.of("previous_page_lore")),
|
||||
REGIONS(TranslationKey.of("regions")),
|
||||
DISCOVERED_ON(TranslationKey.of("discovered_on")),
|
||||
DISCOVERED_TITLE(TranslationKey.of("discovered_title")),
|
||||
DISCOVERED_SUBTITLE(TranslationKey.of("discovered_subtitle")),
|
||||
ALREADY_DISCOVERED_TITLE(TranslationKey.of("already_discovered_title")),
|
||||
ALREADY_DISCOVERED_SUBTITLE(TranslationKey.of("already_discovered_subtitle")),
|
||||
TELEPORT(TranslationKey.of("teleport")),
|
||||
CANNOT_TELEPORT(TranslationKey.of("cannot_teleport")),
|
||||
UNKNOWN_REGION(TranslationKey.of("unknown_region")),
|
||||
EXIT(TranslationKey.of("exit")),
|
||||
EXIT_LORE(TranslationKey.of("exit_lore")),
|
||||
CANNOT_ENTER(TranslationKey.of("cannot_enter")),
|
||||
COOLDOWN(TranslationKey.of("cooldown")),
|
||||
REGION_ENTER_ACTIONBAR(TranslationKey.of("region_enter_actionbar"));
|
||||
|
||||
private final String defaultValue;
|
||||
private final TranslationKey key;
|
||||
private final boolean isList;
|
||||
|
||||
Translations(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
Translations(TranslationKey key) {
|
||||
this.key = key;
|
||||
this.isList = false;
|
||||
}
|
||||
|
||||
Translations(String defaultValue, boolean isList) {
|
||||
this.defaultValue = defaultValue;
|
||||
this.isList = isList;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public boolean isList() {
|
||||
return isList;
|
||||
}
|
||||
@@ -60,52 +53,20 @@ public enum Translations {
|
||||
return this.toString().toLowerCase();
|
||||
}
|
||||
|
||||
public void send(Player player) {
|
||||
String message = RPGRegionsAPI.getAPI().getTranslator().getTranslationFor(player, this.getPath());
|
||||
player.sendMessage(message);
|
||||
public void send(Player player, Object... values) {
|
||||
final Translation translation = RPGRegionsAPI.getAPI().getTranslator().getTranslationFor(player, key);
|
||||
for (String translationString : translation.colour()) {
|
||||
player.sendMessage(this.setPapi(player, replaceVariables(translationString, values)));
|
||||
}
|
||||
}
|
||||
|
||||
public void send(Player player, String... values) {
|
||||
String message = RPGRegionsAPI.getAPI().getTranslator().getTranslationFor(player, this.getPath());
|
||||
message = this.setPapi(player, replaceVariables(message, values));
|
||||
player.sendMessage(message);
|
||||
}
|
||||
|
||||
public void sendList(Player player) {
|
||||
List<String> messages = RPGRegionsAPI.getAPI().getTranslator().getTranslationListFor(player, this.getPath());
|
||||
messages.forEach(player::sendMessage);
|
||||
}
|
||||
|
||||
public void sendList(Player player, String... values) {
|
||||
List<String> messages = RPGRegionsAPI.getAPI().getTranslator().getTranslationListFor(player, this.getPath());
|
||||
messages.forEach(message -> {
|
||||
message = this.setPapi(player, replaceVariables(message, values));
|
||||
player.sendMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
public String get(Player player) {
|
||||
return this.setPapi(player, RPGRegionsAPI.getAPI().getTranslator().getTranslationFor(player, this.getPath()));
|
||||
}
|
||||
|
||||
public String get(Player player, String... values) {
|
||||
String message = RPGRegionsAPI.getAPI().getTranslator().getTranslationFor(player, this.getPath());
|
||||
message = replaceVariables(message, values);
|
||||
return this.setPapi(player, message);
|
||||
}
|
||||
|
||||
public List<String> getList(Player player) {
|
||||
List<String> list = new ArrayList<>();
|
||||
RPGRegionsAPI.getAPI().getTranslator().getTranslationListFor(player, this.getPath()).forEach(text -> list.add(this.setPapi(player, text)));
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> getList(Player player, String... values) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
RPGRegionsAPI.getAPI().getTranslator()
|
||||
.getTranslationListFor(player, this.getPath())
|
||||
.forEach(message -> messages.add(this.setPapi(player, replaceVariables(message, values))));
|
||||
return messages;
|
||||
public List<String> get(Player player, Object... values) {
|
||||
final Translation translation = RPGRegionsAPI.getAPI().getTranslator().getTranslationFor(player, key);
|
||||
List<String> transformed = new ArrayList<>();
|
||||
for (String translationString : translation.colour()) {
|
||||
transformed.add(this.setPapi(player, replaceVariables(translationString, values)));
|
||||
}
|
||||
return transformed;
|
||||
}
|
||||
|
||||
public static void generateLang(IRPGRegionsAPI plugin) {
|
||||
@@ -113,24 +74,19 @@ public enum Translations {
|
||||
lang.mkdirs();
|
||||
|
||||
for (Language language : Language.values()) {
|
||||
final LanguageKey languageKey = language.getKey();
|
||||
try {
|
||||
plugin.saveResource("lang/" + language.getCode() + ".yml", false);
|
||||
plugin.getLogger().info("Generated " + language.getCode() + ".yml");
|
||||
plugin.saveResource("lang/" + languageKey.getCode() + ".yml", false);
|
||||
plugin.getLogger().info("Generated " + languageKey.getCode() + ".yml");
|
||||
} catch (IllegalArgumentException ignored) { }
|
||||
|
||||
File file = new File(plugin.getDataFolder() + "/lang/" + language.getCode() + ".yml");
|
||||
File file = new File(plugin.getDataFolder() + "/lang/" + languageKey.getCode() + ".yml");
|
||||
if (file.exists()) {
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
for (Translations key : values()) {
|
||||
if (config.get(key.toString().toLowerCase()) == null) {
|
||||
config.set(key.toString().toLowerCase(), key.defaultValue);
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
plugin.getLogger().warning("No value in translation file for key "
|
||||
+ key + " was found. We will attempt to fix this. Otherwise, try to regenerate language files?");
|
||||
+ key + " was found. Please regenerate or edit your language files with new values!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,10 +94,10 @@ public enum Translations {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String replaceVariables(String message, String... values) {
|
||||
private String replaceVariables(String message, Object... values) {
|
||||
String modifiedMessage = message;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (values.length > i) modifiedMessage = modifiedMessage.replaceAll("%" + i, values[i]);
|
||||
if (values.length > i) modifiedMessage = modifiedMessage.replaceAll("%" + i, String.valueOf(values[i]));
|
||||
else break;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,9 @@ allprojects {
|
||||
//options.deprecation = true
|
||||
//}
|
||||
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
apply(plugin = "java")
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
@@ -46,7 +49,7 @@ allprojects {
|
||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
maven("https://repo.codemc.io/repository/maven-snapshots/")
|
||||
maven("https://jitpack.io")
|
||||
maven("https://repo.convallyria.com/snapshots")
|
||||
maven("https://repo.convallyria.com/releases")
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://oss.sonatype.org/content/groups/public/")
|
||||
maven("https://repo.aikar.co/content/groups/aikar/")
|
||||
@@ -65,6 +68,13 @@ allprojects {
|
||||
|
||||
flatDir { dir("../libraries") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.convallyria.languagy:api:3.0.0")
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT") // spigot
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
plugins {
|
||||
id("java")
|
||||
}
|
||||
|
||||
val ultraRegionsSupport = (properties.getValue("ultraRegionsSupport") as String).toBoolean()
|
||||
|
||||
tasks.compileJava {
|
||||
@@ -12,17 +8,17 @@ tasks.compileJava {
|
||||
|
||||
dependencies {
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
implementation("net.islandearth:languagy:2.0.4-SNAPSHOT") // languagy
|
||||
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT") {
|
||||
exclude("com.destroystokyo.paper")
|
||||
exclude("org.spigotmc")
|
||||
}
|
||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT") // spigot
|
||||
compileOnly(":Residence4.9.2.2") // residence
|
||||
compileOnly(":GriefPrevention") // griefprevention
|
||||
if (ultraRegionsSupport) compileOnly(":UltraRegions") // ultraregions
|
||||
compileOnly("org.jetbrains:annotations:22.0.0")
|
||||
compileOnly(project(":api"))
|
||||
compileOnly(project(":rpgregions"))
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("java")
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://repo.codemc.io/repository/nms/")
|
||||
maven("https://repo.dmulloy2.net/repository/public/")
|
||||
@@ -15,7 +10,6 @@ dependencies {
|
||||
|
||||
implementation("net.wesjd:anvilgui:1.5.3-SNAPSHOT") // anvilgui
|
||||
implementation("com.github.stefvanschie.inventoryframework:IF:0.10.5") // inventory framework
|
||||
implementation("net.islandearth:languagy:2.0.4-SNAPSHOT") // languagy
|
||||
implementation("co.aikar:acf-paper:0.5.0-SNAPSHOT") // commands
|
||||
implementation("co.aikar:idb-core:1.0.0-SNAPSHOT") // database
|
||||
implementation("org.bstats:bstats-bukkit:3.0.0") // plugin stats
|
||||
@@ -31,7 +25,6 @@ dependencies {
|
||||
exclude("org.spigotmc")
|
||||
}
|
||||
//compileOnly 'com.zaxxer:HikariCP:2.4.1' // IMPLEMENTED VIA LIBRARIES - database
|
||||
compileOnly("org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT") // spigot
|
||||
compileOnly("me.clip:placeholderapi:2.10.4") // PAPI
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") { // vault
|
||||
exclude("org.bukkit")
|
||||
@@ -44,7 +37,6 @@ dependencies {
|
||||
exclude("org.apache.commons")
|
||||
}
|
||||
compileOnly(":Dynmap-3.1-spigot") // Dynmap
|
||||
compileOnly("org.jetbrains:annotations:22.0.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:4.7.0")
|
||||
|
||||
compileOnly(project(":api"))
|
||||
|
||||
@@ -3,13 +3,10 @@ package net.islandearth.rpgregions;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import co.aikar.idb.DB;
|
||||
import com.convallyria.languagy.api.language.Translator;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.islandearth.languagy.api.language.Language;
|
||||
import net.islandearth.languagy.api.language.LanguagyImplementation;
|
||||
import net.islandearth.languagy.api.language.LanguagyPluginHook;
|
||||
import net.islandearth.languagy.api.language.Translator;
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
||||
@@ -63,7 +60,6 @@ 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.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -78,7 +74,7 @@ import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, LanguagyPluginHook {
|
||||
public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
||||
|
||||
private RPGRegionsManagers managers;
|
||||
private PaperCommandManager commandManager;
|
||||
@@ -92,7 +88,6 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, Lang
|
||||
return translator;
|
||||
}
|
||||
|
||||
@LanguagyImplementation(Language.ENGLISH)
|
||||
private Translator translator;
|
||||
|
||||
@Override
|
||||
@@ -113,7 +108,7 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, Lang
|
||||
this.registerEffects();
|
||||
this.registerListeners();
|
||||
this.registerCommands();
|
||||
this.hook(this);
|
||||
this.translator = Translator.of(this);
|
||||
this.registerTasks();
|
||||
this.registerMetrics();
|
||||
|
||||
@@ -262,11 +257,6 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI, Lang
|
||||
registry.register(VanishEffect.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLanguagyHook() {
|
||||
translator.setDisplay(Material.MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gson getGson() {
|
||||
return new GsonBuilder()
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PlaceholderRegionHook extends PlaceholderExpansion implements Block
|
||||
if (plugin.getManagers().getIntegrationManager().getPrioritisedRegion(player.getLocation()).isPresent())
|
||||
return plugin.getManagers().getIntegrationManager().getPrioritisedRegion(player.getLocation()).get().getCustomName();
|
||||
else
|
||||
return Translations.UNKNOWN_REGION.get(player);
|
||||
return Translations.UNKNOWN_REGION.get(player).get(0);
|
||||
case "discovered_count":
|
||||
// We have to do a blocking operation :(
|
||||
try {
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
package net.islandearth.rpgregions.effects;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.effects.fog.nms.biome.BiomeBaseWrapper_1_17R1;
|
||||
import net.islandearth.rpgregions.gui.GuiEditable;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.core.IRegistryWritable;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutMapChunk;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -37,7 +28,7 @@ public class FogEffect extends RegionEffect {
|
||||
@GuiEditable("Grass Colour") private final String grassColour;
|
||||
@GuiEditable("Foilage Colour") private final String foilageColour;
|
||||
|
||||
private transient BiomeBase biomeBase;
|
||||
//private transient BiomeBase biomeBase;
|
||||
private transient int biomeId;
|
||||
private transient List<UUID> effect;
|
||||
|
||||
@@ -53,7 +44,7 @@ public class FogEffect extends RegionEffect {
|
||||
}
|
||||
|
||||
public void generateBiomes() {
|
||||
ResourceKey<BiomeBase> key = ResourceKey.a(IRegistry.aO, new MinecraftKey(UUID.randomUUID().toString()));
|
||||
/*ResourceKey<BiomeBase> key = ResourceKey.a(IRegistry.aO, new MinecraftKey(UUID.randomUUID().toString()));
|
||||
BiomeBase biomeBase = new BiomeBaseWrapper_1_17R1()
|
||||
.build(fogColour,
|
||||
waterColour,
|
||||
@@ -66,7 +57,7 @@ public class FogEffect extends RegionEffect {
|
||||
IRegistryWritable<BiomeBase> rw = ds.getCustomRegistry().b(IRegistry.aO);
|
||||
rw.a(key, biomeBase, Lifecycle.stable());
|
||||
this.biomeId = ds.getCustomRegistry().d(IRegistry.aO).getId(biomeBase);
|
||||
this.biomeBase = biomeBase;
|
||||
this.biomeBase = biomeBase;*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,9 +66,16 @@ public class FogEffect extends RegionEffect {
|
||||
|
||||
if (!effect.contains(player.getUniqueId())) {
|
||||
effect.add(player.getUniqueId());
|
||||
|
||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
||||
for (Chunk chunk : getChunkAround(player.getLocation().getChunk(), Bukkit.getServer().getViewDistance())) {
|
||||
net.minecraft.world.level.chunk.Chunk c = ((CraftChunk)chunk).getHandle();
|
||||
((CraftPlayer) player).getHandle().b.sendPacket(new PacketPlayOutMapChunk(c));
|
||||
final PacketContainer packetContainer = new PacketContainer(PacketType.Play.Server.MAP_CHUNK);
|
||||
|
||||
//try {
|
||||
// manager.sendServerPacket(player, packetContainer);
|
||||
//} catch (InvocationTargetException e) {
|
||||
// e.printStackTrace();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,8 +87,8 @@ public class FogEffect extends RegionEffect {
|
||||
if (effect.contains(player.getUniqueId())) {
|
||||
effect.remove(player.getUniqueId());
|
||||
for (Chunk chunk : getChunkAround(player.getLocation().getChunk(), Bukkit.getServer().getViewDistance())) {
|
||||
net.minecraft.world.level.chunk.Chunk c = ((CraftChunk)chunk).getHandle();
|
||||
((CraftPlayer) player).getHandle().b.sendPacket(new PacketPlayOutMapChunk(c));
|
||||
//net.minecraft.world.level.chunk.Chunk c = ((CraftChunk)chunk).getHandle();
|
||||
//((CraftPlayer) player).getHandle().b.sendPacket(new PacketPlayOutMapChunk(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package net.islandearth.rpgregions.effects.fog.nms.biome;
|
||||
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
|
||||
public interface Biome {
|
||||
|
||||
BiomeBase build(String fogColor, String waterColor, String waterFogColor, String skyColor, String grassColor, String foliageColor);
|
||||
|
||||
BiomeBase build(String fogColor, String waterColor, String waterFogColor, String skyColor);
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package net.islandearth.rpgregions.effects.fog.nms.biome;
|
||||
|
||||
import net.minecraft.data.worldgen.BiomeDecoratorGroups;
|
||||
import net.minecraft.data.worldgen.WorldGenSurfaceComposites;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.biome.BiomeFog;
|
||||
import net.minecraft.world.level.biome.BiomeSettingsGeneration;
|
||||
import net.minecraft.world.level.biome.BiomeSettingsMobs;
|
||||
import net.minecraft.world.level.levelgen.WorldGenStage;
|
||||
|
||||
/**
|
||||
* Thanks to ProdigySky for this
|
||||
* @author cocoraid
|
||||
*/
|
||||
public class BiomeBaseWrapper_1_17R1 implements Biome {
|
||||
|
||||
private String fogColor, waterColor, waterFogColor, skyColor;
|
||||
private String grassColor, foliageColor;
|
||||
|
||||
@Override
|
||||
public BiomeBase build(String fogColor, String waterColor, String waterFogColor, String skyColor) {
|
||||
return build(fogColor,waterColor,waterFogColor,skyColor,null,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeBase build(String fogColor, String waterColor, String waterFogColor, String skyColor,String grassColor, String foliageColor) {
|
||||
this.fogColor = fogColor;
|
||||
this.waterColor = waterColor;
|
||||
this.waterFogColor = waterFogColor;
|
||||
this.skyColor = skyColor;
|
||||
this.grassColor = grassColor;
|
||||
this.foliageColor = foliageColor;
|
||||
return build();
|
||||
}
|
||||
|
||||
public BiomeBase build() {
|
||||
//void generation
|
||||
BiomeSettingsGeneration.a gen = (new BiomeSettingsGeneration.a()).a(WorldGenSurfaceComposites.p);
|
||||
gen.a(WorldGenStage.Decoration.j, BiomeDecoratorGroups.W);
|
||||
|
||||
BiomeFog.a biomeFogCodec = new BiomeFog.a()
|
||||
.a(Integer.parseInt(fogColor, 16)) //fog color
|
||||
.b(Integer.parseInt(waterColor, 16)) //water color
|
||||
.c(Integer.parseInt(waterFogColor, 16)) //water fog color
|
||||
.d(Integer.parseInt(skyColor, 16)); //skycolor
|
||||
//.e() //foliage color (leaves, fines and more)
|
||||
//.f() //grass blocks color
|
||||
//.a(BiomeParticle)
|
||||
//a(Music)
|
||||
|
||||
if(foliageColor != null)
|
||||
biomeFogCodec.e(Integer.parseInt(foliageColor, 16));
|
||||
if(grassColor != null)
|
||||
biomeFogCodec.f(Integer.parseInt(grassColor, 16));
|
||||
|
||||
return new BiomeBase.a()
|
||||
.a(BiomeBase.Precipitation.a) //none
|
||||
.a(BiomeBase.Geography.a) //none
|
||||
.a(0F) //depth ocean or not // var3 ? -1.8F : -1.0F
|
||||
.b(0F) //scale Lower values produce flatter terrain
|
||||
.c(0F) //temperature
|
||||
.d(0F) //maybe important, foliage and grass color
|
||||
.a(biomeFogCodec.a()) //biomefog
|
||||
.a(BiomeSettingsMobs.c) //same as void biome
|
||||
.a(gen.a()) //same as void biome
|
||||
.a();
|
||||
}
|
||||
}
|
||||
@@ -52,8 +52,8 @@ public class AddRegionElementGUI extends RPGRegionsGUI {
|
||||
// Exit item
|
||||
Material em = Material.valueOf(plugin.getConfig().getString("settings.server.gui.exit.exit"));
|
||||
ItemStack exitItem = new ItemStackBuilder(em)
|
||||
.withName(Translations.EXIT.get(player))
|
||||
.withLore(Translations.EXIT_LORE.getList(player))
|
||||
.withName(Translations.EXIT.get(player).get(0))
|
||||
.withLore(Translations.EXIT_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build();
|
||||
exit.addItem(new GuiItem(exitItem, event -> {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
this.gui = new ChestGui(plugin.getConfig().getInt("settings.server.gui.general.rows"), Translations.REGIONS.get(player));
|
||||
this.gui = new ChestGui(plugin.getConfig().getInt("settings.server.gui.general.rows"), Translations.REGIONS.get(player).get(0));
|
||||
gui.setOnGlobalClick(click -> click.setCancelled(true));
|
||||
PaginatedPane pane = new PaginatedPane(paneX, paneY, paneL, paneH, Pane.Priority.HIGHEST);
|
||||
OutlinePane oPane = new OutlinePane(oPaneX, oPaneY, oPaneL, oPaneH);
|
||||
@@ -88,15 +88,15 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
||||
ItemStack backItem = bm.startsWith("hdb-") && plugin.hasHeadDatabase()
|
||||
?
|
||||
new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(bm.replace("hdb-", "")))
|
||||
.withName(Translations.PREVIOUS_PAGE.get(player))
|
||||
.withLore(Translations.PREVIOUS_PAGE_LORE.getList(player))
|
||||
.withName(Translations.PREVIOUS_PAGE.get(player).get(0))
|
||||
.withLore(Translations.PREVIOUS_PAGE_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build()
|
||||
:
|
||||
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))
|
||||
.withName(Translations.PREVIOUS_PAGE.get(player).get(0))
|
||||
.withLore(Translations.PREVIOUS_PAGE_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build();
|
||||
|
||||
@@ -115,15 +115,15 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
||||
ItemStack forwardItem = fm.startsWith("hdb-") && plugin.hasHeadDatabase()
|
||||
?
|
||||
new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(fm.replace("hdb-", "")))
|
||||
.withName(Translations.NEXT_PAGE.get(player))
|
||||
.withLore(Translations.NEXT_PAGE_LORE.getList(player))
|
||||
.withName(Translations.NEXT_PAGE.get(player).get(0))
|
||||
.withLore(Translations.NEXT_PAGE_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build()
|
||||
:
|
||||
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))
|
||||
.withName(Translations.NEXT_PAGE.get(player).get(0))
|
||||
.withLore(Translations.NEXT_PAGE_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build();
|
||||
|
||||
@@ -143,15 +143,15 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
||||
ItemStack item = em.startsWith("hdb-") && plugin.hasHeadDatabase()
|
||||
?
|
||||
new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(em.replace("hdb-", "")))
|
||||
.withName(Translations.EXIT.get(player))
|
||||
.withLore(Translations.EXIT_LORE.getList(player))
|
||||
.withName(Translations.EXIT.get(player).get(0))
|
||||
.withLore(Translations.EXIT_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build()
|
||||
:
|
||||
new ItemStackBuilder(Material.valueOf(
|
||||
plugin.getConfig().getString("settings.server.gui.exit.exit")))
|
||||
.withName(Translations.EXIT.get(player))
|
||||
.withLore(Translations.EXIT_LORE.getList(player))
|
||||
.withName(Translations.EXIT.get(player).get(0))
|
||||
.withLore(Translations.EXIT_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build();
|
||||
exit.addItem(new GuiItem(item, event -> {
|
||||
@@ -179,7 +179,7 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
||||
ChatColor colour = hasDiscovered
|
||||
? ChatColor.valueOf(plugin.getConfig().getString("settings.server.discoveries.discovered.name-colour"))
|
||||
: ChatColor.valueOf(plugin.getConfig().getString("settings.server.discoveries.undiscovered.name-colour"));
|
||||
String lore = account.getDiscoveredRegions().containsKey(configuredRegion.getId())
|
||||
List<String> lore = account.getDiscoveredRegions().containsKey(configuredRegion.getId())
|
||||
? Translations.DISCOVERED_ON.get(player,
|
||||
account.getDiscoveredRegions().get(configuredRegion.getId()).getDate())
|
||||
: null;
|
||||
@@ -197,7 +197,7 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
||||
&& !hasDiscovered
|
||||
? translatedHint
|
||||
: null;
|
||||
String teleport = configuredRegion.isTeleportable()
|
||||
List<String> teleport = configuredRegion.isTeleportable()
|
||||
&& player.hasPermission("rpgregions.teleport")
|
||||
&& hasDiscovered
|
||||
? Translations.TELEPORT.get(player)
|
||||
|
||||
@@ -56,8 +56,8 @@ public class EditGuiElementGUI extends RPGRegionsGUI {
|
||||
// Exit item
|
||||
Material em = Material.valueOf(plugin.getConfig().getString("settings.server.gui.exit.exit"));
|
||||
ItemStack exitItem = new ItemStackBuilder(em)
|
||||
.withName(Translations.EXIT.get(player))
|
||||
.withLore(Translations.EXIT_LORE.getList(player))
|
||||
.withName(Translations.EXIT.get(player).get(0))
|
||||
.withLore(Translations.EXIT_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build();
|
||||
exit.addItem(new GuiItem(exitItem, event -> {
|
||||
|
||||
@@ -53,8 +53,8 @@ public class EditRegionElementGUI extends RPGRegionsGUI {
|
||||
// Exit item
|
||||
Material em = Material.valueOf(plugin.getConfig().getString("settings.server.gui.exit.exit"));
|
||||
ItemStack exitItem = new ItemStackBuilder(em)
|
||||
.withName(Translations.EXIT.get(player))
|
||||
.withLore(Translations.EXIT_LORE.getList(player))
|
||||
.withName(Translations.EXIT.get(player).get(0))
|
||||
.withLore(Translations.EXIT_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build();
|
||||
exit.addItem(new GuiItem(exitItem, event -> {
|
||||
|
||||
@@ -137,8 +137,8 @@ public abstract class RPGRegionsGUI {
|
||||
// Back item
|
||||
Material bm = Material.valueOf(plugin.getConfig().getString("settings.server.gui.back.back"));
|
||||
ItemStack backItem = new ItemStackBuilder(bm)
|
||||
.withName(Translations.PREVIOUS_PAGE.get(player))
|
||||
.withLore(Translations.PREVIOUS_PAGE_LORE.getList(player))
|
||||
.withName(Translations.PREVIOUS_PAGE.get(player).get(0))
|
||||
.withLore(Translations.PREVIOUS_PAGE_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build();
|
||||
|
||||
@@ -155,8 +155,8 @@ public abstract class RPGRegionsGUI {
|
||||
// Forward item
|
||||
Material fm = Material.valueOf(plugin.getConfig().getString("settings.server.gui.forward.forward"));
|
||||
ItemStack forwardItem = new ItemStackBuilder(fm)
|
||||
.withName(Translations.NEXT_PAGE.get(player))
|
||||
.withLore(Translations.NEXT_PAGE_LORE.getList(player))
|
||||
.withName(Translations.NEXT_PAGE.get(player).get(0))
|
||||
.withLore(Translations.NEXT_PAGE_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build();
|
||||
|
||||
@@ -173,8 +173,8 @@ public abstract class RPGRegionsGUI {
|
||||
// Exit item
|
||||
Material em = Material.valueOf(plugin.getConfig().getString("settings.server.gui.exit.exit"));
|
||||
ItemStack item = new ItemStackBuilder(em)
|
||||
.withName(Translations.EXIT.get(player))
|
||||
.withLore(Translations.EXIT_LORE.getList(player))
|
||||
.withName(Translations.EXIT.get(player).get(0))
|
||||
.withLore(Translations.EXIT_LORE.get(player))
|
||||
.addFlags(ItemFlag.HIDE_ATTRIBUTES)
|
||||
.build();
|
||||
exit.addItem(new GuiItem(item, event -> {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class RegionListener implements Listener {
|
||||
}
|
||||
|
||||
if (configuredRegion.showActionbar() && event.hasChanged() && prioritised) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(Translations.REGION_ENTER_ACTIONBAR.get(player, configuredRegion.getCustomName())));
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(Translations.REGION_ENTER_ACTIONBAR.get(player, configuredRegion.getCustomName()).get(0)));
|
||||
}
|
||||
|
||||
if (!has && configuredRegion.isDiscoverable() && prioritised) {
|
||||
|
||||
Reference in New Issue
Block a user