mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixes #1686
This commit is contained in:
parent
ccca9300c2
commit
4bcccd3872
@ -57,6 +57,7 @@
|
|||||||
#### Fixes
|
#### Fixes
|
||||||
* Fixed some languages showing numbers larger than 100%
|
* Fixed some languages showing numbers larger than 100%
|
||||||
* Fixed #1570
|
* Fixed #1570
|
||||||
|
* Fixed #1686
|
||||||
|
|
||||||
## Release Candidate 9 (07 Mar 2020)
|
## Release Candidate 9 (07 Mar 2020)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.generat
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
@ -10,6 +11,7 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
|||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
@ -76,4 +78,12 @@ public abstract class SolarGenerator extends SimpleSlimefunItem<GeneratorTicker>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preRegister() {
|
||||||
|
super.preRegister();
|
||||||
|
|
||||||
|
// This prevents Players from toggling the Daylight sensor
|
||||||
|
addItemHandler((BlockUseHandler) PlayerRightClickEvent::cancel);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,29 +48,32 @@ public class Compressor extends MultiBlockMachine {
|
|||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
Dispenser disp = (Dispenser) dispBlock.getState();
|
||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
for (ItemStack current : inv.getContents()) {
|
for (ItemStack item : inv.getContents()) {
|
||||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
for (ItemStack recipeInput : RecipeType.getRecipeInputs(this)) {
|
||||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
if (recipeInput != null && SlimefunManager.isItemSimilar(item, recipeInput, true)) {
|
||||||
ItemStack output = RecipeType.getRecipeOutput(this, convert);
|
ItemStack output = RecipeType.getRecipeOutput(this, recipeInput);
|
||||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
|
|
||||||
if (outputInv != null) {
|
if (outputInv != null) {
|
||||||
craft(p, current, output, inv, outputInv);
|
ItemStack removing = item.clone();
|
||||||
|
removing.setAmount(recipeInput.getAmount());
|
||||||
|
inv.removeItem(removing);
|
||||||
|
|
||||||
|
craft(p, output, inv, outputInv);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
||||||
}
|
}
|
||||||
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocal().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void craft(Player p, ItemStack input, ItemStack output, Inventory inv, Inventory outputInv) {
|
private void craft(Player p, ItemStack output, Inventory inv, Inventory outputInv) {
|
||||||
ItemStack removing = input.clone();
|
|
||||||
removing.setAmount(input.getAmount());
|
|
||||||
inv.removeItem(removing);
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int j = i;
|
int j = i;
|
||||||
|
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
package me.mrCookieSlime.Slimefun;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This enum holds all versions of Minecraft that we currently support.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see SlimefunPlugin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum MinecraftVersion {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant represents Minecraft (Java Edition) Version 1.14
|
||||||
|
* (The "Village & Pillage" Update)
|
||||||
|
*/
|
||||||
|
MINECRAFT_1_14("1.14.x"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant represents Minecraft (Java Edition) Version 1.15
|
||||||
|
* (The "Buzzy Bees" Update)
|
||||||
|
*/
|
||||||
|
MINECRAFT_1_15("1.15.x"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant represents an exceptional state in which we were unable
|
||||||
|
* to identify the Minecraft Version we are using
|
||||||
|
*/
|
||||||
|
UNKNOWN("Unknown");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final String prefix;
|
||||||
|
|
||||||
|
private MinecraftVersion(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.prefix = name().replace("MINECRAFT_", "v") + '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the name of this {@link MinecraftVersion} in a readable format.
|
||||||
|
*
|
||||||
|
* @return The name of this {@link MinecraftVersion}
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method checks whether the given version matches with this
|
||||||
|
* {@link MinecraftVersion}.
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
* The version to compare
|
||||||
|
*
|
||||||
|
* @return Whether the version matches with this one
|
||||||
|
*/
|
||||||
|
public boolean matches(String version) {
|
||||||
|
return version.startsWith(prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Collection<String> getSupportedVersions() {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (MinecraftVersion version : values()) {
|
||||||
|
if (version != UNKNOWN) {
|
||||||
|
list.add(version.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,24 +0,0 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @deprecated Moved to {@code io.github.thebusybiscuit.slimefun4.implementation.items.Alloy}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class Alloy extends io.github.thebusybiscuit.slimefun4.implementation.items.Alloy {
|
|
||||||
|
|
||||||
public Alloy(SlimefunItemStack item, ItemStack[] recipe) {
|
|
||||||
super(item, recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alloy(Category category, SlimefunItemStack item, ItemStack[] recipe) {
|
|
||||||
super(category, item, recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +1,18 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
|
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||||
@ -33,7 +21,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
|||||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -43,13 +30,11 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
|||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||||
|
|
||||||
public abstract class AGenerator extends SlimefunItem implements RecipeDisplayItem, InventoryBlock, EnergyNetComponent {
|
public abstract class AGenerator extends AbstractEnergyGenerator {
|
||||||
|
|
||||||
public static Map<Location, MachineFuel> processing = new HashMap<>();
|
public static Map<Location, MachineFuel> processing = new HashMap<>();
|
||||||
public static Map<Location, Integer> progress = new HashMap<>();
|
public static Map<Location, Integer> progress = new HashMap<>();
|
||||||
|
|
||||||
private final Set<MachineFuel> recipes = new HashSet<>();
|
|
||||||
|
|
||||||
private static final int[] border = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44 };
|
private static final int[] border = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44 };
|
||||||
private static final int[] border_in = { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 };
|
private static final int[] border_in = { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 };
|
||||||
private static final int[] border_out = { 14, 15, 16, 17, 23, 26, 32, 33, 34, 35 };
|
private static final int[] border_out = { 14, 15, 16, 17, 23, 26, 32, 33, 34, 35 };
|
||||||
@ -101,11 +86,6 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
|||||||
this.registerDefaultFuelTypes();
|
this.registerDefaultFuelTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
|
||||||
this(category, item, recipeType, recipe);
|
|
||||||
this.recipeOutput = recipeOutput;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void constructMenu(BlockMenuPreset preset) {
|
private void constructMenu(BlockMenuPreset preset) {
|
||||||
for (int i : border) {
|
for (int i : border) {
|
||||||
preset.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
preset.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
||||||
@ -137,38 +117,6 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
|||||||
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
|
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns the title that is used for the {@link Inventory} of an
|
|
||||||
* {@link AGenerator} that has been opened by a Player.
|
|
||||||
*
|
|
||||||
* Override this method to set the title.
|
|
||||||
*
|
|
||||||
* @return The title of the {@link Inventory} of this {@link AGenerator}
|
|
||||||
*/
|
|
||||||
public abstract String getInventoryTitle();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns the {@link ItemStack} that this {@link AGenerator} will
|
|
||||||
* use as a progress bar.
|
|
||||||
*
|
|
||||||
* Override this method to set the progress bar.
|
|
||||||
*
|
|
||||||
* @return The {@link ItemStack} to use as the progress bar
|
|
||||||
*/
|
|
||||||
public abstract ItemStack getProgressBar();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns the amount of energy that is produced per tick.
|
|
||||||
*
|
|
||||||
* @return The rate of energy generation
|
|
||||||
*/
|
|
||||||
public abstract int getEnergyProduction();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to register the default fuel types.
|
|
||||||
*/
|
|
||||||
protected abstract void registerDefaultFuelTypes();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getInputSlots() {
|
public int[] getInputSlots() {
|
||||||
return new int[] { 19, 20 };
|
return new int[] { 19, 20 };
|
||||||
@ -179,11 +127,6 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
|||||||
return new int[] { 24, 25 };
|
return new int[] { 24, 25 };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnergyNetComponentType getEnergyComponentType() {
|
|
||||||
return EnergyNetComponentType.GENERATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MachineFuel getProcessing(Location l) {
|
public MachineFuel getProcessing(Location l) {
|
||||||
return processing.get(l);
|
return processing.get(l);
|
||||||
}
|
}
|
||||||
@ -192,13 +135,9 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
|||||||
return progress.containsKey(l);
|
return progress.containsKey(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerFuel(MachineFuel fuel) {
|
|
||||||
this.recipes.add(fuel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preRegister() {
|
protected GeneratorTicker onTick() {
|
||||||
addItemHandler(new GeneratorTicker() {
|
return new GeneratorTicker() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double generateEnergy(Location l, SlimefunItem sf, Config data) {
|
public double generateEnergy(Location l, SlimefunItem sf, Config data) {
|
||||||
@ -257,11 +196,11 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
|||||||
public boolean explode(Location l) {
|
public boolean explode(Location l) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private MachineFuel findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
private MachineFuel findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
||||||
for (MachineFuel recipe : recipes) {
|
for (MachineFuel recipe : fuelTypes) {
|
||||||
for (int slot : getInputSlots()) {
|
for (int slot : getInputSlots()) {
|
||||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
||||||
found.put(slot, recipe.getInput().getAmount());
|
found.put(slot, recipe.getInput().getAmount());
|
||||||
@ -273,32 +212,4 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<MachineFuel> getFuelTypes() {
|
|
||||||
return this.recipes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLabelLocalPath() {
|
|
||||||
return "guide.tooltips.recipes.generator";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ItemStack> getDisplayRecipes() {
|
|
||||||
List<ItemStack> list = new ArrayList<>();
|
|
||||||
|
|
||||||
for (MachineFuel fuel : recipes) {
|
|
||||||
ItemStack item = fuel.getInput().clone();
|
|
||||||
ItemMeta im = item.getItemMeta();
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
lore.add(ChatColors.color("&8\u21E8 &7Lasts " + NumberUtils.getTimeLeft(fuel.getTicks() / 2)));
|
|
||||||
lore.add(ChatColors.color("&8\u21E8 &e\u26A1 &7" + getEnergyProduction() * 2) + " J/s");
|
|
||||||
lore.add(ChatColors.color("&8\u21E8 &e\u26A1 &7" + DoubleHandler.getFancyDouble((double) fuel.getTicks() * getEnergyProduction()) + " J in total"));
|
|
||||||
im.setLore(lore);
|
|
||||||
item.setItemMeta(im);
|
|
||||||
list.add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
|
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor;
|
||||||
@ -37,7 +28,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
|||||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -59,15 +49,13 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
|||||||
* @see NetherStarReactor
|
* @see NetherStarReactor
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem, InventoryBlock, EnergyNetComponent {
|
public abstract class AReactor extends AbstractEnergyGenerator {
|
||||||
|
|
||||||
public static Map<Location, MachineFuel> processing = new HashMap<>();
|
public static Map<Location, MachineFuel> processing = new HashMap<>();
|
||||||
public static Map<Location, Integer> progress = new HashMap<>();
|
public static Map<Location, Integer> progress = new HashMap<>();
|
||||||
|
|
||||||
private static final BlockFace[] cooling = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST };
|
private static final BlockFace[] cooling = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST };
|
||||||
|
|
||||||
private final Set<MachineFuel> recipes = new HashSet<>();
|
|
||||||
|
|
||||||
private static final int[] border = { 0, 1, 2, 3, 5, 6, 7, 8, 12, 13, 14, 21, 23 };
|
private static final int[] border = { 0, 1, 2, 3, 5, 6, 7, 8, 12, 13, 14, 21, 23 };
|
||||||
private static final int[] border_1 = { 9, 10, 11, 18, 20, 27, 29, 36, 38, 45, 46, 47 };
|
private static final int[] border_1 = { 9, 10, 11, 18, 20, 27, 29, 36, 38, 45, 46, 47 };
|
||||||
private static final int[] border_2 = { 15, 16, 17, 24, 26, 33, 35, 42, 44, 51, 52, 53 };
|
private static final int[] border_2 = { 15, 16, 17, 24, 26, 33, 35, 42, 44, 51, 52, 53 };
|
||||||
@ -209,38 +197,6 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns the title that is used for the {@link Inventory} of an
|
|
||||||
* {@link AGenerator} that has been opened by a Player.
|
|
||||||
*
|
|
||||||
* Override this method to set the title.
|
|
||||||
*
|
|
||||||
* @return The title of the {@link Inventory} of this {@link AGenerator}
|
|
||||||
*/
|
|
||||||
public abstract String getInventoryTitle();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns the {@link ItemStack} that this {@link AGenerator} will
|
|
||||||
* use as a progress bar.
|
|
||||||
*
|
|
||||||
* Override this method to set the progress bar.
|
|
||||||
*
|
|
||||||
* @return The {@link ItemStack} to use as the progress bar
|
|
||||||
*/
|
|
||||||
public abstract ItemStack getProgressBar();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns the amount of energy that is produced per tick.
|
|
||||||
*
|
|
||||||
* @return The rate of energy generation
|
|
||||||
*/
|
|
||||||
public abstract int getEnergyProduction();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to register the default fuel types.
|
|
||||||
*/
|
|
||||||
protected abstract void registerDefaultFuelTypes();
|
|
||||||
|
|
||||||
public abstract void extraTick(Location l);
|
public abstract void extraTick(Location l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -273,11 +229,6 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
|||||||
return new int[] { 40 };
|
return new int[] { 40 };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnergyNetComponentType getEnergyComponentType() {
|
|
||||||
return EnergyNetComponentType.GENERATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MachineFuel getProcessing(Location l) {
|
public MachineFuel getProcessing(Location l) {
|
||||||
return processing.get(l);
|
return processing.get(l);
|
||||||
}
|
}
|
||||||
@ -286,13 +237,9 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
|||||||
return progress.containsKey(l);
|
return progress.containsKey(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerFuel(MachineFuel fuel) {
|
|
||||||
this.recipes.add(fuel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preRegister() {
|
protected GeneratorTicker onTick() {
|
||||||
addItemHandler(new GeneratorTicker() {
|
return new GeneratorTicker() {
|
||||||
|
|
||||||
private final Set<Location> explode = new HashSet<>();
|
private final Set<Location> explode = new HashSet<>();
|
||||||
|
|
||||||
@ -417,7 +364,7 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
|||||||
}
|
}
|
||||||
return explosion;
|
return explosion;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getPercentage(int time, int total) {
|
private float getPercentage(int time, int total) {
|
||||||
@ -427,7 +374,7 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
|||||||
|
|
||||||
private void restockFuel(BlockMenu menu, BlockMenu port) {
|
private void restockFuel(BlockMenu menu, BlockMenu port) {
|
||||||
for (int slot : getFuelSlots()) {
|
for (int slot : getFuelSlots()) {
|
||||||
for (MachineFuel recipe : recipes) {
|
for (MachineFuel recipe : fuelTypes) {
|
||||||
if (SlimefunManager.isItemSimilar(port.getItemInSlot(slot), recipe.getInput(), true) && menu.fits(new CustomItem(port.getItemInSlot(slot), 1), getFuelSlots())) {
|
if (SlimefunManager.isItemSimilar(port.getItemInSlot(slot), recipe.getInput(), true) && menu.fits(new CustomItem(port.getItemInSlot(slot), 1), getFuelSlots())) {
|
||||||
port.replaceExistingItem(slot, menu.pushItem(port.getItemInSlot(slot), getFuelSlots()));
|
port.replaceExistingItem(slot, menu.pushItem(port.getItemInSlot(slot), getFuelSlots()));
|
||||||
return;
|
return;
|
||||||
@ -437,7 +384,7 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MachineFuel findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
private MachineFuel findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
||||||
for (MachineFuel recipe : recipes) {
|
for (MachineFuel recipe : fuelTypes) {
|
||||||
for (int slot : getInputSlots()) {
|
for (int slot : getInputSlots()) {
|
||||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
||||||
found.put(slot, recipe.getInput().getAmount());
|
found.put(slot, recipe.getInput().getAmount());
|
||||||
@ -449,10 +396,6 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<MachineFuel> getFuelTypes() {
|
|
||||||
return this.recipes;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BlockMenu getAccessPort(Location l) {
|
protected BlockMenu getAccessPort(Location l) {
|
||||||
Location portL = new Location(l.getWorld(), l.getX(), l.getY() + 3, l.getZ());
|
Location portL = new Location(l.getWorld(), l.getX(), l.getY() + 3, l.getZ());
|
||||||
|
|
||||||
@ -464,40 +407,4 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLabelLocalPath() {
|
|
||||||
return "guide.tooltips.recipes.generator";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ItemStack> getDisplayRecipes() {
|
|
||||||
List<ItemStack> list = new ArrayList<>();
|
|
||||||
|
|
||||||
for (MachineFuel fuel : recipes) {
|
|
||||||
ItemStack item = fuel.getInput().clone();
|
|
||||||
ItemMeta im = item.getItemMeta();
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
lore.add(ChatColor.translateAlternateColorCodes('&', "&8\u21E8 &7Lasts " + getTimeLeft(fuel.getTicks() / 2)));
|
|
||||||
lore.add(ChatColor.translateAlternateColorCodes('&', "&8\u21E8 &e\u26A1 &7" + getEnergyProduction() * 2) + " J/s");
|
|
||||||
lore.add(ChatColor.translateAlternateColorCodes('&', "&8\u21E8 &e\u26A1 &7" + DoubleHandler.getFancyDouble((double) fuel.getTicks() * getEnergyProduction()) + " J in total"));
|
|
||||||
im.setLore(lore);
|
|
||||||
item.setItemMeta(im);
|
|
||||||
list.add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getTimeLeft(int seconds) {
|
|
||||||
String timeleft = "";
|
|
||||||
int minutes = (int) (seconds / 60L);
|
|
||||||
|
|
||||||
if (minutes > 0) {
|
|
||||||
timeleft += minutes + "m ";
|
|
||||||
}
|
|
||||||
|
|
||||||
seconds -= minutes * 60;
|
|
||||||
return "&7" + timeleft + seconds + "s";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,111 @@
|
|||||||
|
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
|
abstract class AbstractEnergyGenerator extends SlimefunItem implements InventoryBlock, RecipeDisplayItem, EnergyNetComponent {
|
||||||
|
|
||||||
|
protected final Set<MachineFuel> fuelTypes = new HashSet<>();
|
||||||
|
|
||||||
|
protected AbstractEnergyGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
|
super(category, item, recipeType, recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the title that is used for the {@link Inventory} of an
|
||||||
|
* {@link AGenerator} that has been opened by a Player.
|
||||||
|
*
|
||||||
|
* Override this method to set the title.
|
||||||
|
*
|
||||||
|
* @return The title of the {@link Inventory} of this {@link AGenerator}
|
||||||
|
*/
|
||||||
|
public abstract String getInventoryTitle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the {@link ItemStack} that this {@link AGenerator} will
|
||||||
|
* use as a progress bar.
|
||||||
|
*
|
||||||
|
* Override this method to set the progress bar.
|
||||||
|
*
|
||||||
|
* @return The {@link ItemStack} to use as the progress bar
|
||||||
|
*/
|
||||||
|
public abstract ItemStack getProgressBar();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the amount of energy that is produced per tick.
|
||||||
|
*
|
||||||
|
* @return The rate of energy generation
|
||||||
|
*/
|
||||||
|
public abstract int getEnergyProduction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to register the default fuel types.
|
||||||
|
*/
|
||||||
|
protected abstract void registerDefaultFuelTypes();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnergyNetComponentType getEnergyComponentType() {
|
||||||
|
return EnergyNetComponentType.GENERATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract GeneratorTicker onTick();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preRegister() {
|
||||||
|
super.preRegister();
|
||||||
|
|
||||||
|
addItemHandler(onTick());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerFuel(MachineFuel fuel) {
|
||||||
|
fuelTypes.add(fuel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<MachineFuel> getFuelTypes() {
|
||||||
|
return this.fuelTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabelLocalPath() {
|
||||||
|
return "guide.tooltips.recipes.generator";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
|
List<ItemStack> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (MachineFuel fuel : fuelTypes) {
|
||||||
|
ItemStack item = fuel.getInput().clone();
|
||||||
|
ItemMeta im = item.getItemMeta();
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
lore.add(ChatColor.translateAlternateColorCodes('&', "&8\u21E8 &7Lasts " + NumberUtils.getTimeLeft(fuel.getTicks() / 2)));
|
||||||
|
lore.add(ChatColor.translateAlternateColorCodes('&', "&8\u21E8 &e\u26A1 &7" + getEnergyProduction() * 2) + " J/s");
|
||||||
|
lore.add(ChatColor.translateAlternateColorCodes('&', "&8\u21E8 &e\u26A1 &7" + DoubleHandler.getFancyDouble((double) fuel.getTicks() * getEnergyProduction()) + " J in total"));
|
||||||
|
im.setLore(lore);
|
||||||
|
item.setItemMeta(im);
|
||||||
|
list.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -93,6 +93,8 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
private RecipeSnapshot recipeSnapshot;
|
private RecipeSnapshot recipeSnapshot;
|
||||||
private SlimefunRegistry registry;
|
private SlimefunRegistry registry;
|
||||||
|
|
||||||
|
private MinecraftVersion minecraftVersion = MinecraftVersion.UNKNOWN;
|
||||||
|
|
||||||
// Services - Systems that fulfill certain tasks, treat them as a black box
|
// Services - Systems that fulfill certain tasks, treat them as a black box
|
||||||
private final CustomItemDataService itemDataService = new CustomItemDataService(this, "slimefun_item");
|
private final CustomItemDataService itemDataService = new CustomItemDataService(this, "slimefun_item");
|
||||||
private final CustomTextureService textureService = new CustomTextureService(this);
|
private final CustomTextureService textureService = new CustomTextureService(this);
|
||||||
@ -119,11 +121,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
private ConfigCache settings;
|
private ConfigCache settings;
|
||||||
private SlimefunCommand command;
|
private SlimefunCommand command;
|
||||||
|
|
||||||
// Supported Versions of Minecraft, to ensure people
|
|
||||||
// do not use it on the wrong version.
|
|
||||||
// May not be the best design choice since we have to update that from time to time.
|
|
||||||
private final String[] supportedMinecraftVersions = { "v1_14_", "v1_15_" };
|
|
||||||
|
|
||||||
// Listeners that need to be accessed elsewhere
|
// Listeners that need to be accessed elsewhere
|
||||||
private AncientAltarListener ancientAltarListener;
|
private AncientAltarListener ancientAltarListener;
|
||||||
private BackpackListener backpackListener;
|
private BackpackListener backpackListener;
|
||||||
@ -134,6 +131,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
|
if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
|
||||||
|
|
||||||
|
// We wanna ensure that the Server uses a compatible version of Minecraft
|
||||||
if (isVersionUnsupported()) {
|
if (isVersionUnsupported()) {
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
@ -360,37 +358,21 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
String currentVersion = ReflectionUtils.getVersion();
|
String currentVersion = ReflectionUtils.getVersion();
|
||||||
|
|
||||||
if (currentVersion.startsWith("v")) {
|
if (currentVersion.startsWith("v")) {
|
||||||
boolean compatibleVersion = false;
|
for (MinecraftVersion version : MinecraftVersion.values()) {
|
||||||
StringBuilder versions = new StringBuilder();
|
if (version.matches(currentVersion)) {
|
||||||
|
minecraftVersion = version;
|
||||||
int i = 0;
|
return false;
|
||||||
for (String version : supportedMinecraftVersions) {
|
|
||||||
if (currentVersion.startsWith(version)) {
|
|
||||||
compatibleVersion = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String s = version.substring(1).replaceFirst("_", ".").replace("_", ".X");
|
|
||||||
if (i == 0) versions.append(s);
|
|
||||||
else if (i == supportedMinecraftVersions.length - 1) versions.append(" or ").append(s);
|
|
||||||
else versions.append(", ").append(s);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Looks like you are using an unsupported Minecraft Version
|
// Looks like you are using an unsupported Minecraft Version
|
||||||
if (!compatibleVersion) {
|
getLogger().log(Level.SEVERE, "### Slimefun was not installed correctly!");
|
||||||
getLogger().log(Level.SEVERE, "### Slimefun was not installed correctly!");
|
getLogger().log(Level.SEVERE, "### You are using the wrong version of Minecraft!");
|
||||||
getLogger().log(Level.SEVERE, "###");
|
getLogger().log(Level.SEVERE, "###");
|
||||||
getLogger().log(Level.SEVERE, "### You are using the wrong Version of Minecraft!");
|
getLogger().log(Level.SEVERE, "### You are using Minecraft " + ReflectionUtils.getVersion());
|
||||||
getLogger().log(Level.SEVERE, "###");
|
getLogger().log(Level.SEVERE, "### but Slimefun v" + getDescription().getVersion() + " requires you to be using");
|
||||||
getLogger().log(Level.SEVERE, "### You are using Minecraft " + ReflectionUtils.getVersion());
|
getLogger().log(Level.SEVERE, "### Minecraft {0}", String.join(" / ", MinecraftVersion.getSupportedVersions()));
|
||||||
getLogger().log(Level.SEVERE, "### but Slimefun v" + getDescription().getVersion() + " requires you to be using");
|
return true;
|
||||||
getLogger().log(Level.SEVERE, "### Minecraft {0}", versions);
|
|
||||||
getLogger().log(Level.SEVERE, "###");
|
|
||||||
getLogger().log(Level.SEVERE, "### Please use an older Version of Slimefun and disable auto-updating");
|
|
||||||
getLogger().log(Level.SEVERE, "### or consider updating your Server Software.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -605,6 +587,10 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
return instance.command;
|
return instance.command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MinecraftVersion getMinecraftVersion() {
|
||||||
|
return instance.minecraftVersion;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaPlugin getJavaPlugin() {
|
public JavaPlugin getJavaPlugin() {
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
Reference in New Issue
Block a user