diff --git a/CHANGELOG.md b/CHANGELOG.md index c4268a25..daa51140 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,15 @@ ######0.5 +* Added unpremium command +* Added /premium [player] command with optional player parameter * Added autologin - See config * Added config * Added isRegistered API method * Added forceRegister API method -* Fixed CrazyLogin player data restore -> Fixes memory leaks with this plugin +* Fixed CrazyLogin player data restore -> Fixes memory leaks with this plugin * Fixed premium name check to protocolsupport +* Improved permissions managment ######0.4 diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java index 3a8a462c..44fefbc2 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java @@ -4,6 +4,8 @@ import com.comphenix.protocol.AsynchronousManager; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.utility.SafeCacheBuilder; +import com.github.games647.fastlogin.bukkit.commands.CrackedCommand; +import com.github.games647.fastlogin.bukkit.commands.PremiumCommand; import com.github.games647.fastlogin.bukkit.hooks.AuthPlugin; import com.github.games647.fastlogin.bukkit.listener.BukkitJoinListener; import com.github.games647.fastlogin.bukkit.listener.BungeeCordListener; @@ -22,8 +24,8 @@ import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; import java.util.logging.Level; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang.RandomStringUtils; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -86,6 +88,7 @@ public class FastLoginBukkit extends JavaPlugin { //register commands using a unique name getCommand("premium").setExecutor(new PremiumCommand(this)); + getCommand("cracked").setExecutor(new CrackedCommand(this)); //check for incoming messages from the bungeecord version of this plugin getServer().getMessenger().registerIncomingPluginChannel(this, getName(), new BungeeCordListener(this)); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/CrackedCommand.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/CrackedCommand.java new file mode 100644 index 00000000..738aefb1 --- /dev/null +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/CrackedCommand.java @@ -0,0 +1,46 @@ +package com.github.games647.fastlogin.bukkit.commands; + +import com.github.games647.fastlogin.bukkit.FastLoginBukkit; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CrackedCommand implements CommandExecutor { + + private final FastLoginBukkit plugin; + + public CrackedCommand(FastLoginBukkit plugin) { + this.plugin = plugin; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (args.length == 0) { + if (!(sender instanceof Player)) { + //console or command block + sender.sendMessage(ChatColor.DARK_RED + "Only players can remove themselves from the premium list"); + return true; + } + + String playerName = sender.getName(); + plugin.getEnabledPremium().remove(playerName); + sender.sendMessage(ChatColor.DARK_GREEN + "Removed to the list of premium players"); + notifiyBungeeCord((Player) sender); + return true; + } + + return true; + } + + private void notifiyBungeeCord(Player target) { + ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(); + dataOutput.writeUTF("OFF"); + + target.sendPluginMessage(plugin, plugin.getName(), dataOutput.toByteArray()); + } +} diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/PremiumCommand.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/PremiumCommand.java similarity index 91% rename from bukkit/src/main/java/com/github/games647/fastlogin/bukkit/PremiumCommand.java rename to bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/PremiumCommand.java index 4f682fed..25f9461a 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/PremiumCommand.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/PremiumCommand.java @@ -1,5 +1,6 @@ -package com.github.games647.fastlogin.bukkit; +package com.github.games647.fastlogin.bukkit.commands; +import com.github.games647.fastlogin.bukkit.FastLoginBukkit; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; @@ -43,7 +44,7 @@ public class PremiumCommand implements CommandExecutor { private void notifiyBungeeCord(Player target) { ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(); - dataOutput.writeUTF("ACTIVE"); + dataOutput.writeUTF("ON"); target.sendPluginMessage(plugin, plugin.getName(), dataOutput.toByteArray()); } diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 4f8f9d62..0355e5b7 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -25,12 +25,32 @@ softdepend: commands: ${project.parent.name}: - description: 'Label the invoker or the player specified as premium' + description: 'Label the invoker as premium' aliases: [prem, premium, loginfast] usage: / [player] permission: ${project.artifactId}.command.premium + unpremium: + description: 'Label the invoker or the player specified as cracked if he was marked premium before' + aliases: [cracked] + usage: / [player] + permission: ${project.artifactId}.command.unpremium + permissions: ${project.parent.name}.command.premium: - description: 'Label themselves as premium using a command' - default: true \ No newline at end of file + description: 'Label themselves as premium' + default: true + + ${project.parent.name}.command.premium.other: + description: 'Label others as premium' + children: + ${project.parent.name}.command.premium + + ${project.parent.name}.command.unpremium: + description: 'Label themselves as cracked' + default: true + + ${project.parent.name}.command..unpremium.other: + description: 'Label others as cracked' + children: + ${project.parent.name}.command.unpremium \ No newline at end of file diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/PlayerConnectionListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/PlayerConnectionListener.java index e681e80c..a61e3223 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/PlayerConnectionListener.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/PlayerConnectionListener.java @@ -81,9 +81,12 @@ public class PlayerConnectionListener implements Listener { byte[] data = pluginMessageEvent.getData(); ByteArrayDataInput dataInput = ByteStreams.newDataInput(data); String subchannel = dataInput.readUTF(); - if ("ACTIVE".equals(subchannel)) { + if ("ON".equals(subchannel)) { ProxiedPlayer forPlayer = (ProxiedPlayer) pluginMessageEvent.getReceiver(); plugin.getEnabledPremium().add(forPlayer.getName()); + } else if ("OFF".equals(subchannel)) { + ProxiedPlayer forPlayer = (ProxiedPlayer) pluginMessageEvent.getReceiver(); + plugin.getEnabledPremium().remove(forPlayer.getName()); } } } diff --git a/pom.xml b/pom.xml index ec99ae32..2a5245a8 100644 --- a/pom.xml +++ b/pom.xml @@ -47,14 +47,12 @@ org.apache.maven.plugins maven-compiler-plugin - 3.3 + 3.5.1 1.7 1.7 true true - - false diff --git a/universal/pom.xml b/universal/pom.xml index e7c6a8d7..82349a1b 100644 --- a/universal/pom.xml +++ b/universal/pom.xml @@ -22,7 +22,7 @@ org.apache.maven.plugins maven-shade-plugin - 2.4.2 + 2.4.3 false false