From e67c187f4e7d4c69dc8fe1d3f82259e8fab9bb94 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Sat, 17 May 2025 10:18:58 +0200 Subject: [PATCH] Refactor Signed-off-by: Minecon724 --- README.md | 10 ++++------ .../module/wordcoords/WordCoordsModule.java | 15 +++++++-------- .../m724/tweaks/module/wordcoords/WordList.java | 1 - 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3f18c19..f1424e3 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Adds a "gateway" item that are controlled over internet. \ Control knockback dealt by entities ### Kill switch -Quickly kills (terminates) the server on trigger, via command or HTTP request. +Quickly kills (terminates) the server on trigger, by command or HTTP request. [KILLSWITCH.md for more info](/Minecon724/tweaks724/src/branch/master/docs/KILLSWITCH.md) ### Swing through grass @@ -101,12 +101,10 @@ Self-explanatory ### Durability alert Self-explanatory too. -`/durabilityalert` (`tweaks724.durabilityalert`) +### WordCoords +Converts coords to words and back so you easily remember them. -### Word coords -Convert coordinates to easier to remember words - -`/wordcoords` (`tweaks724.tauth`) +`/wordcoords` (`tweaks724.wordcoords`) ### Utility commands diff --git a/src/main/java/eu/m724/tweaks/module/wordcoords/WordCoordsModule.java b/src/main/java/eu/m724/tweaks/module/wordcoords/WordCoordsModule.java index 01f9101..78c71cc 100644 --- a/src/main/java/eu/m724/tweaks/module/wordcoords/WordCoordsModule.java +++ b/src/main/java/eu/m724/tweaks/module/wordcoords/WordCoordsModule.java @@ -34,6 +34,7 @@ import java.util.NoSuchElementException; public class WordCoordsModule extends TweaksModule implements CommandExecutor, Listener { private static final int MAX_RADIUS = 30_000_000; + private WordList wordList; private WordCoordsCodec converter; @Override @@ -48,14 +49,13 @@ public class WordCoordsModule extends TweaksModule implements CommandExecutor, L } } - WordList wordList; try { - wordList = WordList.fromFile(wordListFile); + this.wordList = WordList.fromFile(wordListFile); } catch (IOException e) { throw new RuntimeException("Failed to load word list", e); } - this.converter = new WordCoordsCodec(wordList); + this.converter = new WordCoordsCodec(this.wordList); registerCommand("wordcoords", this); registerEvents(this); @@ -171,11 +171,10 @@ public class WordCoordsModule extends TweaksModule implements CommandExecutor, L } @EventHandler - public void onCommand(PlayerCommandPreprocessEvent event) { - if (event.getMessage().startsWith("///")) { - event.setCancelled(true); + public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { + if (!event.getMessage().startsWith("///")) return; - event.getPlayer().performCommand("wordcoords " + event.getMessage().substring(3)); - } + event.getPlayer().performCommand("wordcoords " + event.getMessage().substring(3)); + event.setCancelled(true); } } diff --git a/src/main/java/eu/m724/tweaks/module/wordcoords/WordList.java b/src/main/java/eu/m724/tweaks/module/wordcoords/WordList.java index 6ccc0ec..9b3776c 100644 --- a/src/main/java/eu/m724/tweaks/module/wordcoords/WordList.java +++ b/src/main/java/eu/m724/tweaks/module/wordcoords/WordList.java @@ -58,6 +58,5 @@ public class WordList { return new WordList(list); } - } }