From 5bf3e38baef889f849186c9b1f57ee8181a3ca67 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 20 Nov 2020 13:39:25 +0100 Subject: [PATCH] Fixed Armor Stands getting damaged/pushed by Explosive Bow --- CHANGELOG.md | 2 + .../core/guide/options/ContributorsMenu.java | 2 +- .../core/networks/NetworkManager.java | 7 ++- .../core/services/github/Contributor.java | 42 ++++++++++++--- .../core/services/github/GitHubService.java | 25 +++++++-- .../services/localization/Translators.java | 2 +- .../implementation/SlimefunPlugin.java | 3 +- .../items/weapons/ExplosiveBow.java | 12 ++++- .../items/weapons/SeismicAxe.java | 7 ++- .../items/weapons/SwordOfBeheading.java | 52 ++++++++++++++----- .../items/weapons/VampireBlade.java | 6 ++- .../tasks/CapacitorTextureUpdateTask.java | 19 +++++++ .../tasks/SlimefunStartupTask.java | 5 -- .../slimefun4/utils/ChatUtils.java | 1 + .../slimefun4/utils/ColoredMaterial.java | 26 ++++++++++ .../abstractItems/AContainer.java | 2 + .../abstractItems/AGenerator.java | 2 +- .../Objects/handlers/ItemHandler.java | 1 + 18 files changed, 178 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 245bd664b..7b9a59376 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,8 @@ * Fixed #2558 * Fixed a duplication bug with the Block Placer * Fixed Slimefun Guide Settings showing "last activity" as a negative number +* Fixed Armor Stands getting damaged/pushed by Explosive Bow +* Fixed Sword of Beheading dropping Zombie/Skeleton Skulls from Zombie/Skeleton subvariants ## Release Candidate 17 (17 Oct 2020) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java index 5ed9c6918..7ce154874 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java @@ -46,7 +46,7 @@ final class ContributorsMenu { }); List contributors = new ArrayList<>(SlimefunPlugin.getGitHubService().getContributors().values()); - contributors.sort(Comparator.comparingInt(Contributor::index)); + contributors.sort(Comparator.comparingInt(Contributor::getPosition)); for (int i = page * 36; i < contributors.size() && i < (page + 1) * 36; i++) { Contributor contributor = contributors.get(i); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java index 3e0fca2f1..66216750d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java @@ -169,8 +169,11 @@ public class NetworkManager { public void updateAllNetworks(@Nonnull Location l) { Validate.notNull(l, "The Location cannot be null"); - for (Network network : getNetworksFromLocation(l, Network.class)) { - network.markDirty(l); + // No need to create a sublist and loop through it if there are no Networks + if (!networks.isEmpty()) { + for (Network network : getNetworksFromLocation(l, Network.class)) { + network.markDirty(l); + } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java index d558502ad..e1c302e03 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java @@ -38,7 +38,7 @@ public class Contributor { private final ComputedOptional headTexture = ComputedOptional.createNew(); private Optional uuid = Optional.empty(); - private boolean locked = false; + private boolean immutable = false; /** * This creates a new {@link Contributor} with the given ingame name and GitHub profile. @@ -84,7 +84,7 @@ public class Contributor { Validate.notNull(role, "The role cannot be null!"); Validate.isTrue(commits >= 0, "Contributions cannot be negative"); - if (!locked || role.startsWith("translator,")) { + if (!immutable || role.startsWith("translator,")) { contributions.put(role, commits); } } @@ -120,6 +120,13 @@ public class Contributor { return profileLink; } + /** + * This returns a {@link List} of contributions for this {@link Contributor}. + * Each {@link Entry} consists of a {@link String} (for the role) and an {@link Integer} + * (for the amount of commits). + * + * @return A {@link List} of contributions for this {@link Contributor} + */ @Nonnull public List> getContributions() { List> list = new ArrayList<>(contributions.entrySet()); @@ -214,16 +221,35 @@ public class Contributor { return contributions.values().stream().mapToInt(Integer::intValue).sum(); } - public int index() { - return -getTotalContributions(); - } - + /** + * This returns the final display name for this {@link Contributor}. + * The display name is basically the GitHub username but if the Minecraft username differs, + * it will be appended in brackets behind the GitHub username. + * + * @return The final display name of this {@link Contributor}. + */ @Nonnull public String getDisplayName() { return ChatColor.GRAY + githubUsername + (!githubUsername.equals(minecraftUsername) ? ChatColor.DARK_GRAY + " (MC: " + minecraftUsername + ")" : ""); } - public void lock() { - locked = true; + /** + * This returns the position on where to order this {@link Contributor}. + * This is just a convenience method for a {@link Comparator}, it is equivalent to + * {@link #getTotalContributions()} multiplied by minus one. + * + * @return The position of this {@link Contributor} in terms for positioning and ordering. + */ + public int getPosition() { + return -getTotalContributions(); + } + + /** + * This marks this {@link Contributor} as immutable. + * Immutable {@link Contributor Contributors} will no longer be assigned any contributions. + * This is useful when you want to prevent some commits from counting twice. + */ + public void setImmutable() { + immutable = true; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java index f7d103f24..29b66a083 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java @@ -8,6 +8,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -37,6 +38,7 @@ public class GitHubService { private boolean logging = false; private LocalDateTime lastUpdate = LocalDateTime.now(); + private int openIssues = 0; private int pendingPullRequests = 0; private int publicForks = 0; @@ -56,9 +58,18 @@ public class GitHubService { loadConnectors(false); } + /** + * This will start the {@link GitHubService} and run the asynchronous {@link GitHubTask} + * every so often to update its data. + * + * @param plugin + * Our instance of {@link SlimefunPlugin} + */ public void start(@Nonnull SlimefunPlugin plugin) { + long period = TimeUnit.HOURS.toMillis(1); GitHubTask task = new GitHubTask(this); - plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, task, 80L, 60 * 60 * 20L); + + plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, task, 80L, period); } /** @@ -215,8 +226,16 @@ public class GitHubService { texturesCache.save(); } + /** + * This returns the cached skin texture for a given username. + * + * @param username + * The minecraft username + * + * @return The cached skin texture for that user (or null) + */ @Nullable - protected String getCachedTexture(@Nonnull String name) { - return texturesCache.getString(name); + protected String getCachedTexture(@Nonnull String username) { + return texturesCache.getString(username); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java index c82fea35f..ea847bb98 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java @@ -183,7 +183,7 @@ public class Translators { Contributor contributor = github.addContributor(minecraftName, "https://github.com/" + username, "translator," + lang.getLanguageId(), 0); if (lock) { - contributor.lock(); + contributor.setImmutable(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index ea89443dd..132344a7c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -79,6 +79,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.IronGolemList import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.MobDropListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.PiglinListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.SeismicAxeListener; @@ -117,7 +118,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu; /** * This is the main class of Slimefun. * This is where all the magic starts, take a look around. - * Feel like home. * * @author TheBusyBiscuit */ @@ -509,6 +509,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new CauldronListener(this); new GrindstoneListener(this); new CartographyTableListener(this); + new NetworkListener(this, networkManager); if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { new BeeListener(this); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java index e73b78ea3..1086221b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java @@ -2,9 +2,13 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; import java.util.Collection; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Bukkit; import org.bukkit.Particle; import org.bukkit.Sound; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -33,6 +37,7 @@ public class ExplosiveBow extends SlimefunBow { private final ItemSetting range = new IntRangeSetting("explosion-range", 1, 3, Integer.MAX_VALUE); + @ParametersAreNonnullByDefault public ExplosiveBow(Category category, SlimefunItemStack item, ItemStack[] recipe) { super(category, item, recipe); @@ -44,8 +49,9 @@ public class ExplosiveBow extends SlimefunBow { return (e, target) -> { target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation(), 1); target.getWorld().playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1, 1); + int radius = range.getValue(); - Collection entites = target.getWorld().getNearbyEntities(target.getLocation(), range.getValue(), range.getValue(), range.getValue(), entity -> entity instanceof LivingEntity && entity.isValid()); + Collection entites = target.getWorld().getNearbyEntities(target.getLocation(), radius, radius, radius, this::canDamage); for (Entity nearby : entites) { LivingEntity entity = (LivingEntity) nearby; @@ -71,6 +77,10 @@ public class ExplosiveBow extends SlimefunBow { }; } + private boolean canDamage(@Nonnull Entity n) { + return n instanceof LivingEntity && !(n instanceof ArmorStand) && n.isValid(); + } + private double calculateDamage(double distanceSquared, double originalDamage) { if (distanceSquared <= 0.05) { return originalDamage; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java index 53d43e5c8..9f810486b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java @@ -2,6 +2,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; @@ -42,6 +45,7 @@ public class SeismicAxe extends SimpleSlimefunItem implements No private static final float DAMAGE = 6; private static final int RANGE = 10; + @ParametersAreNonnullByDefault public SeismicAxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } @@ -96,7 +100,8 @@ public class SeismicAxe extends SimpleSlimefunItem implements No } } - private Block findGround(Block b) { + @Nonnull + private Block findGround(@Nonnull Block b) { if (b.getType() == Material.AIR) { for (int y = 0; y < b.getY(); y++) { Block block = b.getRelative(0, -y, 0); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java index 9f2d14170..aee48bdf8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java @@ -3,8 +3,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Material; import org.bukkit.entity.Creeper; +import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.WitherSkeleton; @@ -21,6 +24,17 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +/** + * The {@link SwordOfBeheading} is a special kind of sword which allows you to obtain + * {@link Zombie}, {@link Skeleton} and {@link Creeper} skulls when killing the respective {@link Monster}. + * Additionally, you can also obtain the head of a {@link Player} by killing them too. + * This sword also allows you to have a higher chance of getting the skull of a {@link WitherSkeleton} too. + * + * All chances are managed by an {@link ItemSetting} and can be configured. + * + * @author TheBusyBiscuit + * + */ public class SwordOfBeheading extends SimpleSlimefunItem { private final ItemSetting chanceZombie = new IntRangeSetting("chance.ZOMBIE", 0, 40, 100); @@ -29,6 +43,7 @@ public class SwordOfBeheading extends SimpleSlimefunItem { private final ItemSetting chanceCreeper = new IntRangeSetting("chance.CREEPER", 0, 40, 100); private final ItemSetting chancePlayer = new IntRangeSetting("chance.PLAYER", 0, 70, 100); + @ParametersAreNonnullByDefault public SwordOfBeheading(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -40,29 +55,40 @@ public class SwordOfBeheading extends SimpleSlimefunItem { return (e, entity, killer, item) -> { Random random = ThreadLocalRandom.current(); - if (e.getEntity() instanceof Zombie) { + switch (e.getEntityType()) { + case ZOMBIE: if (random.nextInt(100) < chanceZombie.getValue()) { e.getDrops().add(new ItemStack(Material.ZOMBIE_HEAD)); } - } else if (e.getEntity() instanceof WitherSkeleton) { - if (random.nextInt(100) < chanceWitherSkeleton.getValue()) { - e.getDrops().add(new ItemStack(Material.WITHER_SKELETON_SKULL)); - } - } else if (e.getEntity() instanceof Skeleton) { + break; + case SKELETON: if (random.nextInt(100) < chanceSkeleton.getValue()) { e.getDrops().add(new ItemStack(Material.SKELETON_SKULL)); } - } else if (e.getEntity() instanceof Creeper) { + break; + case CREEPER: if (random.nextInt(100) < chanceCreeper.getValue()) { e.getDrops().add(new ItemStack(Material.CREEPER_HEAD)); } - } else if (e.getEntity() instanceof Player && random.nextInt(100) < chancePlayer.getValue()) { - ItemStack skull = new ItemStack(Material.PLAYER_HEAD); - ItemMeta meta = skull.getItemMeta(); - ((SkullMeta) meta).setOwningPlayer((Player) e.getEntity()); - skull.setItemMeta(meta); + break; + case WITHER_SKELETON: + if (random.nextInt(100) < chanceWitherSkeleton.getValue()) { + e.getDrops().add(new ItemStack(Material.WITHER_SKELETON_SKULL)); + } + break; + case PLAYER: + if (random.nextInt(100) < chancePlayer.getValue()) { + ItemStack skull = new ItemStack(Material.PLAYER_HEAD); - e.getDrops().add(skull); + ItemMeta meta = skull.getItemMeta(); + ((SkullMeta) meta).setOwningPlayer((Player) e.getEntity()); + skull.setItemMeta(meta); + + e.getDrops().add(skull); + } + break; + default: + break; } }; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java index f31bd37bd..16f1f2b9e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Sound; import org.bukkit.attribute.Attribute; import org.bukkit.entity.LivingEntity; @@ -28,6 +31,7 @@ public class VampireBlade extends SlimefunItem { private static final double HEALING_AMOUNT = 4.0; private final ItemSetting chance = new IntRangeSetting("chance", 0, 45, 100); + @ParametersAreNonnullByDefault public VampireBlade(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -43,7 +47,7 @@ public class VampireBlade extends SlimefunItem { return chance.getValue(); } - public void heal(Player p) { + public void heal(@Nonnull Player p) { p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.7F, 0.7F); double health = p.getHealth() + HEALING_AMOUNT; double maxHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java index 976b54397..760689e42 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java @@ -21,9 +21,27 @@ import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; */ public class CapacitorTextureUpdateTask implements Runnable { + /** + * The {@link Location} of the {@link Capacitor}. + */ private final Location l; + + /** + * The level of how "full" this {@link Capacitor} is. + * From 0.0 to 1.0. + */ private final double filledPercentage; + /** + * This creates a new {@link CapacitorTextureUpdateTask} with the given parameters. + * + * @param l + * The {@link Location} of the {@link Capacitor} + * @param charge + * The amount of charge in this {@link Capacitor} + * @param capacity + * The capacity of this {@link Capacitor} + */ public CapacitorTextureUpdateTask(@Nonnull Location l, double charge, double capacity) { Validate.notNull(l, "The Location cannot be null"); @@ -36,6 +54,7 @@ public class CapacitorTextureUpdateTask implements Runnable { Block b = l.getBlock(); Material type = b.getType(); + // Ensure that this Block is still a Player Head if (type == Material.PLAYER_HEAD || type == Material.PLAYER_WALL_HEAD) { if (filledPercentage <= 0.25) { SkullBlock.setFromHash(b, HeadTexture.CAPACITOR_25.getTexture()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java index dbb683390..552b881fa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java @@ -9,7 +9,6 @@ import org.bukkit.World; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.listeners.ButcherAndroidListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.TeleporterListener; import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -69,10 +68,6 @@ public class SlimefunStartupTask implements Runnable { if (isEnabled("PROGRAMMABLE_ANDROID_BUTCHER", "PROGRAMMABLE_ANDROID_2_BUTCHER", "PROGRAMMABLE_ANDROID_3_BUTCHER")) { new ButcherAndroidListener(plugin); } - - if (isEnabled("ENERGY_REGULATOR", "CARGO_MANAGER")) { - new NetworkListener(plugin, SlimefunPlugin.getNetworkManager()); - } } private boolean isEnabled(String... itemIds) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java index fe1f75b28..333deeb80 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java @@ -65,6 +65,7 @@ public final class ChatUtils { * * @return A human-friendly version of the given {@link String} */ + @Nonnull public static String humanize(@Nonnull String string) { StringBuilder builder = new StringBuilder(); String[] segments = PatternUtils.UNDERSCORE.split(string.toLowerCase(Locale.ROOT)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java index bb7836767..fb791fda3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java @@ -159,6 +159,9 @@ public enum ColoredMaterial { // @formatter:on + /** + * This is our {@link List} of {@link Material Materials}, the backbone of this enum. + */ private final List list; /** @@ -175,11 +178,25 @@ public enum ColoredMaterial { list = Collections.unmodifiableList(Arrays.asList(materials)); } + /** + * This returns an ordered {@link List} of {@link Material Materials} + * that are part o this {@link ColoredMaterial}. + * + * @return An ordered {@link List} of {@link Material Materials} + */ @Nonnull public List asList() { return list; } + /** + * This returns the {@link Material} at the given index. + * + * @param index + * The index + * + * @return The {@link Material} at that index + */ @Nonnull public Material get(int index) { Validate.isTrue(index >= 0 && index < 16, "The index must be between 0 and 15 (inclusive)."); @@ -187,6 +204,15 @@ public enum ColoredMaterial { return list.get(index); } + /** + * This returns the {@link Material} with the given {@link DyeColor}. + * + * @param color + * The {@link DyeColor} + * + * @return The {@link Material} with that {@link DyeColor} + */ + @Nonnull public Material get(@Nonnull DyeColor color) { Validate.notNull(color, "Color cannot be null!"); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index c0d69f1b1..2572751b1 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -252,6 +252,8 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, * identify all instances of the same {@link AContainer}. * This way we can add the recipes to all instances of the same machine. * + * This method will be deprecated and replaced in the future + * * @return The identifier of this machine */ @Nonnull diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java index 384bfaec9..2d5bc397c 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java @@ -63,7 +63,7 @@ public abstract class AGenerator extends AbstractEnergyProvider { @Override public boolean canOpen(Block b, Player p) { - return p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES); + return p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.INTERACT_BLOCK); } @Override diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/ItemHandler.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/ItemHandler.java index ca6417ae4..7333724c2 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/ItemHandler.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/ItemHandler.java @@ -47,6 +47,7 @@ public interface ItemHandler { * * @param item * The {@link SlimefunItem} to validate + * * @return An {@link Optional} describing the result, it will contain an {@link IncompatibleItemHandlerException} * should there be an issue */