mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Merge branch 'master' into performance/cobblestone
This commit is contained in:
commit
9605ed4d1f
@ -33,6 +33,7 @@
|
||||
#### Changes
|
||||
* Improved Auto-Updater (Multi-Threading and more)
|
||||
* General performance improvements
|
||||
* /sf cheat now shows seasonal categories all year through
|
||||
* Performance Improvements and Optimizations for Cobblestone/Stone/Basalt generators and mining androids
|
||||
* Androids operating on a Cobblestone/Stone/Basalt generator now work faster
|
||||
|
||||
@ -49,6 +50,10 @@
|
||||
* Fixed some cargo incompatibilities with overflowing inventories
|
||||
* Fixed #2353
|
||||
* Fixed #2359
|
||||
* Fixed #2356
|
||||
* Fixed #2358
|
||||
* Fixed #2360
|
||||
* Fixed #2351
|
||||
|
||||
## Release Candidate 16 (07 Sep 2020)
|
||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16
|
||||
|
@ -51,6 +51,8 @@ public class CustomTextureService {
|
||||
config.setDefaultValue("SLIMEFUN_GUIDE", 0);
|
||||
|
||||
config.setDefaultValue("_UI_BACKGROUND", 0);
|
||||
config.setDefaultValue("_UI_INPUT_SLOT", 0);
|
||||
config.setDefaultValue("_UI_OUTPUT_SLOT", 0);
|
||||
config.setDefaultValue("_UI_BACK", 0);
|
||||
config.setDefaultValue("_UI_MENU", 0);
|
||||
config.setDefaultValue("_UI_SEARCH", 0);
|
||||
|
@ -1,14 +1,23 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.guide;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
@ -33,6 +42,29 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link List} of visible {@link Category} instances that the {@link SlimefunGuide} would display.
|
||||
*
|
||||
* @param p
|
||||
* The {@link Player} who opened his {@link SlimefunGuide}
|
||||
* @param profile
|
||||
* The {@link PlayerProfile} of the {@link Player}
|
||||
* @return a {@link List} of visible {@link Category} instances
|
||||
*/
|
||||
@Nonnull
|
||||
@Override
|
||||
protected List<Category> getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) {
|
||||
List<Category> categories = new LinkedList<>();
|
||||
|
||||
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
||||
if (!(category instanceof FlexCategory)) {
|
||||
categories.add(category);
|
||||
}
|
||||
}
|
||||
|
||||
return categories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SlimefunGuideLayout getLayout() {
|
||||
return SlimefunGuideLayout.CHEAT_SHEET;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.guide;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
@ -96,7 +98,17 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<Category> getVisibleCategories(Player p, PlayerProfile profile) {
|
||||
/**
|
||||
* Returns a {@link List} of visible {@link Category} instances that the {@link SlimefunGuide} would display.
|
||||
*
|
||||
* @param p
|
||||
* The {@link Player} who opened his {@link SlimefunGuide}
|
||||
* @param profile
|
||||
* The {@link PlayerProfile} of the {@link Player}
|
||||
* @return a {@link List} of visible {@link Category} instances
|
||||
*/
|
||||
@Nonnull
|
||||
protected List<Category> getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) {
|
||||
List<Category> categories = new LinkedList<>();
|
||||
|
||||
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
||||
|
@ -1,9 +1,11 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||
|
||||
/**
|
||||
* This enum covers all different fuel sources a {@link ProgrammableAndroid} can have.
|
||||
@ -30,7 +32,7 @@ public enum AndroidFuelSource {
|
||||
|
||||
private final String[] lore;
|
||||
|
||||
AndroidFuelSource(String... lore) {
|
||||
AndroidFuelSource(@Nonnull String... lore) {
|
||||
this.lore = lore;
|
||||
}
|
||||
|
||||
@ -39,8 +41,9 @@ public enum AndroidFuelSource {
|
||||
*
|
||||
* @return An {@link ItemStack} to display
|
||||
*/
|
||||
@Nonnull
|
||||
public ItemStack getItem() {
|
||||
return new CustomItem(SlimefunItems.COAL_GENERATOR, "&8\u21E9 &cFuel Input &8\u21E9", lore);
|
||||
return new CustomItem(HeadTexture.GENERATOR.getAsItemStack(), "&8\u21E9 &cFuel Input &8\u21E9", lore);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
@ -314,7 +315,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String duplicateInstruction(String[] script, int index) {
|
||||
private String duplicateInstruction(@Nonnull String[] script, int index) {
|
||||
int i = 0;
|
||||
StringBuilder builder = new StringBuilder(Instruction.START + "-");
|
||||
|
||||
@ -440,13 +441,9 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
||||
menu.open(p);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
private void uploadScript(Player p, Block b, int page) {
|
||||
String code = getScript(b.getLocation());
|
||||
|
||||
if (code == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int nextId = 1;
|
||||
|
||||
for (Script script : Script.getUploadedScripts(getAndroidType())) {
|
||||
@ -545,12 +542,13 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
||||
menu.open(p);
|
||||
}
|
||||
|
||||
protected String getScript(Location l) {
|
||||
@Nonnull
|
||||
protected String getScript(@Nonnull Location l) {
|
||||
String script = BlockStorage.getLocationInfo(l, "script");
|
||||
return script != null ? script : DEFAULT_SCRIPT;
|
||||
}
|
||||
|
||||
protected void setScript(Location l, String script) {
|
||||
protected void setScript(@Nonnull Location l, @Nonnull String script) {
|
||||
BlockStorage.addBlockInfo(l, "script", script);
|
||||
}
|
||||
|
||||
@ -787,10 +785,11 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
||||
return false;
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
private void consumeFuel(Block b, BlockMenu menu) {
|
||||
ItemStack item = menu.getItemInSlot(43);
|
||||
|
||||
if (item != null) {
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
for (MachineFuel fuel : fuelTypes) {
|
||||
if (fuel.test(item)) {
|
||||
menu.consumeItem(43);
|
||||
@ -807,12 +806,12 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
||||
}
|
||||
}
|
||||
|
||||
private void constructMenu(BlockMenuPreset preset) {
|
||||
private void constructMenu(@Nonnull BlockMenuPreset preset) {
|
||||
for (int i : BORDER) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
|
||||
preset.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
for (int i : OUTPUT_BORDER) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
|
||||
preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
for (int i : getOutputSlots()) {
|
||||
|
@ -15,6 +15,7 @@ import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
@ -47,6 +48,7 @@ public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> implements Recip
|
||||
|
||||
drops.addAll(getGoldPanDrops());
|
||||
addItemSetting(drops.toArray(new GoldPanDrop[0]));
|
||||
addItemHandler(onEntityInteract());
|
||||
}
|
||||
|
||||
protected Material getInput() {
|
||||
@ -115,6 +117,16 @@ public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> implements Recip
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This method cancels {@link EntityInteractHandler} to prevent interacting {@link GoldPan}
|
||||
* with entities.
|
||||
*
|
||||
* @return the {@link EntityInteractHandler} of this {@link SlimefunItem}
|
||||
*/
|
||||
public EntityInteractHandler onEntityInteract() {
|
||||
return (e, item, offHand) -> e.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDisplayRecipes() {
|
||||
List<ItemStack> recipes = new LinkedList<>();
|
||||
|
@ -32,6 +32,7 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
* @author VoidAngel
|
||||
* @author Poslovitch
|
||||
* @author TheBusyBiscuit
|
||||
* @author AccelShark
|
||||
*
|
||||
*/
|
||||
public class BlockPhysicsListener implements Listener {
|
||||
@ -54,21 +55,29 @@ public class BlockPhysicsListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPistonExtend(BlockPistonExtendEvent e) {
|
||||
for (Block b : e.getBlocks()) {
|
||||
if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
if (BlockStorage.hasBlockInfo(e.getBlock())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
else {
|
||||
for (Block b : e.getBlocks()) {
|
||||
if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) {
|
||||
e.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetract(BlockPistonRetractEvent e) {
|
||||
if (e.isSticky()) {
|
||||
if (BlockStorage.hasBlockInfo(e.getBlock())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
else if (e.isSticky()) {
|
||||
for (Block b : e.getBlocks()) {
|
||||
if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Bat;
|
||||
@ -24,6 +25,8 @@ import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.entity.PlayerLeashEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
@ -136,6 +139,23 @@ public class GrapplingHookListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// Fixing Issue #2351
|
||||
@EventHandler
|
||||
public void onLeash(PlayerLeashEntityEvent e) {
|
||||
if (!isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player p = e.getPlayer();
|
||||
|
||||
ItemStack item = p.getInventory().getItemInMainHand();
|
||||
SlimefunItem slimeItem = SlimefunItem.getByItem(item);
|
||||
|
||||
if (slimeItem instanceof GrapplingHook) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleGrapplingHook(@Nullable Arrow arrow) {
|
||||
if (arrow != null && arrow.isValid() && arrow.getShooter() instanceof Player) {
|
||||
Player p = (Player) arrow.getShooter();
|
||||
|
@ -1120,7 +1120,7 @@ public final class SlimefunItemSetup {
|
||||
new ItemStack[] {SlimefunItems.COBALT_INGOT, SlimefunItems.COBALT_INGOT, SlimefunItems.COBALT_INGOT, null, SlimefunItems.NICKEL_INGOT, null, null, SlimefunItems.NICKEL_INGOT, null})
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.magicalResources, SlimefunItems.NECROTIC_SKULL, RecipeType.MAGIC_WORKBENCH,
|
||||
new UnplaceableBlock(categories.magicalResources, SlimefunItems.NECROTIC_SKULL, RecipeType.MAGIC_WORKBENCH,
|
||||
new ItemStack[] {SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, null, new ItemStack(Material.WITHER_SKELETON_SKULL), null, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3})
|
||||
.register(plugin);
|
||||
|
||||
|
@ -26,6 +26,9 @@ public final class ChestMenuUtils {
|
||||
private ChestMenuUtils() {}
|
||||
|
||||
private static final ItemStack UI_BACKGROUND = new SlimefunItemStack("_UI_BACKGROUND", Material.GRAY_STAINED_GLASS_PANE, " ");
|
||||
private static final ItemStack INPUT_SLOT = new SlimefunItemStack("_UI_INPUT_SLOT", Material.CYAN_STAINED_GLASS_PANE, " ");
|
||||
private static final ItemStack OUTPUT_SLOT = new SlimefunItemStack("_UI_OUTPUT_SLOT", Material.ORANGE_STAINED_GLASS_PANE, " ");
|
||||
|
||||
private static final ItemStack BACK_BUTTON = new SlimefunItemStack("_UI_BACK", Material.ENCHANTED_BOOK, "&7\u21E6 Back", meta -> meta.addItemFlags(ItemFlag.HIDE_ENCHANTS));
|
||||
private static final ItemStack MENU_BUTTON = new SlimefunItemStack("_UI_MENU", Material.COMPARATOR, "&eSettings / Info", "", "&7\u21E8 Click to see more");
|
||||
private static final ItemStack SEARCH_BUTTON = new SlimefunItemStack("_UI_SEARCH", Material.NAME_TAG, "&bSearch");
|
||||
@ -43,6 +46,16 @@ public final class ChestMenuUtils {
|
||||
return UI_BACKGROUND;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ItemStack getInputSlotTexture() {
|
||||
return INPUT_SLOT;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ItemStack getOutputSlotTexture() {
|
||||
return OUTPUT_SLOT;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static MenuClickHandler getEmptyClickHandler() {
|
||||
return CLICK_HANDLER;
|
||||
|
@ -77,11 +77,11 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
|
||||
}
|
||||
|
||||
for (int i : BORDER_IN) {
|
||||
preset.addItem(i, new CustomItem(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler());
|
||||
preset.addItem(i, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
for (int i : BORDER_OUT) {
|
||||
preset.addItem(i, new CustomItem(Material.ORANGE_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler());
|
||||
preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
preset.addItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler());
|
||||
|
@ -88,11 +88,11 @@ public abstract class AGenerator extends AbstractEnergyProvider {
|
||||
}
|
||||
|
||||
for (int i : border_in) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
|
||||
preset.addItem(i, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
for (int i : border_out) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
|
||||
preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
for (int i : getOutputSlots()) {
|
||||
|
Loading…
Reference in New Issue
Block a user