Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0ea2d4958b
@ -19,7 +19,6 @@ public final class Main extends JavaPlugin {
|
|||||||
private static Logger logger;
|
private static Logger logger;
|
||||||
|
|
||||||
private List<Appliance> appliances;
|
private List<Appliance> appliances;
|
||||||
private HttpServer httpApi;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -62,7 +61,7 @@ public final class Main extends JavaPlugin {
|
|||||||
Main.logger().info(String.format("Initialized %d appliances!", appliances.size()));
|
Main.logger().info(String.format("Initialized %d appliances!", appliances.size()));
|
||||||
|
|
||||||
Main.logger().info("Starting HTTP API...");
|
Main.logger().info("Starting HTTP API...");
|
||||||
this.httpApi = new HttpServer();
|
new HttpServer();
|
||||||
|
|
||||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
Main.logger().info("Startup complete!");
|
Main.logger().info("Startup complete!");
|
||||||
@ -76,7 +75,7 @@ public final class Main extends JavaPlugin {
|
|||||||
appliance.onDisable();
|
appliance.onDisable();
|
||||||
appliance.destruct(this);
|
appliance.destruct(this);
|
||||||
});
|
});
|
||||||
this.httpApi.stop();
|
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
Bukkit.getScheduler().cancelTasks(this);
|
Bukkit.getScheduler().cancelTasks(this);
|
||||||
Main.logger().info("Disabled " + appliances.size() + " appliances!");
|
Main.logger().info("Disabled " + appliances.size() + " appliances!");
|
||||||
|
@ -24,10 +24,6 @@ public class HttpServer {
|
|||||||
Main.instance().getAppliances().forEach(appliance -> appliance.httpApi(new ApiBuilder(appliance)));
|
Main.instance().getAppliances().forEach(appliance -> appliance.httpApi(new ApiBuilder(appliance)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
|
||||||
Spark.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public record Response(Status status, Object error, Object response) {
|
public record Response(Status status, Object error, Object response) {
|
||||||
public enum Status {
|
public enum Status {
|
||||||
FAILURE,
|
FAILURE,
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package eu.mhsl.craftattack.spawn.appliances.maintenance;
|
package eu.mhsl.craftattack.spawn.appliances.maintenance;
|
||||||
|
|
||||||
import eu.mhsl.craftattack.spawn.appliance.ApplianceCommand;
|
import eu.mhsl.craftattack.spawn.appliance.ApplianceCommand;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -18,9 +20,14 @@ public class MaintenanceCommand extends ApplianceCommand<Maintenance> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
|
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
|
||||||
if(args.length != 1 || !arguments.containsKey(args[0])) throw new Error("Argument 'enable' oder 'disable' gefordert!");
|
if(args.length == 1 && arguments.containsKey(args[0])) {
|
||||||
getAppliance().setState(arguments.get(args[0]));
|
getAppliance().setState(arguments.get(args[0]));
|
||||||
sender.sendMessage(String.format("Maintanance: %b", getAppliance().isInMaintenance()));
|
sender.sendMessage(Component.text("Maintanance mode updated!", NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
sender.sendMessage(Component.text(
|
||||||
|
String.format("Maintanance mode is %b", getAppliance().isInMaintenance()),
|
||||||
|
NamedTextColor.GOLD
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user