mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
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:
parent
14c276cefb
commit
f9ab7da980
@ -20,7 +20,7 @@ import java.util.List;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
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 Commands cmd = new Commands(this);
|
||||
private final RTP rtp = new RTP();
|
||||
@ -105,7 +105,7 @@ public class Main extends JavaPlugin {
|
||||
return pInfo;
|
||||
}
|
||||
|
||||
//Load
|
||||
//(Re)Load all plugin systems/files/cache
|
||||
private void loadAll() {
|
||||
files.loadAll();
|
||||
settings.load();
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import xyz.xenondevs.particle.ParticleEffect;
|
||||
|
||||
@ -25,16 +26,21 @@ public class CmdInfo implements RTPCommand {
|
||||
infoShapes(sendi);
|
||||
else if (args[1].equalsIgnoreCase(CmdInfoSub.POTION_EFFECTS.name()))
|
||||
infoEffects(sendi);
|
||||
else
|
||||
infoWorlds(sendi);
|
||||
else if (args[1].equalsIgnoreCase(CmdInfoSub.WORLD.name())) {
|
||||
if (sendi instanceof Player) {
|
||||
sendInfoWorld(sendi, infoGetWorld(((Player) sendi).getWorld()));
|
||||
} else
|
||||
infoWorlds(sendi);
|
||||
infoWorld(sendi);
|
||||
}
|
||||
} else
|
||||
infoWorld(sendi);
|
||||
}
|
||||
|
||||
enum CmdInfoSub { //Sub commands, future expansions
|
||||
PARTICLES, SHAPES, POTION_EFFECTS
|
||||
PARTICLES, SHAPES, POTION_EFFECTS, WORLD
|
||||
}
|
||||
|
||||
//Particles
|
||||
private void infoParticles(CommandSender sendi) {
|
||||
List<String> info = new ArrayList<>();
|
||||
Main pl = Main.getInstance();
|
||||
@ -53,9 +59,9 @@ public class CmdInfo implements RTPCommand {
|
||||
sendi.sendMessage(info.toString());
|
||||
}
|
||||
|
||||
//Shapes
|
||||
private void infoShapes(CommandSender sendi) {
|
||||
List<String> info = new ArrayList<>();
|
||||
Main pl = Main.getInstance();
|
||||
|
||||
for (String shape : RTPParticles.shapeTypes) {
|
||||
if (info.isEmpty()) {
|
||||
@ -67,15 +73,28 @@ public class CmdInfo implements RTPCommand {
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
private void infoWorlds(CommandSender sendi) {
|
||||
//World
|
||||
private void sendInfoWorld(CommandSender sendi, List<String> list) { //Send info
|
||||
list.add(0, "&e&m-----&6 BetterRTP Info &e&m-----");
|
||||
list.forEach(str ->
|
||||
list.set(list.indexOf(str), Main.getInstance().getText().color(str)));
|
||||
sendi.sendMessage(list.toArray(new String[0]));
|
||||
}
|
||||
|
||||
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<>();
|
||||
info.add("&e&m-----&6 BetterRTP Info &e&m-----");
|
||||
Main pl = Main.getInstance();
|
||||
for (World w : Bukkit.getWorlds()) {
|
||||
info.add("&aWorld: &7" + w.getName());
|
||||
if (pl.getRTP().getDisabledWorlds().contains(w.getName())) //DISABLED
|
||||
info.add("&7- &6Disabled: &bTrue");
|
||||
@ -112,15 +131,12 @@ public class CmdInfo implements RTPCommand {
|
||||
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]));
|
||||
return info;
|
||||
}
|
||||
|
||||
void infoEffects(CommandSender sendi) {
|
||||
//Effects
|
||||
private void infoEffects(CommandSender sendi) {
|
||||
List<String> info = new ArrayList<>();
|
||||
Main pl = Main.getInstance();
|
||||
|
||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
||||
if (info.isEmpty()) {
|
||||
@ -132,7 +148,7 @@ public class CmdInfo implements RTPCommand {
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -168,9 +168,11 @@ public class RTP {
|
||||
getPl().getCmd().rtping.put(p.getUniqueId(), true); //Cache player so they cant run '/rtp' again while rtp'ing
|
||||
if (getPl().getSettings().delayEnabled && delay) {
|
||||
new RTPDelay(sendi, pWorld, delayTime, cancelOnMove, cancelOnDamage);
|
||||
} else
|
||||
} else {
|
||||
getPl().getText().getSuccessTeleport(sendi);
|
||||
findSafeLocation(sendi, pWorld);
|
||||
}
|
||||
}
|
||||
|
||||
void findSafeLocation(CommandSender sendi, PlayerWorld pWorld) {
|
||||
if (pWorld.getAttempts() >= maxAttempts) //Cancel out, too many tried
|
||||
|
@ -19,8 +19,8 @@ public class RTPPluginValidation { //Safe locations depending on enabled depende
|
||||
boolean worldguard = getWorlguard(loc);
|
||||
boolean griefPrevention = getGriefprevention(loc);
|
||||
boolean towny = getTowny(loc);
|
||||
boolean redProject = getRedProject(loc);
|
||||
return worldguard && griefPrevention && towny && redProject;
|
||||
boolean redProtect = getRedProtect(loc);
|
||||
return worldguard && griefPrevention && towny && redProtect;
|
||||
}
|
||||
|
||||
// TESTED on v2.12.3
|
||||
@ -71,7 +71,7 @@ public class RTPPluginValidation { //Safe locations depending on enabled depende
|
||||
// TESTED 2.12.3
|
||||
// RedProtect v7.7.2
|
||||
// https://www.spigotmc.org/resources/redprotect.15841/
|
||||
private boolean getRedProject(Location loc) {
|
||||
private boolean getRedProtect(Location loc) {
|
||||
boolean result = true;
|
||||
if (getPl().getSettings().getsDepends().isRedProtect())
|
||||
try {
|
||||
|
@ -50,7 +50,7 @@ public class RTPPotions { //Potions AND Invincibility
|
||||
|
||||
void giveEffects(Player p) {
|
||||
if (invincibleEnabled)
|
||||
p.setNoDamageTicks(invincibleTime);
|
||||
p.setNoDamageTicks(invincibleTime * 20);
|
||||
if (potionEnabled) {
|
||||
List<PotionEffect> effects = new ArrayList<>();
|
||||
for (PotionEffectType e : potionEffects.keySet()) {
|
||||
|
@ -7,15 +7,10 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class Messages {
|
||||
private Main pl;
|
||||
private String preM = "Messages.", preT = "Titles.", preH = "Help.", preU = "Usage.";
|
||||
|
||||
public Messages(Main pl) {
|
||||
this.pl = pl;
|
||||
}
|
||||
private final String preM = "Messages.", preH = "Help.", preU = "Usage.";
|
||||
|
||||
private LangFile getLang() {
|
||||
return pl.getFiles().getLang();
|
||||
return Main.getInstance().getFiles().getLang();
|
||||
}
|
||||
|
||||
public void sms(CommandSender sendi, String msg) {
|
||||
@ -23,6 +18,7 @@ public class Messages {
|
||||
sendi.sendMessage(colorPre(msg));
|
||||
}
|
||||
|
||||
//SUCCESS
|
||||
public void getSuccessPaid(CommandSender sendi, int price, String x, String y, String z, String world, int
|
||||
attempts) {
|
||||
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"));
|
||||
}
|
||||
|
||||
public void getSuccessTeleport(CommandSender sendi) {
|
||||
sms(sendi, getLang().getString(preM + "Success.Teleport"));
|
||||
}
|
||||
|
||||
//FAILED
|
||||
public void getFailedNotSafe(CommandSender sendi, int attempts) {
|
||||
sms(sendi, getLang().getString(preM + "Failed.NotSafe").replaceAll("%attempts%", Integer.toString(attempts)));
|
||||
}
|
||||
|
@ -36,34 +36,39 @@ public class SoftDepends {
|
||||
|
||||
void load() {
|
||||
FileBasics.FILETYPE config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
respect_worldguard = config.getBoolean("Settings.Respect.WorldGuard");
|
||||
respect_griefprevention = config.getBoolean("Settings.Respect.GriefPrevention");
|
||||
respect_towny = config.getBoolean("Settings.Respect.Towny");
|
||||
respect_redProtect = config.getBoolean("Settings.Respect.RedProtect");
|
||||
String pre = "Settings.Respect.";
|
||||
respect_worldguard = config.getBoolean( pre + "WorldGuard");
|
||||
respect_griefprevention = config.getBoolean(pre + "GriefPrevention");
|
||||
respect_towny = config.getBoolean( pre + "Towny");
|
||||
respect_redProtect = config.getBoolean( pre + "RedProtect");
|
||||
registerWorldguard();
|
||||
registerGriefPrevention();
|
||||
registerTowny();
|
||||
registerRedProject();
|
||||
registerRedProtect();
|
||||
}
|
||||
|
||||
public void registerWorldguard() {
|
||||
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() {
|
||||
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() {
|
||||
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");
|
||||
debug("Registered `RedProtect` = " + redProtect);
|
||||
if (respect_redProtect)
|
||||
debug("Respecting `RedProtect` was " + (redProtect ? "SUCCESSFULLY" : "NOT") + " registered");
|
||||
}
|
||||
|
||||
private void debug(String str) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user