mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Cleaned up some old stuff and added new bStats charts
This commit is contained in:
parent
0a3f910892
commit
0228b76f0b
@ -37,8 +37,10 @@
|
||||
## Release Candidate 8 (TBD)
|
||||
|
||||
### Additions
|
||||
* Added some new charts to bStats
|
||||
|
||||
### Changes
|
||||
* Removed some deprecated parts of the API
|
||||
|
||||
### Fixes
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -26,6 +28,7 @@ public class SlimefunCommand implements CommandExecutor, Listener {
|
||||
|
||||
private final SlimefunPlugin plugin;
|
||||
private final List<SubCommand> commands = new LinkedList<>();
|
||||
private final Map<SubCommand, Integer> commandUsage = new HashMap<>();
|
||||
|
||||
public SlimefunCommand(SlimefunPlugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
@ -41,6 +44,10 @@ public class SlimefunCommand implements CommandExecutor, Listener {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public Map<SubCommand, Integer> getCommandUsage() {
|
||||
return commandUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (args.length > 0) {
|
||||
@ -78,6 +85,7 @@ public class SlimefunCommand implements CommandExecutor, Listener {
|
||||
else {
|
||||
for (SubCommand command : commands) {
|
||||
if (args[0].equalsIgnoreCase(command.getName())) {
|
||||
commandUsage.merge(command, 1, Integer::sum);
|
||||
command.onExecute(sender, args);
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.services.metrics;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bstats.bukkit.Metrics.AdvancedPie;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
class AddonsChart extends AdvancedPie {
|
||||
|
||||
public AddonsChart() {
|
||||
super("installed_addons", () -> {
|
||||
Map<String, Integer> addons = new HashMap<>();
|
||||
|
||||
for (Plugin plugin : SlimefunPlugin.getInstalledAddons()) {
|
||||
if (plugin.isEnabled()) {
|
||||
addons.put(plugin.getName(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
return addons;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.services.metrics;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bstats.bukkit.Metrics.AdvancedPie;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
class CommandChart extends AdvancedPie {
|
||||
|
||||
public CommandChart() {
|
||||
super("commands_ran", () -> {
|
||||
Map<String, Integer> commands = new HashMap<>();
|
||||
|
||||
for (Map.Entry<SubCommand, Integer> entry : SlimefunPlugin.getCommand().getCommandUsage().entrySet()) {
|
||||
commands.put("/sf " + entry.getKey().getName(), entry.getValue());
|
||||
}
|
||||
|
||||
return commands;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.services.metrics;
|
||||
|
||||
import org.bstats.bukkit.Metrics.SimplePie;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
class GuideLayoutChart extends SimplePie {
|
||||
|
||||
public GuideLayoutChart() {
|
||||
super("guide_layout", () -> {
|
||||
boolean book = SlimefunPlugin.getCfg().getBoolean("guide.default-view-book");
|
||||
|
||||
return book ? "Book" : "Chest GUI";
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -34,6 +34,10 @@ public class MetricsService {
|
||||
metrics.addCustomChart(new BranchChart());
|
||||
metrics.addCustomChart(new ServerLanguageChart());
|
||||
metrics.addCustomChart(new PlayerLanguageChart());
|
||||
metrics.addCustomChart(new ResearchesEnabledChart());
|
||||
metrics.addCustomChart(new GuideLayoutChart());
|
||||
metrics.addCustomChart(new AddonsChart());
|
||||
metrics.addCustomChart(new CommandChart());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.services.metrics;
|
||||
|
||||
import org.bstats.bukkit.Metrics.SimplePie;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
class ResearchesEnabledChart extends SimplePie {
|
||||
|
||||
public ResearchesEnabledChart() {
|
||||
super("servers_with_researches_enabled", () -> {
|
||||
boolean enabled = SlimefunPlugin.getSettings().researchesEnabled;
|
||||
return enabled ? "enabled" : "disabled";
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -22,7 +22,6 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
public class AdvancedCargoOutputNode extends SlimefunItem {
|
||||
|
@ -20,7 +20,6 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
public class CargoOutputNode extends SlimefunItem {
|
||||
|
@ -2,7 +2,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.food;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.Cooler;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
|
@ -973,10 +973,10 @@ public final class SlimefunItemSetup {
|
||||
new ItemStack[] {null, new ItemStack(Material.WITHER_SKELETON_SKULL), null, null, new ItemStack(Material.WITHER_SKELETON_SKULL), null, null, new ItemStack(Material.BLAZE_ROD), null})
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunMachine(Categories.MACHINES_1, SlimefunItems.DIGITAL_MINER, "DIGITAL_MINER",
|
||||
SlimefunMachine miner = new SlimefunMachine(Categories.MACHINES_1, SlimefunItems.DIGITAL_MINER, "DIGITAL_MINER",
|
||||
new ItemStack[] {SlimefunItems.SOLAR_PANEL, new ItemStack(Material.CHEST), SlimefunItems.SOLAR_PANEL, new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.DISPENSER), new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.HOPPER), new ItemStack(Material.IRON_BLOCK)},
|
||||
new ItemStack[0], BlockFace.SELF)
|
||||
.register(true, new MultiBlockInteractionHandler() {
|
||||
new ItemStack[0], BlockFace.SELF);
|
||||
miner.addItemHandler(new MultiBlockInteractionHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onInteract(Player p, MultiBlock mb, Block b) {
|
||||
@ -1031,11 +1031,12 @@ public final class SlimefunItemSetup {
|
||||
else return false;
|
||||
}
|
||||
});
|
||||
miner.register(plugin);
|
||||
|
||||
new SlimefunMachine(Categories.MACHINES_1, SlimefunItems.ADVANCED_DIGITAL_MINER, "ADVANCED_DIGITAL_MINER",
|
||||
SlimefunMachine advancedMiner = new SlimefunMachine(Categories.MACHINES_1, SlimefunItems.ADVANCED_DIGITAL_MINER, "ADVANCED_DIGITAL_MINER",
|
||||
new ItemStack[] {SlimefunItems.SOLAR_PANEL, new ItemStack(Material.CHEST), SlimefunItems.SOLAR_PANEL, SlimefunItems.GOLD_24K_BLOCK, new ItemStack(Material.DISPENSER), SlimefunItems.GOLD_24K_BLOCK, SlimefunItems.GOLD_24K_BLOCK, new ItemStack(Material.HOPPER), SlimefunItems.GOLD_24K_BLOCK},
|
||||
new ItemStack[0], BlockFace.SELF)
|
||||
.register(true, new MultiBlockInteractionHandler() {
|
||||
new ItemStack[0], BlockFace.SELF);
|
||||
advancedMiner.addItemHandler(new MultiBlockInteractionHandler() {
|
||||
// Determines the drops an Advanced Digital Miner will get
|
||||
private final ItemStack effectivePickaxe = new ItemStack(Material.DIAMOND_PICKAXE);
|
||||
|
||||
@ -1106,6 +1107,7 @@ public final class SlimefunItemSetup {
|
||||
else return false;
|
||||
}
|
||||
});
|
||||
advancedMiner.register(plugin);
|
||||
|
||||
new SlimefunItem(Categories.MISC, (SlimefunItemStack) SlimefunItems.GOLD_24K_BLOCK, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.GOLD_24K, SlimefunItems.GOLD_24K, SlimefunItems.GOLD_24K, SlimefunItems.GOLD_24K, SlimefunItems.GOLD_24K, SlimefunItems.GOLD_24K, SlimefunItems.GOLD_24K, SlimefunItems.GOLD_24K, SlimefunItems.GOLD_24K})
|
||||
|
@ -39,19 +39,6 @@ public class Category implements Keyed {
|
||||
protected final List<SlimefunItem> items;
|
||||
protected final int tier;
|
||||
|
||||
/**
|
||||
* Constructs a Category with the given display item.
|
||||
* The tier is set to a default value of {@code 3}.
|
||||
*
|
||||
* @param item
|
||||
* the display item for this category
|
||||
* @deprecated Use the alternative with a {@link NamespacedKey} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public Category(ItemStack item) {
|
||||
this(item, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link Category} with the given {@link NamespacedKey} as an identifier
|
||||
* and the given {@link ItemStack} as its display item.
|
||||
@ -66,22 +53,6 @@ public class Category implements Keyed {
|
||||
this(key, item, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Category with the given display item and the provided tier.
|
||||
* </br>
|
||||
* A lower tier results in this category being displayed first.
|
||||
*
|
||||
* @param item
|
||||
* the display item for this category
|
||||
* @param tier
|
||||
* the tier for this category
|
||||
* @deprecated Use the alternative with a {@link NamespacedKey} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public Category(ItemStack item, int tier) {
|
||||
this(new NamespacedKey(SlimefunPlugin.instance, "invalid_category"), item, tier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link Category} with the given {@link NamespacedKey} as an identifier
|
||||
* and the given {@link ItemStack} as its display item.
|
||||
|
@ -1,21 +0,0 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated Moved to {@code io.github.thebusybiscuit.slimefun4.implementation.items.tools.SlimefunBackpack}
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class SlimefunBackpack extends io.github.thebusybiscuit.slimefun4.implementation.items.tools.SlimefunBackpack {
|
||||
|
||||
public SlimefunBackpack(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(size, category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
}
|
@ -497,62 +497,6 @@ public class SlimefunItem implements Placeable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is deprecated.
|
||||
*
|
||||
* @deprecated Use {@link SlimefunItem#register(SlimefunAddon)} instead.
|
||||
* @param vanilla
|
||||
* deprecated.
|
||||
* @param handlers
|
||||
* deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public void register(boolean vanilla, ItemHandler... handlers) {
|
||||
addItemHandler(handlers);
|
||||
register(vanilla);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is deprecated.
|
||||
*
|
||||
* @deprecated Use {@link SlimefunItem#register(SlimefunAddon)} instead.
|
||||
* @param handlers
|
||||
* deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public void register(ItemHandler... handlers) {
|
||||
addItemHandler(handlers);
|
||||
register(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is deprecated.
|
||||
*
|
||||
* @deprecated Use {@link SlimefunItem#register(SlimefunAddon)} instead.
|
||||
* @param vanilla
|
||||
* deprecated.
|
||||
* @param handler
|
||||
* deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public void register(boolean vanilla, SlimefunBlockHandler handler) {
|
||||
SlimefunPlugin.getRegistry().getBlockHandlers().put(getID(), handler);
|
||||
register(vanilla);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is deprecated.
|
||||
*
|
||||
* @deprecated Use {@link SlimefunItem#register(SlimefunAddon)} instead.
|
||||
* @param handler
|
||||
* deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public void register(SlimefunBlockHandler handler) {
|
||||
SlimefunPlugin.getRegistry().getBlockHandlers().put(getID(), handler);
|
||||
register(false);
|
||||
}
|
||||
|
||||
public static Set<ItemHandler> getHandlers(Class<? extends ItemHandler> identifier) {
|
||||
return SlimefunPlugin.getRegistry().getItemHandlers().computeIfAbsent(identifier, c -> new HashSet<>());
|
||||
}
|
||||
@ -569,66 +513,11 @@ public class SlimefunItem implements Placeable {
|
||||
*/
|
||||
@Deprecated
|
||||
public void registerChargeableBlock(int capacity) {
|
||||
registerChargeableBlock(false, capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please implement the {@link EnergyNetComponent} interface instead.
|
||||
* @param slimefun
|
||||
* Whether this is from Slimefun or from an Addon.
|
||||
* @param capacity
|
||||
* The capacity of this Block
|
||||
*/
|
||||
@Deprecated
|
||||
public void registerEnergyGenerator(boolean slimefun, int capacity) {
|
||||
register(slimefun);
|
||||
SlimefunPlugin.getRegistry().getEnergyCapacities().put(id, capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please implement the {@link EnergyNetComponent} interface instead.
|
||||
* @param slimefun
|
||||
* Whether this is from Slimefun or from an Addon.
|
||||
* @param capacity
|
||||
* The capacity of this Block
|
||||
*/
|
||||
@Deprecated
|
||||
public void registerChargeableBlock(boolean slimefun, int capacity) {
|
||||
register(slimefun);
|
||||
register();
|
||||
SlimefunPlugin.getRegistry().getEnergyCapacities().put(id, capacity);
|
||||
EnergyNet.registerComponent(id, EnergyNetComponentType.CONSUMER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please implement the {@link EnergyNetComponent} interface instead.
|
||||
* @param slimefun
|
||||
* Whether this is from Slimefun or from an Addon.
|
||||
* @param capacity
|
||||
* The capacity of this Block
|
||||
*/
|
||||
@Deprecated
|
||||
public void registerCapacitor(boolean slimefun, int capacity) {
|
||||
register(slimefun);
|
||||
SlimefunPlugin.getRegistry().getEnergyCapacities().put(id, capacity);
|
||||
SlimefunPlugin.getRegistry().getEnergyCapacitors().add(id);
|
||||
EnergyNet.registerComponent(id, EnergyNetComponentType.CAPACITOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please implement the {@link EnergyNetComponent} interface instead.
|
||||
* @param slimefun
|
||||
* Whether this is from Slimefun or from an Addon.
|
||||
* @param capacity
|
||||
* The capacity of this Block
|
||||
* @param handlers
|
||||
* Your Item Handlers
|
||||
*/
|
||||
@Deprecated
|
||||
public void registerChargeableBlock(boolean vanilla, int capacity, ItemHandler... handlers) {
|
||||
addItemHandler(handlers);
|
||||
registerChargeableBlock(vanilla, capacity);
|
||||
}
|
||||
|
||||
public void preRegister() {
|
||||
// Override this method to execute code before the Item has been registered
|
||||
// Useful for calls to addItemHandler(...)
|
||||
|
@ -72,31 +72,6 @@ public final class SlimefunManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated Use the version with {@link SlimefunAddon} instead.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public static void registerArmorSet(ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean slimefun, boolean vanilla) {
|
||||
String[] components = new String[] { "_HELMET", "_CHESTPLATE", "_LEGGINGS", "_BOOTS" };
|
||||
Category cat = Categories.ARMOR;
|
||||
List<ItemStack[]> recipes = new ArrayList<>();
|
||||
recipes.add(new ItemStack[] { baseComponent, baseComponent, baseComponent, baseComponent, null, baseComponent, null, null, null });
|
||||
recipes.add(new ItemStack[] { baseComponent, null, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent });
|
||||
recipes.add(new ItemStack[] { baseComponent, baseComponent, baseComponent, baseComponent, null, baseComponent, baseComponent, null, baseComponent });
|
||||
recipes.add(new ItemStack[] { null, null, null, baseComponent, null, baseComponent, baseComponent, null, baseComponent });
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (vanilla) {
|
||||
new VanillaItem(cat, items[i], idSyntax + components[i], RecipeType.ARMOR_FORGE, recipes.get(i)).register(slimefun);
|
||||
}
|
||||
else {
|
||||
new SlimefunItem(cat, new SlimefunItemStack(idSyntax + components[i], items[i]), RecipeType.ARMOR_FORGE, recipes.get(i)).register(slimefun);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isItemSimilar(ItemStack item, ItemStack sfitem, boolean checkLore) {
|
||||
if (item == null) return sfitem == null;
|
||||
if (sfitem == null) return false;
|
||||
|
@ -115,6 +115,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
private ProtectionManager protections;
|
||||
private ConfigCache settings;
|
||||
private SlimefunHooks hooks;
|
||||
private SlimefunCommand command;
|
||||
|
||||
// Supported Versions of Minecraft, to ensure people dont use it on the wrong version.
|
||||
private final String[] supportedMinecraftVersions = { "v1_14_", "v1_15_" };
|
||||
@ -278,7 +279,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
}, 0);
|
||||
|
||||
// Setting up the command /sf and all subcommands
|
||||
new SlimefunCommand(this);
|
||||
command = new SlimefunCommand(this);
|
||||
|
||||
// Armor Update Task
|
||||
if (config.getBoolean("options.enable-armor-effects")) {
|
||||
@ -541,6 +542,10 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
return Arrays.stream(instance.getServer().getPluginManager().getPlugins()).filter(plugin -> plugin.getDescription().getDepend().contains(instance.getName()) || plugin.getDescription().getSoftDepend().contains(instance.getName())).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public static SlimefunCommand getCommand() {
|
||||
return instance.command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaPlugin getJavaPlugin() {
|
||||
return this;
|
||||
|
Loading…
Reference in New Issue
Block a user