Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
Florian Bouillon 2020-05-26 00:05:04 +02:00
parent 9c7005f3a8
commit 750e8d3d59
5 changed files with 12 additions and 47 deletions

12
pom.xml
View File

@ -83,11 +83,6 @@
<id>spigotmc-repo</id> <id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository> </repository>
<repository>
<id>bstats-repo</id>
<url>http://repo.bstats.org/content/repositories/releases/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -104,12 +99,5 @@
<version>1.13.1-R0.1-SNAPSHOT</version> <version>1.13.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -15,7 +15,7 @@ public class Delhome implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender s, Command command, String label, String[] a) { public boolean onCommand(CommandSender s, Command command, String label, String[] a) {
if(s instanceof Player && s.hasPermission("bettertp.delhome")) { if(s instanceof Player/* && s.hasPermission("bettertp.delhome")*/) {
if(a.length > 2) return false; //too many arguments if(a.length > 2) return false; //too many arguments
Config c = new Config(API.getPlayersFolder(), s.getName()); Config c = new Config(API.getPlayersFolder(), s.getName());
String homename = a.length == 0 ? "home" : a[0]; String homename = a.length == 0 ? "home" : a[0];
@ -26,8 +26,10 @@ public class Delhome implements CommandExecutor {
c.delete(); c.delete();
} else c.save(); } else c.save();
//sendmessage home deleted //sendmessage home deleted
s.sendMessage(m.getString("home.deleted").replace("[home]", homename).replace("&", "§"));
} else { } else {
//sendmessage home don't exist //sendmessage home don't exist
s.sendMessage(m.getString("home.dont-exist").replace("[home]", homename).replace("&", "§"));
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -17,16 +17,18 @@ public class Home implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender s, Command command, String label, String[] a) { public boolean onCommand(CommandSender s, Command command, String label, String[] a) {
if(s instanceof Player && s.hasPermission("bettertp.home")) { if(s instanceof Player/* && s.hasPermission("bettertp.home")*/) {
if(a.length > 1) return false; //too many arguments if(a.length > 1) return false; //too many arguments
Config c = new Config(API.getPlayersFolder(), s.getName()); Config c = new Config(API.getPlayersFolder(), s.getName());
String homename = a.length == 0 ? "home" : a[0]; String homename = a.length == 0 ? "home" : a[0];
if(c.isSet(homename)) { if(c.isSet(homename)) {
((Player) s).teleport(new Location(Bukkit.getServer().getWorld(c.getString(homename+".world")), c.getDouble(homename+".x"), c.getDouble(homename+".y"), c.getDouble(homename+".z"))); ((Player) s).teleport(new Location(Bukkit.getServer().getWorld(c.getString(homename+".world")), c.getDouble(homename+".x"), c.getDouble(homename+".y"), c.getDouble(homename+".z")));
//sendmessage teleported to home home //sendmessage teleported to home home
s.sendMessage(m.getString("home.teleported").replace("[home]", homename).replace("&", "§"));
return true; return true;
} else { } else {
//sendmessage home don't exist //sendmessage home don't exist
s.sendMessage(m.getString("home.dont-exist").replace("[home]", homename).replace("&", "§"));
return true; return true;
} }
} else if(s instanceof ConsoleCommandSender) { } else if(s instanceof ConsoleCommandSender) {

View File

@ -19,12 +19,12 @@ public class Sethome implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender s, Command command, String label, String[] a) { public boolean onCommand(CommandSender s, Command command, String label, String[] a) {
if(s instanceof Player && s.hasPermission("bettertp.sethome")) { if(s instanceof Player/* && s.hasPermission("bettertp.sethome")*/) {
if(a.length > 2) return false; //too many arguments if(a.length > 2) return false; //too many arguments
Config c = new Config(API.getPlayersFolder(), s.getName()); Config c = new Config(API.getPlayersFolder(), s.getName());
Integer maxhomes = -1; Integer maxhomes = -1;
for(String e : mc.getSection("maxhomes")) { for(String e : mc.getSection("maxhomes")) {
if(s.hasPermission("bettertp.max."+e)) { if(true || s.hasPermission("bettertp.max."+e)) {
Integer max = mc.getInt("maxhomes."+e, 0); Integer max = mc.getInt("maxhomes."+e, 0);
maxhomes = max > maxhomes ? max : maxhomes; //if max > maxhome then maxhome = max maxhomes = max > maxhomes ? max : maxhomes; //if max > maxhome then maxhome = max
} }
@ -37,7 +37,7 @@ public class Sethome implements CommandExecutor {
if(!c.exist()) c.create(); if(!c.exist()) c.create();
String homename = a.length == 0 ? "home" : a[0]; String homename = a.length == 0 ? "home" : a[0];
if(c.isSet(homename)) { if(c.isSet(homename)) {
//sendmessage home already set please delete it before (/delhome) s.sendMessage(m.getString("home.max").replace("[max]", homename).replace("&", "§"));
} else { } else {
Location l = ((Player) s).getLocation(); Location l = ((Player) s).getLocation();
c.set(homename+".world", l.getWorld().getName()); c.set(homename+".world", l.getWorld().getName());
@ -45,7 +45,7 @@ public class Sethome implements CommandExecutor {
c.set(homename+".y", l.getY()); c.set(homename+".y", l.getY());
c.set(homename+".z", l.getZ()); c.set(homename+".z", l.getZ());
c.save(); c.save();
//sendmessage home set s.sendMessage(m.getString("home.set").replace("[home]", homename).replace("&", "§"));
} }
} catch ( IOException e ) { } catch ( IOException e ) {
e.printStackTrace(); e.printStackTrace();

View File

@ -9,8 +9,6 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bstats.bukkit.Metrics;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -53,9 +51,10 @@ public final class Main extends JavaPlugin {
config(); config();
} catch ( IOException e ) { } catch ( IOException e ) {
e.printStackTrace(); e.printStackTrace();
error("Error Config not generated"); error("Error: Config not generated");
error("Shutting Down for security..."); error("Shutting Down for security...");
this.getPluginLoader().disablePlugin(this); this.getPluginLoader().disablePlugin(this);
return
} }
debug("Loaded Configuration !"); debug("Loaded Configuration !");
@ -77,13 +76,6 @@ public final class Main extends JavaPlugin {
getCommand("Homelist").setExecutor(new Homelist()); getCommand("Homelist").setExecutor(new Homelist());
debug("Loaded Commands"); debug("Loaded Commands");
if(new Config("", "config").getBoolean("metrics", true)) {
debug("Enabling Metrics");
loadCharts(new Metrics(this));
log("Metrics Started : https://bstats.org/plugin/bukkit/"+desc.getName()+"/");
}
log("Loaded !"); log("Loaded !");
} }
@ -131,23 +123,4 @@ public final class Main extends JavaPlugin {
c.save(); c.save();
} }
} }
private void loadCharts(Metrics metrics) {
Main.debug("loading custom charts");
metrics.addCustomChart(new Metrics.SingleLineChart("home_number", new Callable<Integer>(){
@Override
public Integer call() throws Exception {
Integer result = 0;
for (String conf : API.listPlayersWithHome()) {
Config c = new Config(API.getPlayersFolder(), conf);
result += c.getSection("").size();
}
return result;
}
}));
Main.debug("loading custom charts");
}
} }