[refactor] try to generate general structures

This commit is contained in:
Hiajen Hiajen 2021-05-22 12:48:12 +02:00
parent ac28939480
commit f19ea5c876
10 changed files with 172 additions and 79 deletions

View file

@ -0,0 +1,14 @@
package net.saltymc.eaa.handler.commands;
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
public interface Command {
boolean run(final FabricClientCommandSource cs, String[] args);
/**
* should message get intercepted and not send to Server?
*/
boolean intercept();
}

View file

@ -0,0 +1,31 @@
package net.saltymc.eaa.handler.commands;
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
import net.minecraft.text.Text;
public class EaaCommand implements Command {
private static final String COMMAND = "echo";
private static final boolean INTERCEPT = true;
@Override
public boolean run( final FabricClientCommandSource cs, String[] args) {
if (!args[0].equalsIgnoreCase(COMMAND)) {
return false;
}
StringBuilder sb = new StringBuilder();
for (String arg : args)
sb.append(arg);
cs.sendFeedback(Text.of(sb.toString().replaceFirst(args[0], "")));
return true;
}
@Override
public boolean intercept() {
return INTERCEPT;
}
}