add debug commands and fix the navigator
This commit is contained in:
parent
0a994a78e9
commit
f21576945a
|
@ -67,6 +67,8 @@ import tc.oc.commons.bukkit.stats.StatsManifest;
|
|||
import tc.oc.commons.bukkit.suspend.SuspendListener;
|
||||
import tc.oc.commons.bukkit.tablist.PlayerTabEntry;
|
||||
import tc.oc.commons.bukkit.tablist.TabRender;
|
||||
import tc.oc.commons.bukkit.teleport.Navigator;
|
||||
import tc.oc.commons.bukkit.teleport.NavigatorInterface;
|
||||
import tc.oc.commons.bukkit.teleport.NavigatorManifest;
|
||||
import tc.oc.commons.bukkit.teleport.PlayerServerChanger;
|
||||
import tc.oc.commons.bukkit.teleport.TeleportCommands;
|
||||
|
@ -155,6 +157,8 @@ public final class CommonsBukkitManifest extends HybridManifest {
|
|||
facets.register(LocaleListener.class);
|
||||
facets.register(LoginListener.class);
|
||||
facets.register(MiscCommands.class);
|
||||
facets.register(Navigator.class);
|
||||
facets.register(NavigatorInterface.class);
|
||||
facets.register(NicknameCommands.class);
|
||||
facets.register(PermissionCommands.class);
|
||||
facets.register(PermissionCommands.Parent.class);
|
||||
|
|
|
@ -3,6 +3,7 @@ package tc.oc.commons.bukkit.teleport;
|
|||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -13,8 +14,13 @@ import javax.inject.Inject;
|
|||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.inject.Singleton;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.api.docs.Arena;
|
||||
import tc.oc.api.docs.Game;
|
||||
|
@ -27,12 +33,13 @@ import tc.oc.api.model.ModelListener;
|
|||
import tc.oc.api.servers.ServerStore;
|
||||
import tc.oc.commons.bukkit.format.GameFormatter;
|
||||
import tc.oc.commons.bukkit.ticket.TicketBooth;
|
||||
import tc.oc.commons.core.commands.Commands;
|
||||
import tc.oc.commons.core.plugin.PluginFacet;
|
||||
import tc.oc.commons.core.util.CacheUtils;
|
||||
import tc.oc.commons.core.util.Utils;
|
||||
|
||||
@Singleton
|
||||
public class Navigator implements PluginFacet, ModelListener {
|
||||
public class Navigator implements PluginFacet, ModelListener, Commands {
|
||||
|
||||
private static final char SERVER_SIGIL = '@';
|
||||
private static final char FAMILY_SIGIL = '.';
|
||||
|
@ -62,6 +69,31 @@ public class Navigator implements PluginFacet, ModelListener {
|
|||
modelDispatcher.subscribe(this);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "showcachedconnectors" },
|
||||
desc = "Print a list of cached connectors",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("ocn.developer")
|
||||
public void servers(final CommandContext args, final CommandSender sender) throws CommandException {
|
||||
sender.sendMessage("Cached Connectors:");
|
||||
final Map<String, SingleServerConnector> servers = serverConnectors.asMap();
|
||||
for (Map.Entry<String, SingleServerConnector> value : servers.entrySet()) {
|
||||
sender.sendMessage(value.getKey() + " : " + value.getValue().toString());
|
||||
}
|
||||
|
||||
final Map<String, FeaturedServerConnector> families = familyConnectors.asMap();
|
||||
for (Map.Entry<String, FeaturedServerConnector> value :families.entrySet()) {
|
||||
sender.sendMessage(value.getKey() + " : " + value.getValue().toString());
|
||||
}
|
||||
|
||||
final Map<String, GameConnector> games = gameConnectors.asMap();
|
||||
for (Map.Entry<String, GameConnector> value : games.entrySet()) {
|
||||
sender.sendMessage(value.getKey() + " : " + value.getValue().toString());
|
||||
}
|
||||
}
|
||||
|
||||
private String localDatacenter() {
|
||||
return featuredServerTracker.localDatacenter();
|
||||
}
|
||||
|
@ -212,7 +244,7 @@ public class Navigator implements PluginFacet, ModelListener {
|
|||
return server != null &&
|
||||
server.datacenter().equals(localDatacenter()) &&
|
||||
server.visibility() == ServerDoc.Visibility.PUBLIC &&
|
||||
server.running();
|
||||
server.online();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,11 +13,16 @@ import javax.inject.Singleton;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -51,6 +56,7 @@ import tc.oc.commons.bukkit.listeners.WindowManager;
|
|||
import tc.oc.commons.bukkit.ticket.TicketBooth;
|
||||
import tc.oc.commons.core.chat.Component;
|
||||
import tc.oc.commons.core.chat.Components;
|
||||
import tc.oc.commons.core.commands.Commands;
|
||||
import tc.oc.commons.core.inject.InnerFactory;
|
||||
import tc.oc.commons.core.plugin.PluginFacet;
|
||||
import tc.oc.minecraft.api.configuration.InvalidConfigurationException;
|
||||
|
@ -58,7 +64,7 @@ import tc.oc.minecraft.api.configuration.InvalidConfigurationException;
|
|||
import static tc.oc.commons.core.exception.LambdaExceptionUtils.rethrowFunction;
|
||||
|
||||
@Singleton
|
||||
public class NavigatorInterface implements PluginFacet, Listener {
|
||||
public class NavigatorInterface implements PluginFacet, Listener, Commands {
|
||||
|
||||
private final GameStore games;
|
||||
private final ServerFormatter serverFormatter = ServerFormatter.light;
|
||||
|
@ -103,6 +109,21 @@ public class NavigatorInterface implements PluginFacet, Listener {
|
|||
configFactory.create(this);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "shownavigatorbuttons" },
|
||||
desc = "Print a list of the buttons in the navigator",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("ocn.developer")
|
||||
public void servers(final CommandContext args, final CommandSender sender) throws CommandException {
|
||||
sender.sendMessage("Buttons:");
|
||||
for (Button button: buttons.values()) {
|
||||
sender.sendMessage(button.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setOpenButtonSlot(Slot.Player openButtonSlot) {
|
||||
this.openButtonSlot = openButtonSlot;
|
||||
}
|
||||
|
@ -248,6 +269,36 @@ public class NavigatorInterface implements PluginFacet, Listener {
|
|||
final Consumer<Navigator.Connector> observer = c ->
|
||||
openWindows.forEach(window -> updateWindow((Player) window.getPlayer(), window.getTopInventory()));
|
||||
|
||||
public String toString() {
|
||||
String string = "{";
|
||||
string += "slot: {" + slot.getColumn() + ", " + slot.getRow() + "}, ";
|
||||
string += "icon: " + icon.getType() + ", ";
|
||||
string += "connector: " + "{isConnectable: " + connector.isConnectable() + ", ";
|
||||
string += "isVisible: " + connector.isVisible() + ", ";
|
||||
if (connector instanceof Navigator.ServerConnector) {
|
||||
Server server = ((Navigator.ServerConnector)connector).server;
|
||||
string += "server: {";
|
||||
string += "bungee_name: " + server.bungee_name() + ", ";
|
||||
string += "box: " + server.box() + ", ";
|
||||
string += "datacenter: " + server.datacenter() + ", ";
|
||||
string += "family: " + server.family() + ", ";
|
||||
string += "description: " + server.description() + ", ";
|
||||
string += "ip: " + server.ip() + ", ";
|
||||
string += "name: " + server.name() + ", ";
|
||||
string += "max_players: " + server.max_players() + ", ";
|
||||
string += "num_online: " + server.num_online() + ", ";
|
||||
string += "_id: " + server._id() + ", ";
|
||||
string += "slug: " + server.slug() + ", ";
|
||||
string += "priority: " + server.priority() + ", ";
|
||||
string += "visibility: " + server.visibility() + ", ";
|
||||
string += "online: " + server.online() + ", ";
|
||||
string += "running: " + server.running();
|
||||
string += "}";
|
||||
}
|
||||
string += "}";
|
||||
return string;
|
||||
}
|
||||
|
||||
Button(ConfigurationSection config, ItemConfigurationParser itemParser) throws InvalidConfigurationException {
|
||||
this.slot = itemParser.needSlotByPosition(config, null, null, Slot.Container.class);
|
||||
this.icon = config.isString("skull") ? itemParser.needSkull(config, "skull")
|
||||
|
|
|
@ -62,7 +62,7 @@ public class Utils {
|
|||
public static ItemStack getGhastTear(Player player, int count) {
|
||||
ItemStack raindrops = new ItemStack(Material.GHAST_TEAR);
|
||||
ItemMeta meta = raindrops.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.AQUA + "Raindrops" + ChatColor.DARK_PURPLE + " | " + ChatColor.WHITE + String.format("%,d", count));
|
||||
meta.setDisplayName(ChatColor.AQUA + "Droplets" + ChatColor.DARK_PURPLE + " | " + ChatColor.WHITE + String.format("%,d", count));
|
||||
raindrops.setItemMeta(meta);
|
||||
|
||||
return raindrops;
|
||||
|
|
Loading…
Reference in New Issue