92 lines
3.5 KiB
Java
92 lines
3.5 KiB
Java
/*
|
|
* Copyright (c) 2017 univento.eu - All rights reserved
|
|
* You are not allowed to use, distribute or modify this code
|
|
*/
|
|
|
|
package eu.univento.core.listeners;
|
|
|
|
import com.google.common.io.ByteArrayDataOutput;
|
|
import com.google.common.io.ByteStreams;
|
|
import eu.univento.commons.player.warn.WarnReason;
|
|
import eu.univento.core.Core;
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
/**
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
|
|
public class PluginMessenger implements PluginMessageListener {
|
|
|
|
@Override
|
|
public void onPluginMessageReceived(String channel, Player player, byte[] data) {
|
|
CustomPlayer p = CustomPlayer.getPlayer(player);
|
|
String string = null;
|
|
try {
|
|
string = new String (data, "UTF-8");
|
|
} catch (UnsupportedEncodingException e) {
|
|
e.printStackTrace();
|
|
}
|
|
assert string != null;
|
|
if(string.endsWith("squidhq")) {
|
|
p.warn(WarnReason.SQUIDHQ, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/hacks");
|
|
}
|
|
|
|
if (channel.equals("WDL|INIT")) {
|
|
String version = null;
|
|
if(data.length == 0) version = "vor 1.8d";
|
|
else try {
|
|
version = new String(data, "UTF-8");
|
|
} catch (UnsupportedEncodingException e) {
|
|
e.printStackTrace();
|
|
}
|
|
p.sendMessage(p.getDatabasePlayer().getLanguage().getWord("Prefix") + p.getDatabasePlayer().getLanguage().getWord("Hack.WorldDownloader"));
|
|
}
|
|
if(channel.equals("WDL|CONTROL")) {
|
|
ByteArrayDataOutput output = ByteStreams.newDataOutput();
|
|
|
|
output.writeInt(1);
|
|
|
|
output.writeBoolean(false);
|
|
output.writeInt(0);
|
|
output.writeBoolean(false);
|
|
output.writeBoolean(false);
|
|
output.writeBoolean(false);
|
|
output.writeBoolean(false);
|
|
|
|
p.sendPluginMessage(Core.getInstance(), "WDL|CONTROL", output.toByteArray());
|
|
}
|
|
if (channel.equals("PERMISSIONSREPL") && string.contains("mod.worlddownloader")) {
|
|
p.warn(WarnReason.WDL, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/hacks");
|
|
p.sendMessage(p.getDatabasePlayer().getLanguage().getWord("Prefix") + p.getDatabasePlayer().getLanguage().getWord("Hack.WorldDownloader"));
|
|
}
|
|
if(channel.equals("5zig_Set")) {
|
|
//https://gist.github.com/5zig/35e0854504edda418f4b shows why its done that way
|
|
|
|
ByteArrayDataOutput output1 = ByteStreams.newDataOutput();
|
|
output1.write(0x01);
|
|
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output1.toByteArray());
|
|
|
|
ByteArrayDataOutput output2 = ByteStreams.newDataOutput();
|
|
output2.write(0x02);
|
|
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output2.toByteArray());
|
|
|
|
ByteArrayDataOutput output3 = ByteStreams.newDataOutput();
|
|
output3.write(0x04);
|
|
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output3.toByteArray());
|
|
|
|
ByteArrayDataOutput output4 = ByteStreams.newDataOutput();
|
|
output4.write(0x08);
|
|
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output4.toByteArray());
|
|
|
|
ByteArrayDataOutput output5 = ByteStreams.newDataOutput();
|
|
output5.write(0x10);
|
|
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output5.toByteArray());
|
|
}
|
|
}
|
|
}
|