1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Fixes #1779 and some other changes

This commit is contained in:
TheBusyBiscuit 2020-04-03 11:41:58 +02:00
parent 2587f77c27
commit 44ab15811a
28 changed files with 156 additions and 58 deletions

View File

@ -50,11 +50,13 @@
#### Additions
* Added GEOResourceGenerationEvent
* Added SlimefunGuide-Options API
* Added 1.13 backwards compatibility
#### Changes
#### Fixes
* Fixed error message when clicking empty slots in the Slimefun Guide
* Fixed #1779
## Release Candidate 10 (28 Mar 2020)

Binary file not shown.

14
pom.xml
View File

@ -14,6 +14,10 @@
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Bukkit properties -->
<bukkit.version>1.15.2</bukkit.version>
<bukkit.javadocs>https://hub.spigotmc.org/javadocs/bukkit/</bukkit.javadocs>
<!-- Default settings for sonarcloud.io -->
<sonar.projectKey>TheBusyBiscuit_Slimefun4</sonar.projectKey>
<sonar.organization>thebusybiscuit-github</sonar.organization>
@ -135,7 +139,7 @@
<!-- We can reference Bukkit's API in our Javadocs -->
<links>
<link>https://hub.spigotmc.org/javadocs/bukkit/</link>
<link>${bukkit.javadocs}</link>
</links>
<!-- We can group pakages together in our Javadocs -->
@ -152,6 +156,10 @@
<title>Slimefun4 - Implementations</title>
<packages>io.github.thebusybiscuit.slimefun4.implementation*</packages>
</group>
<group>
<title>Slimefun4 - Common utility packages</title>
<packages>io.github.thebusybiscuit.slimefun4.utils*</packages>
</group>
<group>
<title>Slimefun4 - Item Implementations</title>
<packages>io.github.thebusybiscuit.slimefun4.implementation.items*</packages>
@ -194,7 +202,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<version>${bukkit.version}-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -208,7 +216,7 @@
<dependency>
<groupId>com.github.thebusybiscuit</groupId>
<artifactId>CS-CoreLib2</artifactId>
<version>bd12910bdb</version>
<version>0.12</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -1,16 +1,17 @@
package me.mrCookieSlime.Slimefun.Objects;
package io.github.thebusybiscuit.slimefun4.core.categories;
import java.time.LocalDate;
import java.time.Month;
import java.util.Calendar;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.LockedCategory;
/**
* Represents a {@link Category} that is only displayed in the Guide during
* a specified month.
* <p>
* See {@link Category} for the complete documentation.
* a specified {@link Month}.
*
* @author TheBusyBiscuit
*
@ -40,9 +41,9 @@ public class SeasonalCategory extends Category {
}
/**
* Gets the month during which the category should be displayed.
* This method returns the {@link Month} in which this {@link SeasonalCategory} will appear.
*
* @return the id of the month this {@link SeasonalCategory} is assigned to (from 1 = January ; to 12 = December)
* @return the {@link Month} in which this {@link SeasonalCategory} appears
*/
public Month getMonth() {
return month;
@ -54,8 +55,7 @@ public class SeasonalCategory extends Category {
*
* @return true if it should, otherwise false
*/
public boolean isUnlocked() {
Calendar calendar = Calendar.getInstance();
return month.ordinal() == calendar.get(Calendar.MONTH);
public boolean isVisible() {
return month == LocalDate.now().getMonth();
}
}

View File

@ -0,0 +1,6 @@
/**
* This package stores API classes that are centered around the extension of the
* {@link me.mrCookieSlime.Slimefun.Objects.Category} class, such as
* {@link me.mrCookieSlime.Slimefun.Objects.SeasonalCategory} for example.
*/
package io.github.thebusybiscuit.slimefun4.core.categories;

View File

@ -1,6 +1,5 @@
package io.github.thebusybiscuit.slimefun4.core.commands;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@ -16,7 +15,7 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
class SlimefunTabCompleter implements TabCompleter {
private static final int MAX_SUGGESTIONS = 50;
private static final int MAX_SUGGESTIONS = 80;
private final SlimefunCommand command;
@ -68,17 +67,17 @@ class SlimefunTabCompleter implements TabCompleter {
if (string.equals("")) return list;
String input = string.toLowerCase(Locale.ROOT);
List<String> returnList = new ArrayList<>();
List<String> returnList = new LinkedList<>();
for (String item : list) {
if (item.contains(input)) {
if (item.toLowerCase(Locale.ROOT).contains(input)) {
returnList.add(item);
if (returnList.size() >= MAX_SUGGESTIONS) {
break;
}
}
else if (item.equals(input)) {
else if (item.equalsIgnoreCase(input)) {
return Collections.emptyList();
}
}

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import java.util.Locale;
import java.util.Optional;
import org.bukkit.command.CommandSender;
@ -41,7 +42,7 @@ class GiveCommand extends SubCommand {
if (player.isPresent()) {
Player p = player.get();
SlimefunItem sfItem = SlimefunItem.getByID(args[2].toUpperCase());
SlimefunItem sfItem = SlimefunItem.getByID(args[2].toUpperCase(Locale.ROOT));
if (sfItem != null) {
int amount = parseAmount(args);

View File

@ -33,6 +33,7 @@ class StatsCommand extends SubCommand {
if (args.length > 1) {
if (sender.hasPermission("slimefun.stats.others") || sender instanceof ConsoleCommandSender) {
Optional<Player> player = PlayerList.findByName(args[1]);
if (player.isPresent()) {
PlayerProfile.get(player.get(), profile -> profile.sendStats(sender));
}

View File

@ -1,8 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services.localization;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

View File

@ -13,6 +13,7 @@ import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
@ -25,7 +26,6 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.LockedCategory;
import me.mrCookieSlime.Slimefun.Objects.Research;
import me.mrCookieSlime.Slimefun.Objects.SeasonalCategory;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.GuideHandler;
import me.mrCookieSlime.Slimefun.api.Slimefun;
@ -110,7 +110,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
actions.add(null);
}
else if (category instanceof SeasonalCategory) {
if (((SeasonalCategory) category).isUnlocked()) {
if (((SeasonalCategory) category).isVisible()) {
texts.add(ChatColors.color(ChatUtils.crop(ChatColor.GREEN, ItemUtils.getItemName(category.getItem(p)))));
tooltips.add(ChatColors.color("&eClick to open the following Category:\n" + ItemUtils.getItemName(category.getItem(p))));
actions.add(new PlayerRunnable(1) {

View File

@ -27,6 +27,7 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.MultiBlock;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
@ -41,7 +42,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.LockedCategory;
import me.mrCookieSlime.Slimefun.Objects.Research;
import me.mrCookieSlime.Slimefun.Objects.SeasonalCategory;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.MultiBlockMachine;
import me.mrCookieSlime.Slimefun.api.GuideHandler;
@ -135,7 +135,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
private boolean displayCategory(ChestMenu menu, Player p, PlayerProfile profile, boolean survival, Category category, int index) {
if (!(category instanceof LockedCategory)) {
if (!(category instanceof SeasonalCategory) || ((SeasonalCategory) category).isUnlocked()) {
if (!(category instanceof SeasonalCategory) || ((SeasonalCategory) category).isVisible()) {
menu.addItem(index, category.getItem(p));
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
openCategory(profile, category, survival, 1);

View File

@ -1,6 +1,5 @@
package io.github.thebusybiscuit.slimefun4.implementation.items;
import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;

View File

@ -9,6 +9,7 @@ import java.util.function.Predicate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
@ -147,8 +148,7 @@ abstract class Android extends SlimefunItem {
j++;
}
builder.append(ScriptAction.REPEAT);
BlockStorage.addBlockInfo(b, "script", builder.toString());
setScript(b.getLocation(), builder.toString());
openScript(pl, b, builder.toString());
}
else if (action.isRightClicked()) {
@ -161,7 +161,7 @@ abstract class Android extends SlimefunItem {
}
builder.append(ScriptAction.REPEAT);
BlockStorage.addBlockInfo(b, "script", builder.toString());
setScript(b.getLocation(), builder.toString());
openScript(pl, b, builder.toString());
}
@ -283,7 +283,7 @@ abstract class Android extends SlimefunItem {
script2.setValue("downloads", script2.getInt("downloads") + 1);
script2.save();
BlockStorage.addBlockInfo(b, "script", script2.getString("code"));
setScript(b.getLocation(), script2.getString("code"));
openScriptEditor(pl, b);
}
return false;
@ -297,7 +297,7 @@ abstract class Android extends SlimefunItem {
}
private void uploadScript(Player p, Block b, int page) {
String code = BlockStorage.getLocationInfo(b.getLocation(), "script");
String code = getScript(b.getLocation());
int num = 1;
for (Config script : getUploadedScripts()) {
@ -339,7 +339,7 @@ abstract class Android extends SlimefunItem {
menu.addItem(1, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDliZjZkYjRhZWRhOWQ4ODIyYjlmNzM2NTM4ZThjMThiOWE0ODQ0Zjg0ZWI0NTUwNGFkZmJmZWU4N2ViIn19fQ=="), "&2> Edit Script", "", "&aEdits your current Script"));
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
openScript(pl, b, BlockStorage.getLocationInfo(b.getLocation(), "script"));
openScript(pl, b, getScript(b.getLocation()));
return false;
});
@ -443,7 +443,7 @@ abstract class Android extends SlimefunItem {
}
builder.append("REPEAT");
BlockStorage.addBlockInfo(b, "script", builder.toString());
setScript(b.getLocation(), builder.toString());
openScript(p, b, builder.toString());
return false;
@ -474,8 +474,16 @@ abstract class Android extends SlimefunItem {
}
builder.append("REPEAT");
BlockStorage.addBlockInfo(b, "script", builder.toString());
setScript(b.getLocation(), builder.toString());
openScript(p, b, builder.toString());
}
protected String getScript(Location l) {
return BlockStorage.getLocationInfo(l, "script");
}
protected void setScript(Location l, String script) {
BlockStorage.addBlockInfo(l, "script", script);
}
}

View File

@ -13,7 +13,7 @@ public class AndroidInstance {
}
public ProgrammableAndroid getAndroid() {
return this.android;
return android;
}
public Block getBlock() {

View File

@ -43,7 +43,7 @@ public abstract class NetherStarReactor extends AReactor {
}
@Override
public void extraTick(final Location l) {
public void extraTick(Location l) {
Slimefun.runSync(() -> {
for (Entity entity : ReactorHologram.getArmorStand(l, true).getNearbyEntities(5, 5, 5)) {
if (entity instanceof LivingEntity) {
@ -58,6 +58,11 @@ public abstract class NetherStarReactor extends AReactor {
return SlimefunItems.NETHER_ICE_COOLANT_CELL;
}
@Override
public ItemStack getFuelIcon() {
return new ItemStack(Material.NETHER_STAR);
}
@Override
public ItemStack getProgressBar() {
return new ItemStack(Material.NETHER_STAR);

View File

@ -50,6 +50,11 @@ public abstract class NuclearReactor extends AReactor {
return SlimefunItems.REACTOR_COOLANT_CELL;
}
@Override
public ItemStack getFuelIcon() {
return SlimefunItems.URANIUM;
}
@Override
public void extraTick(Location l) {
// This machine does not need to perform anything while ticking

View File

@ -30,8 +30,14 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
/**
* This {@link Listener} is responsible for all events centered around a {@link SlimefunBackpack}.
* This also includes the {@link Cooler}
*
* @author TheBusyBiscuit
* @author Walshy
* @author NihilistBrew
* @author AtomicScience
* @author VoidAngel
* @author John000708
*
* @see SlimefunBackpack
* @see PlayerBackpack

View File

@ -14,6 +14,16 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockDispenseHandler;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
/**
* This {@link Listener} listens to the {@link BlockDispenseEvent} and calls the
* {@link BlockDispenseHandler} as a result of that.
*
* @author TheBusyBiscuit
* @author MisterErwin
*
* @see BlockDispenseHandler
*
*/
public class DispenserListener implements Listener {
public DispenserListener(SlimefunPlugin plugin) {

View File

@ -32,6 +32,7 @@ public class ExplosionsListener implements Listener {
if (id != null) {
blocks.remove();
// Hardened Glass and WitherProof blocks cannot be destroyed by explosions
if (!id.equalsIgnoreCase("HARDENED_GLASS") && !SlimefunPlugin.getRegistry().getWitherProofBlocks().containsKey(id)) {
boolean success = true;
SlimefunItem sfItem = SlimefunItem.getByID(id);
@ -49,7 +50,5 @@ public class ExplosionsListener implements Listener {
}
}
}
}
}

View File

@ -14,6 +14,7 @@ import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -26,12 +27,22 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.Slimefun;
/**
* This {@link Listener} is responsible for handling all boots provided by
* Slimefun, such as the Boots of the Stomper or any {@link SlimefunArmorPiece} that
* is a pair of boots and needs to listen to an {@link Event}.
*
* @author TheBusyBiscuit
* @author Walshy
*
*/
public class SlimefunBootsListener implements Listener {
private final Map<String, Predicate<EntityDamageEvent>> cancelledEvents = new HashMap<>();

View File

@ -31,15 +31,20 @@ public class SoulboundListener implements Listener {
for (int slot = 0; slot < p.getInventory().getSize(); slot++) {
ItemStack item = p.getInventory().getItem(slot);
// Store soulbound items for later retrieval
if (SlimefunUtils.isSoulbound(item)) {
storeItem(p.getUniqueId(), slot, item);
}
}
// Remove soulbound items from our drops
Iterator<ItemStack> drops = e.getDrops().iterator();
while (drops.hasNext()) {
ItemStack item = drops.next();
if (SlimefunUtils.isSoulbound(item)) drops.remove();
if (SlimefunUtils.isSoulbound(item)) {
drops.remove();
}
}
}
@ -51,19 +56,17 @@ public class SoulboundListener implements Listener {
}
private void storeItem(UUID uuid, int slot, ItemStack item) {
Map<Integer, ItemStack> items = soulbound.computeIfAbsent(uuid, id -> new HashMap<>());
Map<Integer, ItemStack> items = soulbound.computeIfAbsent(uuid, uid -> new HashMap<>());
items.put(slot, item);
}
private void retrieveItems(Player p) {
Map<Integer, ItemStack> items = soulbound.get(p.getUniqueId());
Map<Integer, ItemStack> items = soulbound.remove(p.getUniqueId());
if (items != null) {
for (Map.Entry<Integer, ItemStack> entry : items.entrySet()) {
p.getInventory().setItem(entry.getKey(), entry.getValue());
}
}
soulbound.remove(p.getUniqueId());
}
}

View File

@ -7,11 +7,11 @@ import java.util.Random;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
@ -50,10 +50,21 @@ public class TalismanListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onDamageGet(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
if (e.getCause() == DamageCause.LAVA) Talisman.checkFor(e, SlimefunItems.TALISMAN_LAVA);
if (e.getCause() == DamageCause.DROWNING) Talisman.checkFor(e, SlimefunItems.TALISMAN_WATER);
if (e.getCause() == DamageCause.FALL) Talisman.checkFor(e, SlimefunItems.TALISMAN_ANGEL);
if (e.getCause() == DamageCause.FIRE) Talisman.checkFor(e, SlimefunItems.TALISMAN_FIRE);
if (e.getCause() == DamageCause.LAVA) {
Talisman.checkFor(e, SlimefunItems.TALISMAN_LAVA);
}
if (e.getCause() == DamageCause.DROWNING) {
Talisman.checkFor(e, SlimefunItems.TALISMAN_WATER);
}
if (e.getCause() == DamageCause.FALL) {
Talisman.checkFor(e, SlimefunItems.TALISMAN_ANGEL);
}
if (e.getCause() == DamageCause.FIRE) {
Talisman.checkFor(e, SlimefunItems.TALISMAN_FIRE);
}
if (e.getCause() == DamageCause.ENTITY_ATTACK) {
Talisman.checkFor(e, SlimefunItems.TALISMAN_KNIGHT);
@ -64,8 +75,10 @@ public class TalismanListener implements Listener {
Projectile projectile = (Projectile) ((EntityDamageByEntityEvent) e).getDamager();
if (Talisman.checkFor(e, SlimefunItems.TALISMAN_WHIRLWIND)) {
Vector direction = ((Player) e.getEntity()).getEyeLocation().getDirection().multiply(2.0);
Projectile clone = (Projectile) e.getEntity().getWorld().spawnEntity(((LivingEntity) e.getEntity()).getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), projectile.getType());
Player p = (Player) e.getEntity();
Vector direction = p.getEyeLocation().getDirection().multiply(2.0);
Location loc = p.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ());
Projectile clone = (Projectile) e.getEntity().getWorld().spawnEntity(loc, projectile.getType());
clone.setShooter(projectile.getShooter());
clone.setVelocity(direction);
projectile.remove();
@ -79,8 +92,10 @@ public class TalismanListener implements Listener {
if (e.getEntity().getKiller() != null && !(e.getEntity() instanceof Player) && !e.getEntity().getCanPickupItems() && Talisman.checkFor(e, SlimefunItems.TALISMAN_HUNTER)) {
List<ItemStack> extraDrops = new ArrayList<>(e.getDrops());
// Prevent doubling of items stored inside a Horse's chest
if (e.getEntity() instanceof ChestedHorse) {
for (ItemStack invItem : ((ChestedHorse) e.getEntity()).getInventory().getStorageContents()) {
ChestedHorse horse = ((ChestedHorse) e.getEntity());
for (ItemStack invItem : horse.getInventory().getStorageContents()) {
extraDrops.remove(invItem);
}
@ -120,6 +135,8 @@ public class TalismanListener implements Listener {
item.setItemMeta(meta);
int itemSlot = slot;
// Update the item forcefully
Slimefun.runSync(() -> inv.setItem(itemSlot, item), 1L);
}
}

View File

@ -27,10 +27,11 @@ public class VanillaMachinesListener implements Listener {
@EventHandler(ignoreCancelled = true)
public void onGrindstone(InventoryClickEvent e) {
// The Grindstone was only ever added in MC 1.14
if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
return;
}
if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.GRINDSTONE) {
ItemStack item1 = e.getInventory().getContents()[0];
ItemStack item2 = e.getInventory().getContents()[1];

View File

@ -6,11 +6,11 @@ import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.LockedCategory;
import me.mrCookieSlime.Slimefun.Objects.SeasonalCategory;
/**
* This class holds a static references to every {@link Category}

View File

@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.Categories;
@ -89,7 +90,7 @@ public class Category implements Keyed {
*/
public void register() {
if (this instanceof SeasonalCategory) {
if (((SeasonalCategory) this).isUnlocked()) {
if (((SeasonalCategory) this).isVisible()) {
SlimefunPlugin.getRegistry().getEnabledCategories().add(this);
Collections.sort(SlimefunPlugin.getRegistry().getEnabledCategories(), Comparator.comparingInt(Category::getTier));
}

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.Slimefun;

View File

@ -179,14 +179,14 @@ public abstract class AReactor extends AbstractEnergyGenerator {
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), ChestMenuUtils.getEmptyClickHandler());
preset.addItem(1, new CustomItem(getFuelIcon(), "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), ChestMenuUtils.getEmptyClickHandler());
for (int i : border_2) {
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
}
if (needsCooling()) {
preset.addItem(7, new CustomItem(this.getCoolant(), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"));
preset.addItem(7, new CustomItem(getCoolant(), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"));
}
else {
preset.addItem(7, new CustomItem(new ItemStack(Material.BARRIER), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells"));
@ -207,7 +207,23 @@ public abstract class AReactor extends AbstractEnergyGenerator {
*/
public abstract ItemStack getCoolant();
private boolean needsCooling() {
/**
* This method returns the displayed icon above the fuel input slot.
* It should reflect the {@link ItemStack} used to power the reactor.
* This method does <b>not</b> determine the fuel input, only the icon.
*
* @return The {@link ItemStack} used as the fuel icon for this {@link AReactor}.
*/
public abstract ItemStack getFuelIcon();
/**
* This method returns whether this {@link AReactor} requires as some form of
* coolant.
* It is a not-null check performed on {@link #getCoolant()}
*
* @return Whether this {@link AReactor} requires cooling
*/
protected final boolean needsCooling() {
return getCoolant() != null;
}

View File

@ -11,9 +11,10 @@ api-version: 1.13
commands:
slimefun:
description: basic Slimefun command
description: Slimefun command
aliases: sf
usage: You either forgot to install CS-CoreLib or you installed an unsupported version.
permissions:
slimefun.cheat.items:
description: Allows you to cheat Items