1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

A LOT more Refactoring + Technical debt reduction

This commit is contained in:
TheBusyBiscuit 2019-08-27 14:08:09 +02:00
parent fd36288efb
commit 641a2e6e30
16 changed files with 110 additions and 121 deletions

View File

@ -5,11 +5,13 @@ import java.util.List;
import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
public class AltarRecipe {
ItemStack catalyst;
List<ItemStack> input;
ItemStack output;
private ItemStack catalyst;
private List<ItemStack> input;
private ItemStack output;
public AltarRecipe(List<ItemStack> input, ItemStack output) {
this.catalyst = input.get(4);
@ -27,7 +29,7 @@ public class AltarRecipe {
this.output = output;
Pedestals.recipes.add(this);
SlimefunStartup.instance.getUtilities().altarRecipes.add(this);
}
public ItemStack getCatalyst() {

View File

@ -8,39 +8,41 @@ import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
public class Pedestals {
public static List<AltarRecipe> recipes = new ArrayList<>();
public final class Pedestals {
private Pedestals() {}
public static List<Block> getPedestals(Block altar) {
String pedestal = "ANCIENT_PEDESTAL";
List<Block> list = new ArrayList<>();
if (BlockStorage.check(altar.getRelative(2, 0, -2), "ANCIENT_PEDESTAL")) {
if (BlockStorage.check(altar.getRelative(2, 0, -2), pedestal)) {
list.add(altar.getRelative(2, 0, -2));
}
if (BlockStorage.check(altar.getRelative(3, 0, 0), "ANCIENT_PEDESTAL")) {
if (BlockStorage.check(altar.getRelative(3, 0, 0), pedestal)) {
list.add(altar.getRelative(3, 0, 0));
}
if (BlockStorage.check(altar.getRelative(2, 0, 2), "ANCIENT_PEDESTAL")) {
if (BlockStorage.check(altar.getRelative(2, 0, 2), pedestal)) {
list.add(altar.getRelative(2, 0, 2));
}
if (BlockStorage.check(altar.getRelative(0, 0, 3), "ANCIENT_PEDESTAL")) {
if (BlockStorage.check(altar.getRelative(0, 0, 3), pedestal)) {
list.add(altar.getRelative(0, 0, 3));
}
if (BlockStorage.check(altar.getRelative(-2, 0, 2), "ANCIENT_PEDESTAL")) {
if (BlockStorage.check(altar.getRelative(-2, 0, 2), pedestal)) {
list.add(altar.getRelative(-2, 0, 2));
}
if (BlockStorage.check(altar.getRelative(-3, 0, 0), "ANCIENT_PEDESTAL")) {
if (BlockStorage.check(altar.getRelative(-3, 0, 0), pedestal)) {
list.add(altar.getRelative(-3, 0, 0));
}
if (BlockStorage.check(altar.getRelative(-2, 0, -2), "ANCIENT_PEDESTAL")) {
if (BlockStorage.check(altar.getRelative(-2, 0, -2), pedestal)) {
list.add(altar.getRelative(-2, 0, -2));
}
if (BlockStorage.check(altar.getRelative(0, 0, -3), "ANCIENT_PEDESTAL")) {
if (BlockStorage.check(altar.getRelative(0, 0, -3), pedestal)) {
list.add(altar.getRelative(0, 0, -3));
}
@ -49,6 +51,7 @@ public class Pedestals {
public static ItemStack getRecipeOutput(ItemStack catalyst, List<ItemStack> input) {
if (input.size() != 8) return null;
if (SlimefunManager.isItemSimiliar(catalyst, SlimefunItems.BROKEN_SPAWNER, false)) {
if (checkRecipe(SlimefunItems.BROKEN_SPAWNER, input) == null) return null;
final ItemStack spawner = SlimefunItems.REPAIRED_SPAWNER.clone();
@ -63,7 +66,7 @@ public class Pedestals {
private static ItemStack checkRecipe(ItemStack catalyst, List<ItemStack> items) {
loop:
for (AltarRecipe recipe: recipes) {
for (AltarRecipe recipe: SlimefunStartup.instance.getUtilities().altarRecipes) {
if (!SlimefunManager.isItemSimiliar(catalyst, recipe.getCatalyst(), true)) {
continue;
}

View File

@ -29,12 +29,12 @@ public class RitualAnimation implements Runnable {
private List<ItemStack> items;
private List<Location> particles;
private Map<Item,Location> itemLock = new HashMap<>();
private Map<Item, Location> itemLock = new HashMap<>();
private boolean running;
private int stage;
private Utilities variables = SlimefunStartup.instance.getUtilities();
private Utilities utilities = SlimefunStartup.instance.getUtilities();
public RitualAnimation(List<Block> altars, Block altar, Location drop, ItemStack output, List<Block> pedestals, List<ItemStack> items) {
this.l = drop;
@ -47,9 +47,10 @@ public class RitualAnimation implements Runnable {
this.running = true;
this.stage = 0;
for(Block ped:this.pedestals) {
Item itm = AncientAltarListener.findItem(ped);
this.itemLock.put(itm, itm.getLocation().clone());
for (Block pedestal: this.pedestals) {
Item item = AncientAltarListener.findItem(pedestal);
this.itemLock.put(item, item.getLocation().clone());
}
}
@ -57,17 +58,17 @@ public class RitualAnimation implements Runnable {
public void run() {
idle();
if(!checkLockedItems()) {
if (!checkLockedItems()) {
abort();
return;
}
if(this.stage == 36) {
if (this.stage == 36) {
finish();
return;
}
if(this.stage > 0 && this.stage % 4 == 0) {
if (this.stage > 0 && this.stage % 4 == 0) {
checkPedestal(pedestals.get(this.stage / 4 - 1));
}
@ -76,8 +77,8 @@ public class RitualAnimation implements Runnable {
}
private boolean checkLockedItems() {
for (Item item : this.itemLock.keySet()) {
if (item.getLocation().distance(this.itemLock.get(item)) > 0.3) {
for (Map.Entry<Item, Location> entry: itemLock.entrySet()) {
if (entry.getKey().getLocation().distance(entry.getValue()) > 0.3) {
return false;
}
}
@ -126,12 +127,10 @@ public class RitualAnimation implements Runnable {
private void abort() {
running = false;
pedestals.forEach(b -> utilities.altarinuse.remove(b.getLocation()));
pedestals.forEach((pblock)-> {
variables.altarinuse.remove(pblock.getLocation());
});
variables.altarinuse.remove(altar.getLocation()); // should re-enable altar blocks on craft failure.
// This should re-enable altar blocks on craft failure.
utilities.altarinuse.remove(altar.getLocation());
l.getWorld().playSound(l, Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 5F, 1F);
itemLock.clear();
altars.remove(altar);
@ -143,10 +142,10 @@ public class RitualAnimation implements Runnable {
l.getWorld().playEffect(l, Effect.STEP_SOUND, Material.EMERALD_BLOCK);
l.getWorld().dropItemNaturally(l.add(0, 1, 0), output);
pedestals.forEach((pblock)->{
variables.altarinuse.remove(pblock.getLocation());
});
variables.altarinuse.remove(altar.getLocation()); // should re-enable altar blocks on craft completion.
pedestals.forEach(b -> utilities.altarinuse.remove(b.getLocation()));
// This should re-enable altar blocks on craft completion.
utilities.altarinuse.remove(altar.getLocation());
altars.remove(altar);
}
else {

View File

@ -12,7 +12,7 @@ public enum AndroidType {
NON_FIGHTER;
public boolean isType(AndroidType type) {
return type.equals(NONE) || type.equals(this) || (type.equals(NON_FIGHTER) && !this.equals(FIGHTER));
return type == NONE || type == this || (type == NON_FIGHTER && this != FIGHTER);
}
}

View File

@ -10,7 +10,9 @@ import org.bukkit.block.Biome;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
public class OreGenSystem {
public final class OreGenSystem {
private OreGenSystem() {}
public static Map<String, OreGenResource> map = new HashMap<>();

View File

@ -1,7 +1,6 @@
package me.mrCookieSlime.Slimefun.GPS;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.ChatColor;
@ -16,13 +15,14 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.CustomBookOverlay;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuHelper;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
import me.mrCookieSlime.Slimefun.Setup.Messages;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
public class Elevator {
public static List<UUID> ignored = new ArrayList<>();
public final class Elevator {
private Elevator() {}
public static void openEditor(Player p, final Block b) {
ChestMenu menu = new ChestMenu("Elevator Settings");
@ -53,8 +53,10 @@ public class Elevator {
}
public static void openDialogue(Player p, Block b) {
if (ignored.contains(p.getUniqueId())) {
ignored.remove(p.getUniqueId());
Set<UUID> elevatorUsers = SlimefunStartup.instance.getUtilities().elevatorUsers;
if (elevatorUsers.contains(p.getUniqueId())) {
elevatorUsers.remove(p.getUniqueId());
return;
}

View File

@ -1,7 +1,6 @@
package me.mrCookieSlime.Slimefun.Objects;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@ -58,12 +57,6 @@ public class Research {
*/
public static List<String> titles;
/**
* Contains all the players (UUIDs) that are currently unlocking a research.
* @since 4.0
*/
public static Set<UUID> researching = new HashSet<>();
/**
* Whether researching in creative is free.
* @since 4.0
@ -275,8 +268,8 @@ public class Research {
FireworkShow.launchRandom(p, 1);
}
}
else if (!researching.contains(p.getUniqueId())){
researching.add(p.getUniqueId());
else if (!SlimefunStartup.instance.getUtilities().researching.contains(p.getUniqueId())){
SlimefunStartup.instance.getUtilities().researching.add(p.getUniqueId());
Messages.local.sendTranslation(p, "messages.research.start", true, new Variable("%research%", getName()));
for (int i = 1; i < research_progress.length + 1; i++) {
@ -296,7 +289,7 @@ public class Research {
FireworkShow.launchRandom(p, 1);
}
researching.remove(p.getUniqueId());
SlimefunStartup.instance.getUtilities().researching.remove(p.getUniqueId());
}, (research_progress.length + 1) * 20L);
}
}
@ -354,7 +347,7 @@ public class Research {
* @since 4.0
*/
public static boolean isResearching(Player p) {
return researching.contains(p.getUniqueId());
return SlimefunStartup.instance.getUtilities().researching.contains(p.getUniqueId());
}
/**

View File

@ -1118,13 +1118,13 @@ public class SlimefunSetup {
@Override
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.GRAPPLING_HOOK, true)) {
if (e.getClickedBlock() == null && !variables.jump_state.containsKey(p.getUniqueId())) {
if (e.getClickedBlock() == null && !variables.jumpState.containsKey(p.getUniqueId())) {
e.setCancelled(true);
if (p.getInventory().getItemInOffHand().getType().equals(Material.BOW)) {
// Cancel, to fix dupe #740
return false;
}
variables.jump_state.put(p.getUniqueId(), p.getInventory().getItemInMainHand().getType() != Material.SHEARS);
variables.jumpState.put(p.getUniqueId(), p.getInventory().getItemInMainHand().getType() != Material.SHEARS);
if (p.getInventory().getItemInMainHand().getType() == Material.LEAD) PlayerInventory.consumeItemInHand(p);
Vector direction = p.getEyeLocation().getDirection().multiply(2.0);

View File

@ -18,11 +18,9 @@ import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.PluginUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.CSCoreLibPlugin.general.Reflection.ReflectionUtils;
import me.mrCookieSlime.Slimefun.AncientAltar.Pedestals;
import me.mrCookieSlime.Slimefun.GEO.OreGenSystem;
import me.mrCookieSlime.Slimefun.GEO.Resources.NetherIceResource;
import me.mrCookieSlime.Slimefun.GEO.Resources.OilResource;
import me.mrCookieSlime.Slimefun.GPS.Elevator;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.MultiBlock;
import me.mrCookieSlime.Slimefun.Objects.Research;
@ -56,7 +54,6 @@ import me.mrCookieSlime.Slimefun.commands.SlimefunCommand;
import me.mrCookieSlime.Slimefun.commands.SlimefunTabCompleter;
import me.mrCookieSlime.Slimefun.hooks.PlaceholderAPIHook;
import me.mrCookieSlime.Slimefun.hooks.WorldEditHook;
import me.mrCookieSlime.Slimefun.hooks.github.Contributor;
import me.mrCookieSlime.Slimefun.hooks.github.GitHubConnector;
import me.mrCookieSlime.Slimefun.hooks.github.GitHubSetup;
import me.mrCookieSlime.Slimefun.listeners.AncientAltarListener;
@ -261,22 +258,6 @@ public class SlimefunStartup extends JavaPlugin {
if (SlimefunItem.getByID("ANCIENT_ALTAR") != null) new AncientAltarListener((SlimefunStartup) instance);
}, 0);
// WorldEdit Hook to clear Slimefun Data upon //set 0 //cut or any other equivalent
if (getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
try {
Class.forName("com.sk89q.worldedit.extent.Extent");
new WorldEditHook();
System.out.println("[Slimefun] Successfully hooked into WorldEdit!");
} catch (Exception x) {
System.err.println("[Slimefun] Failed to hook into WorldEdit!");
System.err.println("[Slimefun] Maybe consider updating WorldEdit or Slimefun?");
}
}
if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new PlaceholderAPIHook().register();
}
getCommand("slimefun").setExecutor(new SlimefunCommand(this));
getCommand("slimefun").setTabCompleter(new SlimefunTabCompleter());
@ -340,11 +321,7 @@ public class SlimefunStartup extends JavaPlugin {
getServer().getScheduler().runTaskTimerAsynchronously(this, new BlockAutoSaver(), 2000L, config.getInt("options.auto-save-delay-in-minutes") * 60L * 20L);
getServer().getScheduler().runTaskTimerAsynchronously(this, ticker, 100L, config.getInt("URID.custom-ticker-delay"));
getServer().getScheduler().runTaskTimerAsynchronously(this, () -> {
for (GitHubConnector connector : GitHubConnector.connectors) {
connector.pullFile();
}
}, 80L, 60 * 60 * 20L);
getServer().getScheduler().runTaskTimerAsynchronously(this, () -> utilities.connectors.forEach(GitHubConnector::pullFile), 80L, 60 * 60 * 20L);
// Hooray!
System.out.println("[Slimefun] Finished!");
@ -357,9 +334,25 @@ public class SlimefunStartup extends JavaPlugin {
}, 0);
if (clearlag) new ClearLaggIntegration(this);
if (coreProtect) coreProtectAPI = ((CoreProtect) getServer().getPluginManager().getPlugin("CoreProtect")).getAPI();
// WorldEdit Hook to clear Slimefun Data upon //set 0 //cut or any other equivalent
if (getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
try {
Class.forName("com.sk89q.worldedit.extent.Extent");
new WorldEditHook();
System.out.println("[Slimefun] Successfully hooked into WorldEdit!");
} catch (Exception x) {
System.err.println("[Slimefun] Failed to hook into WorldEdit!");
System.err.println("[Slimefun] Maybe consider updating WorldEdit or Slimefun?");
}
}
if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new PlaceholderAPIHook().register();
}
Research.creative_research = config.getBoolean("options.allow-free-creative-research");
Research.titles = config.getStringList("research-ranks");
@ -422,7 +415,6 @@ public class SlimefunStartup extends JavaPlugin {
Files.WHITELIST = null;
MultiBlock.list = null;
Research.list = null;
Research.researching = null;
SlimefunItem.all = null;
SlimefunItem.items = null;
SlimefunItem.map_id = null;
@ -442,8 +434,6 @@ public class SlimefunStartup extends JavaPlugin {
AContainer.processing = null;
AContainer.progress = null;
Slimefun.guide_handlers = null;
Pedestals.recipes = null;
Elevator.ignored = null;
EnergyNet.listeners = null;
EnergyNet.machines_input = null;
EnergyNet.machines_output = null;
@ -453,8 +443,6 @@ public class SlimefunStartup extends JavaPlugin {
TickerTask.block_timings = null;
OreGenSystem.map = null;
SlimefunGuide.contributors = null;
GitHubConnector.connectors = null;
Contributor.textures = null;
ChestManipulator.listeners = null;
PlayerProfile.profiles = null;

View File

@ -12,6 +12,9 @@ import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.Slimefun.AncientAltar.AltarRecipe;
import me.mrCookieSlime.Slimefun.hooks.github.GitHubConnector;
/**
* Really dirty way to store stuff, but you can dump
* some Objects into here that need to be used throughout
@ -22,7 +25,7 @@ import org.bukkit.inventory.ItemStack;
*/
public final class Utilities {
public Map<UUID, Boolean> jump_state = new HashMap<>();
public Map<UUID, Boolean> jumpState = new HashMap<>();
public Set<UUID> damage = new HashSet<>();
public Map<UUID, Entity[]> remove = new HashMap<>();
public Map<UUID, Integer> mode = new HashMap<>();
@ -31,10 +34,22 @@ public final class Utilities {
public Map<UUID, ItemStack> backpack = new HashMap<>();
public Set<Location> altarinuse = new HashSet<>();
public Set<AltarRecipe> altarRecipes = new HashSet<>();
public Map<UUID, List<ItemStack>> soulbound = new HashMap<>();
public List<UUID> blocks = new ArrayList<>();
public List<UUID> cancelPlace = new ArrayList<>();
public Map<UUID, ItemStack> arrows = new HashMap<>();
public Set<UUID> elevatorUsers = new HashSet<>();
public Set<GitHubConnector> connectors = new HashSet<>();
public Map<String, String> contributorHeads = new HashMap<>();
/**
* Contains all the players (UUIDs) that are currently unlocking a research.
* @since 4.0
*/
public Set<UUID> researching = new HashSet<>();
}

View File

@ -28,7 +28,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.World.TitleBuilder;
import me.mrCookieSlime.CSCoreLibPlugin.general.World.TitleBuilder.TitleType;
import me.mrCookieSlime.Slimefun.SlimefunGuide;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
import me.mrCookieSlime.Slimefun.GPS.Elevator;
import me.mrCookieSlime.Slimefun.GPS.GPSNetwork;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Misc.BookDesign;
@ -143,7 +142,7 @@ public class SlimefunCommand implements CommandExecutor, Listener {
double z = Integer.parseInt(args[3]) + 0.5D;
if (BlockStorage.getLocationInfo(((Player) sender).getWorld().getBlockAt(Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])).getLocation(), "floor") != null) {
Elevator.ignored.add(((Player) sender).getUniqueId());
plugin.getUtilities().elevatorUsers.add(((Player) sender).getUniqueId());
float yaw = ((Player) sender).getEyeLocation().getYaw() + 180;
if (yaw > 180) yaw = -180 + (yaw - 180);
((Player) sender).teleport(new Location(((Player) sender).getWorld(), x, y, z, yaw, ((Player) sender).getEyeLocation().getPitch()));

View File

@ -1,7 +1,6 @@
package me.mrCookieSlime.Slimefun.hooks.github;
import java.util.HashMap;
import java.util.Map;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
/**
* Represents a contributor on Slimefun4's GitHub repository.
@ -10,8 +9,6 @@ import java.util.Map;
*/
public class Contributor {
public static Map<String, String> textures = new HashMap<>();
private String name;
private String job;
private String profile;
@ -72,6 +69,6 @@ public class Contributor {
* @return A Base64-Head Texture
*/
public String getTexture() {
return textures.get(name);
return SlimefunStartup.instance.getUtilities().contributorHeads.get(name);
}
}

View File

@ -9,22 +9,19 @@ import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.HashSet;
import java.util.Set;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
public abstract class GitHubConnector {
public static Set<GitHubConnector> connectors = new HashSet<GitHubConnector>();
private File file;
public GitHubConnector() {
this.file = new File("plugins/Slimefun/cache/github/" + this.getFileName() + ".json");
connectors.add(this);
SlimefunStartup.instance.getUtilities().connectors.add(this);
}
public abstract String getFileName();

View File

@ -42,7 +42,9 @@ public class GitHubSetup {
for (JsonElement e: array) {
String name = e.getAsJsonObject().get("login").getAsString();
if (Contributor.textures.containsKey(name)) continue;
if (SlimefunStartup.instance.getUtilities().contributorHeads.containsKey(name)) {
continue;
}
InputStreamReader profile_reader = null, session_reader = null;
@ -57,12 +59,12 @@ public class GitHubSetup {
for (JsonElement el: properties) {
if (el.isJsonObject() && el.getAsJsonObject().get("name").getAsString().equals("textures")) {
Contributor.textures.put(name, el.getAsJsonObject().get("value").getAsString());
SlimefunStartup.instance.getUtilities().contributorHeads.put(name, el.getAsJsonObject().get("value").getAsString());
break;
}
}
} catch (Exception x) {
Contributor.textures.put(name, null);
SlimefunStartup.instance.getUtilities().contributorHeads.put(name, null);
} finally {
if (profile_reader != null) {
try {

View File

@ -46,9 +46,9 @@ public class BowListener implements Listener {
private void handleGrapplingHook(Arrow arrow) {
if (arrow != null) {
if (arrow.getShooter() instanceof Player && utilities.jump_state.containsKey(((Player) arrow.getShooter()).getUniqueId())) {
if (arrow.getShooter() instanceof Player && utilities.jumpState.containsKey(((Player) arrow.getShooter()).getUniqueId())) {
final Player p = (Player) arrow.getShooter();
if (p.getGameMode() != GameMode.CREATIVE && utilities.jump_state.get(p.getUniqueId())) arrow.getWorld().dropItem(arrow.getLocation(), SlimefunItem.getItem("GRAPPLING_HOOK"));
if (p.getGameMode() != GameMode.CREATIVE && utilities.jumpState.get(p.getUniqueId())) arrow.getWorld().dropItem(arrow.getLocation(), SlimefunItem.getItem("GRAPPLING_HOOK"));
if (p.getLocation().distance(arrow.getLocation()) < 3.0D) {
if (arrow.getLocation().getY() > p.getLocation().getY()) {
p.setVelocity(new Vector(0.0D, 0.25D, 0.0D));
@ -60,7 +60,7 @@ public class BowListener implements Listener {
}
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, () -> {
utilities.jump_state.remove(p.getUniqueId());
utilities.jumpState.remove(p.getUniqueId());
utilities.remove.remove(p.getUniqueId());
}, 20L);
}
@ -89,7 +89,7 @@ public class BowListener implements Listener {
}
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, () -> {
utilities.jump_state.remove(p.getUniqueId());
utilities.jumpState.remove(p.getUniqueId());
utilities.remove.remove(p.getUniqueId());
}, 20L);
}

View File

@ -106,24 +106,14 @@ public class ItemListener implements Listener {
*/
@EventHandler
public void enabledCheck(PlayerInteractEvent e) {
if(e.getAction() != Action.LEFT_CLICK_AIR && e.getAction() != Action.LEFT_CLICK_BLOCK)
if (e.getAction() != Action.LEFT_CLICK_AIR && e.getAction() != Action.LEFT_CLICK_BLOCK) {
return;
}
ItemStack item = e.getItem();
if(item == null)
item = e.getPlayer().getInventory().getItemInMainHand();
if(item == null)
item = e.getPlayer().getInventory().getItemInOffHand();
if(item == null)
return;
if(!Slimefun.isEnabled(e.getPlayer(), item, true))
if (item != null && !Slimefun.isEnabled(e.getPlayer(), item, true)) {
e.setCancelled(true);
}
}
@EventHandler
public void debug(PlayerInteractEvent e) {