[refactor] try to generate general structures
This commit is contained in:
parent
ac28939480
commit
f19ea5c876
10 changed files with 172 additions and 79 deletions
14
src/main/java/net/saltymc/eaa/handler/commands/Command.java
Normal file
14
src/main/java/net/saltymc/eaa/handler/commands/Command.java
Normal 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();
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue