From 3d4fe47cd5ea5a7292907ba7a15e634da2e034e3 Mon Sep 17 00:00:00 2001 From: Oliver-makes-code <59418903+Oliver-makes-code@users.noreply.github.com> Date: Thu, 27 May 2021 19:55:05 -0500 Subject: [PATCH] random fixes before v1.0 --- .../olivermakescode/extension/nicknames.java | 16 ++++++-------- .../olivermakescode/extension/swapRow.java | 22 +++++++------------ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/github/olivermakescode/extension/nicknames.java b/src/main/java/com/github/olivermakescode/extension/nicknames.java index d50cddd..aea90d4 100644 --- a/src/main/java/com/github/olivermakescode/extension/nicknames.java +++ b/src/main/java/com/github/olivermakescode/extension/nicknames.java @@ -57,12 +57,12 @@ public static void load() throws IOException { public static void save() throws IOException { String[] intermediary = new String[username.length]; - StringBuilder toSave = new StringBuilder(); + String toSave = ""; for (int i = 0; i < username.length; i++) { intermediary[i] = username[i] + ":" + nickname[i]; - toSave.append(intermediary[i]).append("\n"); + toSave += intermediary[i] + "\n"; } - loadFile.save("nick.txt",toSave.toString()); + loadFile.save("nick.txt",toSave); } public static String getName(PlayerEntity user) { @@ -78,14 +78,12 @@ public static String getName(PlayerEntity user) { public static void registerCommand() { CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> { - dispatcher.register(literal("nick").then(argument("nickname", StringArgumentType.string()).executes(context -> { + var ctx = argument("nickname", StringArgumentType.string()).executes(context -> { addName(context.getSource().getPlayer(),StringArgumentType.getString(context,"nickname")); return 1; - }))); - dispatcher.register(literal("nickname").then(argument("nickname", StringArgumentType.string()).executes(context -> { - addName(context.getSource().getPlayer(),StringArgumentType.getString(context,"nickname")); - return 1; - }))); + }); + dispatcher.register(literal("nick").then(ctx)); + dispatcher.register(literal("nickname").then(ctx)); }); } } diff --git a/src/main/java/com/github/olivermakescode/extension/swapRow.java b/src/main/java/com/github/olivermakescode/extension/swapRow.java index ce691ea..9878060 100644 --- a/src/main/java/com/github/olivermakescode/extension/swapRow.java +++ b/src/main/java/com/github/olivermakescode/extension/swapRow.java @@ -9,30 +9,24 @@ public class swapRow { public static void swap(int row, PlayerEntity player) { - int startIdx = row*9; - - for (int i = startIdx; i { - dispatcher.register(literal("hb").then(argument("slot", IntegerArgumentType.integer(1,3)).executes(context -> { - swap(IntegerArgumentType.getInteger(context,"slot"), context.getSource().getPlayer()); + var ctx = argument("slot", IntegerArgumentType.integer(1, 3)).executes(context -> { + swap(IntegerArgumentType.getInteger(context, "slot"), context.getSource().getPlayer()); return 1; - }))); - }); - CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> { - dispatcher.register(literal("hotbar").then(argument("slot", IntegerArgumentType.integer(1,3)).executes(context -> { - swap(IntegerArgumentType.getInteger(context,"slot"), context.getSource().getPlayer()); - return 1; - }))); + }); + + dispatcher.register(literal("hotbar").then(ctx)); + dispatcher.register(literal("hb").then(ctx)); }); } }