mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-10 21:10:21 +01:00
Didn't notice the order IDEA generated the onEnable and onDisable methods...
This commit is contained in:
parent
c083b665ec
commit
3b11db7b2a
@ -1,5 +1,8 @@
|
|||||||
package com.jaimemartz.playerbalanceraddon;
|
package com.jaimemartz.playerbalanceraddon;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -13,6 +16,12 @@ public class MainCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
if (cmd.getName().equalsIgnoreCase("balanceraddon"))
|
||||||
|
|
||||||
|
sender.spigot().sendMessage(new ComponentBuilder(Strings.repeat("-", 53)).strikethrough(true).color(ChatColor.GRAY).create());
|
||||||
|
sender.spigot().sendMessage(new ComponentBuilder("Available commands:").color(ChatColor.GRAY).create());
|
||||||
|
sender.spigot().sendMessage(new ComponentBuilder("/section connect <section> [player]").color(ChatColor.AQUA).append(" - ").color(ChatColor.GRAY).append("Connects you or the specified player to that section").color(ChatColor.RED).create());
|
||||||
|
sender.spigot().sendMessage(new ComponentBuilder(Strings.repeat("-", 53)).strikethrough(true).color(ChatColor.GRAY).create());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ public class PlayerBalancerAddon extends JavaPlugin {
|
|||||||
private PluginMessageManager manager;
|
private PluginMessageManager manager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onEnable() {
|
||||||
manager = new PluginMessageManager(this);
|
manager = new PluginMessageManager(this);
|
||||||
getCommand("balancer").setExecutor(new MainCommand(this));
|
getCommand("balanceraddon").setExecutor(new MainCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onDisable() {
|
||||||
|
//Nothing to do...
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginMessageManager getManager() {
|
public PluginMessageManager getManager() {
|
||||||
|
@ -38,7 +38,7 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
||||||
String subchannel = in.readUTF();
|
String subchannel = in.readUTF();
|
||||||
|
|
||||||
contexts.get(new MessageContext(channel, subchannel, player))
|
contexts.get(new MessageContext(channel, subchannel, player.getUniqueId()))
|
||||||
.stream().findFirst().ifPresent(a -> a.accept(in));
|
.stream().findFirst().ifPresent(a -> a.accept(in));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
contexts.put(new MessageContext(
|
contexts.put(new MessageContext(
|
||||||
"PlayerBalancer",
|
"PlayerBalancer",
|
||||||
"GetSectionByName",
|
"GetSectionByName",
|
||||||
player
|
player.getUniqueId()
|
||||||
), ByteArrayDataInput::readUTF);
|
), ByteArrayDataInput::readUTF);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -84,7 +84,7 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
contexts.put(new MessageContext(
|
contexts.put(new MessageContext(
|
||||||
"PlayerBalancer",
|
"PlayerBalancer",
|
||||||
"GetSectionByServer",
|
"GetSectionByServer",
|
||||||
player
|
player.getUniqueId()
|
||||||
), ByteArrayDataInput::readUTF);
|
), ByteArrayDataInput::readUTF);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -98,16 +98,16 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
contexts.put(new MessageContext(
|
contexts.put(new MessageContext(
|
||||||
"PlayerBalancer",
|
"PlayerBalancer",
|
||||||
"GetSectionOfPlayer",
|
"GetSectionOfPlayer",
|
||||||
player
|
player.getUniqueId()
|
||||||
), ByteArrayDataInput::readUTF);
|
), ByteArrayDataInput::readUTF);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class MessageContext {
|
private final class MessageContext {
|
||||||
private final String channel;
|
private final String channel;
|
||||||
private final String subchannel;
|
private final String subchannel;
|
||||||
private final Player player;
|
private final UUID player;
|
||||||
|
|
||||||
public MessageContext(String channel, String subchannel, Player player) {
|
public MessageContext(String channel, String subchannel, UUID player) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.subchannel = subchannel;
|
this.subchannel = subchannel;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
@ -2,3 +2,5 @@ name: PlayerBalancerAddon
|
|||||||
main: com.jaimemartz.playerbalanceraddon.PlayerBalancerAddon
|
main: com.jaimemartz.playerbalanceraddon.PlayerBalancerAddon
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
author: jaime29010
|
author: jaime29010
|
||||||
|
|
||||||
|
softdepend: [PlaceholderAPI]
|
Loading…
Reference in New Issue
Block a user