diff --git a/src/main/java/client/MapleCharacter.java b/src/main/java/client/MapleCharacter.java index 7cc72a00d4..8b692784ca 100644 --- a/src/main/java/client/MapleCharacter.java +++ b/src/main/java/client/MapleCharacter.java @@ -28,7 +28,7 @@ import client.inventory.*; import client.inventory.Equip.StatUpgrade; import client.inventory.manipulator.CashIdGenerator; import client.inventory.manipulator.InventoryManipulator; -import client.keybind.MapleKeyBinding; +import client.keybind.KeyBinding; import client.keybind.MapleQuickslotBinding; import client.newyear.NewYearCardRecord; import client.processor.action.PetAutopotProcessor; @@ -188,7 +188,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject { private Map diseaseExpires = new LinkedHashMap<>(); private Map> buffEffects = new LinkedHashMap<>(); // non-overriding buffs thanks to Ronan private Map buffExpires = new LinkedHashMap<>(); - private Map keymap = new LinkedHashMap<>(); + private Map keymap = new LinkedHashMap<>(); private Map summons = new LinkedHashMap<>(); private Map coolDowns = new LinkedHashMap<>(); private EnumMap> diseases = new EnumMap<>(MapleDisease.class); @@ -395,7 +395,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject { } for (int i = 0; i < selectedKey.length; i++) { - ret.keymap.put(selectedKey[i], new MapleKeyBinding(selectedType[i], selectedAction[i])); + ret.keymap.put(selectedKey[i], new KeyBinding(selectedType[i], selectedAction[i])); } @@ -1203,7 +1203,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject { sendPacket(packet); } - public void changeKeybinding(int key, MapleKeyBinding keybinding) { + public void changeKeybinding(int key, KeyBinding keybinding) { if (keybinding.getType() != 0) { keymap.put(Integer.valueOf(key), keybinding); } else { @@ -5157,7 +5157,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject { return job.getId() / 1000; } - public Map getKeymap() { + public Map getKeymap() { return keymap; } @@ -7376,7 +7376,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject { int key = rs.getInt("key"); int type = rs.getInt("type"); int action = rs.getInt("action"); - ret.keymap.put(key, new MapleKeyBinding(type, action)); + ret.keymap.put(key, new KeyBinding(type, action)); } } } @@ -8514,8 +8514,8 @@ public class MapleCharacter extends AbstractMapleCharacterObject { try (PreparedStatement psKey = con.prepareStatement("INSERT INTO keymap (characterid, `key`, `type`, `action`) VALUES (?, ?, ?, ?)")) { psKey.setInt(1, id); - Set> keybindingItems = Collections.unmodifiableSet(keymap.entrySet()); - for (Entry keybinding : keybindingItems) { + Set> keybindingItems = Collections.unmodifiableSet(keymap.entrySet()); + for (Entry keybinding : keybindingItems) { psKey.setInt(2, keybinding.getKey()); psKey.setInt(3, keybinding.getValue().getType()); psKey.setInt(4, keybinding.getValue().getAction()); @@ -9107,7 +9107,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject { // autopot on HPMP deplete... thanks shavit for finding out D. Roar doesn't trigger autopot request if (hpchange < 0) { - MapleKeyBinding autohpPot = this.getKeymap().get(91); + KeyBinding autohpPot = this.getKeymap().get(91); if (autohpPot != null) { int autohpItemid = autohpPot.getAction(); float autohpAlert = this.getAutopotHpAlert(); @@ -9122,7 +9122,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject { } if (mpchange < 0) { - MapleKeyBinding autompPot = this.getKeymap().get(92); + KeyBinding autompPot = this.getKeymap().get(92); if (autompPot != null) { int autompItemid = autompPot.getAction(); float autompAlert = this.getAutopotMpAlert(); diff --git a/src/main/java/client/keybind/MapleKeyBinding.java b/src/main/java/client/keybind/KeyBinding.java similarity index 90% rename from src/main/java/client/keybind/MapleKeyBinding.java rename to src/main/java/client/keybind/KeyBinding.java index a2b3f23a44..4eecef4a71 100644 --- a/src/main/java/client/keybind/MapleKeyBinding.java +++ b/src/main/java/client/keybind/KeyBinding.java @@ -21,10 +21,11 @@ */ package client.keybind; -public class MapleKeyBinding { - private int type, action; +public class KeyBinding { + private final int type; + private final int action; - public MapleKeyBinding(int type, int action) { + public KeyBinding(int type, int action) { this.type = type; this.action = action; } diff --git a/src/main/java/net/server/channel/handlers/KeymapChangeHandler.java b/src/main/java/net/server/channel/handlers/KeymapChangeHandler.java index 8e471ac2e8..818eea6d0d 100644 --- a/src/main/java/net/server/channel/handlers/KeymapChangeHandler.java +++ b/src/main/java/net/server/channel/handlers/KeymapChangeHandler.java @@ -25,7 +25,7 @@ import client.MapleClient; import client.Skill; import client.SkillFactory; import client.inventory.InventoryType; -import client.keybind.MapleKeyBinding; +import client.keybind.KeyBinding; import constants.game.GameConstants; import net.AbstractPacketHandler; import net.packet.InPacket; @@ -61,7 +61,7 @@ public final class KeymapChangeHandler extends AbstractPacketHandler { } } - c.getPlayer().changeKeybinding(key, new MapleKeyBinding(type, action)); + c.getPlayer().changeKeybinding(key, new KeyBinding(type, action)); } } else if(mode == 1) { // Auto HP Potion int itemID = p.readInt(); @@ -69,14 +69,14 @@ public final class KeymapChangeHandler extends AbstractPacketHandler { c.disconnect(false, false); // Don't let them send a packet with a use item they dont have. return; } - c.getPlayer().changeKeybinding(91, new MapleKeyBinding(7, itemID)); + c.getPlayer().changeKeybinding(91, new KeyBinding(7, itemID)); } else if(mode == 2) { // Auto MP Potion int itemID = p.readInt(); if(itemID != 0 && c.getPlayer().getInventory(InventoryType.USE).findById(itemID) == null) { c.disconnect(false, false); // Don't let them send a packet with a use item they dont have. return; } - c.getPlayer().changeKeybinding(92, new MapleKeyBinding(7, itemID)); + c.getPlayer().changeKeybinding(92, new KeyBinding(7, itemID)); } } } diff --git a/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java b/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java index b2015d9dd1..32f7562479 100644 --- a/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java +++ b/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java @@ -23,7 +23,7 @@ package net.server.channel.handlers; import client.*; import client.inventory.*; -import client.keybind.MapleKeyBinding; +import client.keybind.KeyBinding; import config.YamlConfig; import constants.game.GameConstants; import net.AbstractPacketHandler; @@ -225,10 +225,10 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler { player.sendMacros(); // pot bindings being passed through other characters on the account detected thanks to Croosade dev team - MapleKeyBinding autohpPot = player.getKeymap().get(91); + KeyBinding autohpPot = player.getKeymap().get(91); player.sendPacket(PacketCreator.sendAutoHpPot(autohpPot != null ? autohpPot.getAction() : 0)); - MapleKeyBinding autompPot = player.getKeymap().get(92); + KeyBinding autompPot = player.getKeymap().get(92); player.sendPacket(PacketCreator.sendAutoMpPot(autompPot != null ? autompPot.getAction() : 0)); player.getMap().addPlayer(player); diff --git a/src/main/java/tools/PacketCreator.java b/src/main/java/tools/PacketCreator.java index 0483153a84..8e7e6c80a1 100644 --- a/src/main/java/tools/PacketCreator.java +++ b/src/main/java/tools/PacketCreator.java @@ -24,7 +24,7 @@ import client.*; import client.MapleCharacter.SkillEntry; import client.inventory.*; import client.inventory.Equip.ScrollResult; -import client.keybind.MapleKeyBinding; +import client.keybind.KeyBinding; import client.keybind.MapleQuickslotBinding; import client.newyear.NewYearCardRecord; import client.status.MonsterStatus; @@ -3468,11 +3468,11 @@ public class PacketCreator { return p; } - public static Packet getKeymap(Map keybindings) { + public static Packet getKeymap(Map keybindings) { final OutPacket p = OutPacket.create(SendOpcode.KEYMAP); p.writeByte(0); for (int x = 0; x < 90; x++) { - MapleKeyBinding binding = keybindings.get(x); + KeyBinding binding = keybindings.get(x); if (binding != null) { p.writeByte(binding.getType()); p.writeInt(binding.getAction());