Better /libsdisguises

This commit is contained in:
libraryaddict 2020-04-20 22:00:31 +12:00
parent d4381096ee
commit f1653c0bb0
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
11 changed files with 83 additions and 17 deletions

View File

@ -104,6 +104,8 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
sender.sendMessage(ChatColor.DARK_GREEN + "This server is running " + "Lib's Disguises v" + version + sender.sendMessage(ChatColor.DARK_GREEN + "This server is running " + "Lib's Disguises v" + version +
" by libraryaddict, formerly maintained by Byteflux and NavidK0."); " by libraryaddict, formerly maintained by Byteflux and NavidK0.");
// TODO You can use the following arguments, hover over them for more information
if (sender.hasPermission("libsdisguises.reload")) { if (sender.hasPermission("libsdisguises.reload")) {
sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" + sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" +
ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" + ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" +

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.commands.libsdisguises; package me.libraryaddict.disguise.commands.libsdisguises;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.util.List; import java.util.List;
@ -13,4 +14,6 @@ public interface LDCommand {
String getPermission(); String getPermission();
void onCommand(CommandSender sender, String[] args); void onCommand(CommandSender sender, String[] args);
LibsMsg getHelp();
} }

View File

@ -37,4 +37,9 @@ public class LDConfig implements LDCommand {
sender.sendMessage(ChatColor.AQUA + "[LibsDisguises] " + s); sender.sendMessage(ChatColor.AQUA + "[LibsDisguises] " + s);
} }
} }
@Override
public LibsMsg getHelp() {
return null;
}
} }

View File

@ -35,23 +35,6 @@ public class LDCount implements LDCommand {
for (Set<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) { for (Set<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
for (Disguise disguise : disguises) { for (Disguise disguise : disguises) {
if (disguise.isPlayerDisguise() && DisguiseConfig.isScoreboardDisguiseNames()) {
if (((PlayerDisguise) disguise).hasScoreboardName()) {
for (Player player : Bukkit.getOnlinePlayers()) {
Scoreboard board = player.getScoreboard();
if (board.getEntryTeam(((PlayerDisguise) disguise).getProfileName()) == null) {
DisguiseUtilities.getLogger().warning(
"The player disguise " + ((PlayerDisguise) disguise).getName() +
" is missing a scoreboard team on " + player.getName() +
" and possibly more players!");
break;
}
}
}
}
counts.compute(disguise.getType(), (a, b) -> (b != null ? b : 0) + 1); counts.compute(disguise.getType(), (a, b) -> (b != null ? b : 0) + 1);
} }
} }
@ -79,4 +62,9 @@ public class LDCount implements LDCommand {
sender.sendMessage(LibsMsg.ACTIVE_DISGUISES.get(builder.toString())); sender.sendMessage(LibsMsg.ACTIVE_DISGUISES.get(builder.toString()));
} }
} }
@Override
public LibsMsg getHelp() {
return null;
}
} }

View File

@ -122,4 +122,9 @@ public class LDJson implements LDCommand {
sender.spigot().sendMessage(builder.create()); sender.spigot().sendMessage(builder.create());
} }
@Override
public LibsMsg getHelp() {
return null;
}
} }

View File

@ -73,4 +73,9 @@ public class LDMetaInfo implements LDCommand {
} }
} }
} }
@Override
public LibsMsg getHelp() {
return null;
}
} }

View File

@ -56,4 +56,9 @@ public class LDMods implements LDCommand {
sender.sendMessage(LibsMsg.MODS_LIST.get(player.getName(), sender.sendMessage(LibsMsg.MODS_LIST.get(player.getName(),
StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", "))); StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", ")));
} }
@Override
public LibsMsg getHelp() {
return null;
}
} }

View File

@ -56,4 +56,9 @@ public class LDPermTest implements LDCommand {
sender.sendMessage(LibsMsg.NORMAL_PERM_CHECK_FAIL.get()); sender.sendMessage(LibsMsg.NORMAL_PERM_CHECK_FAIL.get());
} }
} }
@Override
public LibsMsg getHelp() {
return null;
}
} }

View File

@ -26,4 +26,9 @@ public class LDReload implements LDCommand {
DisguiseConfig.loadConfig(); DisguiseConfig.loadConfig();
sender.sendMessage(LibsMsg.RELOADED_CONFIG.get()); sender.sendMessage(LibsMsg.RELOADED_CONFIG.get());
} }
@Override
public LibsMsg getHelp() {
return null;
}
} }

View File

@ -2,6 +2,11 @@ package me.libraryaddict.disguise.commands.libsdisguises;
import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.translations.LibsMsg; import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -10,7 +15,9 @@ import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* Created by libraryaddict on 20/04/2020. * Created by libraryaddict on 20/04/2020.
@ -28,6 +35,32 @@ public class LDScoreboard implements LDCommand {
@Override @Override
public void onCommand(CommandSender sender, String[] args) { public void onCommand(CommandSender sender, String[] args) {
if (DisguiseConfig.isScoreboardDisguiseNames()) {
for (Set<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
for (Disguise disguise : disguises) {
if (!disguise.isPlayerDisguise()) {
continue;
}
if (!((PlayerDisguise) disguise).hasScoreboardName()) {
continue;
}
for (Player player : Bukkit.getOnlinePlayers()) {
Scoreboard board = player.getScoreboard();
if (board.getTeam(((PlayerDisguise) disguise).getScoreboardName().getTeamName()) != null) {
continue;
}
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName() +
" is missing a scoreboard team on " + player.getName() + " and possibly more players!");
break;
}
}
}
}
if (DisguiseConfig.getPushingOption() == DisguiseConfig.DisguisePushing.IGNORE_SCOREBOARD) { if (DisguiseConfig.getPushingOption() == DisguiseConfig.DisguisePushing.IGNORE_SCOREBOARD) {
sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_DISABLED.get()); sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_DISABLED.get());
@ -76,4 +109,9 @@ public class LDScoreboard implements LDCommand {
sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_SUCCESS.get(team.getName())); sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_SUCCESS.get(team.getName()));
} }
@Override
public LibsMsg getHelp() {
return null;
}
} }

View File

@ -72,4 +72,9 @@ public class LDUpdate implements LDCommand {
} }
}.runTaskAsynchronously(LibsDisguises.getInstance()); }.runTaskAsynchronously(LibsDisguises.getInstance());
} }
@Override
public LibsMsg getHelp() {
return null;
}
} }