diff --git a/pom.xml b/pom.xml index 5bb10580..f438060a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ LibsDisguises LibsDisguises - 9.9.1-SNAPSHOT + 9.9.2 clean install diff --git a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java index 9fbb0e7e..b0e73237 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.commands; +import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.DisguiseType; @@ -22,6 +23,8 @@ import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.permissions.Permissible; +import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.Team; import java.util.ArrayList; import java.util.Iterator; @@ -98,6 +101,59 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { DisguiseConfig.loadConfig(); sender.sendMessage(LibsMsg.RELOADED_CONFIG.get()); return true; + } else if (args[0].equalsIgnoreCase("scoreboard") || args[0].equalsIgnoreCase("board")) { + if (!sender.hasPermission("libsdisguises.scoreboardtest")) { + sender.sendMessage(LibsMsg.NO_PERM.get()); + return true; + } + + if (DisguiseConfig.getPushingOption() == DisguiseConfig.DisguisePushing.IGNORE_SCOREBOARD) { + sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_DISABLED.get()); + } + + Player player; + + if (args.length > 1) { + player = Bukkit.getPlayer(args[1]); + + if (player == null) { + sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[1])); + return true; + } + + if (!DisguiseAPI.isDisguised(player)) { + sender.sendMessage(LibsMsg.DMODPLAYER_NODISGUISE.get(player.getName())); + return true; + } + } else if (sender instanceof Player) { + player = (Player) sender; + + if (!DisguiseAPI.isDisguised(player)) { + sender.sendMessage(LibsMsg.NOT_DISGUISED.get()); + return true; + } + } else { + sender.sendMessage(LibsMsg.NO_CONSOLE.get()); + return true; + } + + Scoreboard board = player.getScoreboard(); + + Team team = board.getEntryTeam(sender.getName()); + + if (team == null) { + sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_NO_TEAM.get()); + return true; + } + + if (team.getOption(Team.Option.COLLISION_RULE) != Team.OptionStatus.NEVER && + team.getOption(Team.Option.COLLISION_RULE) != Team.OptionStatus.FOR_OTHER_TEAMS) { + sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_NO_TEAM_PUSH.get()); + return true; + } + + sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_SUCCESS.get()); + return true; } else if (args[0].equalsIgnoreCase("permtest")) { if (!sender.hasPermission("libsdisguises.permtest")) { sender.sendMessage(LibsMsg.NO_PERM.get()); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java index c85a3f58..618d32cc 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java @@ -113,7 +113,8 @@ public enum LibsMsg { PLEASE_WAIT(ChatColor.GRAY + "Please wait..."), INVALID_CLONE(ChatColor.DARK_RED + "Unknown option '%s' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' " + "'DoSneak' 'DoSprint'"), - LIBS_COMMAND_WRONG_ARG(ChatColor.RED + "[LibsDisguises] Did you mean 'reload', 'permtest', 'json' or 'metainfo'?"), + LIBS_COMMAND_WRONG_ARG( + ChatColor.RED + "[LibsDisguises] Did you mean 'reload', 'scoreboard', 'permtest', 'json' or 'metainfo'?"), LIMITED_RADIUS(ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"), LISTEN_ENTITY_ENTITY_DISG_ENTITY(ChatColor.RED + "Disguised %s as a %s!"), LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL(ChatColor.RED + "Failed to disguise %s as a %s!"), @@ -250,7 +251,15 @@ public enum LibsMsg { SWITCH_WORLD_DISGUISE_REMOVED(ChatColor.RED + "Disguise removed as you've switched worlds!"), ACTION_BAR_MESSAGE(ChatColor.GOLD + "Currently disguised as %s"), ITEM_SERIALIZED(ChatColor.GOLD + "Serialized, click to copy: "), - ITEM_SIMPLE_STRING(ChatColor.GOLD + "Simple, click to copy: "); + ITEM_SIMPLE_STRING(ChatColor.GOLD + "Simple, click to copy: "), + LIBS_SCOREBOARD_NO_TEAM(ChatColor.RED + "Not on a scoreboard team!"), + LIBS_SCOREBOARD_NO_TEAM_PUSH(ChatColor.RED + "Scoreboard team has pushing enabled!"), + LIBS_SCOREBOARD_SUCCESS(ChatColor.GOLD + + "On a team and pushing is disabled! If you're still having issues and you are disguised right now, then " + + "you have a plugin modifying scoreboard through packets"), + LIBS_SCOREBOARD_DISABLED( + "The scoreboard modification has been disabled in config, will continue the debug incase this is intended" + + "."); private String string; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c812160c..846675c6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -89,7 +89,6 @@ commands: permissions: libsdisguises.reload: description: Allows the user to reload LibsDisguises. - default: op libsdisguises.seethrough: description: Allows player to see through disguises. default: false @@ -99,18 +98,18 @@ permissions: libsdisguises.pve: description: Allows player to ignore pve restrictions. default: false - libsdisguises.permtest: - description: Allows player to test permissions - default: false - libsdisguises.metainfo: - description: Allows player to get meta info - default: false - libsdisguises.json: - description: Allows player to parse held item to json - default: true libsdisguises.pvp: description: Allows player to ignore pvp restrictions. default: false + libsdisguises.permtest: + description: Allows player to test permissions + libsdisguises.metainfo: + description: Allows player to get meta info + libsdisguises.json: + description: Allows player to parse held item to json + default: true + libsdisguises.scoreboardtest: + description: Test if the scoreboard is valid, this is a simple test. libsdisguises.seecmd: description: See all commands in tab-completion default: true