2.13.0 - Release

Teleport message if not under a delay
Invincibility timer updated to be in seconds rather than ticks
'/rtp info world' added
This commit is contained in:
SuperRonanCraft 2020-09-20 12:51:54 -04:00
parent 14c276cefb
commit f9ab7da980
7 changed files with 101 additions and 77 deletions

View File

@ -20,7 +20,7 @@ import java.util.List;
public class Main extends JavaPlugin { public class Main extends JavaPlugin {
private final Permissions perms = new Permissions(); private final Permissions perms = new Permissions();
private final Messages text = new Messages(this); private final Messages text = new Messages();
private final DepEconomy eco = new DepEconomy(); private final DepEconomy eco = new DepEconomy();
private final Commands cmd = new Commands(this); private final Commands cmd = new Commands(this);
private final RTP rtp = new RTP(); private final RTP rtp = new RTP();
@ -105,7 +105,7 @@ public class Main extends JavaPlugin {
return pInfo; return pInfo;
} }
//Load //(Re)Load all plugin systems/files/cache
private void loadAll() { private void loadAll() {
files.loadAll(); files.loadAll();
settings.load(); settings.load();

View File

@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldBorder; import org.bukkit.WorldBorder;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import xyz.xenondevs.particle.ParticleEffect; import xyz.xenondevs.particle.ParticleEffect;
@ -25,16 +26,21 @@ public class CmdInfo implements RTPCommand {
infoShapes(sendi); infoShapes(sendi);
else if (args[1].equalsIgnoreCase(CmdInfoSub.POTION_EFFECTS.name())) else if (args[1].equalsIgnoreCase(CmdInfoSub.POTION_EFFECTS.name()))
infoEffects(sendi); infoEffects(sendi);
else else if (args[1].equalsIgnoreCase(CmdInfoSub.WORLD.name())) {
infoWorlds(sendi); if (sendi instanceof Player) {
sendInfoWorld(sendi, infoGetWorld(((Player) sendi).getWorld()));
} else
infoWorld(sendi);
}
} else } else
infoWorlds(sendi); infoWorld(sendi);
} }
enum CmdInfoSub { //Sub commands, future expansions enum CmdInfoSub { //Sub commands, future expansions
PARTICLES, SHAPES, POTION_EFFECTS PARTICLES, SHAPES, POTION_EFFECTS, WORLD
} }
//Particles
private void infoParticles(CommandSender sendi) { private void infoParticles(CommandSender sendi) {
List<String> info = new ArrayList<>(); List<String> info = new ArrayList<>();
Main pl = Main.getInstance(); Main pl = Main.getInstance();
@ -53,9 +59,9 @@ public class CmdInfo implements RTPCommand {
sendi.sendMessage(info.toString()); sendi.sendMessage(info.toString());
} }
//Shapes
private void infoShapes(CommandSender sendi) { private void infoShapes(CommandSender sendi) {
List<String> info = new ArrayList<>(); List<String> info = new ArrayList<>();
Main pl = Main.getInstance();
for (String shape : RTPParticles.shapeTypes) { for (String shape : RTPParticles.shapeTypes) {
if (info.isEmpty()) { if (info.isEmpty()) {
@ -67,60 +73,70 @@ public class CmdInfo implements RTPCommand {
} }
info.forEach(str -> info.forEach(str ->
info.set(info.indexOf(str), pl.getText().color(str))); info.set(info.indexOf(str), Main.getInstance().getText().color(str)));
sendi.sendMessage(info.toString()); sendi.sendMessage(info.toString());
} }
private void infoWorlds(CommandSender sendi) { //World
List<String> info = new ArrayList<>(); private void sendInfoWorld(CommandSender sendi, List<String> list) { //Send info
info.add("&e&m-----&6 BetterRTP Info &e&m-----"); list.add(0, "&e&m-----&6 BetterRTP Info &e&m-----");
Main pl = Main.getInstance(); list.forEach(str ->
for (World w : Bukkit.getWorlds()) { list.set(list.indexOf(str), Main.getInstance().getText().color(str)));
info.add("&aWorld: &7" + w.getName()); sendi.sendMessage(list.toArray(new String[0]));
if (pl.getRTP().getDisabledWorlds().contains(w.getName())) //DISABLED
info.add("&7- &6Disabled: &bTrue");
else {
info.add("&7- &6Disabled: &cFalse");
if (pl.getRTP().overriden.containsKey(w.getName()))
info.add("&7- &6Overriden: &bTrue");
else {
info.add("&7- &6WorldType: &f" + pl.getRTP().world_type.getOrDefault(w.getName(), RTP_WORLD_TYPE.NORMAL).name());
info.add("&7- &6Overriden: &cFalse");
RTPWorld _rtpworld = pl.getRTP().defaultWorld;
for (RTPWorld __rtpworld : pl.getRTP().customWorlds.values()) {
if (__rtpworld.getWorld() != null && __rtpworld.getWorld().getName().equals(w.getName())) {
_rtpworld = __rtpworld;
break;
}
}
if (_rtpworld == pl.getRTP().defaultWorld)
info.add("&7- &6Custom: &cFalse");
else
info.add("&7- &6Custom: &bTrue");
if (_rtpworld.getUseWorldborder()) {
info.add("&7- &6UseWorldborder: &bTrue");
WorldBorder border = w.getWorldBorder();
info.add("&7- &6Center X: &7" + border.getCenter().getBlockX());
info.add("&7- &6Center Z: &7" + border.getCenter().getBlockZ());
info.add("&7- &6MaxRad: &7" + (border.getSize() / 2));
} else {
info.add("&7- &6UseWorldborder: &cFalse");
info.add("&7- &6Center X: &7" + _rtpworld.getCenterX());
info.add("&7- &6Center Z: &7" + _rtpworld.getCenterZ());
info.add("&7- &6MaxRad: &7" + _rtpworld.getMaxRad());
}
info.add("&7- &6MinRad: &7" + _rtpworld.getMinRad());
}
}
}
info.forEach(str ->
info.set(info.indexOf(str), pl.getText().color(str)));
sendi.sendMessage(info.toArray(new String[0]));
} }
void infoEffects(CommandSender sendi) { private void infoWorld(CommandSender sendi) { //All worlds
List<String> info = new ArrayList<>();
for (World w : Bukkit.getWorlds())
info.addAll(infoGetWorld(w));
sendInfoWorld(sendi, info);
}
private List<String> infoGetWorld(World w) { //Specific world
List<String> info = new ArrayList<>(); List<String> info = new ArrayList<>();
Main pl = Main.getInstance(); Main pl = Main.getInstance();
info.add("&aWorld: &7" + w.getName());
if (pl.getRTP().getDisabledWorlds().contains(w.getName())) //DISABLED
info.add("&7- &6Disabled: &bTrue");
else {
info.add("&7- &6Disabled: &cFalse");
if (pl.getRTP().overriden.containsKey(w.getName()))
info.add("&7- &6Overriden: &bTrue");
else {
info.add("&7- &6WorldType: &f" + pl.getRTP().world_type.getOrDefault(w.getName(), RTP_WORLD_TYPE.NORMAL).name());
info.add("&7- &6Overriden: &cFalse");
RTPWorld _rtpworld = pl.getRTP().defaultWorld;
for (RTPWorld __rtpworld : pl.getRTP().customWorlds.values()) {
if (__rtpworld.getWorld() != null && __rtpworld.getWorld().getName().equals(w.getName())) {
_rtpworld = __rtpworld;
break;
}
}
if (_rtpworld == pl.getRTP().defaultWorld)
info.add("&7- &6Custom: &cFalse");
else
info.add("&7- &6Custom: &bTrue");
if (_rtpworld.getUseWorldborder()) {
info.add("&7- &6UseWorldborder: &bTrue");
WorldBorder border = w.getWorldBorder();
info.add("&7- &6Center X: &7" + border.getCenter().getBlockX());
info.add("&7- &6Center Z: &7" + border.getCenter().getBlockZ());
info.add("&7- &6MaxRad: &7" + (border.getSize() / 2));
} else {
info.add("&7- &6UseWorldborder: &cFalse");
info.add("&7- &6Center X: &7" + _rtpworld.getCenterX());
info.add("&7- &6Center Z: &7" + _rtpworld.getCenterZ());
info.add("&7- &6MaxRad: &7" + _rtpworld.getMaxRad());
}
info.add("&7- &6MinRad: &7" + _rtpworld.getMinRad());
}
}
return info;
}
//Effects
private void infoEffects(CommandSender sendi) {
List<String> info = new ArrayList<>();
for (PotionEffectType effect : PotionEffectType.values()) { for (PotionEffectType effect : PotionEffectType.values()) {
if (info.isEmpty()) { if (info.isEmpty()) {
@ -132,7 +148,7 @@ public class CmdInfo implements RTPCommand {
} }
info.forEach(str -> info.forEach(str ->
info.set(info.indexOf(str), pl.getText().color(str))); info.set(info.indexOf(str), Main.getInstance().getText().color(str)));
sendi.sendMessage(info.toString()); sendi.sendMessage(info.toString());
} }

View File

@ -168,8 +168,10 @@ public class RTP {
getPl().getCmd().rtping.put(p.getUniqueId(), true); //Cache player so they cant run '/rtp' again while rtp'ing getPl().getCmd().rtping.put(p.getUniqueId(), true); //Cache player so they cant run '/rtp' again while rtp'ing
if (getPl().getSettings().delayEnabled && delay) { if (getPl().getSettings().delayEnabled && delay) {
new RTPDelay(sendi, pWorld, delayTime, cancelOnMove, cancelOnDamage); new RTPDelay(sendi, pWorld, delayTime, cancelOnMove, cancelOnDamage);
} else } else {
getPl().getText().getSuccessTeleport(sendi);
findSafeLocation(sendi, pWorld); findSafeLocation(sendi, pWorld);
}
} }
void findSafeLocation(CommandSender sendi, PlayerWorld pWorld) { void findSafeLocation(CommandSender sendi, PlayerWorld pWorld) {

View File

@ -19,8 +19,8 @@ public class RTPPluginValidation { //Safe locations depending on enabled depende
boolean worldguard = getWorlguard(loc); boolean worldguard = getWorlguard(loc);
boolean griefPrevention = getGriefprevention(loc); boolean griefPrevention = getGriefprevention(loc);
boolean towny = getTowny(loc); boolean towny = getTowny(loc);
boolean redProject = getRedProject(loc); boolean redProtect = getRedProtect(loc);
return worldguard && griefPrevention && towny && redProject; return worldguard && griefPrevention && towny && redProtect;
} }
// TESTED on v2.12.3 // TESTED on v2.12.3
@ -71,7 +71,7 @@ public class RTPPluginValidation { //Safe locations depending on enabled depende
// TESTED 2.12.3 // TESTED 2.12.3
// RedProtect v7.7.2 // RedProtect v7.7.2
// https://www.spigotmc.org/resources/redprotect.15841/ // https://www.spigotmc.org/resources/redprotect.15841/
private boolean getRedProject(Location loc) { private boolean getRedProtect(Location loc) {
boolean result = true; boolean result = true;
if (getPl().getSettings().getsDepends().isRedProtect()) if (getPl().getSettings().getsDepends().isRedProtect())
try { try {

View File

@ -50,7 +50,7 @@ public class RTPPotions { //Potions AND Invincibility
void giveEffects(Player p) { void giveEffects(Player p) {
if (invincibleEnabled) if (invincibleEnabled)
p.setNoDamageTicks(invincibleTime); p.setNoDamageTicks(invincibleTime * 20);
if (potionEnabled) { if (potionEnabled) {
List<PotionEffect> effects = new ArrayList<>(); List<PotionEffect> effects = new ArrayList<>();
for (PotionEffectType e : potionEffects.keySet()) { for (PotionEffectType e : potionEffects.keySet()) {

View File

@ -7,15 +7,10 @@ import org.bukkit.Sound;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class Messages { public class Messages {
private Main pl; private final String preM = "Messages.", preH = "Help.", preU = "Usage.";
private String preM = "Messages.", preT = "Titles.", preH = "Help.", preU = "Usage.";
public Messages(Main pl) {
this.pl = pl;
}
private LangFile getLang() { private LangFile getLang() {
return pl.getFiles().getLang(); return Main.getInstance().getFiles().getLang();
} }
public void sms(CommandSender sendi, String msg) { public void sms(CommandSender sendi, String msg) {
@ -23,6 +18,7 @@ public class Messages {
sendi.sendMessage(colorPre(msg)); sendi.sendMessage(colorPre(msg));
} }
//SUCCESS
public void getSuccessPaid(CommandSender sendi, int price, String x, String y, String z, String world, int public void getSuccessPaid(CommandSender sendi, int price, String x, String y, String z, String world, int
attempts) { attempts) {
sms(sendi, getLang().getString(preM + "Success.Paid").replaceAll("%price%", String.valueOf(price)).replaceAll sms(sendi, getLang().getString(preM + "Success.Paid").replaceAll("%price%", String.valueOf(price)).replaceAll
@ -39,6 +35,11 @@ public class Messages {
sms(sendi, getLang().getString(preM + "Success.Loading")); sms(sendi, getLang().getString(preM + "Success.Loading"));
} }
public void getSuccessTeleport(CommandSender sendi) {
sms(sendi, getLang().getString(preM + "Success.Teleport"));
}
//FAILED
public void getFailedNotSafe(CommandSender sendi, int attempts) { public void getFailedNotSafe(CommandSender sendi, int attempts) {
sms(sendi, getLang().getString(preM + "Failed.NotSafe").replaceAll("%attempts%", Integer.toString(attempts))); sms(sendi, getLang().getString(preM + "Failed.NotSafe").replaceAll("%attempts%", Integer.toString(attempts)));
} }

View File

@ -36,34 +36,39 @@ public class SoftDepends {
void load() { void load() {
FileBasics.FILETYPE config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG); FileBasics.FILETYPE config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
respect_worldguard = config.getBoolean("Settings.Respect.WorldGuard"); String pre = "Settings.Respect.";
respect_griefprevention = config.getBoolean("Settings.Respect.GriefPrevention"); respect_worldguard = config.getBoolean( pre + "WorldGuard");
respect_towny = config.getBoolean("Settings.Respect.Towny"); respect_griefprevention = config.getBoolean(pre + "GriefPrevention");
respect_redProtect = config.getBoolean("Settings.Respect.RedProtect"); respect_towny = config.getBoolean( pre + "Towny");
respect_redProtect = config.getBoolean( pre + "RedProtect");
registerWorldguard(); registerWorldguard();
registerGriefPrevention(); registerGriefPrevention();
registerTowny(); registerTowny();
registerRedProject(); registerRedProtect();
} }
public void registerWorldguard() { public void registerWorldguard() {
worldguard = respect_worldguard && Bukkit.getPluginManager().isPluginEnabled("WorldGuard"); worldguard = respect_worldguard && Bukkit.getPluginManager().isPluginEnabled("WorldGuard");
debug("Registered `WorldGuard` = " + worldguard); if (respect_worldguard)
debug("Respecting `WorldGuard` was " + (worldguard ? "SUCCESSFULLY" : "NOT") + " registered");
} }
public void registerGriefPrevention() { public void registerGriefPrevention() {
griefprevention = respect_griefprevention && Bukkit.getPluginManager().isPluginEnabled("GriefPrevention"); griefprevention = respect_griefprevention && Bukkit.getPluginManager().isPluginEnabled("GriefPrevention");
debug("Registered `GriefPrevention` = " + griefprevention); if (respect_griefprevention)
debug("Respecting `GriefPrevention` was " + (griefprevention ? "SUCCESSFULLY" : "NOT") + " registered");
} }
public void registerTowny() { public void registerTowny() {
towny = respect_towny && Bukkit.getPluginManager().isPluginEnabled("Towny"); towny = respect_towny && Bukkit.getPluginManager().isPluginEnabled("Towny");
debug("Registered `Towny` = " + towny); if (respect_towny)
debug("Respecting `Towny` was " + (towny ? "SUCCESSFULLY" : "NOT") + " registered");
} }
public void registerRedProject() { public void registerRedProtect() {
redProtect = respect_redProtect && Bukkit.getPluginManager().isPluginEnabled("RedProtect"); redProtect = respect_redProtect && Bukkit.getPluginManager().isPluginEnabled("RedProtect");
debug("Registered `RedProtect` = " + redProtect); if (respect_redProtect)
debug("Respecting `RedProtect` was " + (redProtect ? "SUCCESSFULLY" : "NOT") + " registered");
} }
private void debug(String str) { private void debug(String str) {