Added unpremium/cracked command

This commit is contained in:
games647
2016-02-28 18:28:36 +01:00
parent b2ae46a90a
commit 015739fe4c
8 changed files with 86 additions and 12 deletions

View File

@@ -1,12 +1,15 @@
######0.5 ######0.5
* Added unpremium command
* Added /premium [player] command with optional player parameter
* Added autologin - See config * Added autologin - See config
* Added config * Added config
* Added isRegistered API method * Added isRegistered API method
* Added forceRegister 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 * Fixed premium name check to protocolsupport
* Improved permissions managment
######0.4 ######0.4

View File

@@ -4,6 +4,8 @@ import com.comphenix.protocol.AsynchronousManager;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.utility.SafeCacheBuilder; 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.hooks.AuthPlugin;
import com.github.games647.fastlogin.bukkit.listener.BukkitJoinListener; import com.github.games647.fastlogin.bukkit.listener.BukkitJoinListener;
import com.github.games647.fastlogin.bukkit.listener.BungeeCordListener; 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.ConcurrentMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; 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.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@@ -86,6 +88,7 @@ public class FastLoginBukkit extends JavaPlugin {
//register commands using a unique name //register commands using a unique name
getCommand("premium").setExecutor(new PremiumCommand(this)); getCommand("premium").setExecutor(new PremiumCommand(this));
getCommand("cracked").setExecutor(new CrackedCommand(this));
//check for incoming messages from the bungeecord version of this plugin //check for incoming messages from the bungeecord version of this plugin
getServer().getMessenger().registerIncomingPluginChannel(this, getName(), new BungeeCordListener(this)); getServer().getMessenger().registerIncomingPluginChannel(this, getName(), new BungeeCordListener(this));

View File

@@ -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());
}
}

View File

@@ -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.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
@@ -43,7 +44,7 @@ public class PremiumCommand implements CommandExecutor {
private void notifiyBungeeCord(Player target) { private void notifiyBungeeCord(Player target) {
ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(); ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
dataOutput.writeUTF("ACTIVE"); dataOutput.writeUTF("ON");
target.sendPluginMessage(plugin, plugin.getName(), dataOutput.toByteArray()); target.sendPluginMessage(plugin, plugin.getName(), dataOutput.toByteArray());
} }

View File

@@ -25,12 +25,32 @@ softdepend:
commands: commands:
${project.parent.name}: ${project.parent.name}:
description: 'Label the invoker or the player specified as premium' description: 'Label the invoker as premium'
aliases: [prem, premium, loginfast] aliases: [prem, premium, loginfast]
usage: /<command> [player] usage: /<command> [player]
permission: ${project.artifactId}.command.premium 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: /<command> [player]
permission: ${project.artifactId}.command.unpremium
permissions: permissions:
${project.parent.name}.command.premium: ${project.parent.name}.command.premium:
description: 'Label themselves as premium using a command' description: 'Label themselves as premium'
default: true 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

View File

@@ -81,9 +81,12 @@ public class PlayerConnectionListener implements Listener {
byte[] data = pluginMessageEvent.getData(); byte[] data = pluginMessageEvent.getData();
ByteArrayDataInput dataInput = ByteStreams.newDataInput(data); ByteArrayDataInput dataInput = ByteStreams.newDataInput(data);
String subchannel = dataInput.readUTF(); String subchannel = dataInput.readUTF();
if ("ACTIVE".equals(subchannel)) { if ("ON".equals(subchannel)) {
ProxiedPlayer forPlayer = (ProxiedPlayer) pluginMessageEvent.getReceiver(); ProxiedPlayer forPlayer = (ProxiedPlayer) pluginMessageEvent.getReceiver();
plugin.getEnabledPremium().add(forPlayer.getName()); plugin.getEnabledPremium().add(forPlayer.getName());
} else if ("OFF".equals(subchannel)) {
ProxiedPlayer forPlayer = (ProxiedPlayer) pluginMessageEvent.getReceiver();
plugin.getEnabledPremium().remove(forPlayer.getName());
} }
} }
} }

View File

@@ -47,14 +47,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version> <version>3.5.1</version>
<configuration> <configuration>
<source>1.7</source> <source>1.7</source>
<target>1.7</target> <target>1.7</target>
<showWarnings>true</showWarnings> <showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation> <showDeprecation>true</showDeprecation>
<!--false means actual true http://jira.codehaus.org/browse/MCOMPILER-209-->
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration> </configuration>
</plugin> </plugin>

View File

@@ -22,7 +22,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>2.4.2</version> <version>2.4.3</version>
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>false</shadedArtifactAttached> <shadedArtifactAttached>false</shadedArtifactAttached>