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

Merge pull request #2 from TheBusyBiscuit/master

Sync
This commit is contained in:
penta 2019-12-18 13:31:42 +01:00 committed by GitHub
commit e41b2762f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
96 changed files with 607 additions and 542 deletions

View File

@ -11,11 +11,11 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable; import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage; import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage;
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage.HoverAction; import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage.HoverAction;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.CustomBookOverlay; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.CustomBookOverlay;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunGuide;
import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Category;

View File

@ -24,6 +24,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe; import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem; import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
import io.github.thebusybiscuit.slimefun4.core.utils.ChatUtils;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunGuide;
import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.SlimefunPlugin;
@ -429,9 +430,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide {
menu.addItem(8, new CustomItem(Material.KNOWLEDGE_BOOK, "&rView this Item on our Wiki &7(Slimefun Wiki)", "", "&7\u21E8 Click to open")); menu.addItem(8, new CustomItem(Material.KNOWLEDGE_BOOK, "&rView this Item on our Wiki &7(Slimefun Wiki)", "", "&7\u21E8 Click to open"));
menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> { menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> {
pl.closeInventory(); pl.closeInventory();
pl.sendMessage(""); ChatUtils.sendURL(pl, item.getWiki());
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + item.getWiki()));
pl.sendMessage("");
return false; return false;
}); });
} catch (Exception x) { } catch (Exception x) {
@ -444,9 +443,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide {
menu.addItem(7, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzNTNmZDBmODYzMTQzNTM4NzY1ODYwNzViOWJkZjBjNDg0YWFiMDMzMWI4NzJkZjExYmQ1NjRmY2IwMjllZCJ9fX0="), "&rDemonstration Video &7(Youtube)", "", "&7\u21E8 Click to watch")); menu.addItem(7, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzNTNmZDBmODYzMTQzNTM4NzY1ODYwNzViOWJkZjBjNDg0YWFiMDMzMWI4NzJkZjExYmQ1NjRmY2IwMjllZCJ9fX0="), "&rDemonstration Video &7(Youtube)", "", "&7\u21E8 Click to watch"));
menu.addMenuClickHandler(7, (pl, slot, itemstack, action) -> { menu.addMenuClickHandler(7, (pl, slot, itemstack, action) -> {
pl.closeInventory(); pl.closeInventory();
pl.sendMessage(""); ChatUtils.sendURL(pl, Slimefun.getItemConfig().getString(item.getID() + ".youtube"));
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(item.getID() + ".youtube")));
pl.sendMessage("");
return false; return false;
}); });
} catch (Exception x) { } catch (Exception x) {

View File

@ -15,13 +15,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem; import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
import io.github.thebusybiscuit.slimefun4.core.services.github.Contributor; import io.github.thebusybiscuit.slimefun4.core.services.github.Contributor;
import io.github.thebusybiscuit.slimefun4.core.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.core.utils.ChatUtils;
import io.github.thebusybiscuit.slimefun4.core.utils.NumberUtils; import io.github.thebusybiscuit.slimefun4.core.utils.NumberUtils;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunGuide;
import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;

View File

@ -16,9 +16,8 @@ public class ContributionsConnector extends GitHubConnector {
private static final List<String> blacklist = Arrays.asList( private static final List<String> blacklist = Arrays.asList(
"invalid-email-address", "invalid-email-address",
"renovate-bot", "renovate-bot",
"ImgBotApp",
"TheBusyBot", "TheBusyBot",
"imgbot" "imgbot[bot]"
); );
// Matches a GitHub name with a Minecraft name. // Matches a GitHub name with a Minecraft name.

View File

@ -78,6 +78,7 @@ public class GitHubService {
for (JsonElement elem : array) { for (JsonElement elem : array) {
JsonObject obj = elem.getAsJsonObject(); JsonObject obj = elem.getAsJsonObject();
if (obj.has("pull_request")) prCount++; if (obj.has("pull_request")) prCount++;
else issueCount++; else issueCount++;
} }

View File

@ -0,0 +1,61 @@
package io.github.thebusybiscuit.slimefun4.core.services.github;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import io.github.thebusybiscuit.cscorelib2.players.MinecraftAccount;
import io.github.thebusybiscuit.cscorelib2.players.MinecraftAccount.TooManyRequestsException;
public class GitHubTask implements Runnable {
private final GitHubService gitHubService;
public GitHubTask(GitHubService github) {
gitHubService = github;
}
@Override
public void run() {
gitHubService.getConnectors().forEach(GitHubConnector::pullFile);
// Store all queried usernames to prevent 429 responses for pinging the
// same URL twice in one run.
Map<String, String> skins = new HashMap<>();
for (Contributor contributor : gitHubService.getContributors().values()) {
if (!contributor.hasTexture()) {
try {
if (skins.containsKey(contributor.getMinecraftName())) {
contributor.setTexture(Optional.of(skins.get(contributor.getMinecraftName())));
}
else {
contributor.setTexture(grabTexture(skins, contributor.getMinecraftName()));
}
}
catch(IllegalArgumentException x) {
// There cannot be a texture found because it is not a valid MC username
contributor.setTexture(Optional.empty());
}
catch(TooManyRequestsException x) {
break;
}
}
}
}
private Optional<String> grabTexture(Map<String, String> skins, String username) throws TooManyRequestsException {
Optional<UUID> uuid = MinecraftAccount.getUUID(username);
if (uuid.isPresent()) {
Optional<String> skin = MinecraftAccount.getSkin(uuid.get());
skins.put(username, skin.orElse(""));
return skin;
}
else {
return Optional.empty();
}
}
}

View File

@ -1,4 +1,4 @@
package me.mrCookieSlime.Slimefun.GEO.resources; package io.github.thebusybiscuit.slimefun4.implementation.geo.resources;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -25,7 +25,7 @@ public class NetherIceResource implements OreGenResource {
@Override @Override
public String getMeasurementUnit() { public String getMeasurementUnit() {
return "Blocks"; return "Block(s)";
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package me.mrCookieSlime.Slimefun.GEO.resources; package io.github.thebusybiscuit.slimefun4.implementation.geo.resources;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -10,10 +11,10 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
public class OilResource implements OreGenResource { public class OilResource implements OreGenResource {
private final Random random = new Random();
@Override @Override
public int getDefaultSupply(Biome biome) { public int getDefaultSupply(Biome biome) {
Random random = ThreadLocalRandom.current();
switch (biome) { switch (biome) {
case SNOWY_BEACH: case SNOWY_BEACH:
case STONE_SHORE: case STONE_SHORE:
@ -55,6 +56,13 @@ public class OilResource implements OreGenResource {
case DEEP_OCEAN: case DEEP_OCEAN:
case OCEAN: case OCEAN:
case COLD_OCEAN:
case DEEP_COLD_OCEAN:
case DEEP_FROZEN_OCEAN:
case DEEP_LUKEWARM_OCEAN:
case DEEP_WARM_OCEAN:
case LUKEWARM_OCEAN:
case WARM_OCEAN:
return random.nextInt(62) + 24; return random.nextInt(62) + 24;
case SWAMP: case SWAMP:
@ -78,7 +86,7 @@ public class OilResource implements OreGenResource {
@Override @Override
public String getMeasurementUnit() { public String getMeasurementUnit() {
return "Buckets"; return "Bucket(s)";
} }
@Override @Override

View File

@ -0,0 +1,73 @@
package io.github.thebusybiscuit.slimefun4.implementation.geo.resources;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.Slimefun.GEO.OreGenResource;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
public class SaltResource implements OreGenResource {
@Override
public int getDefaultSupply(Biome biome) {
Random random = ThreadLocalRandom.current();
switch (biome) {
case SNOWY_BEACH:
case STONE_SHORE:
case BEACH:
case DESERT_LAKES:
case RIVER:
case ICE_SPIKES:
case FROZEN_RIVER:
return random.nextInt(40) + 3;
case DEEP_OCEAN:
case OCEAN:
case COLD_OCEAN:
case DEEP_COLD_OCEAN:
case DEEP_FROZEN_OCEAN:
case DEEP_LUKEWARM_OCEAN:
case DEEP_WARM_OCEAN:
case FROZEN_OCEAN:
case LUKEWARM_OCEAN:
case WARM_OCEAN:
return random.nextInt(60) + 24;
case SWAMP:
case SWAMP_HILLS:
return random.nextInt(20) + 4;
case THE_END:
case NETHER:
return 0;
default:
return random.nextInt(6) + 4;
}
}
@Override
public String getName() {
return "Salt";
}
@Override
public ItemStack getIcon() {
return SlimefunItems.SALT.clone();
}
@Override
public String getMeasurementUnit() {
return "Crystal(s)";
}
@Override
public boolean isLiquid() {
return false;
}
}

View File

@ -1,6 +1,7 @@
package me.mrCookieSlime.Slimefun.GEO.resources; package io.github.thebusybiscuit.slimefun4.implementation.geo.resources;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -10,10 +11,10 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
public class UraniumResource implements OreGenResource { public class UraniumResource implements OreGenResource {
private final Random random = new Random();
@Override @Override
public int getDefaultSupply(Biome biome) { public int getDefaultSupply(Biome biome) {
Random random = ThreadLocalRandom.current();
switch (biome) { switch (biome) {
case THE_END: case THE_END:
case END_BARRENS: case END_BARRENS:
@ -38,7 +39,7 @@ public class UraniumResource implements OreGenResource {
@Override @Override
public String getMeasurementUnit() { public String getMeasurementUnit() {
return "Pieces"; return "Piece(s)";
} }
@Override @Override

View File

@ -43,9 +43,11 @@ public final class GEOScanner {
int supply = OreGenSystem.getSupplies(resource, chunk, true); int supply = OreGenSystem.getSupplies(resource, chunk, true);
ItemStack item = new CustomItem(resource.getItem(), "&r" + resource.getName(), "&8\u21E8 &e" + supply + ' ' + resource.getMeasurementUnit()); ItemStack item = new CustomItem(resource.getItem(), "&r" + resource.getName(), "&8\u21E8 &e" + supply + ' ' + resource.getMeasurementUnit());
if (supply > 1) { if (supply > 1) {
item.setAmount(supply > item.getMaxStackSize() ? item.getMaxStackSize(): supply); item.setAmount(supply > item.getMaxStackSize() ? item.getMaxStackSize(): supply);
} }
menu.addItem(index, item, (pl, slot, stack, action) -> false); menu.addItem(index, item, (pl, slot, stack, action) -> false);
index++; index++;

View File

@ -828,6 +828,9 @@ public final class SlimefunItems {
public static final ItemStack TOTEM_OF_UNDYING = new ItemStack(Material.TOTEM_OF_UNDYING); public static final ItemStack TOTEM_OF_UNDYING = new ItemStack(Material.TOTEM_OF_UNDYING);
public static final ItemStack MAGNESIUM_SALT = new SlimefunItemStack("MAGNESIUM_SALT", Material.SUGAR, "&cMagnesium Salt", "", "&7A special type of fuel that can be", "&7used in a Magnesium-powered Generator");
public static final ItemStack MAGNESIUM_GENERATOR = new SlimefunItemStack("MAGNESIUM_GENERATOR", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ==", "&cMagnesium-powered Generator", "", MachineTier.MEDIUM.and(MachineType.GENERATOR), "&8\u21E8 &e\u26A1 &7128 J Buffer", "&8\u21E8 &e\u26A1 &736 J/s");
static { static {
INFUSED_ELYTRA.addUnsafeEnchantment(Enchantment.MENDING, 1); INFUSED_ELYTRA.addUnsafeEnchantment(Enchantment.MENDING, 1);
} }

View File

@ -4,13 +4,17 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import me.mrCookieSlime.Slimefun.SlimefunGuide;
import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Lists.Categories;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
/** /**
* Statically handles categories. * Statically handles categories.
@ -25,9 +29,9 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
*/ */
public class Category { public class Category {
private ItemStack item; private final ItemStack item;
private List<SlimefunItem> items; private final List<SlimefunItem> items;
private int tier; private final int tier;
/** /**
* Constructs a Category with the given display item. * Constructs a Category with the given display item.
@ -132,22 +136,6 @@ public class Category {
return this.items; return this.items;
} }
/**
* Attempts to get the category with the given display item.
*
* @param item the display item of the category to get
* @return Category if found, or null
*
* @since 4.0
*/
@Deprecated
public static Category getByItem(ItemStack item) {
for (Category c: list()) {
if (c.getItem().isSimilar(item)) return c;
}
return null;
}
/** /**
* Returns the tier of this category. * Returns the tier of this category.
* *

View File

@ -86,7 +86,8 @@ public class LockedCategory extends Category {
* @see #removeParent(Category) * @see #removeParent(Category)
*/ */
public void addParent(Category category) { public void addParent(Category category) {
if (category == this) throw new IllegalArgumentException("Category '" + this.getItem().getItemMeta().getDisplayName() + "' cannot be a parent of itself."); if (category == this || category == null) throw new IllegalArgumentException("Category '" + this.getItem().getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent.");
this.parents.add(category); this.parents.add(category);
} }
@ -126,6 +127,7 @@ public class LockedCategory extends Category {
return false; return false;
} }
} }
return true; return true;
} }
} }

View File

@ -34,7 +34,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
*/ */
public class Research { public class Research {
private static final int[] research_progress = {23, 44, 57, 92}; private static final int[] RESEARCH_PROGRESS = {23, 44, 57, 92};
private int id; private int id;
private String name; private String name;
@ -94,32 +94,6 @@ public class Research {
return name; return name;
} }
/**
* Gets the cost in XP levels to unlock the research.
*
* @return The cost in XP levels of the research
*
* @since 4.0
* @deprecated Moved to {@link #getCost()}
*/
@Deprecated
public int getLevel() {
return getCost();
}
/**
* Sets the cost in XP levels to unlock the research.
*
* @param level Cost in XP levels
*
* @since 4.0
* @deprecated Moved to {@link #setCost(int)}
*/
@Deprecated
public void setLevel(int level) {
setCost(level);
}
/** /**
* Gets the cost in XP levels to unlock the research. * Gets the cost in XP levels to unlock the research.
* *
@ -258,19 +232,19 @@ public class Research {
SlimefunPlugin.getUtilities().researching.add(p.getUniqueId()); SlimefunPlugin.getUtilities().researching.add(p.getUniqueId());
SlimefunPlugin.getLocal().sendMessage(p, "messages.research.start", true, msg -> msg.replace("%research%", getName())); SlimefunPlugin.getLocal().sendMessage(p, "messages.research.start", true, msg -> msg.replace("%research%", getName()));
for (int i = 1; i < research_progress.length + 1; i++) { for (int i = 1; i < RESEARCH_PROGRESS.length + 1; i++) {
int j = i; int j = i;
Slimefun.runSync(() -> { Slimefun.runSync(() -> {
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F); p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F);
SlimefunPlugin.getLocal().sendMessage(p, "messages.research.progress", true, msg -> msg.replace("%research%", getName()).replace("%progress%", research_progress[j - 1] + "%")); SlimefunPlugin.getLocal().sendMessage(p, "messages.research.progress", true, msg -> msg.replace("%research%", getName()).replace("%progress%", RESEARCH_PROGRESS[j - 1] + "%"));
}, i * 20L); }, i * 20L);
} }
Slimefun.runSync(() -> { Slimefun.runSync(() -> {
runnable.run(); runnable.run();
SlimefunPlugin.getUtilities().researching.remove(p.getUniqueId()); SlimefunPlugin.getUtilities().researching.remove(p.getUniqueId());
}, (research_progress.length + 1) * 20L); }, (RESEARCH_PROGRESS.length + 1) * 20L);
} }
} }
}); });

View File

@ -18,7 +18,7 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class SeasonalCategory extends Category { public class SeasonalCategory extends Category {
private int month = -1; private final int month;
/** /**
* The constructor for a SeasonCategory. * The constructor for a SeasonCategory.
@ -34,6 +34,11 @@ public class SeasonalCategory extends Category {
*/ */
public SeasonalCategory(int month, int tier, ItemStack item) { public SeasonalCategory(int month, int tier, ItemStack item) {
super(item, tier); super(item, tier);
if (month < 1 || month > 12) {
throw new IllegalArgumentException("There is no month no. " + month);
}
this.month = month - 1; this.month = month - 1;
} }
@ -58,7 +63,6 @@ public class SeasonalCategory extends Category {
* @see #getMonth() * @see #getMonth()
*/ */
public boolean isUnlocked() { public boolean isUnlocked() {
if (month == -1) return true;
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
return month == calendar.get(Calendar.MONTH); return month == calendar.get(Calendar.MONTH);
} }

View File

@ -15,9 +15,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> { public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> {
private int speed; private final int speed;
private int efficiency; private final int efficiency;
private int fortune; private final int fortune;
public EnhancedFurnace(int speed, int efficiency, int fortune, SlimefunItemStack item, ItemStack[] recipe) { public EnhancedFurnace(int speed, int efficiency, int fortune, SlimefunItemStack item, ItemStack[] recipe) {
super(Categories.MACHINES_1, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe); super(Categories.MACHINES_1, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe);
@ -36,11 +36,11 @@ public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> {
} }
public int getOutput() { public int getOutput() {
int fortune = this.fortune; int bonus = this.fortune;
fortune = new Random().nextInt(fortune + 2) - 1; bonus = new Random().nextInt(bonus + 2) - 1;
if (fortune <= 0) fortune = 0; if (bonus <= 0) bonus = 0;
fortune++; bonus++;
return fortune; return bonus;
} }
@Override @Override

View File

@ -6,6 +6,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
* @since 4.1.10 * @since 4.1.10
*/ */
public enum ItemState { public enum ItemState {
/** /**
* This SlimefunItem is enabled. * This SlimefunItem is enabled.
*/ */

View File

@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
public class JetBoots extends DamagableChargableItem { public class JetBoots extends DamagableChargableItem {
private double speed; private final double speed;
public JetBoots(SlimefunItemStack item, ItemStack[] recipe, double speed) { public JetBoots(SlimefunItemStack item, ItemStack[] recipe, double speed) {
super(Categories.TECH, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe, "Jet Boots"); super(Categories.TECH, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe, "Jet Boots");

View File

@ -9,7 +9,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class SlimefunArmorPiece extends SlimefunItem { public class SlimefunArmorPiece extends SlimefunItem {
private PotionEffect[] effects; private final PotionEffect[] effects;
public SlimefunArmorPiece(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) { public SlimefunArmorPiece(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) {
super(category, item, id, recipeType, recipe); super(category, item, id, recipeType, recipe);

View File

@ -8,7 +8,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class SlimefunBackpack extends SlimefunItem { public class SlimefunBackpack extends SlimefunItem {
private int size; private final int size;
public SlimefunBackpack(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public SlimefunBackpack(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);

View File

@ -12,6 +12,7 @@ public class SlimefunBow extends SlimefunItem {
super(Categories.WEAPONS, item, id, RecipeType.MAGIC_WORKBENCH, recipe); super(Categories.WEAPONS, item, id, RecipeType.MAGIC_WORKBENCH, recipe);
} }
@Deprecated
public SlimefunBow(SlimefunItemStack item, ItemStack[] recipe) { public SlimefunBow(SlimefunItemStack item, ItemStack[] recipe) {
super(Categories.WEAPONS, item, RecipeType.MAGIC_WORKBENCH, recipe); super(Categories.WEAPONS, item, RecipeType.MAGIC_WORKBENCH, recipe);
} }

View File

@ -16,9 +16,9 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayIt
public class SlimefunMachine extends SlimefunItem implements RecipeDisplayItem { public class SlimefunMachine extends SlimefunItem implements RecipeDisplayItem {
protected List<ItemStack[]> recipes; protected final List<ItemStack[]> recipes;
protected List<ItemStack> shownRecipes; protected final List<ItemStack> shownRecipes;
private BlockFace trigger; protected final BlockFace trigger;
@Deprecated @Deprecated
public SlimefunMachine(Category category, ItemStack item, String id, ItemStack[] recipe, ItemStack[] machineRecipes, Material trigger) { public SlimefunMachine(Category category, ItemStack item, String id, ItemStack[] recipe, ItemStack[] machineRecipes, Material trigger) {
@ -80,20 +80,20 @@ public class SlimefunMachine extends SlimefunItem implements RecipeDisplayItem {
@Override @Override
public void install() { public void install() {
for (ItemStack i: shownRecipes) { for (ItemStack recipeItem : shownRecipes) {
SlimefunItem item = SlimefunItem.getByItem(i); SlimefunItem item = SlimefunItem.getByItem(recipeItem);
if (item == null || !SlimefunItem.isDisabled(i)) { if (item == null || !SlimefunItem.isDisabled(recipeItem)) {
this.recipes.add(new ItemStack[] {i}); this.recipes.add(new ItemStack[] {recipeItem});
} }
} }
} }
private static Material[] convertItemStacksToMaterial(ItemStack[] items) { private static Material[] convertItemStacksToMaterial(ItemStack[] items) {
List<Material> mats = new ArrayList<>(); List<Material> mats = new ArrayList<>();
for (ItemStack i: items) { for (ItemStack item : items) {
if (i == null) mats.add(null); if (item == null) mats.add(null);
else if (i.getType() == Material.FLINT_AND_STEEL) mats.add(Material.FIRE); else if (item.getType() == Material.FLINT_AND_STEEL) mats.add(Material.FIRE);
else mats.add(i.getType()); else mats.add(item.getType());
} }
return mats.toArray(new Material[mats.size()]); return mats.toArray(new Material[mats.size()]);

View File

@ -100,6 +100,7 @@ public class Talisman extends SlimefunItem {
public void install() { public void install() {
EnderTalisman talisman = (EnderTalisman) SlimefunItem.getByItem(upgrade()); EnderTalisman talisman = (EnderTalisman) SlimefunItem.getByItem(upgrade());
Research research = Research.getByID(112); Research research = Research.getByID(112);
if (talisman != null) { if (talisman != null) {
Slimefun.addOfficialWikiPage(talisman.getID(), "Talismans"); Slimefun.addOfficialWikiPage(talisman.getID(), "Talismans");
if (research != null) talisman.bindToResearch(research); if (research != null) talisman.bindToResearch(research);

View File

@ -27,6 +27,7 @@ public class VanillaItem extends SlimefunItem {
*/ */
public VanillaItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) { public VanillaItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, id, recipeType, recipe); super(category, item, id, recipeType, recipe);
useableInWorkbench = true; useableInWorkbench = true;
} }
} }

View File

@ -4,9 +4,9 @@ import org.bukkit.inventory.ItemStack;
public class MachineFuel { public class MachineFuel {
private int ticks; private final int ticks;
private ItemStack fuel; private final ItemStack fuel;
private ItemStack output; private final ItemStack output;
public MachineFuel(int seconds, ItemStack fuel) { public MachineFuel(int seconds, ItemStack fuel) {
this.ticks = seconds * 2; this.ticks = seconds * 2;

View File

@ -77,7 +77,7 @@ public class ExplosivePickaxe extends SimpleSlimefunItem<BlockBreakHandler> impl
b.breakNaturally(); b.breakNaturally();
} }
else { else {
for (ItemStack drop: b.getDrops()) { for (ItemStack drop : b.getDrops(getItem())) {
b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE) ? new CustomItem(drop, fortune): drop); b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE) ? new CustomItem(drop, fortune): drop);
} }
b.setType(Material.AIR); b.setType(Material.AIR);

View File

@ -52,7 +52,7 @@ public class ExplosiveShovel extends SimpleSlimefunItem<BlockBreakHandler> imple
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
for (ItemStack drop: b.getDrops()) { for (ItemStack drop : b.getDrops(getItem())) {
if (drop != null) { if (drop != null) {
b.getWorld().dropItemNaturally(b.getLocation(), drop); b.getWorld().dropItemNaturally(b.getLocation(), drop);
} }

View File

@ -33,7 +33,7 @@ public class HerculesPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
drops.add(new CustomItem(SlimefunItems.GOLD_DUST, 2)); drops.add(new CustomItem(SlimefunItems.GOLD_DUST, 2));
} }
else { else {
for (ItemStack drop: e.getBlock().getDrops()) { for (ItemStack drop : e.getBlock().getDrops(getItem())) {
drops.add(new CustomItem(drop, drop.getAmount() * 2)); drops.add(new CustomItem(drop, drop.getAmount() * 2));
} }
} }

View File

@ -44,7 +44,7 @@ public class LumberAxe extends SimpleSlimefunItem<BlockBreakHandler> implements
if (SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK)) { if (SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK)) {
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
for (ItemStack drop: b.getDrops()) { for (ItemStack drop : b.getDrops(getItem())) {
b.getWorld().dropItemNaturally(b.getLocation(), drop); b.getWorld().dropItemNaturally(b.getLocation(), drop);
} }

View File

@ -40,7 +40,7 @@ public class PickaxeOfVeinMining extends SimpleSlimefunItem<BlockBreakHandler> {
if (SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) { if (SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
for (ItemStack drop: b.getDrops()) { for (ItemStack drop : b.getDrops(getItem())) {
b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop: new CustomItem(drop, fortune)); b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop: new CustomItem(drop, fortune));
} }

View File

@ -35,7 +35,7 @@ public class SmeltersPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
if (BlockStorage.hasBlockInfo(e.getBlock())) return true; if (BlockStorage.hasBlockInfo(e.getBlock())) return true;
if (e.getBlock().getType() == Material.PLAYER_HEAD) return true; if (e.getBlock().getType() == Material.PLAYER_HEAD) return true;
Collection<ItemStack> blockDrops = e.getBlock().getDrops(); Collection<ItemStack> blockDrops = e.getBlock().getDrops(getItem());
for (ItemStack drop : blockDrops) { for (ItemStack drop : blockDrops) {
if (drop != null) { if (drop != null) {
ItemStack output = drop; ItemStack output = drop;

View File

@ -2,7 +2,6 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Nameable; import org.bukkit.Nameable;
@ -11,7 +10,7 @@ import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BlockStateMeta;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Category;
@ -54,9 +53,11 @@ public class BlockPlacer extends SimpleSlimefunItem<AutonomousMachineHandler> {
block.setType(e.getItem().getType()); block.setType(e.getItem().getType());
BlockStorage.store(block, sfItem.getID()); BlockStorage.store(block, sfItem.getID());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, e.getItem().getType()); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, e.getItem().getType());
if (d.getInventory().containsAtLeast(e.getItem(), 2)) d.getInventory().removeItem(new CustomItem(e.getItem(), 1)); if (d.getInventory().containsAtLeast(e.getItem(), 2)) {
d.getInventory().removeItem(new CustomItem(e.getItem(), 1));
}
else { else {
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> d.getInventory().removeItem(e.getItem()), 2L); Slimefun.runSync(() -> d.getInventory().removeItem(e.getItem()), 2L);
} }
} }
} }
@ -76,14 +77,16 @@ public class BlockPlacer extends SimpleSlimefunItem<AutonomousMachineHandler> {
//Changing the inventory of the block based on the inventory of the block's itemstack (Currently only applies to shulker boxes) //Changing the inventory of the block based on the inventory of the block's itemstack (Currently only applies to shulker boxes)
//Inventory has to be changed after blockState.update() as updating it will create a different Inventory for the object //Inventory has to be changed after blockState.update() as updating it will create a different Inventory for the object
if (block.getState() instanceof BlockInventoryHolder) { if (block.getState() instanceof BlockInventoryHolder) {
((BlockInventoryHolder) block.getState()).getInventory().setContents(((BlockInventoryHolder) itemBlockState).getInventory().getContents());; ((BlockInventoryHolder) block.getState()).getInventory().setContents(((BlockInventoryHolder) itemBlockState).getInventory().getContents());
} }
} }
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, e.getItem().getType()); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, e.getItem().getType());
if (d.getInventory().containsAtLeast(e.getItem(), 2)) d.getInventory().removeItem(new CustomItem(e.getItem(), 1)); if (d.getInventory().containsAtLeast(e.getItem(), 2)) {
d.getInventory().removeItem(new CustomItem(e.getItem(), 1));
}
else { else {
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> d.getInventory().removeItem(e.getItem()), 2L); Slimefun.runSync(() -> d.getInventory().removeItem(e.getItem()), 2L);
} }
} }
} }
@ -96,6 +99,6 @@ public class BlockPlacer extends SimpleSlimefunItem<AutonomousMachineHandler> {
@Override @Override
public void postRegister() { public void postRegister() {
List<?> list = (List<?>) Slimefun.getItemValue(getID(), "unplaceable-blocks"); List<?> list = (List<?>) Slimefun.getItemValue(getID(), "unplaceable-blocks");
blacklist = list.toArray(new String[list.size()]); blacklist = list.toArray(new String[0]);
} }
} }

View File

@ -66,8 +66,8 @@ public class Composter extends SlimefunGadget {
String id = BlockStorage.checkID(e.getClickedBlock()); String id = BlockStorage.checkID(e.getClickedBlock());
if (id != null && id.equals(getID())) { if (id != null && id.equals(getID())) {
if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, e.getClickedBlock().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) { if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, e.getClickedBlock().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) {
final ItemStack input = p.getInventory().getItemInMainHand(); ItemStack input = p.getInventory().getItemInMainHand();
final Block b = e.getClickedBlock(); Block b = e.getClickedBlock();
SlimefunItem machine = SlimefunItem.getByID(id); SlimefunItem machine = SlimefunItem.getByID(id);
for (ItemStack convert : RecipeType.getRecipeInputs(machine)) { for (ItemStack convert : RecipeType.getRecipeInputs(machine)) {
@ -79,6 +79,7 @@ public class Composter extends SlimefunGadget {
for (int i = 1; i < 12; i++) { for (int i = 1; i < 12; i++) {
int j = i; int j = i;
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> { Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
if (j < 11) { if (j < 11) {
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, input.getType().isBlock() ? input.getType() : Material.HAY_BLOCK); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, input.getType().isBlock() ? input.getType() : Material.HAY_BLOCK);

View File

@ -85,12 +85,14 @@ public class Crucible extends SlimefunGadget {
level -= 8; level -= 8;
if (level == 0) { if (level == 0) {
block.getWorld().playSound(block.getLocation(), water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1F, 1F); block.getWorld().playSound(block.getLocation(), water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1F, 1F);
} else { }
else {
int finalLevel = 7 - level; int finalLevel = 7 - level;
Slimefun.runSync(() -> runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, finalLevel), 50L); Slimefun.runSync(() -> runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, finalLevel), 50L);
} }
return true; return true;
} else if (block.getType() == (water ? Material.LAVA : Material.WATER)) { }
else if (block.getType() == (water ? Material.LAVA : Material.WATER)) {
int level = ((Levelled) block.getBlockData()).getLevel(); int level = ((Levelled) block.getBlockData()).getLevel();
block.setType(level == 0 || level == 8 ? Material.OBSIDIAN : Material.STONE); block.setType(level == 0 || level == 8 ? Material.OBSIDIAN : Material.STONE);
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F); block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
@ -136,11 +138,13 @@ public class Crucible extends SlimefunGadget {
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F); block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F);
return; return;
} }
block.getWorld().playSound(block.getLocation(), sound, 1F, 1F); block.getWorld().playSound(block.getLocation(), sound, 1F, 1F);
int level = 8 - times; int level = 8 - times;
Levelled le = (Levelled) block.getBlockData(); Levelled le = (Levelled) block.getBlockData();
le.setLevel(level); le.setLevel(level);
block.setBlockData(le, false); block.setBlockData(le, false);
if (times < 8) if (times < 8)
Slimefun.runSync(() -> runPostTask(block, sound, times + 1), 50L); Slimefun.runSync(() -> runPostTask(block, sound, times + 1), 50L);
} }

View File

@ -34,7 +34,7 @@ public class InfusedHopper extends SimpleSlimefunItem<BlockTicker> {
return new BlockTicker() { return new BlockTicker() {
@Override @Override
public void tick(Block b, SlimefunItem item, Config data) { public void tick(Block b, SlimefunItem sfItem, Config data) {
if (b.getType() != Material.HOPPER) { if (b.getType() != Material.HOPPER) {
// we're no longer a hopper, we were probably destroyed. skipping this tick. // we're no longer a hopper, we were probably destroyed. skipping this tick.
BlockStorage.clearBlockInfo(b); BlockStorage.clearBlockInfo(b);
@ -44,9 +44,9 @@ public class InfusedHopper extends SimpleSlimefunItem<BlockTicker> {
Location l = b.getLocation().add(0.5, 1.2, 0.5); Location l = b.getLocation().add(0.5, 1.2, 0.5);
boolean sound = false; boolean sound = false;
for (Entity n: b.getWorld().getNearbyEntities(l, 3.5D, 3.5D, 3.5D, n -> n instanceof Item && n.isValid() && !n.hasMetadata("no_pickup") && n.getLocation().distanceSquared(l) > 0.1)) { for (Entity item : b.getWorld().getNearbyEntities(l, 3.5D, 3.5D, 3.5D, n -> n instanceof Item && n.isValid() && !n.hasMetadata("no_pickup") && n.getLocation().distanceSquared(l) > 0.1)) {
n.setVelocity(new Vector(0, 0.1, 0)); item.setVelocity(new Vector(0, 0.1, 0));
n.teleport(l); item.teleport(l);
sound = true; sound = true;
} }

View File

@ -48,6 +48,7 @@ public class TrashCan extends SlimefunItem implements InventoryBlock {
@Override @Override
public void tick(Block b, SlimefunItem item, Config data) { public void tick(Block b, SlimefunItem item, Config data) {
BlockMenu menu = BlockStorage.getInventory(b); BlockMenu menu = BlockStorage.getInventory(b);
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
menu.replaceExistingItem(slot, null); menu.replaceExistingItem(slot, null);
} }

View File

@ -73,11 +73,7 @@ public class AnimalGrowthAccelerator extends SlimefunItem implements InventoryBl
@Override @Override
public void tick(Block b, SlimefunItem sf, Config data) { public void tick(Block b, SlimefunItem sf, Config data) {
try {
AnimalGrowthAccelerator.this.tick(b); AnimalGrowthAccelerator.this.tick(b);
} catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while ticking an Animal Growth Accelerator for Slimefun " + Slimefun.getVersion(), x);
}
} }
@Override @Override

View File

@ -99,6 +99,7 @@ public abstract class AutoAnvil extends AContainer {
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1)); menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
} }
processing.put(b, recipe); processing.put(b, recipe);
progress.put(b, recipe.getTicks()); progress.put(b, recipe.getTicks());
} }

View File

@ -81,7 +81,7 @@ public class AutoDisenchanter extends AContainer {
else { else {
MachineRecipe recipe = null; MachineRecipe recipe = null;
Map<Enchantment, Integer> enchantments = new HashMap<>(); Map<Enchantment, Integer> enchantments = new HashMap<>();
Set<ItemEnchantment> enchantments2 = new HashSet<>(); Set<ItemEnchantment> emeraldEnchantments = new HashSet<>();
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]); ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]);
@ -108,15 +108,15 @@ public class AutoDisenchanter extends AContainer {
if (item != null && target != null && target.getType() == Material.BOOK) { if (item != null && target != null && target.getType() == Material.BOOK) {
int amount = 0; int amount = 0;
for (Map.Entry<Enchantment, Integer> e : item.getEnchantments().entrySet()) { for (Map.Entry<Enchantment, Integer> entry : item.getEnchantments().entrySet()) {
enchantments.put(e.getKey(), e.getValue()); enchantments.put(entry.getKey(), entry.getValue());
amount++; amount++;
} }
if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) { if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) {
for (ItemEnchantment enchantment : EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) { for (ItemEnchantment enchantment : EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
amount++; amount++;
enchantments2.add(enchantment); emeraldEnchantments.add(enchantment);
} }
} }
@ -136,16 +136,16 @@ public class AutoDisenchanter extends AContainer {
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta(); EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta();
for (Map.Entry<Enchantment,Integer> e : enchantments.entrySet()) { for (Map.Entry<Enchantment,Integer> entry : enchantments.entrySet()) {
newItem.removeEnchantment(e.getKey()); newItem.removeEnchantment(entry.getKey());
meta.addStoredEnchant(e.getKey(), e.getValue(), true); meta.addStoredEnchant(entry.getKey(), entry.getValue(), true);
} }
book.setItemMeta(meta); book.setItemMeta(meta);
for (ItemEnchantment e : enchantments2) { for (ItemEnchantment ench : emeraldEnchantments) {
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(book, e.getEnchantment(), e.getLevel()); EmeraldEnchants.getInstance().getRegistry().applyEnchantment(book, ench.getEnchantment(), ench.getLevel());
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, e.getEnchantment(), 0); EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, ench.getEnchantment(), 0);
} }
recipe = new MachineRecipe(100 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, book}); recipe = new MachineRecipe(100 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, book});

View File

@ -85,7 +85,7 @@ public class AutoEnchanter extends AContainer {
// Enchant // Enchant
if (item != null && item.getType() == Material.ENCHANTED_BOOK && target != null) { if (item != null && item.getType() == Material.ENCHANTED_BOOK && target != null) {
Map<Enchantment, Integer> enchantments = new HashMap<>(); Map<Enchantment, Integer> enchantments = new HashMap<>();
Set<ItemEnchantment> enchantments2 = new HashSet<>(); Set<ItemEnchantment> emeraldEnchantments = new HashSet<>();
int amount = 0; int amount = 0;
int specialAmount = 0; int specialAmount = 0;
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta(); EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
@ -102,7 +102,7 @@ public class AutoEnchanter extends AContainer {
if (EmeraldEnchants.getInstance().getRegistry().isApplicable(target, enchantment.getEnchantment()) && EmeraldEnchants.getInstance().getRegistry().getEnchantmentLevel(target, enchantment.getEnchantment().getName()) < enchantment.getLevel()) { if (EmeraldEnchants.getInstance().getRegistry().isApplicable(target, enchantment.getEnchantment()) && EmeraldEnchants.getInstance().getRegistry().getEnchantmentLevel(target, enchantment.getEnchantment().getName()) < enchantment.getLevel()) {
amount++; amount++;
specialAmount++; specialAmount++;
enchantments2.add(enchantment); emeraldEnchantments.add(enchantment);
} }
} }
specialAmount += EmeraldEnchants.getInstance().getRegistry().getEnchantments(target).size(); specialAmount += EmeraldEnchants.getInstance().getRegistry().getEnchantments(target).size();
@ -110,12 +110,13 @@ public class AutoEnchanter extends AContainer {
if (amount > 0 && specialAmount <= SlimefunPlugin.getSettings().emeraldEnchantsLimit) { if (amount > 0 && specialAmount <= SlimefunPlugin.getSettings().emeraldEnchantsLimit) {
ItemStack newItem = target.clone(); ItemStack newItem = target.clone();
for (Map.Entry<Enchantment, Integer> e: enchantments.entrySet()) {
newItem.addUnsafeEnchantment(e.getKey(), e.getValue()); for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
newItem.addUnsafeEnchantment(entry.getKey(), entry.getValue());
} }
for (ItemEnchantment e: enchantments2) { for (ItemEnchantment ench: emeraldEnchantments) {
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, e.getEnchantment(), e.getLevel()); EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, ench.getEnchantment(), ench.getLevel());
} }
recipe = new MachineRecipe(75 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, new ItemStack(Material.BOOK)}); recipe = new MachineRecipe(75 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, new ItemStack(Material.BOOK)});

View File

@ -39,6 +39,7 @@ public class ChargingBench extends AContainer {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return; if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
BlockMenu menu = BlockStorage.getInventory(b); BlockMenu menu = BlockStorage.getInventory(b);
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
ItemStack stack = menu.getItemInSlot(slot); ItemStack stack = menu.getItemInSlot(slot);
if (ItemEnergy.getMaxEnergy(stack) > 0) { if (ItemEnergy.getMaxEnergy(stack) > 0) {
@ -46,6 +47,7 @@ public class ChargingBench extends AContainer {
ChargableBlock.addCharge(b, -getEnergyConsumption()); ChargableBlock.addCharge(b, -getEnergyConsumption());
float rest = ItemEnergy.addStoredEnergy(stack, getEnergyConsumption() / 2F); float rest = ItemEnergy.addStoredEnergy(stack, getEnergyConsumption() / 2F);
if (rest > 0F) { if (rest > 0F) {
if (menu.fits(stack, getOutputSlots())) { if (menu.fits(stack, getOutputSlots())) {
menu.pushItem(stack, getOutputSlots()); menu.pushItem(stack, getOutputSlots());

View File

@ -88,11 +88,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem implements Inve
@Override @Override
public void tick(Block b, SlimefunItem sf, Config data) { public void tick(Block b, SlimefunItem sf, Config data) {
try {
CropGrowthAccelerator.this.tick(b); CropGrowthAccelerator.this.tick(b);
} catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while ticking a Crop Growth Accelerator for Slimefun " + Slimefun.getVersion(), x);
}
} }
@Override @Override

View File

@ -73,8 +73,8 @@ public abstract class ElectricDustWasher extends AContainer {
if (!SlimefunPlugin.getSettings().legacyDustWasher) { if (!SlimefunPlugin.getSettings().legacyDustWasher) {
boolean emptySlot = false; boolean emptySlot = false;
for (int output_slot: getOutputSlots()) { for (int outputSlot : getOutputSlots()) {
if (menu.getItemInSlot(output_slot) == null) { if (menu.getItemInSlot(outputSlot) == null) {
emptySlot = true; emptySlot = true;
break; break;
} }

View File

@ -31,8 +31,8 @@ public abstract class ElectricFurnace extends AContainer {
} }
//Bukkit Recipe Iterator does not seem to include _LOG's of any type for charcoal... Manually adding them all. //Bukkit Recipe Iterator does not seem to include _LOG's of any type for charcoal... Manually adding them all.
for (Material mat:Tag.LOGS.getValues()) { for (Material log : Tag.LOGS.getValues()) {
registerRecipe(4, new ItemStack[] {new ItemStack(mat,1)}, new ItemStack[] {new ItemStack(Material.CHARCOAL, 1)}); registerRecipe(4, new ItemStack[] {new ItemStack(log, 1)}, new ItemStack[] {new ItemStack(Material.CHARCOAL, 1)});
} }
} }

View File

@ -20,6 +20,7 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
@ -31,10 +32,10 @@ public abstract class ElectricSmeltery extends AContainer {
private static final int[] border_in = {0, 1, 2, 3, 9, 12, 18, 21, 27, 30, 36, 37, 38, 39}; private static final int[] border_in = {0, 1, 2, 3, 9, 12, 18, 21, 27, 30, 36, 37, 38, 39};
private static final int[] border_out = {14, 15, 16, 17, 23, 26, 32, 33, 34, 35}; private static final int[] border_out = {14, 15, 16, 17, 23, 26, 32, 33, 34, 35};
public ElectricSmeltery(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) { public ElectricSmeltery(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, name, recipeType, recipe); super(category, item, recipeType, recipe);
new BlockMenuPreset(name, getInventoryTitle()) { new BlockMenuPreset(getID(), getInventoryTitle()) {
@Override @Override
public void init() { public void init() {
@ -68,7 +69,6 @@ public abstract class ElectricSmeltery extends AContainer {
} }
else { else {
Collections.sort(slots, new RecipeSorter(menu)); Collections.sort(slots, new RecipeSorter(menu));
int[] array = new int[slots.size()]; int[] array = new int[slots.size()];
for (int i = 0; i < slots.size(); i++) { for (int i = 0; i < slots.size(); i++) {
@ -80,8 +80,9 @@ public abstract class ElectricSmeltery extends AContainer {
} }
}; };
registerBlockHandler(name, (p, b, tool, reason) -> { registerBlockHandler(getID(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
if (inv.getItemInSlot(slot) != null) { if (inv.getItemInSlot(slot) != null) {
@ -89,6 +90,7 @@ public abstract class ElectricSmeltery extends AContainer {
inv.replaceExistingItem(slot, null); inv.replaceExistingItem(slot, null);
} }
} }
for (int slot : getOutputSlots()) { for (int slot : getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) { if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
@ -96,6 +98,7 @@ public abstract class ElectricSmeltery extends AContainer {
} }
} }
} }
progress.remove(b); progress.remove(b);
processing.remove(b); processing.remove(b);
return true; return true;

View File

@ -92,6 +92,7 @@ public class FluidPump extends SlimefunItem implements InventoryBlock {
if (output != null && ChargableBlock.getCharge(b) >= energyConsumption) { if (output != null && ChargableBlock.getCharge(b) >= energyConsumption) {
BlockMenu menu = BlockStorage.getInventory(b); BlockMenu menu = BlockStorage.getInventory(b);
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) { if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) {
if (!menu.fits(output, getOutputSlots())) return; if (!menu.fits(output, getOutputSlots())) return;

View File

@ -72,7 +72,6 @@ public abstract class HeatedPressureChamber extends AContainer {
} }
else { else {
Collections.sort(slots, new RecipeSorter(menu)); Collections.sort(slots, new RecipeSorter(menu));
int[] array = new int[slots.size()]; int[] array = new int[slots.size()];
for (int i = 0; i < slots.size(); i++) { for (int i = 0; i < slots.size(); i++) {
@ -96,6 +95,7 @@ public abstract class HeatedPressureChamber extends AContainer {
registerRecipe(90, new ItemStack[] {SlimefunItems.PLUTONIUM, SlimefunItems.URANIUM}, new ItemStack[] {SlimefunItems.BOOSTED_URANIUM}); registerRecipe(90, new ItemStack[] {SlimefunItems.PLUTONIUM, SlimefunItems.URANIUM}, new ItemStack[] {SlimefunItems.BOOSTED_URANIUM});
registerRecipe(60, new ItemStack[] {SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM}, new ItemStack[] {new CustomItem(SlimefunItems.ENRICHED_NETHER_ICE, 4)}); registerRecipe(60, new ItemStack[] {SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM}, new ItemStack[] {new CustomItem(SlimefunItems.ENRICHED_NETHER_ICE, 4)});
registerRecipe(45, new ItemStack[] {SlimefunItems.ENRICHED_NETHER_ICE}, new ItemStack[] {new CustomItem(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8)}); registerRecipe(45, new ItemStack[] {SlimefunItems.ENRICHED_NETHER_ICE}, new ItemStack[] {new CustomItem(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8)});
registerRecipe(8, new ItemStack[] {SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT}, new ItemStack[] {SlimefunItems.MAGNESIUM_SALT});
} }
@Override @Override
@ -153,7 +153,7 @@ public abstract class HeatedPressureChamber extends AContainer {
} }
else { else {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " ")); menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
pushItems(b, processing.get(b).getOutput()); menu.pushItem(processing.get(b).getOutput()[0], getOutputSlots());
progress.remove(b); progress.remove(b);
processing.remove(b); processing.remove(b);
@ -164,7 +164,7 @@ public abstract class HeatedPressureChamber extends AContainer {
MachineRecipe recipe = findRecipe(menu, found); MachineRecipe recipe = findRecipe(menu, found);
if (recipe != null) { if (recipe != null) {
if (!fits(b, recipe.getOutput())) return; if (!menu.fits(recipe.getOutput()[0], getOutputSlots())) return;
for (Map.Entry<Integer, Integer> entry : found.entrySet()) { for (Map.Entry<Integer, Integer> entry : found.entrySet()) {
menu.replaceExistingItem(entry.getKey(), InvUtils.decreaseItem(menu.getItemInSlot(entry.getKey()), entry.getValue())); menu.replaceExistingItem(entry.getKey(), InvUtils.decreaseItem(menu.getItemInSlot(entry.getKey()), entry.getValue()));

View File

@ -19,6 +19,7 @@ import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.utils.MachineHelper; import me.mrCookieSlime.Slimefun.utils.MachineHelper;
public abstract class Refinery extends AContainer implements RecipeDisplayItem { public abstract class Refinery extends AContainer implements RecipeDisplayItem {
@ -49,21 +50,25 @@ public abstract class Refinery extends AContainer implements RecipeDisplayItem {
@Override @Override
protected void tick(Block b) { protected void tick(Block b) {
BlockMenu menu = BlockStorage.getInventory(b);
if (isProcessing(b)) { if (isProcessing(b)) {
int timeleft = progress.get(b); int timeleft = progress.get(b);
if (timeleft > 0) { if (timeleft > 0) {
MachineHelper.updateProgressbar(BlockStorage.getInventory(b), 22, timeleft, processing.get(b).getTicks(), getProgressBar()); MachineHelper.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
if (ChargableBlock.isChargable(b)) { if (ChargableBlock.isChargable(b)) {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return; if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
ChargableBlock.addCharge(b, -getEnergyConsumption()); ChargableBlock.addCharge(b, -getEnergyConsumption());
progress.put(b, timeleft - 1); progress.put(b, timeleft - 1);
} }
else progress.put(b, timeleft - 1); else progress.put(b, timeleft - 1);
} }
else { else {
BlockStorage.getInventory(b).replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " ")); menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
pushItems(b, processing.get(b).getOutput()); menu.pushItem(processing.get(b).getOutput()[0], getOutputSlots());
progress.remove(b); progress.remove(b);
processing.remove(b); processing.remove(b);
@ -71,10 +76,12 @@ public abstract class Refinery extends AContainer implements RecipeDisplayItem {
} }
else { else {
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.BUCKET_OF_OIL, true)) { if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.BUCKET_OF_OIL, true)) {
MachineRecipe r = new MachineRecipe(40, new ItemStack[0], new ItemStack[] {SlimefunItems.BUCKET_OF_FUEL}); MachineRecipe r = new MachineRecipe(40, new ItemStack[0], new ItemStack[] {SlimefunItems.BUCKET_OF_FUEL});
if (!fits(b, r.getOutput())) return;
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1)); if (!menu.fits(SlimefunItems.BUCKET_OF_FUEL, getOutputSlots())) return;
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
processing.put(b, r); processing.put(b, r);
progress.put(b, r.getTicks()); progress.put(b, r.getTicks());
break; break;

View File

@ -1,8 +1,5 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric; package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -25,6 +22,7 @@ import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
@ -40,10 +38,10 @@ public class WitherAssembler extends SlimefunItem {
protected int energyConsumption = 4096; protected int energyConsumption = 4096;
public WitherAssembler(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) { public WitherAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, name, recipeType, recipe); super(category, item, recipeType, recipe);
new BlockMenuPreset(name, "&5Wither Assembler") { new BlockMenuPreset(getID(), "&5Wither Assembler") {
@Override @Override
public void init() { public void init() {
@ -52,7 +50,6 @@ public class WitherAssembler extends SlimefunItem {
@Override @Override
public void newInstance(final BlockMenu menu, final Block b) { public void newInstance(final BlockMenu menu, final Block b) {
try {
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) { if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.GUNPOWDER), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine")); menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.GUNPOWDER), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
menu.addMenuClickHandler(22, (p, slot, item, action) -> { menu.addMenuClickHandler(22, (p, slot, item, action) -> {
@ -79,9 +76,6 @@ public class WitherAssembler extends SlimefunItem {
newInstance(menu, b); newInstance(menu, b);
return false; return false;
}); });
} catch(Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while creating a Wither Assembler for Slimefun " + Slimefun.getVersion(), x);
}
} }
@Override @Override
@ -105,7 +99,7 @@ public class WitherAssembler extends SlimefunItem {
} }
}; };
registerBlockHandler(name, new SlimefunBlockHandler() { registerBlockHandler(getID(), new SlimefunBlockHandler() {
@Override @Override
public void onPlace(Player p, Block b, SlimefunItem item) { public void onPlace(Player p, Block b, SlimefunItem item) {
@ -117,6 +111,7 @@ public class WitherAssembler extends SlimefunItem {
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
if (reason == UnregisterReason.EXPLODE) return false; if (reason == UnregisterReason.EXPLODE) return false;
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot : getSoulSandSlots()) { for (int slot : getSoulSandSlots()) {
if (inv.getItemInSlot(slot) != null) { if (inv.getItemInSlot(slot) != null) {
@ -124,6 +119,7 @@ public class WitherAssembler extends SlimefunItem {
inv.replaceExistingItem(slot, null); inv.replaceExistingItem(slot, null);
} }
} }
for (int slot : getWitherSkullSlots()) { for (int slot : getWitherSkullSlots()) {
if (inv.getItemInSlot(slot) != null) { if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
@ -216,7 +212,8 @@ public class WitherAssembler extends SlimefunItem {
if (soulsand > 3 && skulls > 2) { if (soulsand > 3 && skulls > 2) {
for (int slot : getSoulSandSlots()) { for (int slot : getSoulSandSlots()) {
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) { if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) {
final int amount = BlockStorage.getInventory(b).getItemInSlot(slot).getAmount(); int amount = BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
if (amount >= soulsand) { if (amount >= soulsand) {
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), soulsand)); BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), soulsand));
break; break;
@ -230,7 +227,8 @@ public class WitherAssembler extends SlimefunItem {
for (int slot : getWitherSkullSlots()) { for (int slot : getWitherSkullSlots()) {
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true)) { if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true)) {
final int amount = BlockStorage.getInventory(b).getItemInSlot(slot).getAmount(); int amount = BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
if (amount >= skulls) { if (amount >= skulls) {
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), skulls)); BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), skulls));
break; break;
@ -243,10 +241,9 @@ public class WitherAssembler extends SlimefunItem {
} }
ChargableBlock.addCharge(b, -energyConsumption); ChargableBlock.addCharge(b, -energyConsumption);
double offset = Double.parseDouble(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
final double offset = Double.parseDouble(BlockStorage.getLocationInfo(b.getLocation(), "offset")); Slimefun.runSync(() -> b.getWorld().spawnEntity(new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + offset, b.getZ() + 0.5D), EntityType.WITHER));
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> b.getWorld().spawnEntity(new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + offset, b.getZ() + 0.5D), EntityType.WITHER));
} }
} }
} }

View File

@ -70,10 +70,8 @@ public class XPCollector extends SlimefunItem implements InventoryBlock {
} }
protected void constructMenu(BlockMenuPreset preset) { protected void constructMenu(BlockMenuPreset preset) {
for (int i : border) { for (int slot : border) {
preset.addItem(i, new CustomItem(new ItemStack(Material.PURPLE_STAINED_GLASS_PANE), " "), preset.addItem(slot, new CustomItem(new ItemStack(Material.PURPLE_STAINED_GLASS_PANE), " "), (p, s, item, action) -> false);
(p, slot, item, action) -> false
);
} }
} }
@ -83,11 +81,7 @@ public class XPCollector extends SlimefunItem implements InventoryBlock {
@Override @Override
public void tick(Block b, SlimefunItem sf, Config data) { public void tick(Block b, SlimefunItem sf, Config data) {
try {
XPCollector.this.tick(b); XPCollector.this.tick(b);
} catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while ticking an Exp Collector for Slimefun " + Slimefun.getVersion(), x);
}
} }
@Override @Override
@ -112,6 +106,7 @@ public class XPCollector extends SlimefunItem implements InventoryBlock {
int withdrawn = 0; int withdrawn = 0;
BlockMenu menu = BlockStorage.getInventory(b); BlockMenu menu = BlockStorage.getInventory(b);
for (int level = 0; level < getEXP(b); level = level + 10) { for (int level = 0; level < getEXP(b); level = level + 10) {
if (menu.fits(new CustomItem(Material.EXPERIENCE_BOTTLE, "&aFlask of Knowledge"), getOutputSlots())) { if (menu.fits(new CustomItem(Material.EXPERIENCE_BOTTLE, "&aFlask of Knowledge"), getOutputSlots())) {
withdrawn = withdrawn + 10; withdrawn = withdrawn + 10;
@ -124,7 +119,9 @@ public class XPCollector extends SlimefunItem implements InventoryBlock {
private int getEXP(Block b) { private int getEXP(Block b) {
Config cfg = BlockStorage.getLocationInfo(b.getLocation()); Config cfg = BlockStorage.getLocationInfo(b.getLocation());
if (cfg.contains("stored-exp")) return Integer.parseInt(cfg.getString("stored-exp")); if (cfg.contains("stored-exp")) {
return Integer.parseInt(cfg.getString("stored-exp"));
}
else { else {
BlockStorage.addBlockInfo(b, "stored-exp", "0"); BlockStorage.addBlockInfo(b, "stored-exp", "0");
return 0; return 0;

View File

@ -0,0 +1,34 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.generators;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public abstract class MagnesiumGenerator extends AGenerator {
public MagnesiumGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}
@Override
public void registerDefaultRecipes() {
registerFuel(new MachineFuel(12, SlimefunItems.MAGNESIUM_SALT));
}
@Override
public ItemStack getProgressBar() {
return new ItemStack(Material.FLINT_AND_STEEL);
}
@Override
public String getInventoryTitle() {
return "&cMagnesium-powered Generator";
}
}

View File

@ -109,6 +109,7 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
@Override @Override
public List<ItemStack> getDisplayRecipes() { public List<ItemStack> getDisplayRecipes() {
List<ItemStack> displayRecipes = new LinkedList<>(); List<ItemStack> displayRecipes = new LinkedList<>();
for (OreGenResource resource : OreGenSystem.listResources()) { for (OreGenResource resource : OreGenSystem.listResources()) {
if (!resource.isLiquid()) { if (!resource.isLiquid()) {
displayRecipes.add(new CustomItem(resource.getItem(), "&r" + resource.getName())); displayRecipes.add(new CustomItem(resource.getItem(), "&r" + resource.getName()));
@ -182,6 +183,7 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
} }
else { else {
int supplies = OreGenSystem.getSupplies(resource, chunk, false); int supplies = OreGenSystem.getSupplies(resource, chunk, false);
if (supplies > 0) { if (supplies > 0) {
MachineRecipe r = new MachineRecipe(getProcessingTime() / getSpeed(), new ItemStack[0], new ItemStack[] {resource.getItem().clone()}); MachineRecipe r = new MachineRecipe(getProcessingTime() / getSpeed(), new ItemStack[0], new ItemStack[] {resource.getItem().clone()});
if (!menu.fits(r.getOutput()[0], getOutputSlots())) return; if (!menu.fits(r.getOutput()[0], getOutputSlots())) return;

View File

@ -1,4 +1,4 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric; package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -44,6 +44,7 @@ public class ElevatorPlate extends SimpleSlimefunItem<ItemInteractionHandler> {
public ItemInteractionHandler getItemHandler() { public ItemInteractionHandler getItemHandler() {
return (e, p, item) -> { return (e, p, item) -> {
if (e.getClickedBlock() == null) return false; if (e.getClickedBlock() == null) return false;
String id = BlockStorage.checkID(e.getClickedBlock()); String id = BlockStorage.checkID(e.getClickedBlock());
if (id == null || !id.equals(getID())) return false; if (id == null || !id.equals(getID())) return false;

View File

@ -52,8 +52,10 @@ public class ArmorForge extends MultiBlockMachine {
if (craft) { if (craft) {
final ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); final ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
if (Slimefun.hasUnlocked(p, adding, true)) { if (Slimefun.hasUnlocked(p, adding, true)) {
Inventory outputInv = findOutputInventory(adding, dispBlock, inv); Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
if (outputInv != null) { if (outputInv != null) {
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
ItemStack item = inv.getContents()[j]; ItemStack item = inv.getContents()[j];
@ -64,6 +66,7 @@ public class ArmorForge extends MultiBlockMachine {
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
int current = j; int current = j;
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> { Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
if (current < 3) { if (current < 3) {
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1F, 2F); p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1F, 2F);

View File

@ -46,15 +46,18 @@ public class Compressor extends MultiBlockMachine {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block dispBlock = b.getRelative(BlockFace.DOWN);
Dispenser disp = (Dispenser) dispBlock.getState(); Dispenser disp = (Dispenser) dispBlock.getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
for (ItemStack current : inv.getContents()) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
final ItemStack adding = RecipeType.getRecipeOutput(this, convert); final ItemStack adding = RecipeType.getRecipeOutput(this, convert);
Inventory outputInv = findOutputInventory(adding, dispBlock, inv); Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
if (outputInv != null) { if (outputInv != null) {
ItemStack removing = current.clone(); ItemStack removing = current.clone();
removing.setAmount(convert.getAmount()); removing.setAmount(convert.getAmount());
inv.removeItem(removing); inv.removeItem(removing);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
int j = i; int j = i;

View File

@ -54,6 +54,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
for (int i = 0; i < inputs.size(); i++) { for (int i = 0; i < inputs.size(); i++) {
boolean craft = true; boolean craft = true;
for (int j = 0; j < inv.getContents().length; j++) { for (int j = 0; j < inv.getContents().length; j++) {
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) { if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) {
if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) { if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) {
@ -92,6 +93,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
break; break;
} }
} }
String id = ""; String id = "";
int size = ((SlimefunBackpack) sfItem).getSize(); int size = ((SlimefunBackpack) sfItem).getSize();
@ -131,6 +133,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
ItemStack item = inv.getContents()[j]; ItemStack item = inv.getContents()[j];
if (item != null && item.getType() != Material.AIR) { if (item != null && item.getType() != Material.AIR) {
ItemUtils.consumeItem(item, true); ItemUtils.consumeItem(item, true);
} }

View File

@ -43,6 +43,7 @@ public class Juicer extends MultiBlockMachine {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block dispBlock = b.getRelative(BlockFace.DOWN);
Dispenser disp = (Dispenser) dispBlock.getState(); Dispenser disp = (Dispenser) dispBlock.getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
for (ItemStack current : inv.getContents()) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {

View File

@ -52,11 +52,12 @@ public class MagicWorkbench extends MultiBlockMachine {
else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) dispBlock = b.getRelative(0, 0, -1); else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) dispBlock = b.getRelative(0, 0, -1);
Dispenser disp = (Dispenser) dispBlock.getState(); Dispenser disp = (Dispenser) dispBlock.getState();
final Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this); List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
for (int i = 0; i < inputs.size(); i++) { for (int i = 0; i < inputs.size(); i++) {
boolean craft = true; boolean craft = true;
for (int j = 0; j < inv.getContents().length; j++) { for (int j = 0; j < inv.getContents().length; j++) {
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) { if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) {
if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) { if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) {
@ -73,7 +74,8 @@ public class MagicWorkbench extends MultiBlockMachine {
} }
if (craft) { if (craft) {
final ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
if (Slimefun.hasUnlocked(p, adding, true)) { if (Slimefun.hasUnlocked(p, adding, true)) {
Inventory inv2 = Bukkit.createInventory(null, 9, "test"); Inventory inv2 = Bukkit.createInventory(null, 9, "test");
@ -137,14 +139,17 @@ public class MagicWorkbench extends MultiBlockMachine {
else inv.setItem(j, null); else inv.setItem(j, null);
} }
} }
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
int current = j; int current = j;
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> { Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1); p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1); p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);
if (current < 3) { if (current < 3) {
p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F); p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F);
} else { }
else {
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
outputInv.addItem(adding); outputInv.addItem(adding);
} }

View File

@ -37,7 +37,8 @@ public class OreCrusher extends MultiBlockMachine {
SlimefunItems.PURE_ORE_CLUSTER, SlimefunItems.TINY_URANIUM, SlimefunItems.PURE_ORE_CLUSTER, SlimefunItems.TINY_URANIUM,
new ItemStack(Material.COBBLESTONE, 8), new ItemStack(Material.SAND, 1), new ItemStack(Material.COBBLESTONE, 8), new ItemStack(Material.SAND, 1),
new ItemStack(Material.GOLD_INGOT), SlimefunItems.GOLD_DUST, new ItemStack(Material.GOLD_INGOT), SlimefunItems.GOLD_DUST,
SlimefunItems.GOLD_4K, SlimefunItems.GOLD_DUST SlimefunItems.GOLD_4K, SlimefunItems.GOLD_DUST,
new ItemStack(Material.GRAVEL), new ItemStack(Material.SAND)
}, },
BlockFace.SELF BlockFace.SELF
); );
@ -58,6 +59,7 @@ public class OreCrusher extends MultiBlockMachine {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block dispBlock = b.getRelative(BlockFace.DOWN);
Dispenser disp = (Dispenser) dispBlock.getState(); Dispenser disp = (Dispenser) dispBlock.getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
for (ItemStack current : inv.getContents()) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {

View File

@ -1,6 +1,8 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks; package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.stream.Collectors;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Material; import org.bukkit.Material;
@ -41,6 +43,11 @@ public class OreWasher extends MultiBlockMachine {
); );
} }
@Override
public List<ItemStack> getDisplayRecipes() {
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
}
@Override @Override
public void onInteract(Player p, Block b) { public void onInteract(Player p, Block b) {
Block dispBlock = b.getRelative(BlockFace.UP); Block dispBlock = b.getRelative(BlockFace.UP);

View File

@ -1,161 +0,0 @@
package me.mrCookieSlime.Slimefun.Setup;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
import org.bukkit.plugin.Plugin;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@Deprecated
public class CSCoreLibLoader {
private Plugin plugin;
private URL url;
private URL download;
private File file;
public CSCoreLibLoader(Plugin plugin) {
this.plugin = plugin;
try {
this.url = new URL("https://api.curseforge.com/servermods/files?projectIds=88802");
} catch (MalformedURLException e) {
plugin.getLogger().log(Level.SEVERE, "The Auto-Updater URL is malformed!", e);
}
}
public boolean load() {
if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
return true;
}
else {
plugin.getLogger().log(Level.INFO, " ");
plugin.getLogger().log(Level.INFO, "#################### - INFO - ####################");
plugin.getLogger().log(Level.INFO, " ");
plugin.getLogger().log(Level.INFO, plugin.getName() + " could not be loaded (yet).");
plugin.getLogger().log(Level.INFO, "It appears that you have not installed CS-CoreLib.");
plugin.getLogger().log(Level.INFO, "Your Server will now try to download and install");
plugin.getLogger().log(Level.INFO, "CS-CoreLib for you.");
plugin.getLogger().log(Level.INFO, "You will be asked to restart your Server when it's finished.");
plugin.getLogger().log(Level.INFO, "If this somehow fails, please download and install CS-CoreLib manually:");
plugin.getLogger().log(Level.INFO, "https://dev.bukkit.org/projects/cs-corelib");
plugin.getLogger().log(Level.INFO, " ");
plugin.getLogger().log(Level.INFO, "#################### - INFO - ####################");
plugin.getLogger().log(Level.INFO, " ");
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (connect()) {
install();
}
}, 10L);
return false;
}
}
private boolean connect() {
try {
final URLConnection connection = this.url.openConnection();
connection.setConnectTimeout(5000);
connection.addRequestProperty("User-Agent", "CS-CoreLib Loader (by mrCookieSlime)");
connection.setDoOutput(true);
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
final JsonArray array = new JsonParser().parse(reader).getAsJsonArray();
final JsonObject json = array.get(array.size() - 1).getAsJsonObject();
download = traceURL(json.get("downloadUrl").getAsString().replace("https:", "http:"));
file = new File("plugins/" + json.get("name").getAsString() + ".jar");
return true;
} catch (IOException e) {
plugin.getLogger().log(Level.WARNING, " ");
plugin.getLogger().log(Level.WARNING, "#################### - WARNING - ####################");
plugin.getLogger().log(Level.WARNING, " ");
plugin.getLogger().log(Level.WARNING, "Could not connect to BukkitDev.");
plugin.getLogger().log(Level.WARNING, "Please download & install CS-CoreLib manually:");
plugin.getLogger().log(Level.WARNING, "https://dev.bukkit.org/projects/cs-corelib");
plugin.getLogger().log(Level.WARNING, " ");
plugin.getLogger().log(Level.WARNING, "#################### - WARNING - ####################");
plugin.getLogger().log(Level.WARNING, " ");
return false;
}
}
private URL traceURL(String location) throws IOException {
HttpURLConnection connection = null;
while (true) {
URL url = new URL(location);
connection = (HttpURLConnection) url.openConnection();
connection.setInstanceFollowRedirects(false);
connection.setConnectTimeout(5000);
connection.addRequestProperty("User-Agent", "Auto Updater (by mrCookieSlime)");
int response = connection.getResponseCode();
if (response == HttpURLConnection.HTTP_MOVED_PERM || response == HttpURLConnection.HTTP_MOVED_TEMP) {
String loc = connection.getHeaderField("Location");
location = new URL(new URL(location), loc).toExternalForm();
}
else {
break;
}
}
return new URL(connection.getURL().toString().replace(" ", "%20"));
}
private void install() {
BufferedInputStream input = null;
FileOutputStream output = null;
try {
input = new BufferedInputStream(download.openStream());
output = new FileOutputStream(file);
final byte[] data = new byte[1024];
int read;
while ((read = input.read(data, 0, 1024)) != -1) {
output.write(data, 0, read);
}
} catch (Exception ex) {
plugin.getLogger().log(Level.WARNING, " ");
plugin.getLogger().log(Level.WARNING, "#################### - WARNING - ####################");
plugin.getLogger().log(Level.WARNING, " ");
plugin.getLogger().log(Level.WARNING, "Failed to download CS-CoreLib");
plugin.getLogger().log(Level.WARNING, "Please download & install CS-CoreLib manually:");
plugin.getLogger().log(Level.WARNING, "https://dev.bukkit.org/projects/cs-corelib");
plugin.getLogger().log(Level.WARNING, " ");
plugin.getLogger().log(Level.WARNING, "#################### - WARNING - ####################");
plugin.getLogger().log(Level.WARNING, " ");
} finally {
try {
if (input != null) input.close();
if (output != null) output.close();
plugin.getLogger().log(Level.INFO, " ");
plugin.getLogger().log(Level.INFO, "#################### - INFO - ####################");
plugin.getLogger().log(Level.INFO, " ");
plugin.getLogger().log(Level.INFO, "Please restart your Server to finish the Installation");
plugin.getLogger().log(Level.INFO, "of " + plugin.getName() + " and CS-CoreLib");
plugin.getLogger().log(Level.INFO, " ");
plugin.getLogger().log(Level.INFO, "#################### - INFO - ####################");
plugin.getLogger().log(Level.INFO, " ");
} catch (IOException x) {
plugin.getLogger().log(Level.SEVERE, "An Error occured while closing the Download Stream for CS-CoreLib", x);
}
}
}
}

View File

@ -248,5 +248,6 @@ public final class ResearchSetup {
Slimefun.registerResearch(new Research(250, "Charging Bench", 8), SlimefunItems.CHARGING_BENCH); Slimefun.registerResearch(new Research(250, "Charging Bench", 8), SlimefunItems.CHARGING_BENCH);
Slimefun.registerResearch(new Research(251, "Nether Gold Pan", 8), SlimefunItems.NETHER_GOLD_PAN); Slimefun.registerResearch(new Research(251, "Nether Gold Pan", 8), SlimefunItems.NETHER_GOLD_PAN);
Slimefun.registerResearch(new Research(252, "Electric Press", 16), SlimefunItems.ELECTRIC_PRESS, SlimefunItems.ELECTRIC_PRESS_2); Slimefun.registerResearch(new Research(252, "Electric Press", 16), SlimefunItems.ELECTRIC_PRESS, SlimefunItems.ELECTRIC_PRESS_2);
Slimefun.registerResearch(new Research(253, "Power from Magnesium", 20), SlimefunItems.MAGNESIUM_SALT, SlimefunItems.MAGNESIUM_GENERATOR);
} }
} }

View File

@ -132,7 +132,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.Electric
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricPress; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricPress;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricSmeltery; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricSmeltery;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectrifiedCrucible; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectrifiedCrucible;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElevatorPlate;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.EnergyRegulator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.EnergyRegulator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FluidPump; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FluidPump;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FoodComposter; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FoodComposter;
@ -146,10 +145,12 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.generato
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.generators.CoalGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.generators.CoalGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.generators.CombustionGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.generators.CombustionGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.generators.LavaGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.generators.LavaGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.generators.MagnesiumGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOMiner; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOMiner;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOScannerBlock; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOScannerBlock;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.NetherDrill; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.NetherDrill;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.OilPump; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.OilPump;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.ElevatorPlate;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.GPSTransmitter; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.GPSTransmitter;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.ArmorForge; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.ArmorForge;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.AutomatedPanningMachine; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.AutomatedPanningMachine;
@ -1092,7 +1093,8 @@ public final class SlimefunSetup {
new ItemStack[] {SlimefunItems.SOLAR_PANEL, new ItemStack(Material.CHEST), SlimefunItems.SOLAR_PANEL, SlimefunItems.GOLD_24K_BLOCK, new ItemStack(Material.DISPENSER), SlimefunItems.GOLD_24K_BLOCK, SlimefunItems.GOLD_24K_BLOCK, new ItemStack(Material.HOPPER), SlimefunItems.GOLD_24K_BLOCK}, new ItemStack[] {SlimefunItems.SOLAR_PANEL, new ItemStack(Material.CHEST), SlimefunItems.SOLAR_PANEL, SlimefunItems.GOLD_24K_BLOCK, new ItemStack(Material.DISPENSER), SlimefunItems.GOLD_24K_BLOCK, SlimefunItems.GOLD_24K_BLOCK, new ItemStack(Material.HOPPER), SlimefunItems.GOLD_24K_BLOCK},
new ItemStack[0], BlockFace.SELF) new ItemStack[0], BlockFace.SELF)
.register(true, new MultiBlockInteractionHandler() { .register(true, new MultiBlockInteractionHandler() {
// Determines the drops an Advanced Digital Miner will get
private final ItemStack EFFECTIVE_PICKAXE = new ItemStack(Material.DIAMOND_PICKAXE);
@Override @Override
public boolean onInteract(final Player p, MultiBlock mb, final Block b) { public boolean onInteract(final Player p, MultiBlock mb, final Block b) {
if (mb.isMultiBlock(SlimefunItem.getByID("ADVANCED_DIGITAL_MINER"))) { if (mb.isMultiBlock(SlimefunItem.getByID("ADVANCED_DIGITAL_MINER"))) {
@ -1128,7 +1130,7 @@ public final class SlimefunSetup {
else if (ore == Material.NETHER_QUARTZ_ORE) drop = new ItemStack(Material.QUARTZ, 4); else if (ore == Material.NETHER_QUARTZ_ORE) drop = new ItemStack(Material.QUARTZ, 4);
else if (ore == Material.LAPIS_ORE) drop = new ItemStack(Material.LAPIS_LAZULI, 12); else if (ore == Material.LAPIS_ORE) drop = new ItemStack(Material.LAPIS_LAZULI, 12);
else { else {
for (ItemStack drops: ores.get(0).getBlock().getDrops()) { for (ItemStack drops: ores.get(0).getBlock().getDrops(EFFECTIVE_PICKAXE)) {
if (!drops.getType().isBlock()) drop = new CustomItem(drops, 2); if (!drops.getType().isBlock()) drop = new CustomItem(drops, 2);
} }
} }
@ -2092,6 +2094,20 @@ public final class SlimefunSetup {
}.registerChargeableBlock(true, 1024); }.registerChargeableBlock(true, 1024);
new SlimefunItem(Categories.RESOURCES, (SlimefunItemStack) SlimefunItems.MAGNESIUM_SALT, RecipeType.HEATED_PRESSURE_CHAMBER,
new ItemStack[] {SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT, null, null, null, null, null, null, null})
.register(true);
new MagnesiumGenerator(Categories.ELECTRICITY, (SlimefunItemStack) SlimefunItems.MAGNESIUM_GENERATOR, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, SlimefunItems.ELECTRIC_MOTOR, null, SlimefunItems.COMPRESSED_CARBON, new ItemStack(Material.WATER_BUCKET), SlimefunItems.COMPRESSED_CARBON, SlimefunItems.DURALUMIN_INGOT, SlimefunItems.DURALUMIN_INGOT, SlimefunItems.DURALUMIN_INGOT}) {
@Override
public int getEnergyProduction() {
return 18;
}
}.registerUnrechargeableBlock(true, 128);
new AutoEnchanter(Categories.ELECTRICITY, (SlimefunItemStack) SlimefunItems.AUTO_ENCHANTER, RecipeType.ENHANCED_CRAFTING_TABLE, new AutoEnchanter(Categories.ELECTRICITY, (SlimefunItemStack) SlimefunItems.AUTO_ENCHANTER, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new ItemStack(Material.ENCHANTING_TABLE), null, SlimefunItems.CARBONADO, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.CARBONADO, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_OBSIDIAN}) new ItemStack[] {null, new ItemStack(Material.ENCHANTING_TABLE), null, SlimefunItems.CARBONADO, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.CARBONADO, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_OBSIDIAN})
.registerChargeableBlock(true, 128); .registerChargeableBlock(true, 128);
@ -3224,7 +3240,7 @@ public final class SlimefunSetup {
}.registerChargeableBlock(true, 512); }.registerChargeableBlock(true, 512);
new ElectricSmeltery(Categories.ELECTRICITY, SlimefunItems.ELECTRIC_SMELTERY, "ELECTRIC_SMELTERY", RecipeType.ENHANCED_CRAFTING_TABLE, new ElectricSmeltery(Categories.ELECTRICITY, (SlimefunItemStack) SlimefunItems.ELECTRIC_SMELTERY, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.NETHER_BRICKS), SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.NETHER_BRICKS), SlimefunItems.HEATING_COIL, SlimefunItems.ELECTRIC_INGOT_FACTORY, SlimefunItems.HEATING_COIL, SlimefunItems.GILDED_IRON, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.GILDED_IRON}) { new ItemStack[] {new ItemStack(Material.NETHER_BRICKS), SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.NETHER_BRICKS), SlimefunItems.HEATING_COIL, SlimefunItems.ELECTRIC_INGOT_FACTORY, SlimefunItems.HEATING_COIL, SlimefunItems.GILDED_IRON, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.GILDED_IRON}) {
@Override @Override
@ -3239,7 +3255,7 @@ public final class SlimefunSetup {
}.registerChargeableBlock(true, 512); }.registerChargeableBlock(true, 512);
new ElectricSmeltery(Categories.ELECTRICITY, SlimefunItems.ELECTRIC_SMELTERY_2, "ELECTRIC_SMELTERY_2", RecipeType.ENHANCED_CRAFTING_TABLE, new ElectricSmeltery(Categories.ELECTRICITY, (SlimefunItemStack) SlimefunItems.ELECTRIC_SMELTERY_2, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.POWER_CRYSTAL, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.HEATING_COIL, SlimefunItems.ELECTRIC_SMELTERY, SlimefunItems.HEATING_COIL, SlimefunItems.GILDED_IRON, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.GILDED_IRON}) { new ItemStack[] {SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.POWER_CRYSTAL, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.HEATING_COIL, SlimefunItems.ELECTRIC_SMELTERY, SlimefunItems.HEATING_COIL, SlimefunItems.GILDED_IRON, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.GILDED_IRON}) {
@Override @Override
@ -3254,10 +3270,9 @@ public final class SlimefunSetup {
}.registerChargeableBlock(true, 1024); }.registerChargeableBlock(true, 1024);
new WitherAssembler(Categories.ELECTRICITY, SlimefunItems.WITHER_ASSEMBLER, "WITHER_ASSEMBLER", RecipeType.ENHANCED_CRAFTING_TABLE, new WitherAssembler(Categories.ELECTRICITY, (SlimefunItemStack) SlimefunItems.WITHER_ASSEMBLER, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.NETHER_STAR), SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR}) new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.NETHER_STAR), SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR})
.registerChargeableBlock(true, 4096); .registerChargeableBlock(true, 4096);
} }
public static void registerPostHandler(PostSlimefunLoadingHandler handler) { public static void registerPostHandler(PostSlimefunLoadingHandler handler) {

View File

@ -1,8 +1,6 @@
package me.mrCookieSlime.Slimefun; package me.mrCookieSlime.Slimefun;
import java.io.File; import java.io.File;
import java.util.Optional;
import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -11,8 +9,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import io.github.thebusybiscuit.cscorelib2.players.MinecraftAccount;
import io.github.thebusybiscuit.cscorelib2.players.MinecraftAccount.TooManyRequestsException;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager; import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager;
import io.github.thebusybiscuit.cscorelib2.recipes.RecipeSnapshot; import io.github.thebusybiscuit.cscorelib2.recipes.RecipeSnapshot;
import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils; import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils;
@ -23,16 +19,16 @@ import io.github.thebusybiscuit.slimefun4.core.services.BlockDataService;
import io.github.thebusybiscuit.slimefun4.core.services.CustomItemDataService; import io.github.thebusybiscuit.slimefun4.core.services.CustomItemDataService;
import io.github.thebusybiscuit.slimefun4.core.services.CustomTextureService; import io.github.thebusybiscuit.slimefun4.core.services.CustomTextureService;
import io.github.thebusybiscuit.slimefun4.core.services.MetricsService; import io.github.thebusybiscuit.slimefun4.core.services.MetricsService;
import io.github.thebusybiscuit.slimefun4.core.services.github.Contributor;
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubConnector;
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService; import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService;
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubTask;
import io.github.thebusybiscuit.slimefun4.implementation.geo.resources.NetherIceResource;
import io.github.thebusybiscuit.slimefun4.implementation.geo.resources.OilResource;
import io.github.thebusybiscuit.slimefun4.implementation.geo.resources.SaltResource;
import io.github.thebusybiscuit.slimefun4.implementation.geo.resources.UraniumResource;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.PluginUtils; import me.mrCookieSlime.CSCoreLibPlugin.PluginUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.GEO.OreGenSystem; import me.mrCookieSlime.Slimefun.GEO.OreGenSystem;
import me.mrCookieSlime.Slimefun.GEO.resources.NetherIceResource;
import me.mrCookieSlime.Slimefun.GEO.resources.OilResource;
import me.mrCookieSlime.Slimefun.GEO.resources.UraniumResource;
import me.mrCookieSlime.Slimefun.GPS.GPSNetwork; import me.mrCookieSlime.Slimefun.GPS.GPSNetwork;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@ -40,7 +36,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
import me.mrCookieSlime.Slimefun.Objects.tasks.ArmorTask; import me.mrCookieSlime.Slimefun.Objects.tasks.ArmorTask;
import me.mrCookieSlime.Slimefun.Setup.CSCoreLibLoader;
import me.mrCookieSlime.Slimefun.Setup.Files; import me.mrCookieSlime.Slimefun.Setup.Files;
import me.mrCookieSlime.Slimefun.Setup.MiscSetup; import me.mrCookieSlime.Slimefun.Setup.MiscSetup;
import me.mrCookieSlime.Slimefun.Setup.ResearchSetup; import me.mrCookieSlime.Slimefun.Setup.ResearchSetup;
@ -110,7 +105,7 @@ public final class SlimefunPlugin extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
if (new CSCoreLibLoader(this).load()) { if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
String currentVersion = ReflectionUtils.getVersion(); String currentVersion = ReflectionUtils.getVersion();
@ -232,10 +227,11 @@ public final class SlimefunPlugin extends JavaPlugin {
getLogger().log(Level.INFO, "Loading World Generators..."); getLogger().log(Level.INFO, "Loading World Generators...");
// Generating Oil as an OreGenResource (its a cool API) // Generating Oil as an OreGenResource (it iss a cool API)
OreGenSystem.registerResource(new OilResource()); OreGenSystem.registerResource(new OilResource());
OreGenSystem.registerResource(new NetherIceResource()); OreGenSystem.registerResource(new NetherIceResource());
OreGenSystem.registerResource(new UraniumResource()); OreGenSystem.registerResource(new UraniumResource());
OreGenSystem.registerResource(new SaltResource());
// Setting up GitHub Connectors... // Setting up GitHub Connectors...
gitHubService.connect(config.getBoolean("options.print-out-github-data-retrieving")); gitHubService.connect(config.getBoolean("options.print-out-github-data-retrieving"));
@ -308,32 +304,7 @@ public final class SlimefunPlugin extends JavaPlugin {
} }
}, 100L, config.getInt("URID.custom-ticker-delay")); }, 100L, config.getInt("URID.custom-ticker-delay"));
getServer().getScheduler().runTaskTimerAsynchronously(this, () -> { getServer().getScheduler().runTaskTimerAsynchronously(this, new GitHubTask(gitHubService), 80L, 60 * 60 * 20L);
gitHubService.getConnectors().forEach(GitHubConnector::pullFile);
for (Contributor contributor : gitHubService.getContributors().values()) {
if (!contributor.hasTexture()) {
try {
Optional<UUID> uuid = MinecraftAccount.getUUID(contributor.getMinecraftName());
if (uuid.isPresent()) {
Optional<String> skin = MinecraftAccount.getSkin(uuid.get());
contributor.setTexture(skin);
}
else {
contributor.setTexture(Optional.empty());
}
}
catch(IllegalArgumentException x) {
// There cannot be a texture found because it is not a valid MC username
contributor.setTexture(Optional.empty());
}
catch(TooManyRequestsException x) {
break;
}
}
}
}, 80L, 60 * 60 * 20L);
// Hooray! // Hooray!
getLogger().log(Level.INFO, "Finished!"); getLogger().log(Level.INFO, "Finished!");
@ -345,9 +316,16 @@ public final class SlimefunPlugin extends JavaPlugin {
CSCoreLib.getLib().filterLog("([A-Za-z0-9_]{3,16}) issued server command: /sf elevator (.{0,})"); CSCoreLib.getLib().filterLog("([A-Za-z0-9_]{3,16}) issued server command: /sf elevator (.{0,})");
} }
else { else {
getLogger().log(Level.INFO, "#################### - INFO - ####################");
getLogger().log(Level.INFO, " ");
getLogger().log(Level.INFO, "Slimefun could not be loaded (yet).");
getLogger().log(Level.INFO, "It appears that you have not installed CS-CoreLib.");
getLogger().log(Level.INFO, "Please download and install CS-CoreLib manually:");
getLogger().log(Level.INFO, "https://thebusybiscuit.github.io/builds/TheBusyBiscuit/CS-CoreLib/master/");
getCommand("slimefun").setExecutor((sender, cmd, label, args) -> { getCommand("slimefun").setExecutor((sender, cmd, label, args) -> {
sender.sendMessage("You have forgotten to install CS-CoreLib! Slimefun is disabled."); sender.sendMessage("You have forgotten to install CS-CoreLib! Slimefun is disabled.");
sender.sendMessage("https://dev.bukkit.org/projects/cs-corelib"); sender.sendMessage("https://thebusybiscuit.github.io/builds/TheBusyBiscuit/CS-CoreLib/master/");
return true; return true;
}); });
} }

View File

@ -9,9 +9,9 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
public class AltarRecipe { public class AltarRecipe {
private ItemStack catalyst; private final ItemStack catalyst;
private List<ItemStack> input; private final List<ItemStack> input;
private ItemStack output; private final ItemStack output;
public AltarRecipe(List<ItemStack> input, ItemStack output) { public AltarRecipe(List<ItemStack> input, ItemStack output) {
this.catalyst = input.get(4); this.catalyst = input.get(4);

View File

@ -54,7 +54,8 @@ public final class Pedestals {
if (SlimefunManager.isItemSimilar(catalyst, SlimefunItems.BROKEN_SPAWNER, false)) { if (SlimefunManager.isItemSimilar(catalyst, SlimefunItems.BROKEN_SPAWNER, false)) {
if (checkRecipe(SlimefunItems.BROKEN_SPAWNER, input) == null) return null; if (checkRecipe(SlimefunItems.BROKEN_SPAWNER, input) == null) return null;
final ItemStack spawner = SlimefunItems.REPAIRED_SPAWNER.clone();
ItemStack spawner = SlimefunItems.REPAIRED_SPAWNER.clone();
ItemMeta im = spawner.getItemMeta(); ItemMeta im = spawner.getItemMeta();
im.setLore(Arrays.asList(catalyst.getItemMeta().getLore().get(0))); im.setLore(Arrays.asList(catalyst.getItemMeta().getLore().get(0)));
spawner.setItemMeta(im); spawner.setItemMeta(im);

View File

@ -74,6 +74,9 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
public abstract class ProgrammableAndroid extends SlimefunItem implements InventoryBlock { public abstract class ProgrammableAndroid extends SlimefunItem implements InventoryBlock {
// Determines the drops a miner android will get
private static final ItemStack EFFECTIVE_PICKAXE = new ItemStack(Material.DIAMOND_PICKAXE);
private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 24, 25, 26, 27, 33, 35, 36, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53}; private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 24, 25, 26, 27, 33, 35, 36, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53};
private static final int[] border_out = {10, 11, 12, 13, 14, 19, 23, 28, 32, 37, 38, 39, 40, 41}; private static final int[] border_out = {10, 11, 12, 13, 14, 19, 23, 28, 32, 37, 38, 39, 40, 41};
@ -497,7 +500,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
} }
private void mine(Block b, BlockMenu menu, Block block) { private void mine(Block b, BlockMenu menu, Block block) {
Collection<ItemStack> drops = block.getDrops(); Collection<ItemStack> drops = block.getDrops(EFFECTIVE_PICKAXE);
if (!MaterialCollections.getAllUnbreakableBlocks().contains(block.getType()) && !drops.isEmpty() && SlimefunPlugin.getProtectionManager().hasPermission(Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))), block.getLocation(), ProtectableAction.BREAK_BLOCK)) { if (!MaterialCollections.getAllUnbreakableBlocks().contains(block.getType()) && !drops.isEmpty() && SlimefunPlugin.getProtectionManager().hasPermission(Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))), block.getLocation(), ProtectableAction.BREAK_BLOCK)) {
String item = BlockStorage.checkID(block); String item = BlockStorage.checkID(block);
@ -532,7 +535,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
private void movedig(Block b, BlockMenu menu, BlockFace face, Block block) { private void movedig(Block b, BlockMenu menu, BlockFace face, Block block) {
Collection<ItemStack> drops = block.getDrops(); Collection<ItemStack> drops = block.getDrops(EFFECTIVE_PICKAXE);
if (!MaterialCollections.getAllUnbreakableBlocks().contains(block.getType()) && !drops.isEmpty() && SlimefunPlugin.getProtectionManager().hasPermission(Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))), block.getLocation(), ProtectableAction.BREAK_BLOCK)) { if (!MaterialCollections.getAllUnbreakableBlocks().contains(block.getType()) && !drops.isEmpty() && SlimefunPlugin.getProtectionManager().hasPermission(Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))), block.getLocation(), ProtectableAction.BREAK_BLOCK)) {
SlimefunItem item = BlockStorage.check(block); SlimefunItem item = BlockStorage.check(block);

View File

@ -158,8 +158,10 @@ public class BlockStorage {
else f.mkdirs(); else f.mkdirs();
File chunks = new File(path_chunks + "chunks.sfc"); File chunks = new File(path_chunks + "chunks.sfc");
if (chunks.exists()) { if (chunks.exists()) {
FileConfiguration cfg = YamlConfiguration.loadConfiguration(chunks); FileConfiguration cfg = YamlConfiguration.loadConfiguration(chunks);
for (String key : cfg.getKeys(false)) { for (String key : cfg.getKeys(false)) {
try { try {
if (world.getName().equals(key.split(";")[0])) { if (world.getName().equals(key.split(";")[0])) {
@ -180,6 +182,7 @@ public class BlockStorage {
try { try {
BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset")); BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset"));
if (preset == null) { if (preset == null) {
preset = BlockMenuPreset.getPreset(checkID(l)); preset = BlockMenuPreset.getPreset(checkID(l));
} }
@ -342,6 +345,7 @@ public class BlockStorage {
if (json != null && json.length() > 2) { if (json != null && json.length() > 2) {
JsonParser parser = new JsonParser(); JsonParser parser = new JsonParser();
JsonObject obj = parser.parse(json).getAsJsonObject(); JsonObject obj = parser.parse(json).getAsJsonObject();
for (Map.Entry<String, JsonElement> entry : obj.entrySet()) { for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
map.put(entry.getKey(), entry.getValue().getAsString()); map.put(entry.getKey(), entry.getValue().getAsString());
} }
@ -367,9 +371,11 @@ public class BlockStorage {
private static String serializeBlockInfo(Config cfg) { private static String serializeBlockInfo(Config cfg) {
JsonObject json = new JsonObject(); JsonObject json = new JsonObject();
for (String key : cfg.getKeys()) { for (String key : cfg.getKeys()) {
json.add(key, new JsonPrimitive(cfg.getString(key))); json.add(key, new JsonPrimitive(cfg.getString(key)));
} }
return json.toString(); return json.toString();
} }
@ -426,6 +432,7 @@ public class BlockStorage {
public static void setBlockInfo(Location l, Config cfg, boolean updateTicker) { public static void setBlockInfo(Location l, Config cfg, boolean updateTicker) {
BlockStorage storage = getStorage(l.getWorld()); BlockStorage storage = getStorage(l.getWorld());
storage.storage.put(l, cfg); storage.storage.put(l, cfg);
if (BlockMenuPreset.isInventory(cfg.getString("id"))) { if (BlockMenuPreset.isInventory(cfg.getString("id"))) {
if (BlockMenuPreset.isUniversalInventory(cfg.getString("id"))) { if (BlockMenuPreset.isUniversalInventory(cfg.getString("id"))) {
if (!SlimefunPlugin.getUtilities().universalInventories.containsKey(cfg.getString("id"))) { if (!SlimefunPlugin.getUtilities().universalInventories.containsKey(cfg.getString("id"))) {
@ -439,6 +446,7 @@ public class BlockStorage {
else storage.loadInventory(l, BlockMenuPreset.getPreset(cfg.getString("id"))); else storage.loadInventory(l, BlockMenuPreset.getPreset(cfg.getString("id")));
} }
} }
refreshCache(getStorage(l.getWorld()), l, cfg.getString("id"), serializeBlockInfo(cfg), updateTicker); refreshCache(getStorage(l.getWorld()), l, cfg.getString("id"), serializeBlockInfo(cfg), updateTicker);
} }
@ -470,6 +478,7 @@ public class BlockStorage {
public static void _integrated_removeBlockInfo(Location l, boolean destroy) { public static void _integrated_removeBlockInfo(Location l, boolean destroy) {
BlockStorage storage = getStorage(l.getWorld()); BlockStorage storage = getStorage(l.getWorld());
if (hasBlockInfo(l)) { if (hasBlockInfo(l)) {
refreshCache(storage, l, getLocationInfo(l).getString("id"), null, destroy); refreshCache(storage, l, getLocationInfo(l).getString("id"), null, destroy);
storage.storage.remove(l); storage.storage.remove(l);
@ -477,14 +486,17 @@ public class BlockStorage {
if (destroy) { if (destroy) {
if (storage.hasInventory(l)) storage.clearInventory(l); if (storage.hasInventory(l)) storage.clearInventory(l);
if (storage.hasUniversalInventory(l)) { if (storage.hasUniversalInventory(l)) {
storage.getUniversalInventory(l).close(); storage.getUniversalInventory(l).close();
storage.getUniversalInventory(l).save(); storage.getUniversalInventory(l).save();
} }
String chunkString = locationToChunkString(l); String chunkString = locationToChunkString(l);
if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) { if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) {
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString); Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString);
locations.remove(l); locations.remove(l);
if (locations.isEmpty()) { if (locations.isEmpty()) {
SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString); SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString);
SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString); SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString);
@ -513,6 +525,7 @@ public class BlockStorage {
BlockStorage storage = getStorage(from.getWorld()); BlockStorage storage = getStorage(from.getWorld());
setBlockInfo(to, getLocationInfo(from), true); setBlockInfo(to, getLocationInfo(from), true);
if (storage.inventories.containsKey(from)) { if (storage.inventories.containsKey(from)) {
BlockMenu menu = storage.inventories.get(from); BlockMenu menu = storage.inventories.get(from);
storage.inventories.put(to, menu); storage.inventories.put(to, menu);
@ -524,9 +537,11 @@ public class BlockStorage {
storage.storage.remove(from); storage.storage.remove(from);
String chunkString = locationToChunkString(from); String chunkString = locationToChunkString(from);
if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) { if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) {
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString); Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString);
locations.remove(from); locations.remove(from);
if (locations.isEmpty()) { if (locations.isEmpty()) {
SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString); SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString);
SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString); SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString);
@ -541,8 +556,10 @@ public class BlockStorage {
if (updateTicker) { if (updateTicker) {
SlimefunItem item = SlimefunItem.getByID(key); SlimefunItem item = SlimefunItem.getByID(key);
if (item != null && item.isTicking()) { if (item != null && item.isTicking()) {
String chunkString = locationToChunkString(l); String chunkString = locationToChunkString(l);
if (value != null) { if (value != null) {
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString); Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString);
if (locations == null) locations = new HashSet<>(); if (locations == null) locations = new HashSet<>();
@ -615,9 +632,11 @@ public class BlockStorage {
@Deprecated @Deprecated
public static Set<Block> getTickingBlocks(String chunk) { public static Set<Block> getTickingBlocks(String chunk) {
Set<Block> ret = new HashSet<>(); Set<Block> ret = new HashSet<>();
for (Location l : getTickingLocations(chunk)) { for (Location l : getTickingLocations(chunk)) {
ret.add(l.getBlock()); ret.add(l.getBlock());
} }
return ret; return ret;
} }

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable; import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
@Deprecated
public interface GuideHandler { public interface GuideHandler {
public abstract void addEntry(List<String> texts, List<String> tooltips); public abstract void addEntry(List<String> texts, List<String> tooltips);

View File

@ -110,6 +110,7 @@ public class SlimefunCommand implements CommandExecutor, Listener {
sender.sendMessage(""); sender.sendMessage("");
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSlimefun &2v" + Slimefun.getVersion())); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSlimefun &2v" + Slimefun.getVersion()));
sender.sendMessage(""); sender.sendMessage("");
for (SubCommand cmd : commands) { for (SubCommand cmd : commands) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&3/sf " + cmd.getName() + " &b") + cmd.getDescription()); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&3/sf " + cmd.getName() + " &b") + cmd.getDescription());
} }

View File

@ -29,9 +29,11 @@ public class SlimefunTabCompleter implements TabCompleter {
} }
else if (args[0].equalsIgnoreCase("research")) { else if (args[0].equalsIgnoreCase("research")) {
List<String> researches = new ArrayList<>(); List<String> researches = new ArrayList<>();
for (Research res : Research.list()) { for (Research res : Research.list()) {
researches.add(res.getName().toUpperCase().replace(' ', '_')); researches.add(res.getName().toUpperCase().replace(' ', '_'));
} }
researches.add("all"); researches.add("all");
researches.add("reset"); researches.add("reset");
return createReturnList(researches, args[2]); return createReturnList(researches, args[2]);
@ -55,11 +57,13 @@ public class SlimefunTabCompleter implements TabCompleter {
if (string.equals("")) return list; if (string.equals("")) return list;
List<String> returnList = new ArrayList<>(); List<String> returnList = new ArrayList<>();
for (String item : list) { for (String item : list) {
if (item.toLowerCase().startsWith(string.toLowerCase())) { if (item.toLowerCase().startsWith(string.toLowerCase())) {
returnList.add(item); returnList.add(item);
} }
} }
return returnList; return returnList;
} }

View File

@ -23,10 +23,12 @@ public class WorldEditHook {
@Subscribe @Subscribe
public void wrapForLogging(final EditSessionEvent event) { public void wrapForLogging(final EditSessionEvent event) {
event.setExtent(new AbstractDelegateExtent(event.getExtent()) { event.setExtent(new AbstractDelegateExtent(event.getExtent()) {
@Override @Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block) throws WorldEditException { public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block) throws WorldEditException {
if (block.getBlockType().getMaterial().isAir()) { if (block.getBlockType().getMaterial().isAir()) {
World world = Bukkit.getWorld(event.getWorld().getName()); World world = Bukkit.getWorld(event.getWorld().getName());
if (world != null) { if (world != null) {
Location l = new Location(world, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); Location l = new Location(world, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
if (BlockStorage.hasBlockInfo(l)) BlockStorage.clearBlockInfo(l); if (BlockStorage.hasBlockInfo(l)) BlockStorage.clearBlockInfo(l);
@ -34,6 +36,7 @@ public class WorldEditHook {
} }
return getExtent().setBlock(pos, block); return getExtent().setBlock(pos, block);
} }
}); });
} }

View File

@ -3,6 +3,7 @@ package me.mrCookieSlime.Slimefun.listeners;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -21,8 +22,6 @@ import me.mrCookieSlime.Slimefun.androids.AndroidEntity;
public class AndroidKillingListener implements Listener { public class AndroidKillingListener implements Listener {
private final Random random = new Random();
public AndroidKillingListener(SlimefunPlugin plugin) { public AndroidKillingListener(SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
@ -42,6 +41,8 @@ public class AndroidKillingListener implements Listener {
} }
} }
Random random = ThreadLocalRandom.current();
switch (e.getEntityType()) { switch (e.getEntityType()) {
case BLAZE: case BLAZE:
items.add(new ItemStack(Material.BLAZE_ROD, 1 + random.nextInt(2))); items.add(new ItemStack(Material.BLAZE_ROD, 1 + random.nextInt(2)));
@ -58,7 +59,7 @@ public class AndroidKillingListener implements Listener {
break; break;
} }
obj.getAndroid().addItems(obj.getBlock(), items.toArray(new ItemStack[items.size()])); obj.getAndroid().addItems(obj.getBlock(), items.toArray(new ItemStack[0]));
ExperienceOrb exp = (ExperienceOrb) e.getEntity().getWorld().spawnEntity(e.getEntity().getLocation(), EntityType.EXPERIENCE_ORB); ExperienceOrb exp = (ExperienceOrb) e.getEntity().getWorld().spawnEntity(e.getEntity().getLocation(), EntityType.EXPERIENCE_ORB);
exp.setExperience(1 + random.nextInt(6)); exp.setExperience(1 + random.nextInt(6));
}, 1L); }, 1L);

View File

@ -49,6 +49,7 @@ public class BackpackListener implements Listener {
if (SlimefunPlugin.getUtilities().backpack.containsKey(e.getPlayer().getUniqueId())){ if (SlimefunPlugin.getUtilities().backpack.containsKey(e.getPlayer().getUniqueId())){
ItemStack item = e.getItemDrop().getItemStack(); ItemStack item = e.getItemDrop().getItemStack();
SlimefunItem sfItem = SlimefunItem.getByItem(item); SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem instanceof SlimefunBackpack) e.setCancelled(true); if (sfItem instanceof SlimefunBackpack) e.setCancelled(true);
} }
} }

View File

@ -1,6 +1,5 @@
package me.mrCookieSlime.Slimefun.listeners; package me.mrCookieSlime.Slimefun.listeners;
import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
@ -19,6 +18,7 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.handlers.BowShootHandler; import me.mrCookieSlime.Slimefun.Objects.handlers.BowShootHandler;
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler; import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
import me.mrCookieSlime.Slimefun.api.Slimefun;
public class BowListener implements Listener { public class BowListener implements Listener {
@ -35,10 +35,14 @@ public class BowListener implements Listener {
@EventHandler @EventHandler
public void onArrowHit(final ProjectileHitEvent e) { public void onArrowHit(final ProjectileHitEvent e) {
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> { Slimefun.runSync(() -> {
if (!e.getEntity().isValid()) return; if (e.getEntity().isValid()) {
SlimefunPlugin.getUtilities().arrows.remove(e.getEntity().getUniqueId()); SlimefunPlugin.getUtilities().arrows.remove(e.getEntity().getUniqueId());
if (e.getEntity() instanceof Arrow) handleGrapplingHook((Arrow) e.getEntity());
if (e.getEntity() instanceof Arrow) {
handleGrapplingHook((Arrow) e.getEntity());
}
}
}, 4L); }, 4L);
} }
@ -62,7 +66,7 @@ public class BowListener implements Listener {
if (n.isValid()) n.remove(); if (n.isValid()) n.remove();
} }
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> { Slimefun.runSync(() -> {
SlimefunPlugin.getUtilities().jumpState.remove(p.getUniqueId()); SlimefunPlugin.getUtilities().jumpState.remove(p.getUniqueId());
SlimefunPlugin.getUtilities().remove.remove(p.getUniqueId()); SlimefunPlugin.getUtilities().remove.remove(p.getUniqueId());
}, 20L); }, 20L);
@ -91,7 +95,7 @@ public class BowListener implements Listener {
if (n.isValid()) n.remove(); if (n.isValid()) n.remove();
} }
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> { Slimefun.runSync(() -> {
SlimefunPlugin.getUtilities().jumpState.remove(p.getUniqueId()); SlimefunPlugin.getUtilities().jumpState.remove(p.getUniqueId());
SlimefunPlugin.getUtilities().remove.remove(p.getUniqueId()); SlimefunPlugin.getUtilities().remove.remove(p.getUniqueId());
}, 20L); }, 20L);
@ -104,7 +108,9 @@ public class BowListener implements Listener {
if (e.getDamager() instanceof Arrow) { if (e.getDamager() instanceof Arrow) {
if (SlimefunPlugin.getUtilities().arrows.containsKey(e.getDamager().getUniqueId()) && e.getEntity() instanceof LivingEntity) { if (SlimefunPlugin.getUtilities().arrows.containsKey(e.getDamager().getUniqueId()) && e.getEntity() instanceof LivingEntity) {
for (ItemHandler handler : SlimefunItem.getHandlers("BowShootHandler")) { for (ItemHandler handler : SlimefunItem.getHandlers("BowShootHandler")) {
if (((BowShootHandler) handler).onHit(e, (LivingEntity) e.getEntity())) break; if (((BowShootHandler) handler).onHit(e, (LivingEntity) e.getEntity())) {
break;
}
} }
SlimefunPlugin.getUtilities().arrows.remove(e.getDamager().getUniqueId()); SlimefunPlugin.getUtilities().arrows.remove(e.getDamager().getUniqueId());

View File

@ -359,7 +359,7 @@ public class ItemListener implements Listener {
// Remove the glass bottle once drunk // Remove the glass bottle once drunk
final int m = mode; final int m = mode;
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> { Slimefun.runSync(() -> {
if (m == 0) p.getEquipment().getItemInMainHand().setAmount(0); if (m == 0) p.getEquipment().getItemInMainHand().setAmount(0);
else if (m == 1) p.getEquipment().getItemInOffHand().setAmount(0); else if (m == 1) p.getEquipment().getItemInOffHand().setAmount(0);
else if (m == 2) p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1)); else if (m == 2) p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1));

View File

@ -40,7 +40,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class TalismanListener implements Listener { public class TalismanListener implements Listener {
private Random random = new Random(); private final Random random = new Random();
public TalismanListener(SlimefunPlugin plugin) { public TalismanListener(SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
@ -89,7 +89,7 @@ public class TalismanListener implements Listener {
} }
} }
final ItemStack item = e.getBrokenItem().clone(); ItemStack item = e.getBrokenItem().clone();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
if (meta instanceof Damageable) { if (meta instanceof Damageable) {
@ -98,14 +98,16 @@ public class TalismanListener implements Listener {
item.setItemMeta(meta); item.setItemMeta(meta);
final int itemSlot = slot; int itemSlot = slot;
SlimefunPlugin.instance.getServer().getScheduler().runTaskLater(SlimefunPlugin.instance, () -> inv.setItem(itemSlot, item), 1L); Slimefun.runSync(() -> inv.setItem(itemSlot, item), 1L);
} }
} }
@EventHandler @EventHandler
public void onSprint(PlayerToggleSprintEvent e) { public void onSprint(PlayerToggleSprintEvent e) {
if (e.isSprinting()) Talisman.checkFor(e, (SlimefunItemStack) SlimefunItems.TALISMAN_TRAVELLER); if (e.isSprinting()) {
Talisman.checkFor(e, (SlimefunItemStack) SlimefunItems.TALISMAN_TRAVELLER);
}
} }
@EventHandler @EventHandler

View File

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
@ -47,7 +48,6 @@ public class ToolListener implements Listener {
// Materials that require a Block under it, e.g. Pressure Plates // Materials that require a Block under it, e.g. Pressure Plates
private final Set<Material> sensitiveMaterials = new HashSet<>(); private final Set<Material> sensitiveMaterials = new HashSet<>();
private final Random random = new Random();
private final Utilities utilities; private final Utilities utilities;
public ToolListener(SlimefunPlugin plugin) { public ToolListener(SlimefunPlugin plugin) {
@ -164,7 +164,7 @@ public class ToolListener implements Listener {
gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_APPLE_PIE, 4)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_APPLE_PIE, 4));
gifts.add(new ItemStack(Material.EMERALD)); gifts.add(new ItemStack(Material.EMERALD));
e.getBlockPlaced().getWorld().dropItemNaturally(e.getBlockPlaced().getLocation(), gifts.get(random.nextInt(gifts.size()))); e.getBlockPlaced().getWorld().dropItemNaturally(e.getBlockPlaced().getLocation(), gifts.get(ThreadLocalRandom.current().nextInt(gifts.size())));
} }
else if (SlimefunManager.isItemSimilar(item, SlimefunItems.CARGO_INPUT, false)) { else if (SlimefunManager.isItemSimilar(item, SlimefunItems.CARGO_INPUT, false)) {
if (e.getBlock().getY() != e.getBlockAgainst().getY()) { if (e.getBlock().getY() != e.getBlockAgainst().getY()) {
@ -266,6 +266,8 @@ public class ToolListener implements Listener {
} }
else if (item != null) { else if (item != null) {
if (item.getEnchantments().containsKey(Enchantment.LOOT_BONUS_BLOCKS) && !item.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { if (item.getEnchantments().containsKey(Enchantment.LOOT_BONUS_BLOCKS) && !item.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) {
Random random = ThreadLocalRandom.current();
fortune = random.nextInt(item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS) + 2) - 1; fortune = random.nextInt(item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS) + 2) - 1;
if (fortune <= 0) fortune = 1; if (fortune <= 0) fortune = 1;
fortune = (e.getBlock().getType() == Material.LAPIS_ORE ? 4 + random.nextInt(5) : 1) * (fortune + 1); fortune = (e.getBlock().getType() == Material.LAPIS_ORE ? 4 + random.nextInt(5) : 1) * (fortune + 1);