Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Keal
- * La classe suivante ainsi que les méthodes getCommand()/isCommand()/addCommand() vont dans World.java
- */
- public static class FastCmd
- {
- private String name;
- private int actionId;
- private String args;
- public FastCmd(String name, int actionId, String args)
- {
- this.name = name;
- this.actionId = actionId;
- this.args = args;
- }
- public String getName() {
- return name;
- }
- public int getActionId() {
- return actionId;
- }
- public String getArgs() {
- return args;
- }
- }
- public static FastCmd getCommand(String name)
- {
- for(Entry<String, FastCmd> curCmd : Commands.entrySet())
- {
- if(curCmd.getKey() == name)
- {
- return curCmd.getValue();
- }
- }
- return null;
- }
- public static boolean isCommand(String name)
- {
- return Commands.containsKey(name);
- }
- public static void addFastCmd(FastCmd fastCmd)
- {
- Commands.put(fastCmd.getName(), fastCmd);
- }
- //Dans SQLManager.java
- public static void LOAD_FAST_COMMANDS()
- {
- try {
- ResultSet RS = SQLManager.executeQuery("SELECT * from commands;", Faith.STATIC_DB_NAME);
- while (RS.next())
- {
- World.addFastCmd(new World.FastCmd(
- RS.getString("commandName"),
- RS.getInt("actionId"),
- RS.getString("args")
- ));
- }
- closeResultSet(RS);
- } catch (SQLException e) {
- System.out.println("Game: SQL ERROR: " + e.getMessage());
- System.exit(1);
- }
- }
- //Dans GameThread.java dans la méthode Basic_chatMessage après if (msg.charAt(0) == '.') {
- if(World.isCommand(msg))
- {
- FastCmd cmd = World.getCommand(msg);
- new Action(cmd.getActionId(), cmd.getArgs(), "").apply(_perso, null, 0, -1);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment