From c29c88609564bc0c10a23906f79162c79a9af74a Mon Sep 17 00:00:00 2001 From: Harry Zhou Date: Fri, 10 Jun 2022 00:09:21 -0500 Subject: [PATCH] Fixed gamemode commands in 1.19 --- .../github/hhhzzzsss/songplayer/CommandProcessor.java | 10 ++++++++-- .../songplayer/noteblocks/BuildingThread.java | 2 +- .../hhhzzzsss/songplayer/noteblocks/PlayingThread.java | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/CommandProcessor.java b/src/main/java/com/github/hhhzzzsss/songplayer/CommandProcessor.java index d0c914e..963de98 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/CommandProcessor.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/CommandProcessor.java @@ -337,7 +337,10 @@ public class CommandProcessor { public boolean processCommand(String args) { if (args.length() > 0) { SongPlayer.creativeCommand = args; - SongPlayer.addChatMessage("§6Set creative command to " + SongPlayer.creativeCommand); + if (SongPlayer.creativeCommand.startsWith("/")) { + SongPlayer.creativeCommand = SongPlayer.creativeCommand.substring(1); + } + SongPlayer.addChatMessage("§6Set creative command to /" + SongPlayer.creativeCommand); return true; } else { @@ -359,7 +362,10 @@ public class CommandProcessor { public boolean processCommand(String args) { if (args.length() > 0) { SongPlayer.survivalCommand = args; - SongPlayer.addChatMessage("§6Set survival command to " + SongPlayer.survivalCommand); + if (SongPlayer.survivalCommand.startsWith("/")) { + SongPlayer.survivalCommand = SongPlayer.survivalCommand.substring(1); + } + SongPlayer.addChatMessage("§6Set survival command to /" + SongPlayer.survivalCommand); return true; } else { diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/BuildingThread.java b/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/BuildingThread.java index 693cbc5..38898d7 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/BuildingThread.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/BuildingThread.java @@ -75,7 +75,7 @@ public class BuildingThread extends Thread { } } - player.sendChatMessage(SongPlayer.creativeCommand); + player.sendCommand(SongPlayer.creativeCommand); try { //delay in case of block updates Thread.sleep(1000); } catch (InterruptedException e) { diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/PlayingThread.java b/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/PlayingThread.java index e9fb5e4..7dfecfa 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/PlayingThread.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/PlayingThread.java @@ -14,7 +14,7 @@ public class PlayingThread extends Thread{ private final Song song = SongPlayer.song; public void run() { - player.sendChatMessage(SongPlayer.survivalCommand); + player.sendCommand(SongPlayer.survivalCommand); while (SongPlayer.MC.interactionManager.getCurrentGameMode() != GameMode.SURVIVAL) { if (SongPlayer.mode != SongPlayer.Mode.PLAYING) {return;} try {