Skip to content

Instantly share code, notes, and snippets.

@zh32
Created January 22, 2013 16:14
Show Gist options
  • Save zh32/4595919 to your computer and use it in GitHub Desktop.
Save zh32/4595919 to your computer and use it in GitHub Desktop.
package de.zh32.bungeeex;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
public class BungeeEx extends Plugin {
@Override
public void onEnable() {
ProxyServer.getInstance().getPluginManager().registerListener(new TestListener());
}
}
##########################################################################################
package de.zh32.bungeeex;
import com.google.common.eventbus.Subscribe;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ChatEvent;
import net.md_5.bungee.api.plugin.Listener;
public class TestListener implements Listener {
@Subscribe
public void onChat(ChatEvent event) {
if (event.getMessage().startsWith("@")) {
final String message = event.getMessage();
int spaceIndex = message.indexOf(" ");
if (event.getSender() instanceof ProxiedPlayer) {
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
if (spaceIndex > -1) {
String name = message.substring(1, spaceIndex);
if (name.length() <= 0) {
return;
}
if (ProxyServer.getInstance().getPlayer(name) != null) {
ProxyServer.getInstance().getPlayer(name).sendMessage(message.substring(spaceIndex + 1));
player.sendMessage(message.substring(spaceIndex + 1));
}
else {
player.sendMessage("Spieler nicht gefunden.");
}
event.setCancelled(true);
}
}
}
}
/*
public void onProxyPing(ProxyPingEvent event) {
Random rand = new Random();
int oi = rand.nextInt((2542+1) - 2476) + 2476;
Integer i = new Integer(oi);
String online = i.toString();
ServerPing response = new ServerPing((byte) 51, "1.4.7", "hallo " + event.getRemoteAddress().toString(), online, "3000");
event.setResponse(response);
}
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment