Skip to content

Commit

Permalink
Merge pull request #1 from exit91/master
Browse files Browse the repository at this point in the history
Anpassung an neue Bungee API
  • Loading branch information
Sascha Hanke committed Apr 2, 2013
2 parents 1548f93 + 1d2ea19 commit 495db2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
6 changes: 2 additions & 4 deletions src/com/github/calenria/scbungee/SimpleChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
import java.util.ResourceBundle;

import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.Logger;
import net.md_5.bungee.api.plugin.Plugin;

public class SimpleChat extends Plugin {
private static Logger log = Logger.$();
public static ResourceBundle messages = null;
public static String pluginPath = "./plugins/SimpleChat-Bungee/";
public File messagesFile = new File(pluginPath + "messages.properties");
Expand All @@ -37,7 +35,7 @@ public void onEnable() {
out.newLine();
out.close();
} catch (Exception ex) {
log.warning(ex.getLocalizedMessage());
BungeeCord.getInstance().getLogger().warning(ex.getLocalizedMessage());
}
}

Expand All @@ -63,7 +61,7 @@ private PropertyResourceBundle readProperties() {
out.newLine();
out.close();
} catch (Exception e) {
log.warning(e.getLocalizedMessage());
BungeeCord.getInstance().getLogger().warning(e.getLocalizedMessage());
}
}
try {
Expand Down
17 changes: 7 additions & 10 deletions src/com/github/calenria/scbungee/SimpleChatListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.StringTokenizer;

import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.Logger;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
Expand All @@ -21,14 +20,12 @@

public class SimpleChatListener implements Listener {

private static Logger log = Logger.$();

@Subscribe
public void onLogin(LoginEvent event) {
if (SimpleChat.hideStream) {
return;
}
log.info("Player Login: " + event.getConnection().getName());
BungeeCord.getInstance().getLogger().info("Player Login: " + event.getConnection().getName());
sendAll(ChatColor.translateAlternateColorCodes('&', String.format(SimpleChat.messages.getString("login"), event.getConnection().getName())));
}

Expand All @@ -37,15 +34,15 @@ public void onDisconnect(PlayerDisconnectEvent event) {
if (SimpleChat.hideStream) {
return;
}
log.info("Player Disconnect: " + event.getPlayer().getName());
BungeeCord.getInstance().getLogger().info("Player Disconnect: " + event.getPlayer().getName());
sendAll(ChatColor.translateAlternateColorCodes('&', String.format(SimpleChat.messages.getString("logout"), event.getPlayer().getName())));
}

@Subscribe
public void onPluginMessage(PluginMessageEvent event) {
String pluginMessage = new String(event.getData());
if (SimpleChat.debug) {
log.info("Recived plugin message: " + pluginMessage);
BungeeCord.getInstance().getLogger().info("Recived plugin message: " + pluginMessage);
}
if (!event.getTag().equals("SimpleChat"))
return;
Expand Down Expand Up @@ -113,20 +110,20 @@ public void onPluginMessage(PluginMessageEvent event) {

private void sendPluginMessage(String pluginMessage, Entry<String, ServerInfo> server) {
if (SimpleChat.debug) {
log.info("[perUser] Sending Message to: " + server.getKey());
BungeeCord.getInstance().getLogger().info("[perUser] Sending Message to: " + server.getKey());
}
List<ProxiedPlayer> pPlayers = new ArrayList<ProxiedPlayer>(server.getValue().getPlayers());
if (!pPlayers.isEmpty()) {
ProxiedPlayer pPlayer = pPlayers.get(0);
pPlayer.sendData("SimpleChat", pluginMessage.getBytes());
} else {
log.info("No Player found on Server: " + server.getKey());
BungeeCord.getInstance().getLogger().info("No Player found on Server: " + server.getKey());
}
}

private void sendPluginMessage(String pluginMessage, Server server) {
if (SimpleChat.debug) {
log.info("[perServer] Sending Message to: " + server.getInfo().getName());
BungeeCord.getInstance().getLogger().info("[perServer] Sending Message to: " + server.getInfo().getName());
}
server.sendData("SimpleChat", pluginMessage.getBytes());
}
Expand All @@ -136,7 +133,7 @@ private void sendAll(String msg) {
if (!pPlayers.isEmpty()) {
for (ProxiedPlayer proxiedPlayer : pPlayers) {
if (SimpleChat.debug) {
log.info("Sending Message to: " + proxiedPlayer.getName());
BungeeCord.getInstance().getLogger().info("Sending Message to: " + proxiedPlayer.getName());
}
proxiedPlayer.sendMessage(msg);
}
Expand Down

0 comments on commit 495db2b

Please sign in to comment.