Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Buddelbubi authored Mar 20, 2022
1 parent ab1a288 commit ce23d88
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 43 deletions.
1 change: 0 additions & 1 deletion Sourcecode/src/de/buddelbubi/Commands/AliasManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class AliasManager extends Command {

public AliasManager(String name) {
super(name);
// TODO Auto-generated constructor stub
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Random;

import org.iq80.leveldb.util.FileUtils;

import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.command.Command;
Expand Down
2 changes: 0 additions & 2 deletions Sourcecode/src/de/buddelbubi/Events/Addons.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.buddelbubi.Events;

import java.io.BufferedReader;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -12,7 +11,6 @@
import java.nio.file.StandardCopyOption;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.command.CommandSender;
Expand Down
8 changes: 1 addition & 7 deletions Sourcecode/src/de/buddelbubi/WorldManager.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package de.buddelbubi;

import java.io.File;


import cn.nukkit.Server;



import cn.nukkit.command.Command;
import cn.nukkit.plugin.Plugin;
import cn.nukkit.plugin.PluginBase;
Expand All @@ -29,21 +24,20 @@ public void onEnable() {

plugin = this;


Command command = new WorldManagerCommand("WorldManager");
command.setAliases(new String[] {"wm", "mw", "mv", "levelmanager", "lm"});
command.setDescription("The main WorldManager Command");
getServer().getCommandMap().register(command.getName(), command);
getServer().getPluginManager().registerEvents(new Events(), plugin);
getServer().getPluginManager().registerEvents(new WorldManagerUI(), plugin);
//getServer().getPluginManager().registerEvents(new Addons(), plugin);
getServer().getPluginManager().registerEvents(new Addons(), plugin);
LoadWorlds.loadWorlds();
AliasManager.registerAliases();
Addons.initJson();

CustomMetricsManager.loadMetrics();

//Disabling the Auto-Updater is not recommended unless your host disables file downloads.

File file = new File(Server.getInstance().getPluginPath(), "worldmanager.yml");
if(file.exists()) {
Expand Down
3 changes: 1 addition & 2 deletions Sourcecode/src/de/buddelbubi/api/World.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package de.buddelbubi.api;

import java.io.File;


import cn.nukkit.Server;
import cn.nukkit.level.Level;
import cn.nukkit.utils.Config;
Expand All @@ -19,6 +17,7 @@ public class World {
private boolean protect;
private String note;


public World(Level level) {

this.level = level.getName();
Expand Down
2 changes: 0 additions & 2 deletions Sourcecode/src/de/buddelbubi/utils/Cache.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package de.buddelbubi.utils;

import java.util.HashMap;


import cn.nukkit.Server;
import cn.nukkit.level.Level;
import de.buddelbubi.api.World;
Expand Down
3 changes: 1 addition & 2 deletions Sourcecode/src/de/buddelbubi/utils/CustomMetricsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Callable;

import cn.nukkit.Server;
import de.buddelbubi.WorldManager;
import de.buddelbubi.utils.Metrics.DrilldownPie;
Expand All @@ -14,7 +13,7 @@
public class CustomMetricsManager {


// WorldManager got a custom property to dont send its data in the bukkit tab of bStats.
// WorldManager got a custom property so it does not send its data in the bukkit tab of bStats.
// It has now the "other" tag. It does not have any have default charts. So I have to add them here.


Expand Down
2 changes: 1 addition & 1 deletion Sourcecode/src/de/buddelbubi/utils/LoadWorlds.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.buddelbubi.utils;

import java.io.File;
import java.io.IOException;

import java.io.IOException;
import cn.nukkit.Server;
import cn.nukkit.level.Level;
import cn.nukkit.utils.Config;
Expand Down
23 changes: 8 additions & 15 deletions Sourcecode/src/de/buddelbubi/utils/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,15 @@
import cn.nukkit.utils.Config;


// This metrics class is unusable unless your plugin got a entry in the hidden "other" section!


public class Metrics {

private final Plugin plugin;

private final MetricsBase metricsBase;

/**
* Creates a new Metrics instance.
*
* @param plugin Your plugin instance.
* @param serviceId The id of the service. It can be found at <a
* href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
*/
public Metrics(Plugin plugin, int serviceId) {

Server.getInstance().getLogger().info("bStats Metrics loaded");
Expand All @@ -63,9 +59,7 @@ public Metrics(Plugin plugin, int serviceId) {
config.save(configFile);
}
// Load the data
boolean enabled = true; //config.getBoolean("enabled", true);

//Yea.. I removed the ability to disable bStats for my Plugins... I just love statistics so much <3
final boolean enabled = true;

String serverUUID = config.getString("serverUuid");
boolean logErrors = config.getBoolean("logFailedRequests", false);
Expand Down Expand Up @@ -99,8 +93,11 @@ public void addCustomChart(CustomChart chart) {

private void appendPlatformData(JsonObjectBuilder builder) {

// Unused because everything is handled in CustomMetricsManager.java

/* builder.appendField("playerAmount", getPlayerAmount());
/* Default code
builder.appendField("playerAmount", getPlayerAmount());
builder.appendField("onlineMode", Server.getInstance().getPropertyBoolean("xbox-auth", false) ? 1 : 0);
builder.appendField("bukkitVersion", Server.getInstance().getVersion());
builder.appendField("bukkitName", Server.getInstance().getName());
Expand All @@ -116,10 +113,6 @@ private void appendServiceData(JsonObjectBuilder builder) {
builder.appendField("pluginVersion", plugin.getDescription().getVersion());
}

/*private int getPlayerAmount() {
return Server.getInstance().getOnlinePlayers().size();
} */

public static class MetricsBase {

/** The version of the Metrics class. */
Expand Down
13 changes: 4 additions & 9 deletions Sourcecode/src/de/buddelbubi/utils/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Scanner;

import cn.nukkit.Server;
import de.buddelbubi.WorldManager;

public class Updater {


public static void checkAndDoUpdateIfAvailable() {

if(updateAvailable()) {
installLastestVersion();
}

}



@SuppressWarnings("resource")
public static boolean updateAvailable() {

try {
URL githuburl = new URL("https://raw.githubusercontent.com/Buddelbubi/WorldManager/main/version");
if(!(new Scanner(githuburl.openStream()).next().contains(WorldManager.plugin.getDescription().getVersion()))) {
Server.getInstance().getLogger().info("§eA new version of WorldManager is available. Try to Auto-Update!");
WorldManager.plugin.getLogger().info("§eA new version of WorldManager is available. Try to Auto-Update!");
return true;
} else return false;
} catch (Exception e) {
Expand All @@ -46,11 +42,10 @@ public static void installLastestVersion() {
File file = new File(WorldManager.plugin.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
InputStream in = url.openStream();
Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
Server.getInstance().getLogger().info("§aUpdated WorldManager successfully. Please reload or reboot your Server.");

WorldManager.plugin.getLogger().info("§aUpdated WorldManager successfully. Please reload or reboot your Server.");

} catch (IOException e) {
Server.getInstance().getLogger().error("§cUpdate failed... Please update manually. (" + e.getMessage() + ")");
WorldManager.plugin.getLogger().error("§cUpdate failed... Please update manually. (" + e.getMessage() + ")");

}
}
Expand Down

0 comments on commit ce23d88

Please sign in to comment.