Skip to content

Commit

Permalink
Fixed Configuration implementation and added /atlas reload argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
funkemunky committed Jan 11, 2019
1 parent 87226d1 commit 5620b51
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 160 deletions.
265 changes: 115 additions & 150 deletions API/.idea/workspace.xml

Large diffs are not rendered by default.

Binary file modified API/out/artifacts/Atlas_jar/Atlas.jar
Binary file not shown.
Binary file modified API/out/production/Atlas/cc/funkemunky/api/Atlas.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified API/out/production/Atlas/cc/funkemunky/api/updater/Updater.class
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion API/out/production/Atlas/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
updater:
autoDownload: false
checkForUpdates: true
notifyWhenUpdate: true
notifyOnJoin: true
metrics: true
2 changes: 1 addition & 1 deletion API/out/production/Atlas/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Atlas
main: cc.funkemunky.api.Atlas
version: 1.0.3
version: 1.0.4
author: funkemunky
commands:
atlas:
14 changes: 12 additions & 2 deletions API/src/cc/funkemunky/api/Atlas.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cc.funkemunky.api.metrics.Metrics;
import cc.funkemunky.api.tinyprotocol.api.TinyProtocolHandler;
import cc.funkemunky.api.updater.Updater;
import cc.funkemunky.api.updater.UpdaterListener;
import cc.funkemunky.api.utils.BlockUtils;
import cc.funkemunky.api.utils.Color;
import cc.funkemunky.api.utils.MiscUtils;
Expand Down Expand Up @@ -52,8 +53,17 @@ public void onEnable() {

funkeCommandManager.addCommand(new AtlasCommand());

if(updater.needsToUpdate())
MiscUtils.printToConsole(Color.Green + "There is an update available. See more information with /atlas update.");
Bukkit.getPluginManager().registerEvents(new UpdaterListener(), this);

if(updater.needsToUpdate()) {
MiscUtils.printToConsole(Color.Yellow + "There is an update available. See more information with /atlas update.");

if(getConfig().getBoolean("updater.autoDownload")) {
MiscUtils.printToConsole(Color.Gray + "Downloading new version...");
updater.downloadNewVersion();
MiscUtils.printToConsole(Color.Green + "Atlas v" + updater.getVersion() + " has been downloaded. Please restart/reload your server to import it.");
}
}

MiscUtils.printToConsole(Color.Green + "Successfully loaded Atlas and its utilities!");
}
Expand Down
5 changes: 3 additions & 2 deletions API/src/cc/funkemunky/api/commands/impl/AtlasCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import cc.funkemunky.api.Atlas;
import cc.funkemunky.api.commands.FunkeCommand;
import cc.funkemunky.api.commands.impl.args.ReloadArgument;
import cc.funkemunky.api.commands.impl.args.UpdateArgument;
import org.bukkit.plugin.java.JavaPlugin;

public class AtlasCommand extends FunkeCommand {
public AtlasCommand() {
Expand All @@ -12,6 +12,7 @@ public AtlasCommand() {

@Override
protected void addArguments() {
getArguments().add(new UpdateArgument("update", "update <check, download> [args]", "manage updates for Atlas.", "atlas.update"));
getArguments().add(new UpdateArgument());
getArguments().add(new ReloadArgument());
}
}
19 changes: 19 additions & 0 deletions API/src/cc/funkemunky/api/commands/impl/args/ReloadArgument.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cc.funkemunky.api.commands.impl.args;

import cc.funkemunky.api.Atlas;
import cc.funkemunky.api.commands.FunkeArgument;
import cc.funkemunky.api.utils.Color;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

public class ReloadArgument extends FunkeArgument {
public ReloadArgument() {
super("reload", "reload", "reload the configuration.", "atlas.reload");
}

@Override
public void onArgument(CommandSender sender, Command cmd, String[] args) {
Atlas.getInstance().reloadConfig();
sender.sendMessage(Color.Green + "Successfully reloaded the Atlas configuration file!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.bukkit.command.CommandSender;

public class UpdateArgument extends FunkeArgument {
public UpdateArgument(String name, String display, String description, String... permission) {
super(name, display, description, permission);
public UpdateArgument() {
super("update", "update <check, download> [args]", "manage updates for Atlas.", "atlas.update");

addTabComplete(2, "check", "download", "update");
addTabComplete(3, "confirm,!check,2");
Expand Down
7 changes: 5 additions & 2 deletions API/src/cc/funkemunky/api/updater/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

@Getter
public class Updater {
private int update = - 1, currentUpdate = 4;
private int update = - 1, currentUpdate = 5;
private String version, downloadLink;
private File pluginLocation;
private boolean importantUpdate;
private boolean importantUpdate = false;

public Updater() {
if(Atlas.getInstance().getConfig().getBoolean("updater.checkForUpdates")) {
Expand All @@ -32,6 +32,9 @@ public Updater() {
} else {
version = downloadLink = "N/A";
}
} else {
version = Atlas.getInstance().getDescription().getVersion();

}
}

Expand Down
19 changes: 19 additions & 0 deletions API/src/cc/funkemunky/api/updater/UpdaterListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cc.funkemunky.api.updater;


import cc.funkemunky.api.Atlas;
import cc.funkemunky.api.utils.Color;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

public class UpdaterListener implements Listener {

@EventHandler
public void onEvent(PlayerJoinEvent event) {
if(event.getPlayer().hasPermission("api.admin")
&& Atlas.getInstance().getConfig().getBoolean("updater.notifyOnJoin") && Atlas.getInstance().getUpdater().needsToUpdate()) {
event.getPlayer().sendMessage(Color.translate("&8[&a&lAtlas&8] &7A new version of Atlas has been released (&f" + Atlas.getInstance().getUpdater().getVersion() + "&7)!"));
}
}
}

0 comments on commit 5620b51

Please sign in to comment.