-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix case commands + forge not checking for a
/
before running comma…
…nds (#413)
- Loading branch information
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...om/mitchej123/hodgepodge/mixins/early/minecraft/MixinClientCommandHandler_CommandFix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.mitchej123.hodgepodge.mixins.early.minecraft; | ||
|
||
import java.util.Locale; | ||
|
||
import net.minecraft.command.ICommandSender; | ||
import net.minecraftforge.client.ClientCommandHandler; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
|
||
@Mixin(ClientCommandHandler.class) | ||
public class MixinClientCommandHandler_CommandFix { | ||
|
||
@Inject(method = "executeCommand", at = @At("HEAD"), cancellable = true) | ||
private void hodgepodge$checkSlash(ICommandSender sender, String message, CallbackInfoReturnable<Integer> cir) { | ||
if (!message.trim().startsWith("/")) { | ||
cir.setReturnValue(0); | ||
} | ||
} | ||
|
||
@ModifyExpressionValue( | ||
method = "executeCommand", | ||
at = @At(value = "INVOKE", target = "Ljava/lang/String;split(Ljava/lang/String;)[Ljava/lang/String;")) | ||
private String[] hodgepodge$caseCommand(String[] original) { | ||
final String s = original[0]; | ||
if (s != null) { | ||
original[0] = s.toLowerCase(Locale.ENGLISH); | ||
} | ||
return original; | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinCommandHandler_CommandFix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.mitchej123.hodgepodge.mixins.early.minecraft; | ||
|
||
import java.util.Locale; | ||
|
||
import net.minecraft.command.CommandHandler; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
|
||
@Mixin(CommandHandler.class) | ||
public class MixinCommandHandler_CommandFix { | ||
|
||
@ModifyExpressionValue( | ||
method = "executeCommand", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Ljava/lang/String;split(Ljava/lang/String;)[Ljava/lang/String;", | ||
remap = false)) | ||
private String[] hodgepodge$caseCommand(String[] original) { | ||
final String s = original[0]; | ||
if (s != null) { | ||
original[0] = s.toLowerCase(Locale.ENGLISH); | ||
} | ||
return original; | ||
} | ||
|
||
@ModifyArg( | ||
method = "registerCommand", | ||
index = 0, | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", | ||
remap = false)) | ||
private Object hodgepodge$caseCommand(Object s) { | ||
if (s instanceof String) { | ||
s = ((String) s).toLowerCase(Locale.ENGLISH); | ||
} | ||
return s; | ||
} | ||
|
||
@ModifyExpressionValue( | ||
method = "getPossibleCommands(Lnet/minecraft/command/ICommandSender;Ljava/lang/String;)Ljava/util/List;", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Ljava/lang/String;split(Ljava/lang/String;I)[Ljava/lang/String;", | ||
remap = false)) | ||
private String[] hodgepodge$caseCommandTabComplete(String[] original) { | ||
final String s = original[0]; | ||
if (s != null) { | ||
original[0] = s.toLowerCase(Locale.ENGLISH); | ||
} | ||
return original; | ||
} | ||
|
||
} |