Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package redeminecraft.staff.bukkit.main;
- import com.google.common.io.ByteArrayDataInput;
- import com.google.common.io.ByteStreams;
- import org.bukkit.Bukkit;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.plugin.messaging.PluginMessageListener;
- public class Main extends JavaPlugin implements PluginMessageListener {
- public Main plugin;
- @Override
- public void onEnable() {
- plugin = this;
- getServer().getMessenger().registerOutgoingPluginChannel(this, "Staff");
- getServer().getMessenger().registerIncomingPluginChannel(this, "Staff", this);
- System.out.println("§c" + plugin.getDescription().getName() + " - Modo Bukkit habilitado.");
- }
- private void debug(String message) {
- Bukkit.getConsoleSender().sendMessage("§a[rmcStaff] - " + message);
- }
- public void onPluginMessageReceived(String channel, Player player, byte[] message) {
- if (!channel.equals("Staff")) return;
- ByteArrayDataInput in = ByteStreams.newDataInput(message);
- String subChannel = in.readUTF();
- if (subChannel.equals("promote")) {
- String data = in.readUTF();
- String office = data.split(";")[0];
- String target = data.split(";")[1];
- if (Bukkit.getPlayer(target) != null) {
- sendCommand("lp user " + target + " parent set " + office);
- Bukkit.getPlayer(target).sendMessage("§a» §7Você foi promovido para: §f" + office + "§7.");
- }
- plugin.debug("§f" + target + " §efoi promovido para §f" + office);
- }
- if (subChannel.equals("demote")) {
- String data = in.readUTF();
- String office = data.split(";")[0];
- String target = data.split(";")[1];
- if (Bukkit.getPlayer(target) != null) {
- sendCommand("lp user " + target + " parent remove " + office);
- sendCommand("lp user " + target + " parent set normal");
- Bukkit.getPlayer(target).sendMessage("§c» §7Você foi demotado.");
- }
- plugin.debug("§f" + target + " §efoi demotado para §f" + "Membro");
- }
- }
- private void sendCommand(String command) {
- Bukkit.getScheduler().runTask(this, () -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment