mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-02-16 10:30:58 +00:00
file and message system revamp + rtp error reasons
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>me.SuperRonanCraft</groupId>
|
||||
<artifactId>BetterRTP</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>3.4.5</version>
|
||||
<version>3.4.5.1-DEV</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
||||
@@ -13,7 +13,7 @@ import me.SuperRonanCraft.BetterRTP.references.Permissions;
|
||||
import me.SuperRonanCraft.BetterRTP.references.web.Updater;
|
||||
import me.SuperRonanCraft.BetterRTP.references.depends.DepEconomy;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.Files;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.Messages;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.MessagesOLD;
|
||||
import me.SuperRonanCraft.BetterRTP.references.invs.RTPInventories;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.CooldownHandler;
|
||||
import me.SuperRonanCraft.BetterRTP.references.settings.Settings;
|
||||
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
|
||||
public class BetterRTP extends JavaPlugin {
|
||||
private final Permissions perms = new Permissions();
|
||||
private final Messages text = new Messages();
|
||||
private final MessagesOLD text = new MessagesOLD();
|
||||
private final DepEconomy eco = new DepEconomy();
|
||||
private final Commands cmd = new Commands(this);
|
||||
private final RTP rtp = new RTP();
|
||||
@@ -92,7 +92,7 @@ public class BetterRTP extends JavaPlugin {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public Messages getText() {
|
||||
public MessagesOLD getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandType;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.Messages;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.MessagesOLD;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -17,7 +16,7 @@ public class CmdHelp implements RTPCommand, RTPCommandHelpable {
|
||||
}
|
||||
|
||||
public void execute(CommandSender sendi, String label, String[] args) {
|
||||
Messages txt = BetterRTP.getInstance().getText();
|
||||
MessagesOLD txt = BetterRTP.getInstance().getText();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(txt.getHelpPrefix());
|
||||
list.add(txt.getHelpMain());
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandType;
|
||||
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -20,7 +20,7 @@ class Interact {
|
||||
|
||||
void load() {
|
||||
String pre = "Settings.";
|
||||
FileBasics.FILETYPE file = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.SIGNS);
|
||||
FileOther.FILETYPE file = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.SIGNS);
|
||||
enabled = file.getBoolean(pre + "Enabled");
|
||||
title = file.getString(pre + "Title");
|
||||
coloredTitle = BetterRTP.getInstance().getText().color(title);
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.SuperRonanCraft.BetterRTP.player.events;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||
import me.SuperRonanCraft.BetterRTP.references.web.Updater;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||
@@ -23,7 +24,7 @@ public class Join {
|
||||
|
||||
//Updater
|
||||
private static void updater(Player p) {
|
||||
if (!getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG).getBoolean("Settings.DisableUpdater") && PermissionNode.UPDATER.check(p))
|
||||
if (!getPl().getFiles().getType(FileOther.FILETYPE.CONFIG).getBoolean("Settings.DisableUpdater") && PermissionNode.UPDATER.check(p))
|
||||
if (!getPl().getDescription().getVersion().equals(Updater.updatedVersion))
|
||||
getPl().getText().sms(p, "&7There is currently an update for &6BetterRTP &7version &e#" +
|
||||
Updater.updatedVersion + " &7you have version &e#" + getPl().getDescription().getVersion());
|
||||
|
||||
@@ -5,15 +5,18 @@ import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.WarningHandler;
|
||||
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_SettingUpEvent;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.PermissionGroup;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RTP {
|
||||
|
||||
@@ -35,7 +38,7 @@ public class RTP {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||
disabledWorlds = config.getStringList("DisabledWorlds");
|
||||
maxAttempts = config.getInt("Settings.MaxAttempts");
|
||||
delayTime = config.getInt("Settings.Delay.Time");
|
||||
@@ -128,21 +131,21 @@ public class RTP {
|
||||
pWorld.setup(null, RTPdefaultWorld, setup_info.getBiomes());
|
||||
}
|
||||
//World type
|
||||
pWorld.setWorldtype(getWorldType(pWorld));
|
||||
pWorld.setWorldtype(getWorldType(pWorld.getWorld()));
|
||||
return pWorld;
|
||||
}
|
||||
|
||||
public static WORLD_TYPE getWorldType(RTPWorld pWorld) {
|
||||
public static WORLD_TYPE getWorldType(World world) {
|
||||
WORLD_TYPE world_type;
|
||||
RTP rtp = BetterRTP.getInstance().getRTP();
|
||||
if (rtp.world_type.containsKey(pWorld.getWorld().getName()))
|
||||
world_type = rtp.world_type.get(pWorld.getWorld().getName());
|
||||
if (rtp.world_type.containsKey(world.getName()))
|
||||
world_type = rtp.world_type.get(world.getName());
|
||||
else {
|
||||
world_type = WORLD_TYPE.NORMAL;
|
||||
rtp.world_type.put(pWorld.getWorld().getName(), world_type); //Defaults this so the error message isn't spammed
|
||||
WarningHandler.warn(WarningHandler.WARNING.NO_WORLD_TYPE_DECLARED, "Seems like the world `" + pWorld.getWorld().getName() + "` does not have a `WorldType` declared. " +
|
||||
rtp.world_type.put(world.getName(), world_type); //Defaults this so the error message isn't spammed
|
||||
WarningHandler.warn(WarningHandler.WARNING.NO_WORLD_TYPE_DECLARED, "Seems like the world `" + world.getName() + "` does not have a `WorldType` declared. " +
|
||||
"Please add/fix this in the config.yml file! This world will be treated as an overworld! " +
|
||||
"If this world is a nether world, configure it to NETHER (example: `- " + pWorld.getWorld().getName() + ": NETHER`", false);
|
||||
"If this world is a nether world, configure it to NETHER (example: `- " + world.getName() + ": NETHER`", false);
|
||||
}
|
||||
return world_type;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.PermissionGroup;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.*;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -20,7 +21,7 @@ public class RTPLoader {
|
||||
customWorlds.clear();
|
||||
BetterRTP.debug("Loading Custom Worlds...");
|
||||
try {
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||
List<Map<?, ?>> map = config.getMapList("CustomWorlds");
|
||||
for (Map<?, ?> m : map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
@@ -45,7 +46,7 @@ public class RTPLoader {
|
||||
BetterRTP.debug("Loading Overrides...");
|
||||
overriden.clear();
|
||||
try {
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||
List<Map<?, ?>> override_map = config.getMapList("Overrides");
|
||||
for (Map<?, ?> m : override_map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
@@ -64,7 +65,7 @@ public class RTPLoader {
|
||||
BetterRTP.debug("Loading World Types...");
|
||||
world_type.clear();
|
||||
try {
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||
for (World world : Bukkit.getWorlds())
|
||||
world_type.put(world.getName(), WORLD_TYPE.NORMAL);
|
||||
List<Map<?, ?>> world_map = config.getMapList("WorldType");
|
||||
@@ -99,7 +100,7 @@ public class RTPLoader {
|
||||
|
||||
static void loadLocations(@NotNull HashMap<String, RTPWorld> worlds) {
|
||||
worlds.clear();
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.LOCATIONS;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.LOCATIONS;
|
||||
if (!config.getBoolean("Enabled"))
|
||||
return;
|
||||
BetterRTP.debug("Loading Locations...");
|
||||
@@ -116,7 +117,7 @@ public class RTPLoader {
|
||||
|
||||
static void loadPermissionGroups(@NotNull HashMap<String, PermissionGroup> permissionGroup) {
|
||||
permissionGroup.clear();
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||
if (!getPl().getSettings().isPermissionGroupEnabled())
|
||||
return;
|
||||
BetterRTP.debug("Loading Permission Groups...");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class RTPParticles {
|
||||
};
|
||||
|
||||
void load() {
|
||||
FileBasics.FILETYPE config = getPl().getFiles().getType(FileBasics.FILETYPE.EFFECTS);
|
||||
FileOther.FILETYPE config = getPl().getFiles().getType(FileOther.FILETYPE.EFFECTS);
|
||||
enabled = config.getBoolean("Particles.Enabled");
|
||||
if (!enabled) return;
|
||||
//Enabled? Load all this junk
|
||||
|
||||
@@ -19,7 +19,7 @@ public class RTPPotions { //Potions AND Invincibility
|
||||
|
||||
void load() {
|
||||
potionEffects.clear();
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.EFFECTS;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.EFFECTS;
|
||||
//Invincible
|
||||
invincibleEnabled = config.getBoolean("Invincible.Enabled");
|
||||
if (invincibleEnabled)
|
||||
|
||||
@@ -16,7 +16,7 @@ public class RTPSounds {
|
||||
private String soundTeleport, soundDelay;
|
||||
|
||||
void load() {
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.EFFECTS;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.EFFECTS;
|
||||
enabled = config.getBoolean("Sounds.Enabled");
|
||||
if (enabled) {
|
||||
soundTeleport = config.getString("Sounds.Success");
|
||||
|
||||
@@ -14,7 +14,7 @@ public class RTPTitles {
|
||||
|
||||
void load() {
|
||||
titles.clear();
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.EFFECTS;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.EFFECTS;
|
||||
enabled = config.getBoolean("Titles.Enabled");
|
||||
if (enabled)
|
||||
for (RTP_TITLE_TYPE type : RTP_TITLE_TYPE.values())
|
||||
@@ -65,7 +65,7 @@ public class RTPTitles {
|
||||
boolean send_message;
|
||||
|
||||
RTP_TITLE(String path) {
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.EFFECTS;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.EFFECTS;
|
||||
title = config.getString("Titles." + path + ".Title");
|
||||
subTitle = config.getString("Titles." + path + ".Subtitle");
|
||||
send_message = config.getBoolean("Titles." + path + ".SendMessage");
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||
|
||||
public enum RTP_ERROR_REQUEST_REASON {
|
||||
IS_RTPING,
|
||||
NO_PERMISSION,
|
||||
WORLD_DISABLED,
|
||||
COOLDOWN,
|
||||
PRICE_ECONOMY,
|
||||
PRICE_HUNGER,
|
||||
}
|
||||
@@ -3,10 +3,12 @@ package me.SuperRonanCraft.BetterRTP.references.depends;
|
||||
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
@@ -56,16 +58,6 @@ public class DepEconomy {
|
||||
public boolean hasBalance(CommandSender sendi, WorldPlayer pWorld) {
|
||||
check(false);
|
||||
Player player = pWorld.getPlayer();
|
||||
//Hunger Stuff
|
||||
if (hunger != 0
|
||||
&& !PermissionNode.BYPASS_HUNGER.check(sendi)
|
||||
&& (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) {
|
||||
boolean has_hunger = player.getFoodLevel() > hunger;
|
||||
if (!has_hunger) {
|
||||
BetterRTP.getInstance().getText().getFailedHunger(sendi);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Economy Stuff
|
||||
if (e != null && pWorld.getPrice() != 0 && !PermissionNode.BYPASS_ECONOMY.check(sendi)) {
|
||||
try {
|
||||
@@ -82,6 +74,23 @@ public class DepEconomy {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasHunger(CommandSender sendi, WorldPlayer pWorld) {
|
||||
check(false);
|
||||
Player player = pWorld.getPlayer();
|
||||
//Hunger Stuff
|
||||
if (hunger != 0
|
||||
&& !PermissionNode.BYPASS_HUNGER.check(sendi)
|
||||
&& (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) {
|
||||
boolean has_hunger = player.getFoodLevel() > hunger;
|
||||
if (!has_hunger) {
|
||||
BetterRTP.getInstance().getText().getFailedHunger(sendi);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Default value
|
||||
return true;
|
||||
}
|
||||
|
||||
/*public void unCharge(Player p, WorldPlayer pWorld) {
|
||||
if (e != null && pWorld.getPrice() != 0 && pWorld.eco_money_taken)
|
||||
e.depositPlayer(p, pWorld.getPrice());
|
||||
@@ -94,15 +103,15 @@ public class DepEconomy {
|
||||
private void check(boolean force) {
|
||||
if (!checked || force)
|
||||
registerEconomy();
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Hunger.Enabled"))
|
||||
hunger = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getInt("Hunger.Honches");
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getBoolean("Hunger.Enabled"))
|
||||
hunger = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getInt("Hunger.Honches");
|
||||
else
|
||||
hunger = 0;
|
||||
}
|
||||
|
||||
private void registerEconomy() {
|
||||
try {
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (BetterRTP.getInstance().getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
RegisteredServiceProvider<Economy> rsp = BetterRTP.getInstance().getServer().getServicesManager().getRegistration(Economy.class);
|
||||
e = rsp.getProvider();
|
||||
|
||||
@@ -3,10 +3,7 @@ package me.SuperRonanCraft.BetterRTP.references.depends;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperDate;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_Command;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_Info;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.*;
|
||||
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.CooldownData;
|
||||
@@ -99,12 +96,15 @@ public class DepPlaceholderAPI extends PlaceholderExpansion {
|
||||
return BetterRTP.getInstance().getSettings().getPlaceholder_nopermission();
|
||||
RTPSetupInformation setupInformation = new RTPSetupInformation(world, player, player, true);
|
||||
//Cooldown
|
||||
if (!HelperRTP.isCoolingDown(player, player, setupInformation, false))
|
||||
if (!HelperRTP_Check.isCoolingDown(player, player, world))
|
||||
return BetterRTP.getInstance().getSettings().getPlaceholder_cooldown();
|
||||
WorldPlayer worldPlayer = BetterRTP.getInstance().getRTP().getPlayerWorld(setupInformation);
|
||||
//Price
|
||||
if (!BetterRTP.getInstance().getEco().hasBalance(player, worldPlayer))
|
||||
return BetterRTP.getInstance().getSettings().getPlaceholder_balance();
|
||||
//Hunger
|
||||
if (!BetterRTP.getInstance().getEco().hasHunger(player, worldPlayer))
|
||||
return BetterRTP.getInstance().getSettings().getPlaceholder_balance();
|
||||
//True
|
||||
return BetterRTP.getInstance().getSettings().getPlaceholder_true();
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class EcoFile {
|
||||
private YamlConfiguration lang = new YamlConfiguration();
|
||||
private File langFile;
|
||||
|
||||
void load() {
|
||||
BetterRTP pl = BetterRTP.getInstance();
|
||||
langFile = new File(pl.getDataFolder(), "economy.yml");
|
||||
if (!langFile.exists())
|
||||
pl.saveResource("economy.yml", false);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
public String getString(String path) {
|
||||
if (lang.isString(path))
|
||||
return lang.getString(path);
|
||||
return "SOMETHING WENT WRONG";
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public List<String> getStringList(String path) {
|
||||
if (lang.isList(path))
|
||||
return lang.getStringList(path);
|
||||
return Arrays.asList("SOMETHING WENT WRONG!");
|
||||
}
|
||||
|
||||
public int getInt(String path) {
|
||||
return lang.getInt(path);
|
||||
}
|
||||
|
||||
public boolean getBoolean(String path) {
|
||||
return lang.getBoolean(path);
|
||||
}
|
||||
|
||||
|
||||
private void loadFile() {
|
||||
try {
|
||||
lang.load(langFile);
|
||||
setDefaults();
|
||||
lang.save(langFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setDefaults() {
|
||||
final InputStream defConfigStream = BetterRTP.getInstance().getResource("economy.yml");
|
||||
if (defConfigStream == null)
|
||||
return;
|
||||
lang.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream)));
|
||||
lang.options().copyDefaults(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface FileData {
|
||||
|
||||
YamlConfiguration getConfig();
|
||||
|
||||
File getFile();
|
||||
|
||||
String fileName();
|
||||
|
||||
Plugin plugin();
|
||||
|
||||
default String getString(String path) {
|
||||
if (getConfig().isString(path))
|
||||
return getConfig().getString(path);
|
||||
return "SOMETHING WENT WRONG";
|
||||
}
|
||||
|
||||
default boolean exists(String path) {
|
||||
return getConfig().contains(path);
|
||||
}
|
||||
|
||||
default boolean getBoolean(String path) {
|
||||
return getConfig().getBoolean(path);
|
||||
}
|
||||
|
||||
default int getInt(String path) {
|
||||
return getConfig().getInt(path);
|
||||
}
|
||||
|
||||
default long getLong(String path) {
|
||||
return getConfig().getLong(path);
|
||||
}
|
||||
|
||||
default List<String> getStringList(String path) {
|
||||
if (getConfig().isList(path))
|
||||
return getConfig().getStringList(path);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
//Can be configured as a String OR List
|
||||
default List<String> getList(String path) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (getConfig().isList(path)) list.addAll(getStringList(path));
|
||||
else if (getConfig().isString(path)) list.add(getString(path));
|
||||
else return List.of("&7The path &e" + path + " &7was not configured correctly!");
|
||||
return list;
|
||||
}
|
||||
|
||||
default ConfigurationSection getConfigurationSection(String path) {
|
||||
return getConfig().getConfigurationSection(path);
|
||||
}
|
||||
|
||||
default boolean isString(String path) {
|
||||
return getConfig().isString(path);
|
||||
}
|
||||
|
||||
default boolean isList(String path) {
|
||||
return getConfig().isList(path);
|
||||
}
|
||||
|
||||
default List<Map<?, ?>> getMapList(String path) {
|
||||
return getConfig().getMapList(path);
|
||||
}
|
||||
|
||||
default void setValue(String path, Object value) {
|
||||
getConfig().set(path, value);
|
||||
}
|
||||
|
||||
//PROCCESSING
|
||||
default void load() {
|
||||
YamlConfiguration config = getConfig();
|
||||
File file = getFile();
|
||||
if (!getFile().exists()) {
|
||||
plugin().saveResource(fileName(), false);
|
||||
try {
|
||||
config.load(file);
|
||||
} catch (Exception e) {
|
||||
plugin().getLogger().info("File " + fileName() + " was unable to load!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
config.load(file);
|
||||
final InputStream in = plugin().getResource(fileName().replace(File.separator, "/"));
|
||||
if (in != null && in.available() > 0) {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(in)));
|
||||
config.options().copyDefaults(true);
|
||||
in.close();
|
||||
} else {
|
||||
System.out.println("Input file was nulled " + fileName());
|
||||
}
|
||||
config.save(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default void save() {
|
||||
try {
|
||||
getConfig().save(getFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class FileLanguage implements FileData {
|
||||
private final YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
@Override
|
||||
public YamlConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fileName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin plugin() {
|
||||
return BetterRTP.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
generateDefaults();
|
||||
String fileName = "lang" + File.separator + FileOther.FILETYPE.CONFIG.getString("Language-File");
|
||||
File file = new File(plugin().getDataFolder(), fileName);
|
||||
if (!file.exists()) {
|
||||
fileName = "lang" + File.separator + defaultLangs[0]; //Default to english
|
||||
file = new File(plugin().getDataFolder(), fileName);
|
||||
}
|
||||
try {
|
||||
config.load(file);
|
||||
InputStream in = plugin().getResource(fileName);
|
||||
if (in == null)
|
||||
in = plugin().getResource(fileName.replace(File.separator, "/"));
|
||||
if (in != null) {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(in)));
|
||||
config.options().copyDefaults(true);
|
||||
in.close();
|
||||
}
|
||||
config.save(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private final String[] defaultLangs = {
|
||||
"chs.yml", //Chinese Simplified (OasisAkari)
|
||||
"cht.yml", //Chinese (OasisAkari & kamiya10)
|
||||
"cs.yml", //Czech (Lewisparkle)
|
||||
"da.yml", //Danish (Janbchr)
|
||||
"de.yml", //German (IBimsDaNico#8690)
|
||||
"en.yml",
|
||||
"es.yml", //Spanish (emgv)
|
||||
"fr.yml", //French (At0micA55 & Mrflo67)
|
||||
"he.yml", //Hebrew (thefourcraft)
|
||||
"it.yml", //Italian (iVillager)
|
||||
"ja.yml", //Japanese (ViaSnake)
|
||||
"nl.yml", //Dutch (QuestalNetwork) (GeleVla)
|
||||
"no.yml", //Norwegian (Fraithor & Janbchr)
|
||||
"pl.yml", //Polish (Farum & TeksuSiK)
|
||||
"ro.yml", //Romanian (GamingXBlood)
|
||||
"ru.yml", //Russian (Logan)
|
||||
"vi.yml", //Vietnamese (VoChiDanh#0862)
|
||||
};
|
||||
|
||||
private void generateDefaults() {
|
||||
//Generate all language files
|
||||
for (String yaml : defaultLangs) {
|
||||
generateDefaultConfig(yaml, yaml); //Generate its own defaults
|
||||
if (!yaml.equals(defaultLangs[0]))
|
||||
generateDefaultConfig(yaml, defaultLangs[0]); //Generate the english defaults (incase)
|
||||
}
|
||||
}
|
||||
|
||||
private void generateDefaultConfig(String fName, String fNameDef /*Name of file to generate defaults*/) {
|
||||
String fileName = "lang" + File.separator + fName;
|
||||
File file = new File(plugin().getDataFolder(), fileName);
|
||||
if (!file.exists())
|
||||
plugin().saveResource(fileName, false);
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.load(file);
|
||||
String fileNameDef = "lang" + File.separator + fNameDef;
|
||||
InputStream in = plugin().getResource(fileNameDef);
|
||||
if (in == null)
|
||||
in = plugin().getResource(fileNameDef.replace(File.separator, "/"));
|
||||
if (in != null) {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(in)));
|
||||
config.options().copyDefaults(true);
|
||||
in.close();
|
||||
}
|
||||
config.save(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FileOther {
|
||||
|
||||
List<FILETYPE> types = new ArrayList<>();
|
||||
|
||||
void load() {
|
||||
types.clear();
|
||||
for (FILETYPE type : FILETYPE.values()) {
|
||||
type.load();
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public enum FILETYPE implements FileData {
|
||||
CONFIG("config"),
|
||||
ECO("economy"),
|
||||
SIGNS("signs"),
|
||||
EFFECTS("effects"),
|
||||
LOCATIONS("locations"),
|
||||
PLACEHOLDERS("placeholders")
|
||||
;
|
||||
|
||||
private final String fileName;
|
||||
private final YamlConfiguration config = new YamlConfiguration();
|
||||
private final File file;
|
||||
|
||||
FILETYPE(String str) {
|
||||
this.fileName = str + ".yml";
|
||||
this.file = new File(plugin().getDataFolder(), fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin plugin() {
|
||||
return BetterRTP.getInstance();
|
||||
}
|
||||
|
||||
//PUBLIC
|
||||
@Override
|
||||
public YamlConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fileName() {
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
public class Files {
|
||||
private final LangFile langFile = new LangFile();
|
||||
private final FileBasics basics = new FileBasics();
|
||||
private final FileLanguage langFile = new FileLanguage();
|
||||
private final FileOther basics = new FileOther();
|
||||
|
||||
LangFile getLang() {
|
||||
FileLanguage getLang() {
|
||||
return langFile;
|
||||
}
|
||||
|
||||
public FileBasics.FILETYPE getType(FileBasics.FILETYPE type) {
|
||||
public FileOther.FILETYPE getType(FileOther.FILETYPE type) {
|
||||
return basics.types.get(basics.types.indexOf(type));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class LangFile {
|
||||
@SuppressWarnings("all")
|
||||
public void load() {
|
||||
generateDefaults();
|
||||
String fileName = "lang" + File.separator + getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG).getString("Language-File");
|
||||
String fileName = "lang" + File.separator + getPl().getFiles().getType(FileOther.FILETYPE.CONFIG).getString("Language-File");
|
||||
File file = new File(getPl().getDataFolder(), fileName);
|
||||
if (!file.exists()) {
|
||||
fileName = "lang" + File.separator + defaultLangs[0]; //Default to english
|
||||
|
||||
@@ -8,10 +8,10 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Messages {
|
||||
public class MessagesOLD {
|
||||
private final String preM = "Messages.", preH = "Help.", preU = "Usage.";
|
||||
|
||||
private LangFile getLang() {
|
||||
private FileLanguage getLang() {
|
||||
return BetterRTP.getInstance().getFiles().getLang();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.SuperRonanCraft.BetterRTP.references.helpers;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.types.CmdLocation;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_ERROR_REQUEST_REASON;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.CooldownData;
|
||||
@@ -41,21 +42,14 @@ public class HelperRTP {
|
||||
|
||||
public static void tp(@NotNull Player player, CommandSender sendi, @Nullable World world, List<String> biomes, RTP_TYPE rtpType,
|
||||
boolean ignoreCooldown, boolean ignoreDelay, WorldLocations locations) {
|
||||
if (isRTPing(player, sendi)) //Is RTP'ing
|
||||
return;
|
||||
if (world == null)
|
||||
world = player.getWorld();
|
||||
if (BetterRTP.getInstance().getRTP().overriden.containsKey(world.getName()))
|
||||
world = Bukkit.getWorld(BetterRTP.getInstance().getRTP().overriden.get(world.getName()));
|
||||
RTP_ERROR_REQUEST_REASON cantReason = HelperRTP_Check.canRTP(player, sendi, world, ignoreCooldown);
|
||||
// Not forced and has 'betterrtp.world.<world>'
|
||||
if (sendi == player && !PermissionNode.getAWorld(sendi, world.getName())) {
|
||||
getPl().getText().getNoPermissionWorld(player, world.getName());
|
||||
return;
|
||||
}
|
||||
// Check disabled worlds
|
||||
if (getPl().getRTP().getDisabledWorlds().contains(world.getName())) {
|
||||
getPl().getText().getDisabledWorld(sendi, world.getName());
|
||||
return;
|
||||
if (cantReason != null) {
|
||||
|
||||
}
|
||||
boolean delay = false;
|
||||
if (!ignoreDelay && sendi == player) //Forced?
|
||||
@@ -63,65 +57,8 @@ public class HelperRTP {
|
||||
if (!PermissionNode.BYPASS_DELAY.check(player)) //Can bypass?
|
||||
delay = true;
|
||||
RTPSetupInformation setup_info = new RTPSetupInformation(world, sendi, player, true,
|
||||
biomes, delay, rtpType, locations, !ignoreCooldown && cooldownApplies(sendi, player)); //ignore cooldown or else
|
||||
if (ignoreCooldown || isCoolingDown(sendi, player, setup_info, true)) { //Is Cooling down
|
||||
getPl().getRTP().start(setup_info);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isRTPing(Player player, CommandSender sendi) {
|
||||
if (getPl().getpInfo().getRtping().getOrDefault(player, false)) {
|
||||
getPl().getText().getAlready(sendi);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isCoolingDown(CommandSender sendi, Player player, RTPSetupInformation setupInfo, boolean sendText) {
|
||||
if (!cooldownApplies(sendi, player)) //Bypassing/Forced?
|
||||
return true;
|
||||
CooldownHandler cooldownHandler = getPl().getCooldowns();
|
||||
if (!cooldownHandler.isLoaded() || !cooldownHandler.loadedPlayer(player)) { //Cooldowns have yet to download
|
||||
if (sendText)
|
||||
getPl().getText().getCooldown(sendi, String.valueOf(-1L));
|
||||
return false;
|
||||
}
|
||||
//Cooldown Data
|
||||
CooldownData cooldownData = getPl().getCooldowns().get(player, setupInfo.getWorld());
|
||||
if (cooldownData != null) {
|
||||
if (cooldownData.getTime() == 0) //Global cooldown with nothing
|
||||
return true;
|
||||
else if (cooldownHandler.locked(player)) { //Infinite cooldown (locked)
|
||||
if (sendText)
|
||||
getPl().getText().getNoPermission(sendi);
|
||||
return false;
|
||||
} else { //Normal cooldown
|
||||
long timeLeft = cooldownHandler.timeLeft(player, cooldownData, BetterRTP.getInstance().getRTP().getPlayerWorld(setupInfo));
|
||||
if (timeLeft > 0) {
|
||||
//Still cooling down
|
||||
if (sendText)
|
||||
getPl().getText().getCooldown(sendi, String.valueOf(timeLeft));
|
||||
return false;
|
||||
} else {
|
||||
//Reset timer, but allow them to tp
|
||||
//cooldowns.add(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean cooldownOverride(CommandSender sendi, Player player) {
|
||||
return sendi != player || PermissionNode.BYPASS_COOLDOWN.check(player);
|
||||
}
|
||||
|
||||
private static boolean cooldownEnabled() {
|
||||
return getPl().getCooldowns().isEnabled();
|
||||
}
|
||||
|
||||
private static boolean cooldownApplies(CommandSender sendi, Player player) {
|
||||
return cooldownEnabled() && !cooldownOverride(sendi, player);
|
||||
biomes, delay, rtpType, locations, !ignoreCooldown && HelperRTP_Check.checkCooldown(sendi, player)); //ignore cooldown or else
|
||||
getPl().getRTP().start(setup_info);
|
||||
}
|
||||
|
||||
private static BetterRTP getPl() {
|
||||
@@ -138,4 +75,6 @@ public class HelperRTP {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.helpers;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.types.CmdLocation;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_ERROR_REQUEST_REASON;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.CooldownData;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.CooldownHandler;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldLocations;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class HelperRTP_Check {
|
||||
|
||||
public static RTP_ERROR_REQUEST_REASON canRTP(Player player, CommandSender sendi, World world, boolean ignoreCooldown) {
|
||||
if (isRTPing(player)) { //Is RTP'ing
|
||||
//getPl().getText().getAlready(sendi);
|
||||
return RTP_ERROR_REQUEST_REASON.IS_RTPING;
|
||||
}
|
||||
// Not forced and has 'betterrtp.world.<world>'
|
||||
if (sendi == player && !PermissionNode.getAWorld(sendi, world.getName())) {
|
||||
//getPl().getText().getNoPermissionWorld(player, world.getName());
|
||||
return RTP_ERROR_REQUEST_REASON.NO_PERMISSION;
|
||||
}
|
||||
// Check disabled worlds
|
||||
if (getPl().getRTP().getDisabledWorlds().contains(world.getName())) {
|
||||
//getPl().getText().getDisabledWorld(sendi, world.getName());
|
||||
return RTP_ERROR_REQUEST_REASON.WORLD_DISABLED;
|
||||
}
|
||||
if (sendi == player && checkCooldown(sendi, player) && !isCoolingDown(sendi, player, world)) { //Is Cooling down
|
||||
return RTP_ERROR_REQUEST_REASON.COOLDOWN;
|
||||
}
|
||||
if (getPl().getEco().hasBalance(sendi, ))
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isRTPing(Player player) {
|
||||
return getPl().getpInfo().getRtping().getOrDefault(player, false);
|
||||
}
|
||||
|
||||
public static boolean isCoolingDown(CommandSender sendi, Player player, World world) {
|
||||
if (!checkCooldown(sendi, player)) //Bypassing/Forced?
|
||||
return true;
|
||||
CooldownHandler cooldownHandler = getPl().getCooldowns();
|
||||
if (!cooldownHandler.isLoaded() || !cooldownHandler.loadedPlayer(player)) { //Cooldowns have yet to download
|
||||
getPl().getText().getCooldown(sendi, String.valueOf(-1L));
|
||||
return false;
|
||||
}
|
||||
//Cooldown Data
|
||||
CooldownData cooldownData = getPl().getCooldowns().get(player, world);
|
||||
if (cooldownData != null) {
|
||||
if (cooldownData.getTime() == 0) //Global cooldown with nothing
|
||||
return true;
|
||||
else if (cooldownHandler.locked(player)) { //Infinite cooldown (locked)
|
||||
getPl().getText().getNoPermission(sendi);
|
||||
return false;
|
||||
} else { //Normal cooldown
|
||||
long timeLeft = cooldownHandler.timeLeft(player, cooldownData, world);
|
||||
if (timeLeft > 0) {
|
||||
//Still cooling down
|
||||
getPl().getText().getCooldown(sendi, String.valueOf(timeLeft));
|
||||
return false;
|
||||
} else {
|
||||
//Reset timer, but allow them to tp
|
||||
//cooldowns.add(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean checkCooldown(CommandSender sendi, Player player) {
|
||||
return getPl().getCooldowns().isEnabled() && !(sendi != player || PermissionNode.BYPASS_COOLDOWN.check(player));
|
||||
}
|
||||
|
||||
private static BetterRTP getPl() {
|
||||
return BetterRTP.getInstance();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package me.SuperRonanCraft.BetterRTP.references.helpers;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.types.CmdEdit;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WORLD_TYPE;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -17,17 +18,17 @@ public class HelperRTP_EditWorlds {
|
||||
|
||||
public static void editCustomWorld(CommandSender sendi, CmdEdit.RTP_CMD_EDIT_SUB cmd, String world, String val) {
|
||||
String path = "CustomWorlds";
|
||||
if (editSingleMap(sendi, cmd, world, val, path, FileBasics.FILETYPE.CONFIG))
|
||||
if (editSingleMap(sendi, cmd, world, val, path, FileOther.FILETYPE.CONFIG))
|
||||
BetterRTP.getInstance().getRTP().loadWorlds();
|
||||
}
|
||||
|
||||
public static void editLocation(CommandSender sendi, CmdEdit.RTP_CMD_EDIT_SUB cmd, String location, String val) {
|
||||
String path = "Locations";
|
||||
if (editSingleMap(sendi, cmd, location, val, path, FileBasics.FILETYPE.LOCATIONS))
|
||||
if (editSingleMap(sendi, cmd, location, val, path, FileOther.FILETYPE.LOCATIONS))
|
||||
BetterRTP.getInstance().getRTP().loadLocations();
|
||||
}
|
||||
|
||||
private static boolean editSingleMap(CommandSender sendi, CmdEdit.RTP_CMD_EDIT_SUB cmd, String field, String val, String path, FileBasics.FILETYPE file) {
|
||||
private static boolean editSingleMap(CommandSender sendi, CmdEdit.RTP_CMD_EDIT_SUB cmd, String field, String val, String path, FileOther.FILETYPE file) {
|
||||
Object value;
|
||||
try {
|
||||
value = cmd.getResult(val);
|
||||
@@ -91,7 +92,7 @@ public class HelperRTP_EditWorlds {
|
||||
}
|
||||
|
||||
String path = "PermissionGroup.Groups";
|
||||
FileBasics.FILETYPE file = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE file = FileOther.FILETYPE.CONFIG;
|
||||
YamlConfiguration config = file.getConfig();
|
||||
|
||||
List<Map<?, ?>> map = config.getMapList(path);
|
||||
@@ -150,7 +151,7 @@ public class HelperRTP_EditWorlds {
|
||||
return;
|
||||
}
|
||||
|
||||
FileBasics.FILETYPE file = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE file = FileOther.FILETYPE.CONFIG;
|
||||
YamlConfiguration config = file.getConfig();
|
||||
|
||||
config.set("Default." + cmd.get(), value);
|
||||
@@ -175,7 +176,7 @@ public class HelperRTP_EditWorlds {
|
||||
return;
|
||||
}
|
||||
|
||||
FileBasics.FILETYPE file = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE file = FileOther.FILETYPE.CONFIG;
|
||||
YamlConfiguration config = file.getConfig();
|
||||
|
||||
List<Map<?, ?>> world_map = config.getMapList("WorldType");
|
||||
@@ -204,7 +205,7 @@ public class HelperRTP_EditWorlds {
|
||||
|
||||
public static void editOverride(CommandSender sendi, String world, String val) {
|
||||
|
||||
FileBasics.FILETYPE file = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE file = FileOther.FILETYPE.CONFIG;
|
||||
YamlConfiguration config = file.getConfig();
|
||||
|
||||
List<Map<?, ?>> world_map = config.getMapList("Overrides");
|
||||
@@ -237,7 +238,7 @@ public class HelperRTP_EditWorlds {
|
||||
|
||||
public static void editBlacklisted(CommandSender sendi, String block, boolean add) {
|
||||
|
||||
FileBasics.FILETYPE file = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE file = FileOther.FILETYPE.CONFIG;
|
||||
YamlConfiguration config = file.getConfig();
|
||||
|
||||
List<String> world_map = config.getStringList("BlacklistedBlocks");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.invs;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics.FILETYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther.FILETYPE;
|
||||
|
||||
public enum RTP_SETTINGS {
|
||||
BLACKLIST( SETTINGS_TYPE.BOOLEAN, FILETYPE.CONFIG, "Template.Enabled",
|
||||
|
||||
@@ -2,7 +2,7 @@ package me.SuperRonanCraft.BetterRTP.references.invs.types;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTPInventory;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics.FILETYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther.FILETYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTP_INV_ITEMS;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.messages;
|
||||
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import lombok.NonNull;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileData;
|
||||
import me.ronancraft.AmethystGear.AmethystGear;
|
||||
import me.ronancraft.AmethystGear.resources.files.FileData;
|
||||
import me.ronancraft.AmethystGear.resources.messages.placeholderdata.PlaceholderAnalyzer;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public interface Message {
|
||||
|
||||
FileData lang();
|
||||
|
||||
static void sms(Message messenger, CommandSender sendi, String msg) {
|
||||
if (!msg.isEmpty())
|
||||
Bukkit.getScheduler().runTask(AmethystGear.getInstance(), () ->
|
||||
sendi.sendMessage(placeholder(sendi, getPrefix(messenger) + msg)));
|
||||
}
|
||||
|
||||
static void sms(Message messenger, CommandSender sendi, String msg, Object placeholderInfo) {
|
||||
if (!msg.isEmpty())
|
||||
Bukkit.getScheduler().runTask(AmethystGear.getInstance(), () ->
|
||||
sendi.sendMessage(Objects.requireNonNull(placeholder(sendi, getPrefix(messenger) + msg, placeholderInfo))));
|
||||
}
|
||||
|
||||
static void sms(Message messenger, CommandSender sendi, String msg, List<Object> placeholderInfo) {
|
||||
if (!msg.isEmpty())
|
||||
Bukkit.getScheduler().runTask(AmethystGear.getInstance(), () ->
|
||||
sendi.sendMessage(placeholder(sendi, getPrefix(messenger) + msg, placeholderInfo)));
|
||||
}
|
||||
|
||||
static void sms(CommandSender sendi, List<String> msg, Object placeholderInfo) {
|
||||
if (msg != null && !msg.isEmpty()) {
|
||||
Bukkit.getScheduler().runTask(AmethystGear.getInstance(), () -> {
|
||||
msg.forEach(str -> msg.set(msg.indexOf(str), placeholder(sendi, str, placeholderInfo)));
|
||||
sendi.sendMessage(msg.toArray(new String[0]));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void smsActionBar(Player sendi, List<String> msg) {
|
||||
if (msg == null || msg.isEmpty()) return;
|
||||
String str = msg.get(new Random().nextInt(msg.size()));
|
||||
smsActionBar(sendi, str);
|
||||
}
|
||||
|
||||
static void smsActionBar(Player sendi, String msg) {
|
||||
if (msg == null || msg.isEmpty()) return;
|
||||
sendi.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
||||
TextComponent.fromLegacyText(msg));
|
||||
}
|
||||
|
||||
static void smsTitle(Player sendi, List<String> msg) {
|
||||
if (msg == null || msg.isEmpty()) return;
|
||||
if (msg.size() == 1)
|
||||
Audience.audience(sendi).showTitle(Title.title(Component.text(" "), Component.text(msg.get(0))));
|
||||
else
|
||||
Audience.audience(sendi).showTitle(Title.title(Component.text(msg.get(0)), Component.text(msg.get(1))));
|
||||
}
|
||||
|
||||
static String getPrefix(Message messenger) {
|
||||
return messenger.lang().getString("Messages.Prefix");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param info: Accepts String, PersistentDataContainer
|
||||
* **/
|
||||
static List<String> placeholder(@Nullable CommandSender p, List<String> str, Object info) {
|
||||
if (str instanceof ImmutableCollection)
|
||||
return str;
|
||||
for (int i = 0; i < str.size(); i++) {
|
||||
String s = placeholder(p, str.get(i), info);
|
||||
if (s != null)
|
||||
str.set(i, s);
|
||||
else {
|
||||
str.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
//str.forEach(s -> str.set(str.indexOf(s), placeholder(p, s, info)));
|
||||
return str;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static String placeholder(@Nullable CommandSender p, String str, @Nullable Object info) {
|
||||
if (info instanceof Collection<?>)
|
||||
str = placeholder(p, str, Collections.unmodifiableList((List<?>) info));
|
||||
else if (str != null)
|
||||
str = PlaceholderAnalyzer.applyPlaceholders(p, str, info);
|
||||
if (str != null)
|
||||
return color(str);
|
||||
return null;
|
||||
}
|
||||
|
||||
static String placeholder(@Nullable CommandSender p, String str, @NonNull List<Object> info) {
|
||||
for (Object obj : info)
|
||||
str = placeholder(p, str, obj);
|
||||
return str;
|
||||
}
|
||||
|
||||
static String placeholder(@Nullable CommandSender p, String str) {
|
||||
if (str != null)
|
||||
str = PlaceholderAnalyzer.applyPlaceholders(p, str, null);
|
||||
if (str != null)
|
||||
return color(str);
|
||||
return null;
|
||||
}
|
||||
|
||||
static String color(String str) {
|
||||
str = ChatColor.translateAlternateColorCodes('&', str);
|
||||
return translateHexColorCodes(str);
|
||||
}
|
||||
|
||||
char COLOR_CHAR = ChatColor.COLOR_CHAR;
|
||||
|
||||
private static String translateHexColorCodes(String message)
|
||||
{
|
||||
final Pattern hexPattern = Pattern.compile("&#" + "([A-Fa-f0-9]{6})");
|
||||
Matcher matcher = hexPattern.matcher(message);
|
||||
StringBuilder buffer = new StringBuilder(message.length() + 4 * 8);
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group(1);
|
||||
matcher.appendReplacement(buffer, COLOR_CHAR + "x"
|
||||
+ COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
|
||||
+ COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
|
||||
+ COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
|
||||
);
|
||||
}
|
||||
return matcher.appendTail(buffer).toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.messages;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileData;
|
||||
import me.ronancraft.AmethystGear.resources.files.FileData;
|
||||
|
||||
public interface MessageData {
|
||||
|
||||
String section();
|
||||
|
||||
String prefix();
|
||||
|
||||
FileData file();
|
||||
|
||||
default String get() {
|
||||
return file().getString(prefix() + section());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.messages;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.ronancraft.AmethystGear.AmethystGear;
|
||||
import me.ronancraft.AmethystGear.resources.files.FileData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Message_RTP implements Message {
|
||||
|
||||
static Message_RTP msg = new Message_RTP();
|
||||
|
||||
public static FileData getLang() {
|
||||
return BetterRTP.getInstance().getFiles().getLang();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileData lang() {
|
||||
return getLang();
|
||||
}
|
||||
|
||||
public static void sms(CommandSender sendi, String msg) {
|
||||
Message.sms(Message_Gear.msg, sendi, msg);
|
||||
}
|
||||
|
||||
public static void sms(CommandSender sendi, String msg, Object placeholderInfo) {
|
||||
Message.sms(Message_Gear.msg, sendi, msg, placeholderInfo);
|
||||
}
|
||||
|
||||
public static void sms(CommandSender sendi, String msg, List<Object> placeholderInfo) {
|
||||
Message.sms(Message_Gear.msg, sendi, msg, placeholderInfo);
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return Message.getPrefix(Message_Gear.msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.messages;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public enum MessagesCore {
|
||||
RELOAD("Reload"),
|
||||
NOPERMISSION("NoPermission"),
|
||||
INVALID("Invalid"),
|
||||
INVALID_MATERIAL("InvalidMaterial"),
|
||||
ERROR("DatabaseError"),
|
||||
PLAYER_DOESNT_EXIST("PlayerExist"),
|
||||
UNSUPPORTED_MOB("UnsupportedMob"),
|
||||
//GEAR
|
||||
GEAR_GIVEN("Gear.Given"),
|
||||
GEAR_EQUIPPED("Gear.Equipped"),
|
||||
GEAR_EQUIPPED_FULL("Gear.FullInventory"),
|
||||
GEAR_UNEQUIPPED("Gear.Unequipped"),
|
||||
GEAR_UPGRADED("Gear.Upgraded"),
|
||||
GEAR_CATALYST_UPGRADED("Gear.Catalyst-Upgraded"),
|
||||
//CATALYSTS
|
||||
CATALYST_GIVEN("Catalyst.Given"),
|
||||
CATALYST_ADDED("Catalyst.Added"),
|
||||
CATALYST_REMOVED("Catalyst.Removed"),
|
||||
CATALYST_REMOVED_SHATTERED("Catalyst.Removed-Shattered"),
|
||||
CATALYST_UPGRADED("Catalyst.Upgraded"),
|
||||
//COINS
|
||||
COINS_GIVEN("Coins.Given"),
|
||||
COINS_NOTENOUGH("Coins.NotEnough"),
|
||||
//AMETHYSTS
|
||||
AMETHSYT_GIVEN("Amethyst.Given"),
|
||||
AMETHSYT_NOTENOUGH("Amethyst.NotEnough"),
|
||||
//GEODES
|
||||
GEODE_GIVEN("Geodes.Given"),
|
||||
GEODE_FRAGMENT_GIVEN("Geodes.Fragments.Given"),
|
||||
//TRACKERS
|
||||
TRACKER_GIVEN("Tracker.Given"),
|
||||
TRACKER_ADDED("Tracker.Added"),
|
||||
//SHOP
|
||||
SHOP_LINK("Shop.Link"),
|
||||
;
|
||||
|
||||
final String section;
|
||||
|
||||
MessagesCore(String section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
private static final String pre = "Messages.";
|
||||
|
||||
public void send(CommandSender sendi) {
|
||||
Message_Gear.sms(sendi, Message_Gear.getLang().getString(pre + section));
|
||||
}
|
||||
|
||||
public void send(CommandSender sendi, Object placeholderInfo) {
|
||||
Message_Gear.sms(sendi, Message_Gear.getLang().getString(pre + section), placeholderInfo);
|
||||
}
|
||||
|
||||
public void send(CommandSender sendi, List<Object> placeholderInfo) {
|
||||
Message_Gear.sms(sendi, Message_Gear.getLang().getString(pre + section), placeholderInfo);
|
||||
}
|
||||
|
||||
public String get(CommandSender p, Object placeholderInfo) {
|
||||
return Message.placeholder(p, Message_Gear.getLang().getString(pre + section), placeholderInfo);
|
||||
}
|
||||
|
||||
public void send(CommandSender sendi, HashMap<String, String> placeholder_values) {
|
||||
String msg = Message_Gear.getLang().getString(pre + section);
|
||||
for (String ph : placeholder_values.values())
|
||||
msg = msg.replace(ph, placeholder_values.get(ph));
|
||||
Message_Gear.sms(sendi, msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.messages;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileData;
|
||||
import me.ronancraft.AmethystGear.resources.files.FileData;
|
||||
|
||||
public enum MessagesHelp implements MessageData {
|
||||
|
||||
PREFIX("Prefix"),
|
||||
//Amethyst
|
||||
AMETHYST_ADMIN("Admin"),
|
||||
AMETHYST_CATALOG("Catalog"),
|
||||
AMETHYST_CATALYSTS("Catalysts"),
|
||||
AMETHYST_GEAR("Gear"),
|
||||
AMETHYST_GEODES("Geodes"),
|
||||
AMETHYST_GIVE("Give"),
|
||||
AMETHYST_PROFILE("Profile"),
|
||||
AMETHYST_SHOP("Shop"),
|
||||
AMETHYST_XPBOOST("XPBoost"),
|
||||
//Base
|
||||
RELOAD("Reload"),
|
||||
HELP("Help"),
|
||||
;
|
||||
|
||||
final String section;
|
||||
|
||||
MessagesHelp(String section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String prefix() {
|
||||
return "Help.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileData file() {
|
||||
return Message_Gear.getLang();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String section() {
|
||||
return section;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.messages;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileData;
|
||||
import me.ronancraft.AmethystGear.resources.files.FileData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public enum MessagesUsage implements MessageData {
|
||||
|
||||
GIVE_GEAR("Give.Gear"),
|
||||
GIVE_CATALYST("Give.Catalyst"),
|
||||
GIVE_TRACKER("Give.Tracker"),
|
||||
GIVE_COINS("Give.Coins"),
|
||||
GIVE_AMETHYSTS("Give.Amethysts"),
|
||||
GIVE_GEODES("Give.Geodes"),
|
||||
XPBOOST_PLAYER("XpBoost.Player"),
|
||||
XPBOOST_ONLINE("XpBoost.Online"),
|
||||
XPBOOST_GLOBAL("XpBoost.Global"),
|
||||
SPAWN_MOB("SpawnMob"),
|
||||
RELOAD("Reload"),
|
||||
;
|
||||
|
||||
final String section;
|
||||
|
||||
MessagesUsage(String section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
public void send(CommandSender sendi, Object placeholderInfo) {
|
||||
Message_Gear.sms(sendi, Message_Gear.getLang().getString(prefix() + section), placeholderInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String prefix() {
|
||||
return "Usage.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String section() {
|
||||
return section;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileData file() {
|
||||
return Message_Gear.getLang();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.database.DatabaseCooldowns;
|
||||
import me.SuperRonanCraft.BetterRTP.references.database.DatabaseHandler;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||
@@ -29,7 +30,7 @@ public class CooldownHandler {
|
||||
|
||||
public void load() {
|
||||
//configfile = new File(BetterRTP.getInstance().getDataFolder(), "data/cooldowns.yml");
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||
enabled = config.getBoolean("Settings.Cooldown.Enabled");
|
||||
downloading.clear();
|
||||
loaded = false;
|
||||
@@ -96,7 +97,7 @@ public class CooldownHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long timeLeft(CommandSender sendi, CooldownData data, RTPWorld rtpWorld) {
|
||||
public long timeLeft(CommandSender sendi, CooldownData data, World world) {
|
||||
long cooldown = data.getTime();
|
||||
long timeLeft = ((cooldown / 1000) + rtpWorld.getCooldown()) - (System.currentTimeMillis() / 1000);
|
||||
if (BetterRTP.getInstance().getSettings().isDelayEnabled() && !PermissionNode.BYPASS_DELAY.check(sendi))
|
||||
|
||||
@@ -199,7 +199,7 @@ public class QueueHandler implements Listener { //Randomly queues up some safe l
|
||||
PaperLib.getChunkAtAsync(loc)
|
||||
.thenAccept(v -> {
|
||||
Location safeLoc = RTPPlayer.getSafeLocation(
|
||||
RTP.getWorldType(rtpWorld),
|
||||
RTP.getWorldType(rtpWorld.getWorld()),
|
||||
loc.getWorld(),
|
||||
loc,
|
||||
rtpWorld.getMinY(),
|
||||
|
||||
@@ -21,7 +21,7 @@ public class WorldCustom implements RTPWorld, RTPWorld_Defaulted {
|
||||
|
||||
public WorldCustom(World world) {
|
||||
//String pre = "CustomWorlds.";
|
||||
FileBasics.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
FileOther.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.CONFIG);
|
||||
List<Map<?, ?>> map = config.getMapList("CustomWorlds");
|
||||
this.world = world;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class WorldCustom implements RTPWorld, RTPWorld_Defaulted {
|
||||
BetterRTP.debug("- Biomes: " + this.biomes);
|
||||
}
|
||||
}
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (test.get("Price") != null) {
|
||||
if (test.get("Price").getClass() == Integer.class)
|
||||
this.price = Integer.parseInt(test.get("Price").toString());
|
||||
|
||||
@@ -23,7 +23,7 @@ public class WorldDefault implements RTPWorld {
|
||||
BetterRTP.debug("Loading Defaults...");
|
||||
//Setups
|
||||
String pre = "Default";
|
||||
FileBasics.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
FileOther.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.CONFIG);
|
||||
//Booleans
|
||||
useWorldborder = config.getBoolean(pre + ".UseWorldBorder");
|
||||
//Integers
|
||||
@@ -45,10 +45,10 @@ public class WorldDefault implements RTPWorld {
|
||||
minRad = 0;
|
||||
}
|
||||
prices.clear();
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled")) {
|
||||
price = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getInt("Economy.Price");
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("CustomWorlds.Enabled")) {
|
||||
List<Map<?, ?>> world_map = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getMapList("CustomWorlds.Prices");
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getBoolean("Economy.Enabled")) {
|
||||
price = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getInt("Economy.Price");
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getBoolean("CustomWorlds.Enabled")) {
|
||||
List<Map<?, ?>> world_map = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getMapList("CustomWorlds.Prices");
|
||||
for (Map<?, ?> m : world_map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
String _world = entry.getKey().toString();
|
||||
|
||||
@@ -2,7 +2,7 @@ package me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_SHAPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -22,7 +22,7 @@ public class WorldLocations implements RTPWorld, RTPWorld_Defaulted {
|
||||
private final String name;
|
||||
|
||||
public WorldLocations(String location_name) {
|
||||
FileBasics.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.LOCATIONS);
|
||||
FileOther.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.LOCATIONS);
|
||||
List<Map<?, ?>> map = config.getMapList("Locations");
|
||||
//WorldDefault worldDefault = BetterRTP.getInstance().getRTP().defaultWorld;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class WorldLocations implements RTPWorld, RTPWorld_Defaulted {
|
||||
BetterRTP.debug("- - Biomes: " + this.biomes);
|
||||
}
|
||||
}
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (test.get("Price") != null) {
|
||||
if (test.get("Price").getClass() == Integer.class) {
|
||||
this.price = Integer.parseInt(test.get("Price").toString());
|
||||
|
||||
@@ -86,7 +86,7 @@ public class WorldPermissionGroup implements RTPWorld, RTPWorld_Defaulted {
|
||||
BetterRTP.debug("- - Biomes: " + biomes);
|
||||
}
|
||||
}
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (field.equalsIgnoreCase("Price")) {
|
||||
if (hash3.getValue().getClass() == Integer.class) {
|
||||
this.price = Integer.parseInt(hash3.getValue().toString());
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Settings {
|
||||
|
||||
|
||||
public void load() { //Load Settings
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||
debug = config.getBoolean("Settings.Debugger");
|
||||
delayEnabled = config.getBoolean("Settings.Delay.Enabled");
|
||||
delayTime = config.getInt("Settings.Delay.Time");
|
||||
@@ -46,20 +46,20 @@ public class Settings {
|
||||
statusMessages = config.getBoolean("Settings.StatusMessages");
|
||||
permissionGroupEnabled = config.getBoolean("PermissionGroup.Enabled");
|
||||
queueEnabled = config.getBoolean("Settings.Queue.Enabled");
|
||||
protocolLibSounds = FileBasics.FILETYPE.EFFECTS.getBoolean("Sounds.ProtocolLibSound");
|
||||
useLocationIfAvailable = FileBasics.FILETYPE.LOCATIONS.getBoolean("UseLocationIfAvailable");
|
||||
locationNeedPermission = FileBasics.FILETYPE.LOCATIONS.getBoolean("RequirePermission");
|
||||
useLocationsInSameWorld = FileBasics.FILETYPE.LOCATIONS.getBoolean("UseLocationsInSameWorld");
|
||||
protocolLibSounds = FileOther.FILETYPE.EFFECTS.getBoolean("Sounds.ProtocolLibSound");
|
||||
useLocationIfAvailable = FileOther.FILETYPE.LOCATIONS.getBoolean("UseLocationIfAvailable");
|
||||
locationNeedPermission = FileOther.FILETYPE.LOCATIONS.getBoolean("RequirePermission");
|
||||
useLocationsInSameWorld = FileOther.FILETYPE.LOCATIONS.getBoolean("UseLocationsInSameWorld");
|
||||
//Placeholders
|
||||
placeholder_true = FileBasics.FILETYPE.PLACEHOLDERS.getString("Config.CanRTP.Success");
|
||||
placeholder_nopermission = FileBasics.FILETYPE.PLACEHOLDERS.getString("Config.CanRTP.NoPermission");
|
||||
placeholder_cooldown = FileBasics.FILETYPE.PLACEHOLDERS.getString("Config.CanRTP.Cooldown");
|
||||
placeholder_balance = FileBasics.FILETYPE.PLACEHOLDERS.getString("Config.CanRTP.Price");
|
||||
placeholder_timeFormat = FileBasics.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Format");
|
||||
placeholder_timeDays = FileBasics.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Days");
|
||||
placeholder_timeHours = FileBasics.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Hours");
|
||||
placeholder_timeMinutes = FileBasics.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Minutes");
|
||||
placeholder_timeSeconds = FileBasics.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Seconds");
|
||||
placeholder_true = FileOther.FILETYPE.PLACEHOLDERS.getString("Config.CanRTP.Success");
|
||||
placeholder_nopermission = FileOther.FILETYPE.PLACEHOLDERS.getString("Config.CanRTP.NoPermission");
|
||||
placeholder_cooldown = FileOther.FILETYPE.PLACEHOLDERS.getString("Config.CanRTP.Cooldown");
|
||||
placeholder_balance = FileOther.FILETYPE.PLACEHOLDERS.getString("Config.CanRTP.Price");
|
||||
placeholder_timeFormat = FileOther.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Format");
|
||||
placeholder_timeDays = FileOther.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Days");
|
||||
placeholder_timeHours = FileOther.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Hours");
|
||||
placeholder_timeMinutes = FileOther.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Minutes");
|
||||
placeholder_timeSeconds = FileOther.FILETYPE.PLACEHOLDERS.getString("Config.TimeFormat.Seconds");
|
||||
depends.load();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SoftDepends {
|
||||
}
|
||||
|
||||
public void registerPlugin(REGIONPLUGINS pl) {
|
||||
FileBasics.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
FileOther.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.CONFIG);
|
||||
String pre = "Settings.Respect.";
|
||||
pl.getPlugin().setRespecting(config.getBoolean(pre + pl.getSetting_name()));
|
||||
if (pl.getPlugin().isRespecting())
|
||||
|
||||
@@ -18,4 +18,5 @@ Config:
|
||||
Success: '&aYes'
|
||||
NoPermission: '&cNo Permission'
|
||||
Cooldown: '&fCooling Down'
|
||||
Price: '&cNo. &7Reason: &eBankrupt'
|
||||
Price: '&cNo. &7Reason: &eBankrupt'
|
||||
Hunger: '&cNo. &7Reason: &3Starvation'
|
||||
Reference in New Issue
Block a user