Skip to content

Commit

Permalink
Fix reconnecting behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxopoly committed Nov 20, 2018
1 parent b3c734c commit b4e6937
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.maxopoly</groupId>
<artifactId>angelia-cmd</artifactId>
<version>1.0.02</version>
<version>1.0.03</version>
<packaging>jar</packaging>

<name>Angelia-cmd</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public CommandLineReader(Logger logger, ActiveConnectionManager connectionMan, S
this.connectionMan = connectionMan;
this.playerName = playerName;
this.mode = Mode.COMMAND;
getConnection().getLogger().info("--- Set console to command mode");
ServerConnection conn = getConnection();
if (conn != null) {
getConnection().getLogger().info("--- Set console to command mode");
}
this.cmdHandler = cmdHandler;
}

Expand All @@ -39,6 +42,9 @@ public void start() {
}
while (true) {
String msg = c.readLine("");
if (msg == null) {
continue;
}
if (msg.equals("++")) {
if (mode == Mode.CHAT) {
mode = Mode.COMMAND;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/maxopoly/angelia_cmd/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void main(String[] args) {
System.exit(0);
return;
}
connManager.initConnection(connection, false, null);
connManager.initConnection(connection, null);
connection.getEventHandler().registerListener(new ChatListener(logger));
connection.getEventHandler().registerListener(new PlayerStateListener(logger));
cmdHandler = new CommandHandler(logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public synchronized void handle(String input, ServerConnection connection) {
if (input == null || input.equals("")) {
return;
}
if (connection == null) {
System.out.println("Currently not connected to a server, could not process command");
return;
}
connection.getLogger().info("INPUT: " + input);
String[] args = input.split(" ");
if (args[0].toLowerCase().equals("help")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ChatListener(Logger logger) {
this.logger = logger;
}

@AngeliaEventHandler
@AngeliaEventHandler(autoTransfer = true)
public void chatMessageReceived(ChatMessageReceivedEvent e) {
logger.info("[CHAT] " + e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public PlayerStateListener(Logger logger) {
this.formatter = new DecimalFormat("#.###");
}

@AngeliaEventHandler
@AngeliaEventHandler(autoTransfer = true)
public void chatMessageReceived(HealthChangeEvent e) {
if (e.getNewValue() == e.getOldValue()) {
return;
Expand Down

0 comments on commit b4e6937

Please sign in to comment.