mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-02-16 02:21:06 +00:00
open source
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/bin/
|
||||
/.git/
|
||||
/.settings/
|
||||
/.classpath
|
||||
/.project
|
||||
target
|
||||
.idea
|
||||
*.iml
|
||||
/BetterRTP.wiki
|
||||
/BetterRTP
|
||||
@@ -2,11 +2,12 @@
|
||||
<b><a>Welcome to BetterRTP's repository!</a></b>
|
||||
</p>
|
||||
|
||||
## Wheres the Wiki?
|
||||
The wiki is available [here](../../wiki)!
|
||||
## Where's the Lang files?/Want to Contribute translating?
|
||||
All language files are located [here](src/main/resources/lang)
|
||||
feel free to fork one of the language files and help translate!
|
||||
|
||||
## Want to Contribute translating?
|
||||
Fork one of the [language files](lang) and help translate!
|
||||
## Where's the Wiki?
|
||||
The wiki is available [here](../../wiki)!
|
||||
|
||||
<p align="center">
|
||||
<b>Chat with us on Discord</b><br/>
|
||||
|
||||
75
pom.xml
Normal file
75
pom.xml
Normal file
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>me.SuperRonanCraft</groupId>
|
||||
<artifactId>BetterRTP</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
<!--<repository>
|
||||
<id>minecraftforge</id>
|
||||
<url>https://files.minecraftforge.net/maven</url>
|
||||
</repository>-->
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<!--Spigot API-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.14-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Bukkit API-->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.14-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency> <!-- Spigot (this includes Spigot API, Bukkit API, Craftbukkit and NMS) -->
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.14-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>me.ryanhamshire</groupId>
|
||||
<artifactId>griefprevention</artifactId>
|
||||
<version>1.10.2-4.0.1.451</version>
|
||||
<classifier>api</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
</project>
|
||||
BIN
src/main/java/.DS_Store
vendored
Normal file
BIN
src/main/java/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
src/main/java/me/.DS_Store
vendored
Normal file
BIN
src/main/java/me/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
src/main/java/me/SuperRonanCraft/.DS_Store
vendored
Normal file
BIN
src/main/java/me/SuperRonanCraft/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
src/main/java/me/SuperRonanCraft/BetterRTP/.DS_Store
vendored
Normal file
BIN
src/main/java/me/SuperRonanCraft/BetterRTP/.DS_Store
vendored
Normal file
Binary file not shown.
147
src/main/java/me/SuperRonanCraft/BetterRTP/Main.java
Normal file
147
src/main/java/me/SuperRonanCraft/BetterRTP/Main.java
Normal file
@@ -0,0 +1,147 @@
|
||||
package me.SuperRonanCraft.BetterRTP;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.player.Commands;
|
||||
import me.SuperRonanCraft.BetterRTP.player.RTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.events.Listener;
|
||||
import me.SuperRonanCraft.BetterRTP.references.Econ;
|
||||
import me.SuperRonanCraft.BetterRTP.references.Permissions;
|
||||
import me.SuperRonanCraft.BetterRTP.references.Updater;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.Files;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.Messages;
|
||||
import me.SuperRonanCraft.BetterRTP.references.web.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
private Permissions perms = new Permissions();
|
||||
private Messages text = new Messages(this);
|
||||
private Econ eco = new Econ();
|
||||
private Commands cmd = new Commands(this);
|
||||
private RTP rtp = new RTP(this);
|
||||
private Listener listener = new Listener();
|
||||
private boolean worldguard = false, griefprevention = false, savagefactions = false;
|
||||
private static Main instance;
|
||||
private Files files = new Files();
|
||||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
new Updater(this);
|
||||
new Metrics(this);
|
||||
loadAll();
|
||||
listener.registerEvents(this);
|
||||
}
|
||||
|
||||
public Files getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
public static Main getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sendi, Command cmd, String label, String[] args) {
|
||||
try {
|
||||
this.cmd.commandExecuted(sendi, label, args);
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
text.error(sendi);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return this.cmd.onTabComplete(sender, args);
|
||||
}
|
||||
|
||||
public Permissions getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public Messages getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public Econ getEco() {
|
||||
return eco;
|
||||
}
|
||||
|
||||
public Commands getCmd() {
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public RTP getRTP() {
|
||||
return rtp;
|
||||
}
|
||||
|
||||
public boolean isWorldguard() {
|
||||
return worldguard;
|
||||
}
|
||||
|
||||
public boolean isGriefprevention() {
|
||||
return griefprevention;
|
||||
}
|
||||
|
||||
public void reload(CommandSender sendi) {
|
||||
loadAll();
|
||||
text.getReload(sendi);
|
||||
}
|
||||
|
||||
//Load
|
||||
private void loadAll() {
|
||||
//recreatePermissions();
|
||||
//registerConfig(reload);
|
||||
files.loadAll();
|
||||
rtp.load();
|
||||
cmd.load();
|
||||
listener.load();
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
//private void registerConfig(boolean reload) {
|
||||
//if (reload)
|
||||
// reloadConfig();
|
||||
//getConfig().options().copyDefaults(true);
|
||||
//saveConfig();
|
||||
//}
|
||||
|
||||
private void loadSettings() {
|
||||
FileBasics.FILETYPE config = getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
if (config.getBoolean("Settings.RespectWorldGuard"))
|
||||
registerWorldguard();
|
||||
else if (worldguard)
|
||||
worldguard = false;
|
||||
if (config.getBoolean("Settings.RespectGriefPrevention"))
|
||||
registerGriefPrevention();
|
||||
else if (griefprevention)
|
||||
griefprevention = false;
|
||||
if (config.getBoolean("Settings.RespectSavageFactions"))
|
||||
registerSavageFactions();
|
||||
else if (savagefactions)
|
||||
savagefactions = false;
|
||||
}
|
||||
|
||||
private void recreatePermissions() {
|
||||
//Permissions File
|
||||
saveResource(new File(getDataFolder(), "permissions.yml").getName(), true);
|
||||
}
|
||||
|
||||
private void registerWorldguard() {
|
||||
worldguard = Bukkit.getPluginManager().isPluginEnabled("WorldGuard");
|
||||
}
|
||||
|
||||
private void registerGriefPrevention() {
|
||||
griefprevention = Bukkit.getPluginManager().isPluginEnabled("GriefPrevention");
|
||||
}
|
||||
|
||||
private void registerSavageFactions() {
|
||||
savagefactions = Bukkit.getPluginManager().isPluginEnabled("Factions");
|
||||
}
|
||||
}
|
||||
291
src/main/java/me/SuperRonanCraft/BetterRTP/player/Commands.java
Normal file
291
src/main/java/me/SuperRonanCraft/BetterRTP/player/Commands.java
Normal file
@@ -0,0 +1,291 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Commands {
|
||||
|
||||
private Main pl;
|
||||
HashMap<UUID, Long> cooldowns = new HashMap<>();
|
||||
public HashMap<UUID, Boolean> rtping = new HashMap<>();
|
||||
private boolean cooldownTimer;
|
||||
private int timer, cooldown;
|
||||
public static String[] cmds = {"help", "player", "world", "version", "reload", "biome"};
|
||||
|
||||
public Commands(Main pl) {
|
||||
this.pl = pl;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
FileBasics.FILETYPE config = pl.getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
timer = config.getInt("Settings.Delay.Time");
|
||||
cooldownTimer = config.getBoolean("Settings.Cooldown.Enabled");
|
||||
cooldown = config.getInt("Settings.Cooldown.Time");
|
||||
cooldowns.clear();
|
||||
}
|
||||
|
||||
public void commandExecuted(CommandSender sendi, String cmd, String[] args) {
|
||||
if (pl.getPerms().getUse(sendi))
|
||||
if (args == null)
|
||||
rtp(sendi, cmd, null, null);
|
||||
else if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase(cmds[0]))
|
||||
help(sendi, cmd);
|
||||
else if (args[0].equalsIgnoreCase(cmds[1]))
|
||||
player(sendi, cmd, args);
|
||||
else if (args[0].equalsIgnoreCase(cmds[2]))
|
||||
world(sendi, cmd, args);
|
||||
else if (args[0].equalsIgnoreCase(cmds[3]))
|
||||
version(sendi);
|
||||
else if (args[0].equalsIgnoreCase(cmds[4]))
|
||||
reload(sendi);
|
||||
else if (args[0].equalsIgnoreCase(cmds[5]))
|
||||
biome(sendi, cmd, args);
|
||||
else
|
||||
invalid(sendi, cmd);
|
||||
} else if (args.length >= 2 && args.length <= 3) {
|
||||
if (args[0].equalsIgnoreCase(cmds[1]))
|
||||
player(sendi, cmd, args);
|
||||
else if (args[0].equalsIgnoreCase(cmds[2]))
|
||||
world(sendi, cmd, args);
|
||||
else if (args[0].equalsIgnoreCase(cmds[5]))
|
||||
biome(sendi, cmd, args);
|
||||
else
|
||||
invalid(sendi, cmd);
|
||||
} else if (args.length > 3) {
|
||||
if (args[0].equalsIgnoreCase(cmds[5]))
|
||||
biome(sendi, cmd, args);
|
||||
else if (args[0].equalsIgnoreCase(cmds[1]))
|
||||
player(sendi, cmd, args);
|
||||
else
|
||||
invalid(sendi, cmd);
|
||||
} else
|
||||
rtp(sendi, cmd, null, null);
|
||||
else
|
||||
noPerm(sendi);
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(CommandSender sendi, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
for (String s : cmds)
|
||||
if (s.startsWith(args[0]) && permOf(sendi, s))
|
||||
list.add(s);
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase(cmds[1]) && permOf(sendi, cmds[1])) {
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
if (p.getDisplayName().startsWith(args[1]))
|
||||
list.add(p.getDisplayName());
|
||||
} else if (args[0].equalsIgnoreCase(cmds[2]) && permOf(sendi, cmds[2]))
|
||||
for (World w : Bukkit.getWorlds())
|
||||
if (w.getName().startsWith(args[1]) && !pl.getRTP().disabledWorlds().contains(w.getName()) && pl
|
||||
.getPerms().getAWorld(sendi, w.getName()))
|
||||
list.add(w.getName());
|
||||
} else if (args.length == 3) {
|
||||
if (args[0].equalsIgnoreCase(cmds[1]) && permOf(sendi, cmds[1])) {
|
||||
for (World w : Bukkit.getWorlds())
|
||||
if (w.getName().startsWith(args[2]))
|
||||
list.add(w.getName());
|
||||
} else if (args[0].equalsIgnoreCase(cmds[2]) && permOf(sendi, cmds[2]) && permOf(sendi, cmds[5]))
|
||||
addBiomes(list, args);
|
||||
} else if (args.length > 3) {
|
||||
if (args[0].equalsIgnoreCase(cmds[2]) && permOf(sendi, cmds[2]) && permOf(sendi, cmds[5])) {
|
||||
addBiomes(list, args);
|
||||
} else if (args[0].equalsIgnoreCase(cmds[1]) && permOf(sendi, cmds[1]) && permOf(sendi, cmds[5]))
|
||||
addBiomes(list, args);
|
||||
}
|
||||
if (args[0].equalsIgnoreCase(cmds[5]) && permOf(sendi, cmds[5]))
|
||||
addBiomes(list, args);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void addBiomes(List<String> list, String[] args) {
|
||||
try {
|
||||
for (Biome b : Biome.values())
|
||||
if (b.name().toUpperCase().replaceAll("minecraft:", "").startsWith(args[args.length - 1].toUpperCase()))
|
||||
list.add(b.name().replaceAll("minecraft:", ""));
|
||||
} catch (NoSuchMethodError e) {
|
||||
//Not in 1.14.X
|
||||
}
|
||||
}
|
||||
|
||||
//COMMANDS
|
||||
private void rtp(CommandSender sendi, String cmd, String world, List<String> biomes) {
|
||||
if (sendi instanceof Player)
|
||||
tp((Player) sendi, sendi, world, biomes);
|
||||
else
|
||||
sendi.sendMessage(pl.getText().colorPre("Must be a player to use this command! Try '/" + cmd + " help'"));
|
||||
}
|
||||
|
||||
private void help(CommandSender sendi, String cmd) {
|
||||
pl.getText().getHelpList(sendi, cmd);
|
||||
if (pl.getPerms().getRtpOther(sendi))
|
||||
pl.getText().getHelpPlayer(sendi, cmd);
|
||||
if (sendi instanceof Player) {
|
||||
if (pl.getPerms().getAWorld(sendi, null))
|
||||
pl.getText().getHelpWorld(sendi, cmd);
|
||||
} else
|
||||
pl.getText().getHelpWorld(sendi, cmd);
|
||||
if (pl.getPerms().getReload(sendi))
|
||||
pl.getText().getHelpReload(sendi, cmd);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
private void player(CommandSender sendi, String cmd, String[] args) {
|
||||
if (permOf(sendi, args[0]))
|
||||
if (args.length == 2)
|
||||
if (Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline())
|
||||
tp(Bukkit.getPlayer(args[1]), sendi, Bukkit.getPlayer(args[1]).getWorld().getName(), null);
|
||||
else if (Bukkit.getPlayer(args[1]) != null)
|
||||
playerNotOnline(sendi, args[1]);
|
||||
else
|
||||
usage(sendi, cmd, args[0]);
|
||||
else if (args.length >= 3)
|
||||
if (Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline())
|
||||
tp(Bukkit.getPlayer(args[1]), sendi, Bukkit.getWorld(args[2]).getName(), getBiomes(args, 3, sendi));
|
||||
else if (Bukkit.getPlayer(args[1]) != null)
|
||||
playerNotOnline(sendi, args[1]);
|
||||
else
|
||||
usage(sendi, cmd, args[0]);
|
||||
else
|
||||
usage(sendi, cmd, args[0]);
|
||||
else
|
||||
noPerm(sendi);
|
||||
}
|
||||
|
||||
//rtp world <world> <biome1, biome2...>
|
||||
private void world(CommandSender sendi, String cmd, String[] args) {
|
||||
if (permOf(sendi, args[0]))
|
||||
if (args.length >= 2)
|
||||
rtp(sendi, cmd, args[1], getBiomes(args, 2, sendi));
|
||||
else
|
||||
usage(sendi, cmd, args[0]);
|
||||
else
|
||||
noPerm(sendi);
|
||||
}
|
||||
|
||||
//rtp biome <biome1, biome2...>
|
||||
private void biome(CommandSender sendi, String cmd, String[] args) {
|
||||
if (permOf(sendi, args[0]))
|
||||
if (args.length >= 2)
|
||||
rtp(sendi, cmd, null, getBiomes(args, 1, sendi));
|
||||
else
|
||||
usage(sendi, cmd, args[0]);
|
||||
else
|
||||
noPerm(sendi);
|
||||
}
|
||||
|
||||
private List<String> getBiomes(String[] args, int start, CommandSender sendi) {
|
||||
List<String> biomes = new ArrayList<>();
|
||||
boolean error_sent = false;
|
||||
if (permOf(sendi, cmds[5]))
|
||||
for (int i = start; i < args.length; i++) {
|
||||
String str = args[i];
|
||||
try {
|
||||
biomes.add(Biome.valueOf(str.replaceAll(",", "").toUpperCase()).name());
|
||||
} catch (Exception e) {
|
||||
if (!error_sent) {
|
||||
pl.getText().getOtherBiome(sendi, str);
|
||||
error_sent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return biomes;
|
||||
}
|
||||
|
||||
private void reload(CommandSender sendi) {
|
||||
if (pl.getPerms().getReload(sendi))
|
||||
pl.reload(sendi);
|
||||
else
|
||||
noPerm(sendi);
|
||||
}
|
||||
|
||||
private void version(CommandSender sendi) {
|
||||
sendi.sendMessage(pl.getText().colorPre("&aVersion #&e" + pl.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
private void invalid(CommandSender sendi, String cmd) {
|
||||
pl.getText().getInvalid(sendi, cmd);
|
||||
}
|
||||
|
||||
//INFORMATION
|
||||
private void usage(CommandSender sendi, String cmd, String arg) {
|
||||
if (arg.equalsIgnoreCase(cmds[1]))
|
||||
pl.getText().getUsageRTPOther(sendi, cmd);
|
||||
else if (arg.equalsIgnoreCase(cmds[2]))
|
||||
pl.getText().getUsageWorld(sendi, cmd);
|
||||
else if (arg.equalsIgnoreCase(cmds[5]))
|
||||
pl.getText().getUsageBiome(sendi, cmd);
|
||||
else
|
||||
pl.getText().sms(sendi, "&cSomething went wrong!");
|
||||
}
|
||||
|
||||
private void playerNotOnline(CommandSender sendi, String player) {
|
||||
pl.getText().getNotOnline(sendi, player);
|
||||
}
|
||||
|
||||
private void noPerm(CommandSender sendi) {
|
||||
pl.getText().getNoPermission(sendi);
|
||||
}
|
||||
|
||||
private void tp(Player player, CommandSender sendi, String world, List<String> biomes) {
|
||||
if (cooldown(sendi, player)) {
|
||||
boolean delay = false;
|
||||
if (!pl.getPerms().getBypassDelay(player))
|
||||
if (timer != 0)
|
||||
if (sendi == player)
|
||||
delay = true;
|
||||
pl.getRTP().start(player, sendi, world, biomes, delay);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean cooldown(CommandSender sendi, Player player) {
|
||||
if (sendi != player || pl.getPerms().getBypassCooldown(player))
|
||||
return true;
|
||||
else if (rtping.containsKey(player.getUniqueId()))
|
||||
if (rtping.get(player.getUniqueId())) {
|
||||
pl.getText().getAlready(player);
|
||||
return false;
|
||||
}
|
||||
if (cooldownTimer) {
|
||||
Player p = (Player) sendi;
|
||||
if (cooldowns.containsKey(p.getUniqueId())) {
|
||||
long Left = ((cooldowns.get(p.getUniqueId()) / 1000) + cooldown) - (System.currentTimeMillis() / 1000);
|
||||
if (!pl.getPerms().getBypassDelay(p))
|
||||
Left = Left + timer;
|
||||
if (Left > 0) {
|
||||
// Still cooling down
|
||||
pl.getText().getCooldown(sendi, String.valueOf(Left));
|
||||
return false;
|
||||
} else {
|
||||
cooldowns.remove(p.getUniqueId());
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
cooldowns.put(p.getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean permOf(CommandSender sendi, String cmd) {
|
||||
if (cmd.equalsIgnoreCase(cmds[4]))
|
||||
return pl.getPerms().getReload(sendi);
|
||||
else if (cmd.equalsIgnoreCase(cmds[1]))
|
||||
return pl.getPerms().getRtpOther(sendi);
|
||||
else if (cmd.equalsIgnoreCase(cmds[2]))
|
||||
return pl.getPerms().getWorld(sendi);
|
||||
else if (cmd.equalsIgnoreCase(cmds[5]))
|
||||
return pl.getPerms().getBiome(sendi);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
80
src/main/java/me/SuperRonanCraft/BetterRTP/player/Delay.java
Normal file
80
src/main/java/me/SuperRonanCraft/BetterRTP/player/Delay.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.PlayerWorld;
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
class Delay implements Listener {
|
||||
private int run;
|
||||
private PlayerWorld pWorld;
|
||||
private Main pl = Main.getInstance();
|
||||
|
||||
Delay(CommandSender sendi, PlayerWorld pWorld, int delay, boolean cancelOnMove) {
|
||||
this.pWorld = pWorld;
|
||||
delay(sendi, delay, cancelOnMove);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void delay(CommandSender sendi, int delay, boolean cancelOnMove) {
|
||||
Main pl = Main.getInstance();
|
||||
if (sendi.equals(pWorld.getPlayer()) && delay != 0 && pl.getText().getTitleDelayChat())
|
||||
pl.getText().getDelay(sendi, String.valueOf(delay));
|
||||
if (pl.getText().getSoundsEnabled()) {
|
||||
Sound sound = pl.getText().getSoundsDelay();
|
||||
if (sound != null)
|
||||
pWorld.getPlayer().playSound(pWorld.getPlayer().getLocation(), sound, 1F, 1F);
|
||||
}
|
||||
if (pl.getText().getTitleEnabled()) {
|
||||
String title = pl.getText().getTitleDelay(pWorld.getPlayer().getName(), String.valueOf(delay));
|
||||
String subTitle = pl.getText().getSubTitleDelay(pWorld.getPlayer().getName(), String.valueOf(delay));
|
||||
pWorld.getPlayer().sendTitle(title, subTitle);
|
||||
// int fadeIn = text.getFadeIn();
|
||||
// int stay = text.getStay();
|
||||
// int fadeOut = text.getFadeOut();
|
||||
// player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
|
||||
// pWorld.getPlayer().sendTitle(title, subTitle);
|
||||
}
|
||||
run = Bukkit.getScheduler().scheduleSyncDelayedTask(pl, run(sendi, this), delay * 2 * 10);
|
||||
//Bukkit.getScheduler().scheduleSyncRepeatingTask(pl, run(sendi, this), 0, 10);
|
||||
if (cancelOnMove)
|
||||
Bukkit.getPluginManager().registerEvents(this, Main.getInstance());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@SuppressWarnings("unused")
|
||||
private void event(PlayerMoveEvent e) {
|
||||
if (e.getPlayer().equals(pWorld.getPlayer())) {
|
||||
Bukkit.getScheduler().cancelTask(run);
|
||||
if (!Bukkit.getScheduler().isCurrentlyRunning(run)) {
|
||||
HandlerList.unregisterAll(this);
|
||||
pl.getText().getMoved(pWorld.getPlayer());
|
||||
pl.getEco().unCharge(pWorld.getPlayer(), pWorld.getPrice());
|
||||
pl.getCmd().cooldowns.remove(pWorld.getPlayer().getUniqueId());
|
||||
pl.getCmd().rtping.put(pWorld.getPlayer().getUniqueId(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Runnable run(final CommandSender sendi, final Delay cls) {
|
||||
return () -> {
|
||||
HandlerList.unregisterAll(cls);
|
||||
if (pl.getCmd().rtping.containsKey(pWorld.getPlayer().getUniqueId())) {
|
||||
try {
|
||||
pl.getRTP().tp(sendi, pWorld);
|
||||
} catch (NullPointerException e) {
|
||||
if (pWorld.getPrice() > 0)
|
||||
pl.getEco().unCharge(pWorld.getPlayer(), pWorld.getPrice());
|
||||
}
|
||||
pl.getCmd().rtping.put(pWorld.getPlayer().getUniqueId(), false);
|
||||
} else if (pWorld.getPrice() > 0)
|
||||
pl.getEco().unCharge(pWorld.getPlayer(), pWorld.getPrice());
|
||||
Bukkit.getScheduler().cancelTask(run);
|
||||
};
|
||||
}
|
||||
}
|
||||
373
src/main/java/me/SuperRonanCraft/BetterRTP/player/RTP.java
Normal file
373
src/main/java/me/SuperRonanCraft/BetterRTP/player/RTP.java
Normal file
@@ -0,0 +1,373 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.RegionContainer;
|
||||
import com.sk89q.worldguard.bukkit.WGBukkit;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.Custom;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.Default;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.PlayerWorld;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.RTPWorld;
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class RTP {
|
||||
|
||||
private Main pl;
|
||||
//Cache
|
||||
private HashMap<String, RTPWorld> customWorlds = new HashMap<>();
|
||||
private HashMap<String, String> overriden = new HashMap<>();
|
||||
public me.SuperRonanCraft.BetterRTP.references.worlds.Default Default = new Default();
|
||||
private Random rn = new Random();
|
||||
private List<String> disabledWorlds, blockList;
|
||||
private int maxAttempts, delayTime;
|
||||
private boolean cancelOnMove;
|
||||
|
||||
public RTP(Main pl) {
|
||||
this.pl = pl;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
Default.setup();
|
||||
FileBasics.FILETYPE config = pl.getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
disabledWorlds = config.getStringList("DisabledWorlds");
|
||||
maxAttempts = config.getInt("Settings.MaxAttempts");
|
||||
delayTime = config.getInt("Settings.Delay.Time");
|
||||
cancelOnMove = config.getBoolean("Settings.Delay.CancelOnMove");
|
||||
blockList = config.getStringList("BlacklistedBlocks");
|
||||
try {
|
||||
for (String s : config.getConfigurationSection("Override").getKeys(false))
|
||||
overriden.put(s, config.getString("Override." + s));
|
||||
} catch (Exception e) {
|
||||
//No Overrides
|
||||
}
|
||||
customWorlds.clear();
|
||||
|
||||
List<Map<?, ?>> map = config.getMapList("CustomWorlds");
|
||||
|
||||
//Find Custom World and cache values
|
||||
for (Map<?, ?> m : map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet())
|
||||
customWorlds.put(entry.getKey().toString(), new Custom(entry.getKey().toString()));
|
||||
}
|
||||
|
||||
List<String> disabledWorlds() {
|
||||
return disabledWorlds;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public List<String> getDisabledWorlds() {
|
||||
return disabledWorlds;
|
||||
}
|
||||
|
||||
void start(Player p, CommandSender sendi, String worl, List<String> biomes, boolean delay) {
|
||||
// Check overrides
|
||||
String world = worl;
|
||||
if (world == null)
|
||||
world = p.getWorld().getName();
|
||||
if (overriden.containsKey(world))
|
||||
world = overriden.get(world);
|
||||
if (sendi == p && !pl.getPerms().getAWorld(sendi, world)) {
|
||||
pl.getCmd().cooldowns.remove(p.getUniqueId());
|
||||
pl.getText().getNoPermissionWorld(p, world);
|
||||
return;
|
||||
}
|
||||
// Check disabled worlds
|
||||
if (disabledWorlds.contains(world)) {
|
||||
pl.getText().getDisabledWorld(sendi, world);
|
||||
pl.getCmd().cooldowns.remove(p.getUniqueId());
|
||||
return;
|
||||
}
|
||||
// Check if nulled
|
||||
if (Bukkit.getWorld(world) == null) {
|
||||
pl.getText().getNotExist(sendi, world);
|
||||
pl.getCmd().cooldowns.remove(p.getUniqueId());
|
||||
return;
|
||||
}
|
||||
PlayerWorld pWorld = new PlayerWorld(p, world);
|
||||
//Set all methods
|
||||
if (customWorlds.containsKey(world)) {
|
||||
RTPWorld cWorld = customWorlds.get(pWorld.getWorld());
|
||||
pWorld.setup(cWorld, cWorld.getPrice(), biomes);
|
||||
} else
|
||||
pWorld.setup(Default, Default.getPrice(), biomes);
|
||||
// Check world price
|
||||
if (!pl.getEco().charge(p, pWorld.getPrice())) {
|
||||
pl.getText().getFailedPrice(p, pWorld.getPrice());
|
||||
pl.getCmd().cooldowns.remove(p.getUniqueId());
|
||||
return;
|
||||
}
|
||||
// Delaying? Else, just go
|
||||
if (delay) {
|
||||
pl.getCmd().rtping.put(p.getUniqueId(), true);
|
||||
new Delay(sendi, pWorld, delayTime, cancelOnMove);
|
||||
} else
|
||||
tp(sendi, pWorld);
|
||||
}
|
||||
|
||||
void tp(CommandSender sendi, PlayerWorld pWorld) {
|
||||
Location loc = randomLoc(pWorld);
|
||||
if (loc != null)
|
||||
sendPlayer(sendi, pWorld.getPlayer(), loc, pWorld.getPrice(), pWorld.getAttempts());
|
||||
else
|
||||
metMax(sendi, pWorld.getPlayer(), pWorld.getPrice());
|
||||
}
|
||||
|
||||
private void sendPlayer(final CommandSender sendi, final Player p, final Location loc, final int price,
|
||||
final int attempts) throws NullPointerException {
|
||||
if (sendi != p)
|
||||
checkPH(sendi, p.getDisplayName(), loc, price, false, attempts);
|
||||
if (pl.getText().getTitleSuccessChat())
|
||||
checkPH(p, p.getDisplayName(), loc, price, true, attempts);
|
||||
if (pl.getText().getTitleEnabled())
|
||||
titles(p, loc, attempts);
|
||||
try {
|
||||
//loc.getWorld().loadChunk(loc.getChunk());
|
||||
p.teleport(loc);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (pl.getText().getSoundsEnabled())
|
||||
sounds(p);
|
||||
}
|
||||
|
||||
private void checkPH(CommandSender sendi, String player, Location loc, int price, boolean sameAsPlayer,
|
||||
int attempts) {
|
||||
String x = Integer.toString(loc.getBlockX());
|
||||
String y = Integer.toString(loc.getBlockY());
|
||||
String z = Integer.toString(loc.getBlockZ());
|
||||
String world = loc.getWorld().getName();
|
||||
if (sameAsPlayer) {
|
||||
if (price == 0)
|
||||
pl.getText().getSuccessBypass(sendi, x, y, z, world, attempts);
|
||||
else
|
||||
pl.getText().getSuccessPaid(sendi, price, x, y, z, world, attempts);
|
||||
} else
|
||||
pl.getText().getOtherSuccess(sendi, player, x, y, z, world, attempts);
|
||||
// Organize which message to output respecting what x and z was chosen
|
||||
/*
|
||||
* if (posOrNeg == 0) msg = msg.replaceAll("%x%",
|
||||
* Integer.toString(x)).replaceAll("%z%", Integer.toString(z)); else if
|
||||
* (posOrNeg == 1) msg = msg.replaceAll("%x%",
|
||||
* Integer.toString(x2)).replaceAll("%z%", Integer.toString(z2)); else
|
||||
* if (posOrNeg == 2) msg = msg.replaceAll("%x%",
|
||||
* Integer.toString(x2)).replaceAll("%z%", Integer.toString(z)); else
|
||||
* msg = msg.replaceAll("%x%", Integer.toString(x)).replaceAll("%z%",
|
||||
* Integer.toString(z2));
|
||||
*/
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation"})
|
||||
private void titles(Player p, Location loc, int attempts) {
|
||||
// int fadeIn = pl.text.getFadeIn();
|
||||
// int stay = text.getStay();
|
||||
// int fadeOut = text.getFadeOut();
|
||||
String x = String.valueOf(loc.getBlockX());
|
||||
String y = String.valueOf(loc.getBlockY());
|
||||
String z = String.valueOf(loc.getBlockZ());
|
||||
String title = pl.getText().getTitleSuccess(p.getName(), x, y, z, attempts);
|
||||
String subTitle = pl.getText().getSubTitleSuccess(p.getName(), x, y, z, attempts);
|
||||
// player.sendMessage(Bukkit.getServer().getVersion());
|
||||
// player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
|
||||
p.sendTitle(title, subTitle);
|
||||
}
|
||||
|
||||
private void sounds(Player p) {
|
||||
Sound sound = pl.getText().getSoundsSuccess();
|
||||
if (sound != null)
|
||||
p.playSound(p.getLocation(), sound, 1F, 1F);
|
||||
}
|
||||
|
||||
// Compressed code for MaxAttempts being meet
|
||||
private void metMax(CommandSender sendi, Player p, int price) {
|
||||
if (p == sendi)
|
||||
pl.getText().getFailedNotSafe(sendi, maxAttempts);
|
||||
else
|
||||
pl.getText().getOtherNotSafe(sendi, maxAttempts, p.getDisplayName());
|
||||
pl.getCmd().cooldowns.remove(p.getUniqueId());
|
||||
pl.getEco().unCharge(p, price);
|
||||
}
|
||||
|
||||
private Location randomLoc(PlayerWorld pWorld) {
|
||||
int borderRad = pWorld.getMaxRad();
|
||||
int minVal = pWorld.getMinRad();
|
||||
int CenterX = pWorld.getCenterX();
|
||||
int CenterZ = pWorld.getCenterZ();
|
||||
int posOrNeg = rn.nextInt(4);
|
||||
Player p = pWorld.getPlayer();
|
||||
World world = Bukkit.getWorld(pWorld.getWorld());
|
||||
if (pWorld.getUseWorldborder()) {
|
||||
WorldBorder border = world.getWorldBorder();
|
||||
borderRad = (int) border.getSize() / 2;
|
||||
CenterX = border.getCenter().getBlockX();
|
||||
CenterZ = border.getCenter().getBlockZ();
|
||||
}
|
||||
float yaw = p.getLocation().getYaw(), pitch = p.getLocation().getPitch();
|
||||
boolean normal;
|
||||
try {
|
||||
//1.13
|
||||
normal = !world.getBiome(0, 0).equals(Biome.valueOf("NETHER"));
|
||||
} catch (Exception e) {
|
||||
//1.8-1.12
|
||||
try {
|
||||
normal = !world.getBiome(0, 0).equals(Biome.valueOf("HELL"));
|
||||
} catch (Exception e1) {
|
||||
normal = true;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i <= maxAttempts; i++) {
|
||||
// Get the y-coords from up top, then check if it's SAFE!
|
||||
Location loc;
|
||||
if (borderRad <= minVal) {
|
||||
minVal = Default.getMinRad();
|
||||
if (borderRad <= minVal)
|
||||
minVal = 0;
|
||||
}
|
||||
if (normal)
|
||||
loc = normal(borderRad, minVal, CenterX, CenterZ, posOrNeg, world, pWorld, yaw, pitch);
|
||||
else
|
||||
loc = nether(borderRad, minVal, CenterX, CenterZ, posOrNeg, world, pWorld, yaw, pitch);
|
||||
pWorld.addAttempt();
|
||||
if (loc != null && checkDepends(loc))
|
||||
return loc;
|
||||
posOrNeg = rn.nextInt(4);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location normal(int borderRad, int minVal, int CenterX, int CenterZ, int posOrNeg, World world,
|
||||
PlayerWorld pWorld, Float yaw, Float pitch) {
|
||||
int x, x2, z, z2;
|
||||
Location loc;
|
||||
// Will Check is CenterZ is negative or positive, then set 2 x's
|
||||
// up for choosing up next
|
||||
z = rn.nextInt(borderRad - minVal) + CenterZ + minVal;
|
||||
z2 = -(rn.nextInt(borderRad - minVal) - CenterZ - minVal);
|
||||
// Will Check is CenterZ is negative or positive, then set 2 z's
|
||||
// up for choosing up next
|
||||
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
|
||||
x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
|
||||
if (posOrNeg == 0)
|
||||
// Positive X and Z
|
||||
loc = getLocAtNormal(x, z, world, yaw, pitch, pWorld);
|
||||
else if (posOrNeg == 1)
|
||||
// Negative X and Z
|
||||
loc = getLocAtNormal(x2, z2, world, yaw, pitch, pWorld);
|
||||
else if (posOrNeg == 2)
|
||||
// Negative X and Positive Z
|
||||
loc = getLocAtNormal(x2, z, world, yaw, pitch, pWorld);
|
||||
else
|
||||
// Positive X and Negative Z
|
||||
loc = getLocAtNormal(x, z2, world, yaw, pitch, pWorld);
|
||||
return loc;
|
||||
}
|
||||
|
||||
private Location getLocAtNormal(int x, int z, World world, Float yaw, Float pitch, PlayerWorld pWorld) {
|
||||
int y = world.getHighestBlockYAt(x, z);
|
||||
String block = world.getBlockAt(x, y - 1, z).getType().name();
|
||||
if (!badBlock(block, x, z, pWorld.getWorld(), pWorld.getBiomes()))
|
||||
return new Location(world, (x + 0.5), y, (z + 0.5), yaw, pitch);
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location nether(int borderRad, int minVal, int CenterX, int CenterZ, int posOrNeg, World world,
|
||||
PlayerWorld pWorld, Float yaw, Float pitch) {
|
||||
int x, x2, z, z2;
|
||||
Location loc;
|
||||
// Will Check is CenterZ is negative or positive, then set 2 x's
|
||||
// up for choosing up next
|
||||
z = rn.nextInt((borderRad) - minVal) + CenterZ + minVal;
|
||||
z2 = -(rn.nextInt(borderRad - minVal) - CenterZ - minVal);
|
||||
// Will Check is CenterZ is negative or positive, then set 2 z's
|
||||
// up for choosing up next
|
||||
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
|
||||
x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
|
||||
if (posOrNeg == 0)
|
||||
// Positive X and Z
|
||||
loc = getLocAtNether(x, z, world, yaw, pitch, pWorld);
|
||||
else if (posOrNeg == 1)
|
||||
// Negative X and Z
|
||||
loc = getLocAtNether(x2, z2, world, yaw, pitch, pWorld);
|
||||
else if (posOrNeg == 2)
|
||||
// Negative X and Positive Z
|
||||
loc = getLocAtNether(x2, z, world, yaw, pitch, pWorld);
|
||||
else
|
||||
// Positive X and Negative Z
|
||||
loc = getLocAtNether(x, z2, world, yaw, pitch, pWorld);
|
||||
return loc;
|
||||
}
|
||||
|
||||
private Location getLocAtNether(int x, int z, World world, Float yaw, Float pitch, PlayerWorld pWorld) {
|
||||
for (int y = 0; y < world.getMaxHeight(); y++)
|
||||
if (world.getBlockAt(x, y, z).getType().equals(Material.AIR)) {
|
||||
String block = world.getBlockAt(x, y - 1, z).getType().name();
|
||||
if (!badBlock(block, x, z, pWorld.getWorld(), pWorld.getBiomes()))
|
||||
return new Location(world, (x + 0.5), y, (z + 0.5), yaw, pitch);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
private boolean checkDepends(Location loc) {
|
||||
try {
|
||||
if (pl.isWorldguard()) {
|
||||
WorldGuardPlugin plugin = WGBukkit.getPlugin();
|
||||
RegionContainer container = plugin.getRegionContainer();
|
||||
RegionManager regions = container.get(loc.getWorld());
|
||||
// Check to make sure that "regions" is not null
|
||||
return regions.getApplicableRegions(loc).size() == 0;
|
||||
}
|
||||
return !pl.isGriefprevention() || GriefPrevention.instance.dataStore.getClaimAt(loc, true, null) == null;
|
||||
} catch (NoClassDefFoundError e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Bad blocks, or good block and bad biome
|
||||
private boolean badBlock(String block, int x, int z, String world, List<String> biomes) {
|
||||
for (String currentBlock : blockList) //Check Block
|
||||
if (currentBlock.toUpperCase().equals(block))
|
||||
return true;
|
||||
//Check Biomes
|
||||
if (biomes == null || biomes.isEmpty())
|
||||
return false;
|
||||
String biomeCurrent = Bukkit.getWorld(world).getBiome(x, z).name();
|
||||
for (String biome : biomes)
|
||||
if (biomeCurrent.toUpperCase().contains(biome.toUpperCase()))
|
||||
return false;
|
||||
return true;
|
||||
//FALSE MEANS NO BAD BLOCKS WHERE FOUND!
|
||||
}
|
||||
|
||||
/*if (CenterX >= 0) {
|
||||
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
|
||||
x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
|
||||
} else {
|
||||
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
|
||||
x2 = -(rn.nextInt(borderRad - minVal) + CenterX + minVal);
|
||||
}
|
||||
// Will Check is CenterZ is negative or positive, then set 2 z's
|
||||
// up for choosing up next
|
||||
if (CenterZ >= 0) {
|
||||
z = rn.nextInt((borderRad) - minVal) + CenterZ + minVal;
|
||||
z2 = -(rn.nextInt(borderRad - minVal) - CenterZ - minVal);
|
||||
//sendi.sendMessage("Radius: " + borderRad + " MinRad: " + minVal + " CenterZ: " + CenterZ + " " + "World:"
|
||||
+ " " + pWorld.getWorld() + " TOP Z: " + z + " BOTTOM Z: " + z2);
|
||||
//sendi.sendMessage("Max: " + ((borderRad - minVal) + CenterX + minVal));
|
||||
//sendi.sendMessage("Min: " + (-(borderRad - minVal) + CenterX - minVal));
|
||||
//sendi.sendMessage("QUADRANT: " + posOrNeg);
|
||||
} else {
|
||||
z = (rn.nextInt(borderRad - minVal)) - CenterZ + minVal;
|
||||
z2 = -(rn.nextInt(borderRad - minVal) + CenterZ + minVal);
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.SuperRonanCraft.BetterRTP.player.Commands;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
class Interact {
|
||||
|
||||
private boolean enabled;
|
||||
private String title, coloredTitle;
|
||||
|
||||
void load() {
|
||||
String pre = "Settings.";
|
||||
FileBasics.FILETYPE file = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.SIGNS);
|
||||
enabled = file.getBoolean(pre + "Enabled");
|
||||
title = file.getString(pre + "Title");
|
||||
coloredTitle = Main.getInstance().getText().color(title);
|
||||
}
|
||||
|
||||
void event(PlayerInteractEvent e) {
|
||||
if (enabled && e.getClickedBlock() != null && e.getAction() == Action.RIGHT_CLICK_BLOCK && isSign(e.getClickedBlock())) {
|
||||
Sign sign = (Sign) e.getClickedBlock().getState();
|
||||
if (sign.getLine(0).equals(coloredTitle)) {
|
||||
String command = sign.getLine(1).split(" ")[0];
|
||||
if (cmd(sign.getLines()).split(" ")[0].equalsIgnoreCase("") || cmd(sign.getLines()).split(" ")[0].equalsIgnoreCase("rtp")) {
|
||||
action(e.getPlayer(), null);
|
||||
return;
|
||||
} else
|
||||
for (String cmd : Commands.cmds)
|
||||
if (command.equalsIgnoreCase(cmd)) {
|
||||
action(e.getPlayer(), cmd(sign.getLines()).split(" "));
|
||||
return;
|
||||
}
|
||||
e.getPlayer().sendMessage(Main.getInstance().getText().colorPre("&cError! &7Command &a"
|
||||
+ Arrays.toString(cmd(sign.getLines()).split(" ")) + "&7 does not exist! Defaulting command to /rtp!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void createSign(SignChangeEvent e) {
|
||||
if (enabled && Main.getInstance().getPerms().getSignCreate(e.getPlayer())) {
|
||||
String line = e.getLine(0);
|
||||
if (line != null && (line.equalsIgnoreCase(title) ||
|
||||
line.equalsIgnoreCase("[RTP]"))) {
|
||||
e.setLine(0, coloredTitle != null ? coloredTitle : "[RTP]");
|
||||
Main.getInstance().getText().getSignCreated(e.getPlayer(), cmd(e.getLines()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void action(Player p, String[] line) {
|
||||
Main.getInstance().getCmd().commandExecuted(p, "rtp", line);
|
||||
}
|
||||
|
||||
private String cmd(String[] signArray) {
|
||||
String actions = "";
|
||||
for (int i = 1; i < signArray.length; i++) {
|
||||
String line = signArray[i];
|
||||
if (line != null && !line.equals(""))
|
||||
if (actions.equals(""))
|
||||
actions = line;
|
||||
else
|
||||
actions = actions.concat(" " + line);
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
private boolean isSign(Block block) {
|
||||
return block.getState() instanceof Sign;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.Updater;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class Join {
|
||||
|
||||
void event(PlayerJoinEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
Main pl = Main.getInstance();
|
||||
if (!pl.getFiles().getType(FileBasics.FILETYPE.CONFIG).getBoolean("Settings.DisableUpdater") && pl.getPerms().getUpdate(player))
|
||||
if (!pl.getDescription().getVersion().equals(Updater.updatedVersion))
|
||||
pl.getText().sms(player, "&7There is currently an update for &6BetterRTP &7version &e#" +
|
||||
Updater.updatedVersion + " &7you have version &e#" + pl.getDescription().getVersion());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
class Leave {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
void event(PlayerQuitEvent e) {
|
||||
if (Main.getInstance().getCmd().rtping.containsKey(e.getPlayer().getUniqueId()))
|
||||
Main.getInstance().getCmd().rtping.remove(e.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
public class Listener implements org.bukkit.event.Listener {
|
||||
private Join join = new Join();
|
||||
private Leave leave = new Leave();
|
||||
private Interact interact = new Interact();
|
||||
|
||||
public void registerEvents(Main pl) {
|
||||
PluginManager pm = pl.getServer().getPluginManager();
|
||||
pm.registerEvents(this, pl);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
interact.load();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@SuppressWarnings("unused")
|
||||
private void onLeave(PlayerQuitEvent e) {
|
||||
leave.event(e);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@SuppressWarnings("unused")
|
||||
private void onJoin(PlayerJoinEvent e) {
|
||||
join.event(e);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@SuppressWarnings("unused")
|
||||
private void onInteract(PlayerInteractEvent e) {
|
||||
interact.event(e);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@SuppressWarnings("unused")
|
||||
private void interact(SignChangeEvent e) {
|
||||
interact.createSign(e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class Econ {
|
||||
private Economy e;
|
||||
private boolean checked = false;
|
||||
|
||||
public boolean charge(Player player, int price) {
|
||||
check();
|
||||
//player.sendMessage("Charging = " + (e != null) + " charge = " + price);
|
||||
if (e != null)
|
||||
if (price != 0) {
|
||||
if (!Main.getInstance().getPerms().getEconomy(player)) {
|
||||
EconomyResponse r = e.withdrawPlayer(player, price);
|
||||
return r.transactionSuccess();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void unCharge(Player p, int price) {
|
||||
if (e != null)
|
||||
if (price != 0)
|
||||
e.depositPlayer(p, price);
|
||||
}
|
||||
|
||||
private void check() {
|
||||
if (!checked)
|
||||
registerEconomy();
|
||||
}
|
||||
|
||||
private void registerEconomy() {
|
||||
try {
|
||||
if (Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (Main.getInstance().getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
RegisteredServiceProvider<Economy> rsp = Main.getInstance().getServer().getServicesManager().getRegistration(Economy.class);
|
||||
e = rsp.getProvider();
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
//
|
||||
}
|
||||
checked = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class Permissions {
|
||||
|
||||
private String pre = "betterrtp.";
|
||||
|
||||
public boolean getUse(CommandSender sendi) {
|
||||
return perm(pre + "use", sendi);
|
||||
}
|
||||
|
||||
boolean getEconomy(CommandSender sendi) {
|
||||
return perm(pre + "bypass.economy", sendi);
|
||||
}
|
||||
|
||||
public boolean getBypassCooldown(CommandSender sendi) {
|
||||
return perm(pre + "bypass.cooldown", sendi);
|
||||
}
|
||||
|
||||
public boolean getBypassDelay(CommandSender sendi) {
|
||||
return perm(pre + "bypass.delay", sendi);
|
||||
}
|
||||
|
||||
public boolean getReload(CommandSender sendi) {
|
||||
return perm(pre + "reload", sendi);
|
||||
}
|
||||
|
||||
public boolean getUpdate(CommandSender sendi) {
|
||||
return perm(pre + "updater", sendi);
|
||||
}
|
||||
|
||||
public boolean getRtpOther(CommandSender sendi) {
|
||||
return perm(pre + "player", sendi);
|
||||
}
|
||||
|
||||
public boolean getBiome(CommandSender sendi) {
|
||||
return (perm(pre + "biome", sendi));
|
||||
}
|
||||
|
||||
public boolean getWorld(CommandSender sendi) {
|
||||
return (perm(pre + "world", sendi));
|
||||
}
|
||||
|
||||
public boolean getSignCreate(CommandSender sendi) {
|
||||
return (perm(pre + "sign", sendi));
|
||||
}
|
||||
|
||||
public boolean getAWorld(CommandSender sendi, String world) {
|
||||
if (perm(pre + "world.*", sendi))
|
||||
return true;
|
||||
else if (world == null) {
|
||||
for (World w : Bukkit.getWorlds())
|
||||
if (perm(pre + "world." + w.getName(), sendi))
|
||||
return true;
|
||||
} else
|
||||
return perm(pre + "world." + world, sendi);
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean perm(String str, CommandSender sendi) {
|
||||
return sendi.hasPermission(str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
public class Updater {
|
||||
|
||||
public static String updatedVersion;
|
||||
|
||||
public Updater(Main pl) {
|
||||
try {
|
||||
URLConnection con = new URL(getUrl() + project()).openConnection();
|
||||
updatedVersion = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
||||
} catch (Exception ex) {
|
||||
Bukkit.getConsoleSender().sendMessage("[BetterRTP] Failed to check for an update on spigot");
|
||||
updatedVersion = pl.getDescription().getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
private String getUrl() {
|
||||
return "https://api.spigotmc.org/legacy/update.php?resource=";
|
||||
}
|
||||
|
||||
private String project() {
|
||||
return "36081";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
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() {
|
||||
Main pl = Main.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 = Main.getInstance().getResource("economy.yml");
|
||||
if (defConfigStream == null)
|
||||
return;
|
||||
lang.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream)));
|
||||
lang.options().copyDefaults(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FileBasics {
|
||||
|
||||
List<FILETYPE> types = new ArrayList<>();
|
||||
|
||||
void load() {
|
||||
types.clear();
|
||||
for (FILETYPE type : FILETYPE.values()) {
|
||||
type.load();
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public enum FILETYPE {
|
||||
CONFIG("config"), ECO("economy"), SIGNS("signs");
|
||||
|
||||
private String fileName;
|
||||
private YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
FILETYPE(String str) {
|
||||
this.fileName = str + ".yml";
|
||||
}
|
||||
|
||||
//PUBLIC
|
||||
public String getString(String path) {
|
||||
if (config.isString(path))
|
||||
return config.getString(path);
|
||||
return "SOMETHING WENT WRONG";
|
||||
}
|
||||
|
||||
public boolean getBoolean(String path) {
|
||||
return config.getBoolean(path);
|
||||
}
|
||||
|
||||
public int getInt(String path) {
|
||||
return config.getInt(path);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public List<String> getStringList(String path) {
|
||||
if (config.isList(path))
|
||||
return config.getStringList(path);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getConfigurationSection(String path) {
|
||||
return config.getConfigurationSection(path);
|
||||
}
|
||||
|
||||
public boolean isString(String path) {
|
||||
return config.isString(path);
|
||||
}
|
||||
|
||||
public boolean isList(String path) {
|
||||
return config.isList(path);
|
||||
}
|
||||
|
||||
public List<Map<?, ?>> getMapList(String path) {
|
||||
return config.getMapList(path);
|
||||
}
|
||||
|
||||
public YamlConfiguration getFile() {
|
||||
return config;
|
||||
}
|
||||
|
||||
//PROCCESSING
|
||||
private void load() {
|
||||
Main pl = Main.getInstance();
|
||||
File file = new File(pl.getDataFolder(), fileName);
|
||||
if (!file.exists())
|
||||
pl.saveResource(fileName, false);
|
||||
try {
|
||||
config.load(file);
|
||||
final InputStream defConfigStream = Main.getInstance().getResource(fileName);
|
||||
if (defConfigStream != null) {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream)));
|
||||
config.options().copyDefaults(true);
|
||||
}
|
||||
config.save(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
public class Files {
|
||||
private LangFile langFile = new LangFile();
|
||||
private FileBasics basics = new FileBasics();
|
||||
|
||||
LangFile getLang() {
|
||||
return langFile;
|
||||
}
|
||||
|
||||
public FileBasics.FILETYPE getType(FileBasics.FILETYPE type) {
|
||||
return basics.types.get(basics.types.indexOf(type));
|
||||
}
|
||||
|
||||
public void loadAll() {
|
||||
basics.load();
|
||||
langFile.load();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
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 LangFile {
|
||||
private YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
String getString(String path) {
|
||||
if (config.isString(path))
|
||||
return config.getString(path);
|
||||
return "SOMETHING WENT WRONG";
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public List<String> getStringList(String path) {
|
||||
if (config.isList(path))
|
||||
return config.getStringList(path);
|
||||
return Arrays.asList("SOMETHING WENT WRONG!");
|
||||
}
|
||||
|
||||
public boolean getBoolean(String path) {
|
||||
return config.getBoolean(path);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public void load() {
|
||||
Main pl = Main.getInstance();
|
||||
String fileName = "lang" + File.separator + pl.getFiles().getType(FileBasics.FILETYPE.CONFIG).getString("Language-File");
|
||||
File file = new File(pl.getDataFolder(), fileName);
|
||||
if (!file.exists())
|
||||
pl.saveResource(fileName, false);
|
||||
try {
|
||||
config.load(file);
|
||||
InputStream defConfigStream = Main.getInstance().getResource(fileName);
|
||||
if (defConfigStream == null)
|
||||
defConfigStream = pl.getResource(fileName.replace(File.separator, "/"));
|
||||
if (defConfigStream != null) {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream)));
|
||||
config.options().copyDefaults(true);
|
||||
}
|
||||
config.save(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
generateDefaults(pl);
|
||||
}
|
||||
|
||||
private String[] defaultLangs = {"en.yml", "fr.yml", "ja.yml", "ru.yml"};
|
||||
|
||||
private void generateDefaults(Main pl) {
|
||||
//Generate allLangs
|
||||
for (String yaml : defaultLangs) {
|
||||
if (yaml.equals(defaultLangs[0]) && config.getName().equals(defaultLangs[0]))
|
||||
continue;
|
||||
File f = new File(pl.getDataFolder(), "lang" + File.separator + yaml);
|
||||
if (!f.exists())
|
||||
pl.saveResource("lang" + File.separator + f.getName(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.file;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
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 LangFile getLang() {
|
||||
return pl.getFiles().getLang();
|
||||
}
|
||||
|
||||
public void sms(CommandSender sendi, String msg) {
|
||||
sendi.sendMessage(colorPre(msg));
|
||||
}
|
||||
|
||||
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
|
||||
("%x%", x).replaceAll("%y%", y).replaceAll("%z%", z).replaceAll("%world%", world).replaceAll
|
||||
("%attempts%", Integer.toString(attempts)));
|
||||
}
|
||||
|
||||
public void getSuccessBypass(CommandSender sendi, String x, String y, String z, String world, int attemtps) {
|
||||
sms(sendi, getLang().getString(preM + "Success.Bypass").replaceAll("%x%", x).replaceAll("%y%", y).replaceAll
|
||||
("%z%", z).replaceAll("%world%", world).replaceAll("%attempts%", Integer.toString(attemtps)));
|
||||
}
|
||||
|
||||
public void getFailedNotSafe(CommandSender sendi, int attempts) {
|
||||
sms(sendi, getLang().getString(preM + "Failed.NotSafe").replaceAll("%attempts%", Integer.toString(attempts)));
|
||||
}
|
||||
|
||||
public void getFailedPrice(CommandSender sendi, int price) {
|
||||
sms(sendi, getLang().getString(preM + "Failed.Price").replaceAll("%price%", String.valueOf(price)));
|
||||
}
|
||||
|
||||
public void getOtherNotSafe(CommandSender sendi, int attempts, String player) {
|
||||
sms(sendi, getLang().getString(preM + "Other.NotSafe").replaceAll("%attempts%", Integer.toString(attempts))
|
||||
.replaceAll("%player%", player));
|
||||
}
|
||||
|
||||
public void getOtherSuccess(CommandSender sendi, String player, String x, String y, String z, String world, int
|
||||
attempts) {
|
||||
sms(sendi, getLang().getString(preM + "Other.Success").replaceAll("%player%", player).replaceAll("%x%", x)
|
||||
.replaceAll("%y%", y).replaceAll("%z%", z).replaceAll("%world%", world).replaceAll("%attempts%",
|
||||
Integer.toString(attempts)));
|
||||
}
|
||||
|
||||
public void getOtherBiome(CommandSender sendi, String biome) {
|
||||
sms(sendi, getLang().getString(preM + "Other.Biome").replaceAll("%biome%", biome));
|
||||
}
|
||||
|
||||
public void getNotExist(CommandSender sendi, String world) {
|
||||
sms(sendi, getLang().getString(preM + "NotExist").replaceAll("%world%", world));
|
||||
}
|
||||
|
||||
public void getReload(CommandSender sendi) {
|
||||
sms(sendi, getLang().getString(preM + "Reload"));
|
||||
}
|
||||
|
||||
public void getNoPermission(CommandSender sendi) {
|
||||
sms(sendi, getLang().getString(preM + "NoPermission.Basic"));
|
||||
}
|
||||
|
||||
public void getNoPermissionWorld(CommandSender sendi, String world) {
|
||||
sms(sendi, getLang().getString(preM + "NoPermission.World").replaceAll("%world%", world));
|
||||
}
|
||||
|
||||
public void getDisabledWorld(CommandSender sendi, String world) {
|
||||
sms(sendi, getLang().getString(preM + "DisabledWorld").replaceAll("%world%", world));
|
||||
}
|
||||
|
||||
public void getCooldown(CommandSender sendi, String time) {
|
||||
sms(sendi, getLang().getString(preM + "Cooldown").replaceAll("%time%", time));
|
||||
}
|
||||
|
||||
public void getInvalid(CommandSender sendi, String cmd) {
|
||||
sms(sendi, getLang().getString(preM + "Invalid").replaceAll("%command%", cmd));
|
||||
}
|
||||
|
||||
public void getNotOnline(CommandSender sendi, String player) {
|
||||
sms(sendi, getLang().getString(preM + "NotOnline").replaceAll("%player%", player));
|
||||
}
|
||||
|
||||
public void getDelay(CommandSender sendi, String time) {
|
||||
sms(sendi, getLang().getString(preM + "Delay").replaceAll("%time%", time));
|
||||
}
|
||||
|
||||
public void getSignCreated(CommandSender sendi, String cmd) {
|
||||
sms(sendi, getLang().getString(preM + "Sign").replaceAll("%command%", cmd));
|
||||
}
|
||||
|
||||
public void getMoved(CommandSender sendi) {
|
||||
sms(sendi, getLang().getString(preM + "Moved"));
|
||||
}
|
||||
|
||||
public void getAlready(CommandSender sendi) {
|
||||
sms(sendi, getLang().getString(preM + "Already"));
|
||||
}
|
||||
|
||||
private String getPrefix() {
|
||||
return getLang().getString(preM + "Prefix");
|
||||
}
|
||||
|
||||
public String color(String str) {
|
||||
return ChatColor.translateAlternateColorCodes('&', str);
|
||||
}
|
||||
|
||||
public String colorPre(String str) {
|
||||
return color(getPrefix() + str);
|
||||
}
|
||||
|
||||
// Titles
|
||||
public String getTitleSuccess(String player, String x, String y, String z, int attempts) {
|
||||
return color(getLang().getString(preT + "Success.Title").replaceAll("%player%", player).replaceAll("%x%", x)
|
||||
.replaceAll("%y%", y).replaceAll("%z%", z).replaceAll("%attempts%", Integer.toString(attempts)));
|
||||
}
|
||||
|
||||
public String getSubTitleSuccess(String player, String x, String y, String z, int attempts) {
|
||||
return color(getLang().getString(preT + "Success.Subtitle").replaceAll("%player%", player).replaceAll("%x%",
|
||||
x).replaceAll("%y%", y).replaceAll("%z%", z).replaceAll("%attempts%", Integer.toString(attempts)));
|
||||
}
|
||||
|
||||
public boolean getTitleSuccessChat() {
|
||||
return getLang().getBoolean(preT + "Success.SendChatMessage");
|
||||
}
|
||||
|
||||
public boolean getTitleDelayChat() {
|
||||
return getLang().getBoolean(preT + "Delay.SendChatMessage");
|
||||
}
|
||||
|
||||
public String getTitleDelay(String player, String time) {
|
||||
return color(getLang().getString(preT + "Delay.Title").replaceAll("%player%", player).replaceAll("%time%",
|
||||
time));
|
||||
}
|
||||
|
||||
public String getSubTitleDelay(String player, String time) {
|
||||
return color(getLang().getString(preT + "Delay.Subtitle").replaceAll("%player%", player).replaceAll("%time%",
|
||||
time));
|
||||
}
|
||||
|
||||
public boolean getTitleEnabled() {
|
||||
return getLang().getBoolean(preT + "Enabled");
|
||||
}
|
||||
|
||||
//Help
|
||||
public void getHelpList(CommandSender sendi, String cmd) {
|
||||
for (String s : getLang().getStringList(preH + "List"))
|
||||
sms(sendi, s.replaceAll("%command%", cmd));
|
||||
}
|
||||
|
||||
public void getHelpPlayer(CommandSender sendi, String cmd) {
|
||||
sms(sendi, getLang().getString(preH + "Player").replaceAll("%command%", cmd));
|
||||
}
|
||||
|
||||
public void getHelpWorld(CommandSender sendi, String cmd) {
|
||||
sms(sendi, getLang().getString(preH + "World").replaceAll("%command%", cmd));
|
||||
}
|
||||
|
||||
public void getHelpReload(CommandSender sendi, String cmd) {
|
||||
sms(sendi, getLang().getString(preH + "Reload").replaceAll("%command%", cmd));
|
||||
}
|
||||
|
||||
//Usage
|
||||
public void getUsageRTPOther(CommandSender sendi, String cmd) {
|
||||
sms(sendi, getLang().getString(preU + "Player").replaceAll("%command%", cmd));
|
||||
}
|
||||
|
||||
public void getUsageWorld(CommandSender sendi, String cmd) {
|
||||
sms(sendi, getLang().getString(preU + "World").replaceAll("%command%", cmd));
|
||||
}
|
||||
|
||||
public void getUsageBiome(CommandSender sendi, String cmd) {
|
||||
sms(sendi, getLang().getString(preU + "Biome").replaceAll("%command%", cmd));
|
||||
}
|
||||
/*
|
||||
* public int getFadeIn() { return getLang().getInt("Titles.Time.FadeIn");
|
||||
* }
|
||||
*
|
||||
* public int getStay() { return getLang().getInt("Titles.Time.Stay"); }
|
||||
*
|
||||
* public int getFadeOut() { return
|
||||
* getLang().getInt("Titles.Time.FadeOut"); }
|
||||
*/
|
||||
|
||||
// Sounds
|
||||
public boolean getSoundsEnabled() {
|
||||
return getLang().getBoolean("Sounds.Enabled");
|
||||
}
|
||||
|
||||
public Sound getSoundsSuccess() {
|
||||
try {
|
||||
return Sound.valueOf(getLang().getString("Sounds.Success").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(colorPre("The sound " + getLang().getString("Sounds" +
|
||||
"" + ".Success") + " is invalid!"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Sound getSoundsDelay() {
|
||||
try {
|
||||
return Sound.valueOf(getLang().getString("Sounds.Delay").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(colorPre("The sound " + getLang().getString("Sounds" +
|
||||
"" + ".Delay") + " is invalid!"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Not Found
|
||||
public void error(CommandSender sendi) {
|
||||
sms(sendi, "&cERROR &7Seems like your Administrator did not update their language file!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.web;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* bStats collects some data for plugin authors.
|
||||
*
|
||||
* Check out https://bStats.org/ to learn more about bStats!
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Metrics {
|
||||
|
||||
static {
|
||||
// Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D
|
||||
final String defaultPackage = new String(new byte[] { 'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's' });
|
||||
final String examplePackage = new String(new byte[] { 'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e' });
|
||||
// We want to make sure nobody just copy & pastes the example and use the wrong package names
|
||||
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
|
||||
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
|
||||
}
|
||||
}
|
||||
|
||||
// The version of this bStats class
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
|
||||
// The url to which the data is sent
|
||||
private static final String URL = "https://bStats.org/submitData/bukkit";
|
||||
|
||||
// Should failed requests be logged?
|
||||
private static boolean logFailedRequests;
|
||||
|
||||
// The uuid of the server
|
||||
private static String serverUUID;
|
||||
|
||||
// The plugin
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param plugin The plugin which stats should be submitted.
|
||||
*/
|
||||
public Metrics(JavaPlugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null!");
|
||||
}
|
||||
this.plugin = plugin;
|
||||
|
||||
// Get the config file
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Check if the config file exists
|
||||
if (!config.isSet("serverUuid")) {
|
||||
|
||||
// Add default values
|
||||
config.addDefault("enabled", true);
|
||||
// Every server gets it's unique random id.
|
||||
config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||
// Should failed request be logged?
|
||||
config.addDefault("logFailedRequests", false);
|
||||
|
||||
// Inform the server owners about bStats
|
||||
config.options().header(
|
||||
"bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
|
||||
"To honor their work, you should not disable it.\n" +
|
||||
"This has nearly no effect on the server performance!\n" +
|
||||
"Check out https://bStats.org/ to learn more :)"
|
||||
).copyDefaults(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException ignored) { }
|
||||
}
|
||||
|
||||
// Load the data
|
||||
serverUUID = config.getString("serverUuid");
|
||||
logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
if (config.getBoolean("enabled", true)) {
|
||||
boolean found = false;
|
||||
// Search for all other bStats Metrics classes to see if we are the first one
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
found = true; // We aren't the first
|
||||
break;
|
||||
} catch (NoSuchFieldException ignored) { }
|
||||
}
|
||||
// Register our service
|
||||
Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
|
||||
if (!found) {
|
||||
// We are the first!
|
||||
startSubmitting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Scheduler which submits our data every 30 minutes.
|
||||
*/
|
||||
private void startSubmitting() {
|
||||
final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!plugin.isEnabled()) { // Plugin was disabled
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
|
||||
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
submitData();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 1000*60*5, 1000*60*30);
|
||||
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
|
||||
// WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
|
||||
// WARNING: Just don't do it!
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin specific data.
|
||||
* This method is called using Reflection.
|
||||
*
|
||||
* @return The plugin specific data.
|
||||
*/
|
||||
public JSONObject getPluginData() {
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
String pluginName = plugin.getDescription().getName();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
data.put("pluginName", pluginName); // Append the name of the plugin
|
||||
data.put("pluginVersion", pluginVersion); // Append the version of the plugin
|
||||
JSONArray customCharts = new JSONArray();
|
||||
data.put("customCharts", customCharts);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server specific data.
|
||||
*
|
||||
* @return The server specific data.
|
||||
*/
|
||||
private JSONObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount = Bukkit.getOnlinePlayers().size();
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
String bukkitVersion = Bukkit.getVersion();
|
||||
bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);
|
||||
|
||||
// OS/Java specific data
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
String osName = System.getProperty("os.name");
|
||||
String osArch = System.getProperty("os.arch");
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
data.put("serverUUID", serverUUID);
|
||||
|
||||
data.put("playerAmount", playerAmount);
|
||||
data.put("onlineMode", onlineMode);
|
||||
data.put("bukkitVersion", bukkitVersion);
|
||||
|
||||
data.put("javaVersion", javaVersion);
|
||||
data.put("osName", osName);
|
||||
data.put("osArch", osArch);
|
||||
data.put("osVersion", osVersion);
|
||||
data.put("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the data and sends it afterwards.
|
||||
*/
|
||||
private void submitData() {
|
||||
final JSONObject data = getServerData();
|
||||
|
||||
JSONArray pluginData = new JSONArray();
|
||||
// Search for all other bStats Metrics classes to get their plugin data
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
continue; // Continue "searching"
|
||||
}
|
||||
// Found one!
|
||||
try {
|
||||
pluginData.add(service.getMethod("getPluginData").invoke(Bukkit.getServicesManager().load(service)));
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
||||
}
|
||||
|
||||
data.put("plugins", pluginData);
|
||||
|
||||
// Create a new thread for the connection to the bStats server
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the data to the bStats server.
|
||||
*
|
||||
* @param data The data to send.
|
||||
* @throws Exception If the request failed.
|
||||
*/
|
||||
private static void sendData(JSONObject data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null!");
|
||||
}
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
throw new IllegalAccessException("This method must not be called from the main thread!");
|
||||
}
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
|
||||
// Compress the data to save bandwidth
|
||||
byte[] compressedData = compress(data.toString());
|
||||
|
||||
// Add headers
|
||||
connection.setRequestMethod("POST");
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
|
||||
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
|
||||
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
|
||||
// Send data
|
||||
connection.setDoOutput(true);
|
||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.write(compressedData);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
connection.getInputStream().close(); // We don't care about the response - Just send our data :)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gzips the given String.
|
||||
*
|
||||
* @param str The string to gzip.
|
||||
* @return The gzipped String.
|
||||
* @throws IOException If the compression failed.
|
||||
*/
|
||||
private static byte[] compress(final String str) throws IOException {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
gzip.write(str.getBytes("UTF-8"));
|
||||
gzip.close();
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.worlds;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Custom implements RTPWorld {
|
||||
public World world;
|
||||
private boolean useWorldborder = false;
|
||||
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price;
|
||||
private List<String> Biomes;
|
||||
|
||||
public Custom(String world) {
|
||||
String pre = "CustomWorlds.";
|
||||
FileBasics.FILETYPE config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
List<Map<?, ?>> map = config.getMapList("CustomWorlds");
|
||||
this.world = Bukkit.getWorld(world);
|
||||
|
||||
//Find Custom World and cache values
|
||||
for (Map<?, ?> m : map) {
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
String key = entry.getKey().toString();
|
||||
if (!key.equals(world))
|
||||
continue;
|
||||
Map<?, ?> test = ((Map<?, ?>) m.get(key));
|
||||
if (test == null)
|
||||
continue;
|
||||
if (test.get("UseWorldBorder") != null) {
|
||||
if (test.get("UseWorldBorder").getClass() == Boolean.class)
|
||||
useWorldborder = Boolean.valueOf(test.get("UseWorldBorder").toString());
|
||||
}
|
||||
if (test.get("CenterX") != null) {
|
||||
if (test.get("CenterX").getClass() == Integer.class)
|
||||
CenterX = Integer.valueOf((test.get("CenterX")).toString());
|
||||
}
|
||||
if (test.get("CenterZ") != null) {
|
||||
if (test.get("CenterZ").getClass() == Integer.class)
|
||||
CenterZ = Integer.valueOf((test.get("CenterZ")).toString());
|
||||
}
|
||||
if (test.get("MaxRadius") != null) {
|
||||
if (test.get("MaxRadius").getClass() == Integer.class)
|
||||
maxBorderRad = Integer.valueOf((test.get("MaxRadius")).toString());
|
||||
if (maxBorderRad <= 0) {
|
||||
Main.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Custom world '" + world + "' Maximum radius of '" + maxBorderRad + "' is not allowed! Set to default value!");
|
||||
maxBorderRad = Main.getInstance().getRTP().Default.getMaxRad();
|
||||
}
|
||||
}
|
||||
if (test.get("MinRadius") != null) {
|
||||
if (test.get("MinRadius").getClass() == Integer.class)
|
||||
minBorderRad = Integer.valueOf((test.get("MinRadius")).toString());
|
||||
if (minBorderRad < 0 || minBorderRad >= maxBorderRad) {
|
||||
Main.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Custom world '" + world + "' Minimum radius of '" + minBorderRad + "' is not allowed! Set to default value!");
|
||||
minBorderRad = Main.getInstance().getRTP().Default.getMinRad();
|
||||
if (minBorderRad >= maxBorderRad)
|
||||
maxBorderRad = Main.getInstance().getRTP().Default.getMaxRad();
|
||||
}
|
||||
}
|
||||
if (test.get("Biomes") != null) {
|
||||
if (test.get("Biomes").getClass() == ArrayList.class)
|
||||
this.Biomes = new ArrayList<>((ArrayList) test.get("Biomes"));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Booleans
|
||||
/*useWorldborder = config.getBoolean(pre + world + ".UseWorldBorder");
|
||||
//Integers
|
||||
CenterX = config.getInt(pre + world + ".CenterX");
|
||||
CenterZ = config.getInt(pre + world + ".CenterZ");
|
||||
maxBorderRad = config.getInt(pre + world + ".MaxRadius");
|
||||
if (maxBorderRad <= 0) {
|
||||
Main.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Custom world '" + world + "' Maximum radius of '" + maxBorderRad + "' is not allowed! Set to default value!");
|
||||
maxBorderRad = Main.getInstance().getRTP().Default.getMaxRad();
|
||||
}
|
||||
minBorderRad = config.getInt(pre + world + ".MinRadius");
|
||||
if (minBorderRad <= 0 || minBorderRad >= maxBorderRad) {
|
||||
Main.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Custom world '" + world + "' Minimum radius of '" + minBorderRad + "' is not allowed! Set to default value!");
|
||||
minBorderRad = Main.getInstance().getRTP().Default.getMinRad();
|
||||
}
|
||||
*/
|
||||
if (Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean(pre + "Enabled")) {
|
||||
map.clear();
|
||||
map = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getMapList("CustomWorlds");
|
||||
for (Map<?, ?> m : map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
String key = entry.getKey().toString();
|
||||
Map<?, ?> test = ((Map<?, ?>) m.get(key));
|
||||
if (!key.equals(world))
|
||||
continue;
|
||||
if (test.get("Price") != null)
|
||||
if (test.get("Price").getClass() == Integer.class)
|
||||
price = Integer.valueOf((test.get("Price")).toString());
|
||||
}
|
||||
} else
|
||||
price = Main.getInstance().getRTP().Default.getPrice();
|
||||
//Other
|
||||
this.Biomes = config.getStringList(pre + world + ".Biomes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseWorldborder() {
|
||||
return useWorldborder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCenterX() {
|
||||
return CenterX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCenterZ() {
|
||||
return CenterZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxRad() {
|
||||
return maxBorderRad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinRad() {
|
||||
return minBorderRad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBiomes() {
|
||||
return Biomes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.worlds;
|
||||
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Default implements RTPWorld {
|
||||
private boolean useWorldborder;
|
||||
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price;
|
||||
private List<String> Biomes;
|
||||
|
||||
public void setup() {
|
||||
//Setups
|
||||
String pre = "Default";
|
||||
FileBasics.FILETYPE config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
//Booleans
|
||||
useWorldborder = config.getBoolean(pre + ".UseWorldBorder");
|
||||
//Integers
|
||||
CenterX = config.getInt(pre + ".CenterX");
|
||||
CenterZ = config.getInt(pre + ".CenterZ");
|
||||
maxBorderRad = config.getInt(pre + ".MaxRadius");
|
||||
if (maxBorderRad <= 0) {
|
||||
Main.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Default Maximum radius of '" + maxBorderRad + "' is not allowed! Set to '1000'");
|
||||
maxBorderRad = 1000;
|
||||
}
|
||||
minBorderRad = config.getInt(pre + ".MinRadius");
|
||||
if (minBorderRad < 0 || minBorderRad >= maxBorderRad) {
|
||||
Main.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Default Minimum radius of '" + minBorderRad + "' is not allowed! Set to '0'");
|
||||
minBorderRad = 0;
|
||||
}
|
||||
if (Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
price = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getInt("Economy.Price");
|
||||
//Other
|
||||
this.Biomes = config.getStringList(pre + ".Biomes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseWorldborder() {
|
||||
return useWorldborder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCenterX() {
|
||||
return CenterX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCenterZ() {
|
||||
return CenterZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxRad() {
|
||||
return maxBorderRad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinRad() {
|
||||
return minBorderRad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBiomes() {
|
||||
return Biomes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.worlds;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerWorld implements RTPWorld {
|
||||
private boolean useWorldborder;
|
||||
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price, attempts;
|
||||
private List<String> Biomes;
|
||||
private Player p;
|
||||
private String world;
|
||||
|
||||
public PlayerWorld(Player p, String world) {
|
||||
this.p = p;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void setup(RTPWorld world, int price, List<String> biomes) {
|
||||
setUseWorldborder(world.getUseWorldborder());
|
||||
setCenterX(world.getCenterX());
|
||||
setCenterZ(world.getCenterZ());
|
||||
setMaxRad(world.getMaxRad());
|
||||
setMinRad(world.getMinRad());
|
||||
setPrice(price);
|
||||
List<String> list = new ArrayList<>(world.getBiomes());
|
||||
if (biomes != null)
|
||||
list.addAll(biomes);
|
||||
setBiomes(list);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return p;
|
||||
}
|
||||
|
||||
public String getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseWorldborder() {
|
||||
return useWorldborder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCenterX() {
|
||||
return CenterX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCenterZ() {
|
||||
return CenterZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxRad() {
|
||||
return maxBorderRad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinRad() {
|
||||
return minBorderRad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public int getAttempts() {return attempts; }
|
||||
|
||||
@Override
|
||||
public List<String> getBiomes() {
|
||||
return Biomes;
|
||||
}
|
||||
|
||||
private void setUseWorldborder(boolean bool) {
|
||||
useWorldborder = bool;
|
||||
}
|
||||
|
||||
private void setCenterX(int x) {
|
||||
CenterX = x;
|
||||
}
|
||||
|
||||
private void setCenterZ(int z) {
|
||||
CenterZ = z;
|
||||
}
|
||||
|
||||
private void setMaxRad(int max) {
|
||||
maxBorderRad = max;
|
||||
}
|
||||
|
||||
private void setMinRad(int min) {
|
||||
minBorderRad = min;
|
||||
}
|
||||
|
||||
private void setPrice(int price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public void addAttempt() {
|
||||
this.attempts++;
|
||||
}
|
||||
|
||||
private void setBiomes(List<String> biomes) {
|
||||
Biomes = biomes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.worlds;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RTPWorld {
|
||||
|
||||
boolean getUseWorldborder();
|
||||
|
||||
int getCenterX();
|
||||
|
||||
int getCenterZ();
|
||||
|
||||
int getMaxRad();
|
||||
|
||||
int getMinRad();
|
||||
|
||||
int getPrice();
|
||||
|
||||
List<String> getBiomes();
|
||||
}
|
||||
78
src/main/resources/config.yml
Normal file
78
src/main/resources/config.yml
Normal file
@@ -0,0 +1,78 @@
|
||||
# BetterRTP plugin by SuperRonanCraft! (Join my Public Server mc.RonanCraft.net) #
|
||||
# Please give me credit, I'm a first time coder, and would love to see more discussions on my Spigot page! #
|
||||
|
||||
Language-File: 'en.yml'
|
||||
|
||||
Settings:
|
||||
## Respect WorldGuard areas # IN-PROGRESS
|
||||
RespectWorldGuard: false
|
||||
## Respect GriefPrevention areas # COMING SOON
|
||||
RespectGriefPrevention: false
|
||||
## Respect Faction areas # COMING SOON
|
||||
RespectSavageFactions: false
|
||||
## Must be a positive integer #
|
||||
MinRadius: 25
|
||||
## Maximum amount of tries before BetterRTP gives up and sends a NotSafeMessage #
|
||||
MaxAttempts: 15
|
||||
## Enabled or disabled cooldown timer, time is in SECONDS #
|
||||
Cooldown:
|
||||
Enabled: true
|
||||
Time: 10
|
||||
## Time between command and actually rtp'ing, time is in SECONDS. Set to "0" to disable delay timer #
|
||||
Delay:
|
||||
Time: 5
|
||||
CancelOnMove: true
|
||||
DisableUpdater: false
|
||||
|
||||
Default:
|
||||
UseWorldBorder: true
|
||||
## "Biomes: []" means all biomes are allowed! #
|
||||
## Biomes are optional, more biomes at https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Biome.html #
|
||||
Biomes: []
|
||||
MaxRadius: 100
|
||||
MinRadius: 10
|
||||
## If "UseWorldBorder" is set to true above, these values WILL be ignored! Except Biomes! #
|
||||
CenterX: 0
|
||||
CenterZ: 0
|
||||
|
||||
## Blocks BetterRTP will NOT teleport onto. More Blocks at: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html #
|
||||
BlacklistedBlocks:
|
||||
- stationary_water
|
||||
- stationary_lava
|
||||
- water
|
||||
- lava
|
||||
- cactus
|
||||
- leaves
|
||||
- leaves_2
|
||||
- air
|
||||
|
||||
## Worlds to NOT allow /rtp in, unless there is an override to another enabled world #
|
||||
DisabledWorlds:
|
||||
- prison
|
||||
- creative
|
||||
|
||||
## Worlds you want to have a custom min/max and spawn center in #
|
||||
## [MaxRadius] and [MinRadius] MUST be positive! These cannot be equal to each other!
|
||||
CustomWorlds:
|
||||
- world:
|
||||
UseWorldBorder: false
|
||||
## If UseWorldBorder is true, everything will be ignored EXEPT "MinRadius"!
|
||||
MaxRadius: 1000
|
||||
MinRadius: 100
|
||||
CenterX: 0
|
||||
CenterZ: 0
|
||||
- nether:
|
||||
MaxRadius: 100000
|
||||
MinRadius: 1000
|
||||
CenterX: 123
|
||||
CenterZ: -123
|
||||
## Biomes are optional, but useful! More biomes: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Biome.html
|
||||
Biomes:
|
||||
- 'desert'
|
||||
- 'forest'
|
||||
|
||||
## Override a world and rtp a player executing the command in one world, to another
|
||||
Override:
|
||||
#FORMAT <CURRENT>:<OTHER>
|
||||
world_nether: 'world'
|
||||
creative: 'world'
|
||||
15
src/main/resources/economy.yml
Normal file
15
src/main/resources/economy.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
Economy:
|
||||
## Enable world charges? ALL Worlds included, even custom worlds!
|
||||
Enabled: false
|
||||
## Set to "0" to not charge for rtp, "Success.Bypass" message will be sent!
|
||||
## Give players the permission "betterrtp.eco.bypass" to bypass economy
|
||||
Price: 5
|
||||
|
||||
CustomWorlds:
|
||||
## Enable custom world charging
|
||||
Enabled: true
|
||||
Worlds:
|
||||
## PlayerWorld will be charged "5" when typing /rtp, if they do not have "betterrtp.eco.bypass"
|
||||
world: 5
|
||||
## Setting the price to "0" will make the "Success.Bypass" message show
|
||||
world_end: 0
|
||||
@@ -18,4 +18,4 @@ Fork one of the language files above and help translate!
|
||||
<i><a>Did this wiki help you out? Please give it a <b>Star</b> so I know it's getting use!</a></i><br/>
|
||||
<br/>
|
||||
<b><i><a href="https://www.spigotmc.org/resources/authors/superronancraft.13025/">Check out my other plugins!</a></i></b>
|
||||
</p>
|
||||
</p>
|
||||
@@ -1,7 +1,6 @@
|
||||
Messages:
|
||||
Prefix: '&7[&6BetterRTP&7] '
|
||||
## Placeholders! %x% %y% and %z% are the x, y, and z coordinates that the player is being teleported to! #
|
||||
Success:
|
||||
Success: ## Placeholders! %x% %y% and %z% are the x, y, and z coordinates that the player is being teleported to! #
|
||||
Paid: '&aYou have been tp''d to&7 x=%x% y=%y% z=%z% for &c$%price%&7 in &f%attempts% &7attempts!'
|
||||
Bypass: '&aYou have been tp''d to&7 x=%x% y=%y% z=%z% in &f%attempts% &7attempts'
|
||||
Failed:
|
||||
@@ -10,6 +9,7 @@ Messages:
|
||||
Other:
|
||||
Success: '&a%player% has been tp''d to&7 x=%x% y=%y% z=%z% in &f%attempts% &7attempts!'
|
||||
NotSafe: '&cCould not find safe spot within %attempts% attempts! &7%player% was not rtp''d!'
|
||||
Biome: '&cSeems like the biome&7 %biome%&c does not exist! &7Try using the tab list!'
|
||||
Reload: '&eConfig reloaded successfully!'
|
||||
NoPermission:
|
||||
Basic: '&cSorry! &7You don''t have permission to use this command!'
|
||||
@@ -46,14 +46,16 @@ Help:
|
||||
- ' &7- &e/%command% &7- Randomly teleports you!'
|
||||
- ' &7- &e/%command% help &7- Shows help list'
|
||||
##If the player has permission to rtp another player, this message will be added under the list!
|
||||
Player: ' &7- &e/%command% player <player> [world] &7- Randomly teleport another player'
|
||||
World: ' &7- &e/%command% world <world> &7- Randomly teleport in another world'
|
||||
Player: ' &7- &e/%command% player <player> [world] [biome1, biome2...] &7- Randomly teleport another player'
|
||||
World: ' &7- &e/%command% world <world> [biome1, biome2...] &7- Randomly teleport in another world'
|
||||
##If the player has permission to reload the plugin this message will be added under the list!
|
||||
Biome: ' &7- &e/%command% biome <biome1, biome2...> &7- Randomly teleport withing these biomes'
|
||||
Reload: ' &7- &e/%command% reload &7- Reloads the plugin'
|
||||
|
||||
Usage:
|
||||
Player: '&cUsage&7: /%command% player <player> [world]'
|
||||
World: '&cUsage&7: /%command% world <world>'
|
||||
Player: '&cUsage&7: /%command% player <player> [world] [biome1, biome2]'
|
||||
World: '&cUsage&7: /%command% world <world> [biome1, biome2...]'
|
||||
Biome: '&cUsage&7: /%command% biome <biome1, biome2...>'
|
||||
|
||||
Sounds:
|
||||
Enabled: true
|
||||
@@ -61,4 +61,4 @@ Sounds:
|
||||
## Son à jouer lors de la téléportation avec délai ##
|
||||
Delay: 'entity_tnt_primed'
|
||||
##Son à jouer lorsque la téléportation à réussie ##
|
||||
Success: 'entity_generic_explode'
|
||||
Success: 'entity_generic_explode'
|
||||
42
src/main/resources/permissions.yml
Normal file
42
src/main/resources/permissions.yml
Normal file
@@ -0,0 +1,42 @@
|
||||
permissions:
|
||||
betterrtp.*:
|
||||
children:
|
||||
betterrtp.use: true
|
||||
betterrtp.world: true
|
||||
betterrtp.world.*: true
|
||||
betterrtp.bypass.*: true
|
||||
betterrtp.player: true
|
||||
betterrtp.reload: true
|
||||
betterrtp.updater: true
|
||||
betterrtp.world:
|
||||
description: RTP into other worlds
|
||||
betterrtp.world.*:
|
||||
description: RTP in all enabled worlds
|
||||
betterrtp.world.<world>:
|
||||
description: RTP in <world>
|
||||
betterrtp.bypass.*:
|
||||
children:
|
||||
betterrtp.bypass.cooldown: true
|
||||
betterrtp.bypass.delay: true
|
||||
betterrtp.bypass.economy: true
|
||||
betterrtp.use:
|
||||
description: Use RTP command
|
||||
default: true
|
||||
betterrtp.player:
|
||||
description: RTP another player
|
||||
betterrtp.biome:
|
||||
description: RTP to specific biomes
|
||||
betterrtp.sign:
|
||||
description: Ability to create an RTP sign
|
||||
betterrtp.bypass.cooldown:
|
||||
description: Bypass cooldowns
|
||||
betterrtp.bypass.delay:
|
||||
description: Bypass delays
|
||||
betterrtp.bypass.economy:
|
||||
description: Bypass economy
|
||||
betterrtp.reload:
|
||||
description: Reload the config
|
||||
default: op
|
||||
betterrtp.updater:
|
||||
description: Get notification on new updates
|
||||
default: op
|
||||
51
src/main/resources/plugin.yml
Normal file
51
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
main: me.SuperRonanCraft.BetterRTP.Main
|
||||
version: 2.9.3
|
||||
name: BetterRTP
|
||||
author: SuperRonanCraft
|
||||
softdepend: [Vault, WorldGuard, GriefPrevention, Factions]
|
||||
|
||||
commands:
|
||||
betterrtp:
|
||||
aliases: [brtp, rtp]
|
||||
description: Randomly teleport to a location
|
||||
|
||||
permissions:
|
||||
betterrtp.*:
|
||||
children:
|
||||
betterrtp.use: true
|
||||
betterrtp.world.*: true
|
||||
betterrtp.bypass.*: true
|
||||
betterrtp.player: true
|
||||
betterrtp.reload: true
|
||||
betterrtp.updater: true
|
||||
betterrtp.biome: true
|
||||
betterrtp.world.*:
|
||||
description: RTP in all enabled worlds
|
||||
betterrtp.bypass.*:
|
||||
children:
|
||||
betterrtp.bypass.cooldown: true
|
||||
betterrtp.bypass.delay: true
|
||||
betterrtp.bypass.economy: true
|
||||
betterrtp.use:
|
||||
description: Use RTP command
|
||||
default: true
|
||||
betterrtp.world:
|
||||
description: Use world command
|
||||
betterrtp.player:
|
||||
description: RTP another player
|
||||
betterrtp.biome:
|
||||
description: RTP to specific biomes
|
||||
betterrtp.sign:
|
||||
description: Ability to create an RTP sign
|
||||
betterrtp.bypass.cooldown:
|
||||
description: Bypass cooldowns
|
||||
betterrtp.bypass.delay:
|
||||
description: Bypass delays
|
||||
betterrtp.bypass.economy:
|
||||
description: Bypass economy
|
||||
betterrtp.reload:
|
||||
description: Reload the config
|
||||
default: op
|
||||
betterrtp.updater:
|
||||
description: Get notification on new updates
|
||||
default: op
|
||||
3
src/main/resources/signs.yml
Normal file
3
src/main/resources/signs.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
Settings:
|
||||
Enabled: false
|
||||
Title: "[RTP]"
|
||||
Reference in New Issue
Block a user