Skip to content

Commit

Permalink
Case-insensitive commands glue
Browse files Browse the repository at this point in the history
  • Loading branch information
buj committed May 24, 2024
1 parent 6774b66 commit 2fd1fe1
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/main/java/darkdustry/DarkdustryPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class DarkdustryPlugin extends Plugin {
@Override
public void init() {
Log.info("Loading Darkdustry plugin.");

ModCommandHandler.load(); // ModCommandHandler must be loader before Commands, so
// just in case we're loading it as soon as possible
Time.mark();

Console.load();
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/darkdustry/commands/ClientCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
import darkdustry.features.votes.*;
import darkdustry.listeners.SocketEvents.*;
import darkdustry.utils.*;
import mindustry.content.StatusEffects;
import mindustry.content.UnitTypes;
import mindustry.entities.Effect;
import mindustry.game.Team;
import mindustry.gen.*;
import useful.*;

Expand Down
39 changes: 39 additions & 0 deletions src/main/java/darkdustry/commands/ModCommandHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package darkdustry.commands;

import arc.struct.Seq;
import arc.util.CommandHandler;
import mindustry.Vars;

public class ModCommandHandler extends CommandHandler {
private final CommandHandler proxied;

public static void load() {
Vars.netServer.clientCommands = new ModCommandHandler(Vars.netServer.clientCommands);
}

public ModCommandHandler(CommandHandler proxied) {
super(proxied.prefix);
this.proxied = proxied;
}

@Override
public CommandResponse handleMessage(String message, Object params) {
if (message.contains(" ")) {
message = message.substring(0, message.indexOf(" ")).toLowerCase() + message.substring(message.indexOf(" "));
}
else {
message = message.toLowerCase();
}
return proxied.handleMessage(message, params);
}

@Override
public <T> Command register(String text, String params, String description, CommandRunner<T> runner) {
return proxied.register(text, params, description, runner);
}

@Override
public Seq<Command> getCommandList() {
return proxied.getCommandList();
}
}
5 changes: 5 additions & 0 deletions src/main/java/darkdustry/listeners/PluginEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import mindustry.game.EventType.*;
import mindustry.game.Team;
import mindustry.gen.*;
import mindustry.logic.LExecutor;
import mindustry.world.blocks.payloads.BuildPayload;
import mindustry.world.blocks.storage.CoreBlock;
import useful.Bundle;
Expand Down Expand Up @@ -138,6 +139,10 @@ public static void load() {
Alerts.buildAlert(event);
});

Events.on(BlockDestroyEvent.class, event -> {
if (!(event.tile.build instanceof CoreBlock.CoreBuild)) return;
});

Events.on(GeneratorPressureExplodeEvent.class, event -> app.post(() -> {
if (!Units.canCreate(event.build.team, UnitTypes.latum)) return;

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "Darkdustry Plugin",
"author": "Darkness & xzxADIxzx",
"description": "The main plugin for Darkdustry servers. Includes a lot of useful features.",
"version": "6.6",
"version": "6.7",
"main": "darkdustry.DarkdustryPlugin",
"repo": "Darkdustry-Coders/DarkdustryPlugin",
"dependencies": []
Expand Down

0 comments on commit 2fd1fe1

Please sign in to comment.