Skip to content

Commit 2784659

Browse files
author
bytemaniak
committed
Simplify keybinding code. Fix lang for taunt
1 parent 56efc1d commit 2784659

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/main/java/com/bytemaniak/mcquake3/registry/Keybindings.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,24 @@ public class Keybindings {
1414
private static KeyBinding playerSettingsMenu;
1515
private static KeyBinding playerTaunt;
1616

17-
public static void registerKeybinds() {
18-
playerSettingsMenu = KeyBindingHelper.registerKeyBinding(new KeyBinding(
19-
"key.mcquake3.playermenu",
20-
InputUtil.Type.KEYSYM,
21-
GLFW.GLFW_KEY_O,
17+
private static KeyBinding registerKeybind(String id, int key) {
18+
return KeyBindingHelper.registerKeyBinding(new KeyBinding(
19+
"key.mcquake3."+id, InputUtil.Type.KEYSYM, key,
2220
"category.mcquake3.bindings"));
21+
}
22+
23+
public static void registerKeybinds() {
24+
playerSettingsMenu = registerKeybind("playermenu", GLFW.GLFW_KEY_O);
25+
playerTaunt = registerKeybind("playertaunt", GLFW.GLFW_KEY_Z);
2326

2427
ClientTickEvents.END_CLIENT_TICK.register(client -> {
25-
if (playerSettingsMenu.wasPressed()) {
28+
if (playerSettingsMenu.wasPressed())
2629
client.setScreen(new PlayerSettingsScreen(Text.of("MCQuake3 Player Settings"), client.player));
27-
}
2830
});
2931

30-
playerTaunt = KeyBindingHelper.registerKeyBinding(new KeyBinding(
31-
"key.mcquake3.playertaunt",
32-
InputUtil.Type.KEYSYM,
33-
GLFW.GLFW_KEY_Z,
34-
"category.mcquake3.bindings"));
3532
ClientTickEvents.END_CLIENT_TICK.register(client -> {
36-
if (playerTaunt.wasPressed()) {
33+
if (playerTaunt.wasPressed())
3734
ClientPlayNetworking.send(Packets.PLAYER_TAUNT, PacketByteBufs.empty());
38-
}
3935
});
4036
}
4137
}

src/main/resources/assets/mcquake3/lang/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@
5252
"death.attack.mcquake3.spikes": "%1$s was impaled to death.",
5353
"death.attack.mcquake3.spikes.player": "%2$s did a \"This is Sparta\" on %1$s.",
5454
"key.mcquake3.playermenu": "MCQuake3 Player Settings",
55+
"key.mcquake3.playertaunt": "Taunt",
5556
"category.mcquake3.bindings": "MCQuake3"
5657
}

0 commit comments

Comments
 (0)