Automatisation in progress

This commit is contained in:
Florian Bouillon 2017-05-29 01:15:54 +02:00
parent 0ac988201b
commit c466dbe388
8 changed files with 77 additions and 24 deletions

View File

@ -1,3 +0,0 @@
image: maven:3-jdk-8
build:
script: "mvn install -B"

9
.idea/codeStyleSettings.xml generated Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value />
</option>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</component>
</project>

2
.idea/misc.xml generated
View File

@ -12,7 +12,7 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8.0_131" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -6,7 +6,7 @@
<groupId>Delta-Wings</groupId>
<artifactId>BetterTP</artifactId>
<version>0.0.1</version>
<version>1.1.0-DEV</version>
<packaging>jar</packaging>
<name>BetterTP</name>
@ -18,6 +18,7 @@
<url>https://delta-wings.net</url>
<build>
<finalName>BetterTP</finalName>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>

View File

@ -93,6 +93,8 @@ public class Bettertp implements CommandExecutor {
} else if(s instanceof Player){
s.sendMessage(m.getString("global.permission").replace("&", "§"));
return true;
} else {
s.sendMessage(m.getString("global.not-console"));
}
return false;
}

View File

@ -3,7 +3,9 @@ package net.DeltaWings.Minecraft.BetterTP;
import net.DeltaWings.Minecraft.BetterTP.Commands.*;
import net.DeltaWings.Minecraft.BetterTP.Custom.Config;
import net.DeltaWings.Minecraft.BetterTP.TabCompleter.*;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
@ -11,7 +13,7 @@ import java.util.logging.Level;
public final class Main extends JavaPlugin {
public void log(String Message) {
public static void log(String Message) {
Bukkit.getLogger().log(Level.INFO, Message);
}
@ -20,13 +22,19 @@ public final class Main extends JavaPlugin {
return instance;
}
public static void debug(String message) {
if(new Config("", "config").getBoolean("debug", false)) Main.getInstance().getLogger().info("[Debug] " + message);
}
@Override
public void onEnable() {
instance = this;
getCommand("Spawn").setExecutor(new Spawn());
getCommand("Lobby").setExecutor(new Lobby());
getCommand("Home").setExecutor(new Home());
getCommand("Bettertp").setExecutor(new Bettertp());
PluginCommand bettertp = getCommand("Bettertp");
bettertp.setExecutor(new Bettertp());
bettertp.setTabCompleter(new BettertpTab());
getCommand("Sethome").setExecutor(new Sethome());
getCommand("Delhome").setExecutor(new Delhome());
getCommand("Homelist").setExecutor(new Homelist());
@ -77,9 +85,11 @@ public final class Main extends JavaPlugin {
if(!c.exist()) {
c.create();
c.header("How to config : https://bitbucket.org/delta-wings/bettertp/wiki/");
c.set("debug", false);
c.set("maxhomes.default", 1);
c.set("spawn.work", "world");
c.set("spawn.server.lobby", false);
//new String[]{"debug","maxhomes.default","spawn.work","spawn.server.lobby"};
c.save();
}
}

View File

@ -126,12 +126,7 @@ public class Metrics {
}
// 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();
}
});
Bukkit.getScheduler().runTask(plugin, () -> 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
@ -218,17 +213,14 @@ public class Metrics {
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);
}
new Thread(() -> {
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();

View File

@ -0,0 +1,42 @@
package net.DeltaWings.Minecraft.BetterTP.TabCompleter;
import net.DeltaWings.Minecraft.BetterTP.Main;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class BettertpTab implements TabCompleter {
private final String[] menu = new String[]{"set", "del", "delete", "help", "config"}, setdel = new String[]{"spawn","lobby"}, confopt = new String[]{""};
@Override
public List<String> onTabComplete(CommandSender s, Command c, String unused, String[] a) {
Main.debug("Tab Completing c : "+ c.getName() +" + \nNa : " + a.length);
for (String b: a) Main.debug(b);
if(a.length > 0 && a[0].equals("")) {
return Arrays.asList(menu);
}
if(a.length == 1) {
if(!a[0].equals("")) {
List<String> l = new ArrayList<>();
for (String t: menu) if(t.startsWith(a[0].toLowerCase())) l.add(t);
return l;
}
} else if(a.length == 2) {
String[] y;
if (a[0].equalsIgnoreCase("set") || a[0].equalsIgnoreCase("del") || a[0].equalsIgnoreCase("delete")) y = setdel;
else if (a[0].equalsIgnoreCase("config")) y = confopt;
else return null;
if (!a[1].equals("")) {
List<String> l = new ArrayList<>();
for (String t : y) if (t.startsWith(a[1].toLowerCase())) l.add(t);
return l;
} else return Arrays.asList(y);
}
return null;
}
}