Released 9.8.3, commands disabled for players on non-premium versions

This commit is contained in:
libraryaddict 2019-11-03 18:07:12 +13:00
parent 2f109de685
commit 9df128db6f
11 changed files with 75 additions and 13 deletions

View File

@ -56,17 +56,14 @@ public class LibsDisguises extends JavaPlugin {
LibsPremium.check(getDescription().getVersion(), getFile());
if (!LibsPremium.isPremium()) {
getLogger().severe("You must purchase the plugin to use support for 1.14!");
getLogger().severe("This will be released free once the plugin is stable!");
getLogger().severe("If you've already purchased the plugin, place the purchased jar inside the " +
"Lib's Disguises plugin folder");
getPluginLoader().disablePlugin(this);
return;
getLogger()
.info("You are running the free version, commands limited to non-players (Console, Command " +
"Blocks)");
}
if (!ReflectionManager.getMinecraftVersion().startsWith("1.14")) {
if (!ReflectionManager.getMinecraftVersion().startsWith("1.14.4")) {
getLogger().severe("You're using the wrong version of Lib's Disguises for your server! This is " +
"intended for 1.14!");
"intended for 1.14.4!");
getPluginLoader().disablePlugin(this);
return;
}

View File

@ -1,12 +1,15 @@
package me.libraryaddict.disguise.commands;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
import me.libraryaddict.disguise.utilities.parser.params.ParamInfoManager;
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -36,6 +39,16 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
disguiseCommands = map;
}
protected boolean isNotPremium(CommandSender sender) {
if (sender instanceof Player &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
return true;
}
return false;
}
protected List<String> getTabDisguiseTypes(CommandSender sender, DisguisePermissions perms, String[] allArgs,
int startsAt, String currentArg) {
// If not enough arguments to get current disguise type

View File

@ -23,6 +23,10 @@ import java.util.List;
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (isNotPremium(sender)) {
return true;
}
if (!(sender instanceof Entity)) {
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
return true;

View File

@ -22,6 +22,10 @@ import java.util.List;
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (isNotPremium(sender)) {
return true;
}
if (!(sender instanceof Player)) {
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
return true;

View File

@ -27,6 +27,10 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (isNotPremium(sender)) {
return true;
}
DisguisePermissions permissions = getPermissions(sender);
if (!permissions.hasPermissions()) {

View File

@ -42,6 +42,10 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (isNotPremium(sender)) {
return true;
}
if (sender.getName().equals("CONSOLE")) {
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
return true;

View File

@ -1,7 +1,9 @@
package me.libraryaddict.disguise.commands;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -12,6 +14,12 @@ public class UndisguiseCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
return true;
}
if (sender.getName().equals("CONSOLE")) {
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
return true;

View File

@ -1,15 +1,24 @@
package me.libraryaddict.disguise.commands;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
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 UndisguiseEntityCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
return true;
}
if (sender.getName().equals("CONSOLE")) {
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
return true;

View File

@ -2,8 +2,10 @@ package me.libraryaddict.disguise.commands;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -53,6 +55,12 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
return true;
}
if (!sender.hasPermission("libsdisguises.undisguiseplayer")) {
sender.sendMessage(LibsMsg.NO_PERM.get());
return true;
@ -82,11 +90,11 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
if (DisguiseAPI.isDisguised(entityTarget)) {
DisguiseAPI.undisguiseToAll(entityTarget);
sender.sendMessage(LibsMsg.UNDISG_PLAYER
.get(entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable()));
sender.sendMessage(LibsMsg.UNDISG_PLAYER.get(entityTarget instanceof Player ? entityTarget.getName() :
DisguiseType.getType(entityTarget).toReadable()));
} else {
sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL
.get(entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable()));
sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL.get(entityTarget instanceof Player ? entityTarget.getName() :
DisguiseType.getType(entityTarget).toReadable()));
}
return true;

View File

@ -1,7 +1,9 @@
package me.libraryaddict.disguise.commands;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -27,6 +29,12 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
return true;
}
if (sender.getName().equals("CONSOLE")) {
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
return true;

View File

@ -93,7 +93,10 @@ public class LibsPremium {
// Comparing major versions
// Current version must be the same, or lower than premium version
return Integer.parseInt(currentSplit[0]) <= Integer.parseInt(premSplit[0]);
// return Integer.parseInt(currentSplit[0]) <= Integer.parseInt(premSplit[0]);
// Snapshot must be of current version
return premiumVersion.equals(currentVersion);
}
private static PluginInformation getInformation(File file) throws Exception {