Skip to content

Commit

Permalink
Feat: Overhaul the commands em
Browse files Browse the repository at this point in the history
  • Loading branch information
showierdata9978 committed Jul 27, 2024
1 parent 5513a81 commit 62a6960
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/main/java/tech/showierdata/pickaxe/Constants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tech.showierdata.pickaxe;

import net.fabricmc.loader.impl.lib.sat4j.core.Vec;
import net.minecraft.util.math.Vec3d;

public class Constants {
Expand All @@ -8,6 +9,8 @@ public class Constants {


public static final Vec3d Spawn = new Vec3d(7085, 200, 4115);
public static final Vec3d WahDoor = new Vec3d(64, 0, 77);


public static final int PLOT_ID = 50644;
public static final String SERVER_IP = "mcdiamondfire.com";
Expand Down
57 changes: 46 additions & 11 deletions src/main/java/tech/showierdata/pickaxe/Pickaxe.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,20 @@ public static Pickaxe getInstance() {
public static PickaxeCommand[] getCommands() {
return new PickaxeCommand[] {
new PickaxeCommand("help",
"This command! (Added by pickaxe mod)",
"This command! (Added by Pickaxe Mod)",
new String[]{},
new HelpCommandController()

),

new PickaxeCommand("itemlock", "Locks your held item", new String[] {}, new PassthroughCommand()),
new PickaxeCommand("pay", "Pay's the specified person the amount specified", new String[] {
"[user]",
"[amount]"
}, new PassthroughCommand()),
new PickaxeCommand("lockitem",
"Locks your held item",
new String[] {},
new PassthroughCommand()
),
new PickaxeCommand("pay", "Pay's the specified person the amount specified",
new String[] {"[user]", "[amount]" },
new PassthroughCommand()
),
new PickaxeCommand("up",
"Teleports you to the surface",
new String[] {},
Expand All @@ -104,9 +107,43 @@ public static PickaxeCommand[] getCommands() {
new String[] {"[color]"},
new PassthroughCommand()
),

new PickaxeCommand("item",
"Sends the item you are holding in chat",
new String[] {"[text] "},
new PassthroughCommand()
),
new PickaxeCommand("title",
"Changes the name of a notebook",
new String[] {"[name]"},
new PassthroughCommand()
),
new PickaxeCommand("backup",
"Backs your inventory up! Make sure to run often.",
new String[] { },
new PassthroughCommand()
),
new PickaxeCommand("ach",
"Opens the achievement menu!",
new String[] { },
new PassthroughCommand()
),
new PickaxeCommand("trash",
"Opens a trash can inventory (does the same thing as offhand while in inventory)",
new String[] { },
new PassthroughCommand()
),
new PickaxeCommand("wah",
"Opens a shop for your WAH points.",
new String[] {},
new PassthroughCommand()
),
new PickaxeCommand("pay",
"Pays a user",
new String[]{"[username]"},
new PassthroughCommand()
),
new PickaxeCommand("wiki",
"Sends a link to the wiki (Added by Pickaxe Mod)",
"Sends the link to the wiki (Added by Pickaxe Mod)",
new String[] {},
(name, args) -> {
MinecraftClient client = MinecraftClient.getInstance();
Expand Down Expand Up @@ -358,8 +395,6 @@ private void drawMDT(DrawContext context, TextRenderer renderer) {

context.drawTextWithShadow(renderer, Texts.join(texts, Text.literal(" ")), 5, y, Colors.WHITE);

// Sounds
//prepSounds(client, time);
}

private void register_callbacks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public abstract class ClientPlayNetworkHandlerMixin {
@Shadow
public abstract void sendChatCommand(String message);

@Shadow public abstract void sendChatMessage(String content);

@Unique
private boolean inLoop = false;

Expand All @@ -56,7 +58,8 @@ private void onTick(CallbackInfo info) {
@Inject(at = @At("HEAD"), method = "sendChatMessage", cancellable = true)
private void sendMessage(String chatText, CallbackInfo info) {
MinecraftClient client = MinecraftClient.getInstance();
if (!Pickaxe.getInstance().isInPickaxe()) {
Pickaxe pick = Pickaxe.getInstance();
if (!pick.getInstance().isInPickaxe()) {
return;
}
if (chatText.startsWith("@") && !inLoop) {
Expand All @@ -66,18 +69,29 @@ private void sendMessage(String chatText, CallbackInfo info) {

inLoop = true;

Boolean flag = false;


for (PickaxeCommand pickaxeCommand : Pickaxe.getInstance().commands) {
if (!Objects.equals(pickaxeCommand.name, command.get(0))) {
continue;
}


flag = true;
pickaxeCommand.handler.use(command.get(0), command.subList(1, command.size()));
break;
}


inLoop = false;

info.cancel();
if (!pick.rel_spawn.isInRange(Constants.WahDoor, 6)) {
if (!flag)
client.player.sendMessage(Text.literal(command.get(0) + " is an invalid command! If you think this is wrong, " +
"\n disable the mod, check, then report to ShowierData9978"));
info.cancel();

}

}
}
Expand Down

0 comments on commit 62a6960

Please sign in to comment.