use of xyz.derkades.serverselectorx.placeholders.PlaceholdersEnabled in project ServerSelectorX by ServerSelectorX.
the class Main method onEnable.
@Override
public void onEnable() {
plugin = this;
configurationManager = new ConfigurationManager();
configurationManager.reloadAll();
// Register listeners
Bukkit.getPluginManager().registerEvents(new SelectorOpenListener(), this);
Bukkit.getPluginManager().registerEvents(new OnJoinListener(), this);
Bukkit.getPluginManager().registerEvents(new ItemMoveDropCancelListener(), this);
List<String> offHandVersions = Arrays.asList("1.9", "1.10", "1.11", "1.12");
for (String version : offHandVersions) {
if (Bukkit.getBukkitVersion().contains(version)) {
Bukkit.getPluginManager().registerEvents(new OffHandMoveCancel(), this);
}
}
// Register messaging channels
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Bukkit.getScheduler().runTaskAsynchronously(this, () -> PingServersBackground.startPinging());
// Register command
getCommand("serverselectorx").setExecutor(new ReloadCommand());
// Start bStats
Stats.initialize();
// Check if config is up to date
int version = getConfig().getInt("version");
if (version != CONFIG_VERSION) {
Logger logger = super.getLogger();
logger.log(Level.SEVERE, "************** IMPORTANT **************");
logger.log(Level.SEVERE, "You updated the plugin without deleting the config.");
logger.log(Level.SEVERE, "Please rename config.yml to something else and restart your server.");
logger.log(Level.SEVERE, "If you don't want to redo your config, see resource updates on spigotmc.org for instructions.");
logger.log(Level.SEVERE, "***************************************");
getServer().getPluginManager().disablePlugin(this);
return;
}
// Register custom selector commands
registerCommands();
// Check if PlaceHolderAPI is installed
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
Main.PLACEHOLDER_API = new PlaceholdersEnabled();
getLogger().log(Level.INFO, "PlaceholderAPI is found. Placeholders will work!");
} else {
Main.PLACEHOLDER_API = new PlaceholdersDisabled();
getLogger().log(Level.INFO, "PlaceholderAPI is not installed. The plugin will still work.");
}
// Check for updates asynchronously
getServer().getScheduler().runTaskAsynchronously(this, () -> {
checkForUpdates();
});
}
use of xyz.derkades.serverselectorx.placeholders.PlaceholdersEnabled in project ServerSelectorX by ServerSelectorX.
the class Stats method initialize.
public static void initialize() {
final Metrics metrics = new Metrics(Main.getPlugin());
metrics.addCustomChart(new Metrics.SimplePie("placeholderapi", () -> {
if (Main.PLACEHOLDER_API instanceof PlaceholdersEnabled) {
return "yes";
} else {
return "no";
}
}));
metrics.addCustomChart(new Metrics.SimplePie("number_of_selectors", () -> {
return Main.getConfigurationManager().getAll().size() + "";
}));
metrics.addCustomChart(new Metrics.AdvancedPie("selector_item", () -> {
final Map<String, Integer> map = new HashMap<>();
for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
final Material material = Material.getMaterial(config.getString("item"));
// Do not count invalid items
if (material == null)
continue;
if (map.containsKey(material.toString())) {
map.put(material.toString(), map.get(material.toString() + 1));
} else {
map.put(material.toString(), 1);
}
}
return map;
}));
metrics.addCustomChart(new Metrics.AdvancedPie("type", () -> {
final Map<String, Integer> map = new HashMap<>();
for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
for (final String slot : config.getConfigurationSection("menu").getKeys(false)) {
String action = config.getString("menu." + slot + ".action").split(":")[0].toLowerCase();
if (map.containsKey(action)) {
map.put(action, map.get(action) + 1);
} else {
map.put(action, 1);
}
}
}
return map;
}));
metrics.addCustomChart(new Metrics.SimplePie("ping_api", () -> {
if (Main.getPlugin().getConfig().getBoolean("external-query", true)) {
return "External";
} else {
return "Internal";
}
}));
metrics.addCustomChart(new Metrics.SimplePie("updater", () -> {
if (Main.getPlugin().getConfig().getBoolean("updater", true)) {
return "Enabled";
} else {
return "Disabled";
}
}));
metrics.addCustomChart(new Metrics.SimplePie("player_count_mode", () -> {
return Main.getPlugin().getConfig().getString("item-count-mode", "absolute").toLowerCase();
}));
metrics.addCustomChart(new Metrics.SimplePie("background_pinging", () -> {
if (Main.getPlugin().getConfig().getBoolean("background-pinging", true)) {
return "Enabled";
} else {
return "Disabled";
}
}));
metrics.addCustomChart(new Metrics.AdvancedPie("server_pinging", () -> {
final Map<String, Integer> map = new HashMap<>();
for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
for (final String slot : config.getConfigurationSection("menu").getKeys(false)) {
String action = config.getString("menu." + slot + ".action").split(":")[0].toLowerCase();
if (action.equalsIgnoreCase("srv")) {
if (config.getBoolean("menu." + slot + ".ping-server", false)) {
if (map.containsKey("Enabled")) {
map.put("Enabled", map.get("Enabled") + 1);
} else {
map.put("Enabled", 1);
}
} else {
if (map.containsKey("Disabled")) {
map.put("Disabled", map.get("Disabled") + 1);
} else {
map.put("Disabled", 1);
}
}
}
}
}
return map;
}));
metrics.addCustomChart(new Metrics.SimplePie("permissions", () -> {
if (Main.getPlugin().getConfig().getBoolean("permissions-enabled", false)) {
return "Enabled";
} else {
return "Disabled";
}
}));
metrics.addCustomChart(new Metrics.SimplePie("item_drop", () -> {
if (Main.getPlugin().getConfig().getBoolean("cancel-item-drop", false)) {
return "Cancel";
} else {
return "Allow";
}
}));
metrics.addCustomChart(new Metrics.SimplePie("item_move", () -> {
if (Main.getPlugin().getConfig().getBoolean("cancel-item-move", false)) {
return "Cancel";
} else {
return "Allow";
}
}));
metrics.addCustomChart(new Metrics.AdvancedPie("menu_item_slot", () -> {
final Map<String, Integer> map = new HashMap<>();
for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
int slot = config.getInt("inv-slot", 0);
if (slot < 0) {
if (map.containsKey("Auto")) {
map.put("Auto", map.get("Auto") + 1);
} else {
map.put("Auto", 1);
}
} else {
if (map.containsKey(slot + "")) {
map.put(slot + "", map.get(slot + "") + 1);
} else {
map.put(slot + "", 1);
}
}
}
return map;
}));
metrics.addCustomChart(new Metrics.AdvancedPie("rows", () -> {
final Map<String, Integer> map = new HashMap<>();
for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
int rows = config.getInt("rows", 6);
if (map.containsKey(rows + "")) {
map.put(rows + "", map.get(rows + "") + 1);
} else {
map.put(rows + "", 1);
}
}
return map;
}));
}
Aggregations