mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
commit
e41b2762f0
@ -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;
|
||||||
|
@ -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) {
|
||||||
|
@ -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;
|
||||||
|
@ -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.
|
||||||
|
@ -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++;
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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
|
@ -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
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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
|
@ -39,13 +39,15 @@ public final class GEOScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int index = 10;
|
int index = 10;
|
||||||
for (OreGenResource resource: OreGenSystem.listResources()) {
|
for (OreGenResource resource : OreGenSystem.listResources()) {
|
||||||
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++;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
*
|
*
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,8 +117,8 @@ public class LockedCategory extends Category {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasUnlocked(Player p, PlayerProfile profile) {
|
public boolean hasUnlocked(Player p, PlayerProfile profile) {
|
||||||
for (Category category: parents) {
|
for (Category category : parents) {
|
||||||
for (SlimefunItem item: category.getItems()) {
|
for (SlimefunItem item : category.getItems()) {
|
||||||
if (Slimefun.isEnabled(p, item, false)
|
if (Slimefun.isEnabled(p, item, false)
|
||||||
&& Slimefun.hasPermission(p, item, false)
|
&& Slimefun.hasPermission(p, item, false)
|
||||||
&& item.getResearch() != null
|
&& item.getResearch() != null
|
||||||
@ -126,6 +127,7 @@ public class LockedCategory extends Category {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
@ -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");
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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()]);
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,8 +224,8 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MachineFuel findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
private MachineFuel findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
||||||
for (MachineFuel recipe: recipes) {
|
for (MachineFuel recipe : recipes) {
|
||||||
for (int slot: getInputSlots()) {
|
for (int slot : getInputSlots()) {
|
||||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
||||||
found.put(slot, recipe.getInput().getAmount());
|
found.put(slot, recipe.getInput().getAmount());
|
||||||
return recipe;
|
return recipe;
|
||||||
@ -249,7 +249,7 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
|||||||
public List<ItemStack> getDisplayRecipes() {
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
List<ItemStack> list = new ArrayList<>();
|
List<ItemStack> list = new ArrayList<>();
|
||||||
|
|
||||||
for (MachineFuel fuel: recipes) {
|
for (MachineFuel fuel : recipes) {
|
||||||
ItemStack item = fuel.getInput().clone();
|
ItemStack item = fuel.getInput().clone();
|
||||||
ItemMeta im = item.getItemMeta();
|
ItemMeta im = item.getItemMeta();
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@ 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;
|
||||||
|
|
||||||
|
@ -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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,12 @@ public class Composter extends SlimefunGadget {
|
|||||||
private static ItemStack[] getMachineRecipes() {
|
private static ItemStack[] getMachineRecipes() {
|
||||||
List<ItemStack> items = new LinkedList<>();
|
List<ItemStack> items = new LinkedList<>();
|
||||||
|
|
||||||
for (Material leave: MaterialCollections.getAllLeaves()) {
|
for (Material leave : MaterialCollections.getAllLeaves()) {
|
||||||
items.add(new ItemStack(leave, 8));
|
items.add(new ItemStack(leave, 8));
|
||||||
items.add(new ItemStack(Material.DIRT));
|
items.add(new ItemStack(Material.DIRT));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Material sapling: MaterialCollections.getAllSaplings()) {
|
for (Material sapling : MaterialCollections.getAllSaplings()) {
|
||||||
items.add(new ItemStack(sapling, 8));
|
items.add(new ItemStack(sapling, 8));
|
||||||
items.add(new ItemStack(Material.DIRT));
|
items.add(new ItemStack(Material.DIRT));
|
||||||
}
|
}
|
||||||
@ -66,11 +66,11 @@ 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)) {
|
||||||
if (convert != null && SlimefunManager.isItemSimilar(input, convert, true)) {
|
if (convert != null && SlimefunManager.isItemSimilar(input, convert, true)) {
|
||||||
ItemStack removing = input.clone();
|
ItemStack removing = input.clone();
|
||||||
removing.setAmount(convert.getAmount());
|
removing.setAmount(convert.getAmount());
|
||||||
@ -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);
|
||||||
|
@ -46,12 +46,12 @@ public class Crucible extends SlimefunGadget {
|
|||||||
items.add(new ItemStack(Material.OBSIDIAN, 1));
|
items.add(new ItemStack(Material.OBSIDIAN, 1));
|
||||||
items.add(new ItemStack(Material.LAVA_BUCKET));
|
items.add(new ItemStack(Material.LAVA_BUCKET));
|
||||||
|
|
||||||
for (Material leave: MaterialCollections.getAllLeaves()) {
|
for (Material leave : MaterialCollections.getAllLeaves()) {
|
||||||
items.add(new ItemStack(leave, 16));
|
items.add(new ItemStack(leave, 16));
|
||||||
items.add(new ItemStack(Material.WATER_BUCKET));
|
items.add(new ItemStack(Material.WATER_BUCKET));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Material sapling: MaterialCollections.getAllTerracottaColors()) {
|
for (Material sapling : MaterialCollections.getAllTerracottaColors()) {
|
||||||
items.add(new ItemStack(sapling, 12));
|
items.add(new ItemStack(sapling, 12));
|
||||||
items.add(new ItemStack(Material.LAVA_BUCKET));
|
items.add(new ItemStack(Material.LAVA_BUCKET));
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ public class Crucible extends SlimefunGadget {
|
|||||||
final Block block = e.getClickedBlock().getRelative(BlockFace.UP);
|
final Block block = e.getClickedBlock().getRelative(BlockFace.UP);
|
||||||
SlimefunItem machine = SlimefunItem.getByID(id);
|
SlimefunItem machine = SlimefunItem.getByID(id);
|
||||||
|
|
||||||
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
|
for (ItemStack convert : RecipeType.getRecipeInputs(machine)) {
|
||||||
if (SlimefunManager.isItemSimilar(input, convert, true)) {
|
if (SlimefunManager.isItemSimilar(input, convert, true)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class ReactorAccessPort extends SlimefunItem {
|
|||||||
if (reactor != null) {
|
if (reactor != null) {
|
||||||
menu.replaceExistingItem(INFO_SLOT, new CustomItem(new ItemStack(Material.GREEN_WOOL), "&7Reactor", "", "&6Detected", "", "&7> Click to view Reactor"));
|
menu.replaceExistingItem(INFO_SLOT, new CustomItem(new ItemStack(Material.GREEN_WOOL), "&7Reactor", "", "&6Detected", "", "&7> Click to view Reactor"));
|
||||||
menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> {
|
menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> {
|
||||||
if(reactor != null) {
|
if (reactor != null) {
|
||||||
reactor.open(p);
|
reactor.open(p);
|
||||||
}
|
}
|
||||||
newInstance(menu, b);
|
newInstance(menu, b);
|
||||||
|
@ -48,7 +48,8 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -89,7 +85,7 @@ public class AnimalGrowthAccelerator extends SlimefunItem implements InventoryBl
|
|||||||
|
|
||||||
protected void tick(Block b) {
|
protected void tick(Block b) {
|
||||||
for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), 3.0, 3.0, 3.0, n -> n instanceof Ageable && n.isValid() && !((Ageable) n).isAdult())) {
|
for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), 3.0, 3.0, 3.0, n -> n instanceof Ageable && n.isValid() && !((Ageable) n).isAdult())) {
|
||||||
for (int slot: getInputSlots()) {
|
for (int slot : getInputSlots()) {
|
||||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
|
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
|
||||||
if (ChargableBlock.getCharge(b) < energyConsumption) return;
|
if (ChargableBlock.getCharge(b) < energyConsumption) return;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public abstract class AutoAnvil extends AContainer {
|
|||||||
else {
|
else {
|
||||||
MachineRecipe recipe = null;
|
MachineRecipe recipe = null;
|
||||||
|
|
||||||
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]);
|
||||||
ItemStack item = menu.getItemInSlot(slot);
|
ItemStack item = menu.getItemInSlot(slot);
|
||||||
|
|
||||||
@ -96,9 +96,10 @@ public abstract class AutoAnvil extends AContainer {
|
|||||||
if (recipe != null) {
|
if (recipe != null) {
|
||||||
if (!menu.fits(recipe.getOutput()[0], getOutputSlots())) return;
|
if (!menu.fits(recipe.getOutput()[0], getOutputSlots())) return;
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -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});
|
||||||
|
@ -113,7 +113,7 @@ public class AutoDrier extends AContainer implements RecipeDisplayItem {
|
|||||||
MachineRecipe r = null;
|
MachineRecipe r = null;
|
||||||
int inputSlot = -1;
|
int inputSlot = -1;
|
||||||
|
|
||||||
for (int slot: getInputSlots()) {
|
for (int slot : getInputSlots()) {
|
||||||
ItemStack item = menu.getItemInSlot(slot);
|
ItemStack item = menu.getItemInSlot(slot);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
Material mat = item.getType();
|
Material mat = item.getType();
|
||||||
|
@ -74,7 +74,7 @@ public class AutoEnchanter extends AContainer {
|
|||||||
else {
|
else {
|
||||||
MachineRecipe recipe = null;
|
MachineRecipe recipe = null;
|
||||||
|
|
||||||
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]);
|
||||||
// Check if enchantable
|
// Check if enchantable
|
||||||
SlimefunItem sfTarget = SlimefunItem.getByItem(target);
|
SlimefunItem sfTarget = SlimefunItem.getByItem(target);
|
||||||
@ -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();
|
||||||
@ -98,11 +98,11 @@ public class AutoEnchanter extends AContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) {
|
if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) {
|
||||||
for (ItemEnchantment enchantment: EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
|
for (ItemEnchantment enchantment : EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
|
||||||
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)});
|
||||||
|
@ -110,13 +110,13 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
|
|||||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason 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) {
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||||
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));
|
||||||
inv.replaceExistingItem(slot, null);
|
inv.replaceExistingItem(slot, null);
|
||||||
|
@ -39,13 +39,15 @@ 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) {
|
||||||
if (ItemEnergy.getStoredEnergy(stack) < ItemEnergy.getMaxEnergy(stack)) {
|
if (ItemEnergy.getStoredEnergy(stack) < ItemEnergy.getMaxEnergy(stack)) {
|
||||||
|
|
||||||
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());
|
||||||
|
@ -49,7 +49,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem implements Inve
|
|||||||
registerBlockHandler(getID(), (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) {
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||||
inv.replaceExistingItem(slot, null);
|
inv.replaceExistingItem(slot, null);
|
||||||
@ -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
|
||||||
|
@ -68,13 +68,13 @@ public abstract class ElectricDustWasher extends AContainer {
|
|||||||
else {
|
else {
|
||||||
ItemStack[] items = SlimefunPlugin.getUtilities().oreWasherOutputs;
|
ItemStack[] items = SlimefunPlugin.getUtilities().oreWasherOutputs;
|
||||||
|
|
||||||
for (int slot: getInputSlots()) {
|
for (int slot : getInputSlots()) {
|
||||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.SIFTED_ORE, true)) {
|
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.SIFTED_ORE, true)) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -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)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ public abstract class ElectricGoldPan extends AContainer implements RecipeDispla
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int slot: getInputSlots()) {
|
for (int slot : getInputSlots()) {
|
||||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.GRAVEL), true)) {
|
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.GRAVEL), true)) {
|
||||||
ItemStack output = randomizer.getRandom();
|
ItemStack output = randomizer.getRandom();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class ElectricIngotPulverizer extends AContainer implements RecipeDisplay
|
|||||||
public List<ItemStack> getDisplayRecipes() {
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2);
|
List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2);
|
||||||
|
|
||||||
for (MachineRecipe recipe: recipes) {
|
for (MachineRecipe recipe : recipes) {
|
||||||
displayRecipes.add(recipe.getInput()[0]);
|
displayRecipes.add(recipe.getInput()[0]);
|
||||||
displayRecipes.add(recipe.getOutput()[0]);
|
displayRecipes.add(recipe.getOutput()[0]);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -33,7 +33,7 @@ public abstract class Freezer extends AContainer implements RecipeDisplayItem {
|
|||||||
public List<ItemStack> getDisplayRecipes() {
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2);
|
List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2);
|
||||||
|
|
||||||
for (MachineRecipe recipe: recipes) {
|
for (MachineRecipe recipe : recipes) {
|
||||||
displayRecipes.add(recipe.getInput()[0]);
|
displayRecipes.add(recipe.getInput()[0]);
|
||||||
displayRecipes.add(recipe.getOutput()[recipe.getOutput().length - 1]);
|
displayRecipes.add(recipe.getOutput()[recipe.getOutput().length - 1]);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public abstract class HeatedPressureChamber extends AContainer {
|
|||||||
|
|
||||||
List<Integer> slots = new ArrayList<>();
|
List<Integer> slots = new ArrayList<>();
|
||||||
|
|
||||||
for (int slot: getInputSlots()) {
|
for (int slot : getInputSlots()) {
|
||||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), item, true)) {
|
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), item, true)) {
|
||||||
slots.add(slot);
|
slots.add(slot);
|
||||||
}
|
}
|
||||||
@ -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++) {
|
||||||
@ -94,8 +93,9 @@ public abstract class HeatedPressureChamber extends AContainer {
|
|||||||
registerRecipe(30, new ItemStack[] {SlimefunItems.BLISTERING_INGOT, SlimefunItems.CARBONADO}, new ItemStack[] {SlimefunItems.BLISTERING_INGOT_2});
|
registerRecipe(30, new ItemStack[] {SlimefunItems.BLISTERING_INGOT, SlimefunItems.CARBONADO}, new ItemStack[] {SlimefunItems.BLISTERING_INGOT_2});
|
||||||
registerRecipe(60, new ItemStack[] {SlimefunItems.BLISTERING_INGOT_2, new ItemStack(Material.NETHER_STAR)}, new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3});
|
registerRecipe(60, new ItemStack[] {SlimefunItems.BLISTERING_INGOT_2, new ItemStack(Material.NETHER_STAR)}, new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3});
|
||||||
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,9 +164,9 @@ 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()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,9 +177,9 @@ public abstract class HeatedPressureChamber extends AContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MachineRecipe findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
private MachineRecipe findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
||||||
for (MachineRecipe recipe: recipes) {
|
for (MachineRecipe recipe : recipes) {
|
||||||
for (ItemStack input: recipe.getInput()) {
|
for (ItemStack input : recipe.getInput()) {
|
||||||
for (int slot: getInputSlots()) {
|
for (int slot : getInputSlots()) {
|
||||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), input, true)) {
|
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), input, true)) {
|
||||||
found.put(slot, input.getAmount());
|
found.put(slot, input.getAmount());
|
||||||
break;
|
break;
|
||||||
|
@ -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,32 +50,38 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
@ -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,36 +50,32 @@ 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) -> {
|
BlockStorage.addBlockInfo(b, "enabled", "true");
|
||||||
BlockStorage.addBlockInfo(b, "enabled", "true");
|
|
||||||
newInstance(menu, b);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.REDSTONE), "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
|
|
||||||
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
|
|
||||||
BlockStorage.addBlockInfo(b, "enabled", "false");
|
|
||||||
newInstance(menu, b);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "offset") == null) ? 3.0F: Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
|
|
||||||
|
|
||||||
menu.replaceExistingItem(31, new CustomItem(new ItemStack(Material.PISTON), "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
|
|
||||||
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
|
|
||||||
double offsetv = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (action.isRightClicked() ? -0.1F : 0.1F));
|
|
||||||
BlockStorage.addBlockInfo(b, "offset", String.valueOf(offsetv));
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.REDSTONE), "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
|
||||||
|
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
|
||||||
|
BlockStorage.addBlockInfo(b, "enabled", "false");
|
||||||
|
newInstance(menu, b);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "offset") == null) ? 3.0F: Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
|
||||||
|
|
||||||
|
menu.replaceExistingItem(31, new CustomItem(new ItemStack(Material.PISTON), "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
|
||||||
|
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
|
||||||
|
double offsetv = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (action.isRightClicked() ? -0.1F : 0.1F));
|
||||||
|
BlockStorage.addBlockInfo(b, "offset", String.valueOf(offsetv));
|
||||||
|
newInstance(menu, b);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,13 +111,15 @@ 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) {
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class XPCollector extends SlimefunItem implements InventoryBlock {
|
|||||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||||
BlockMenu inv = BlockStorage.getInventory(b);
|
BlockMenu inv = BlockStorage.getInventory(b);
|
||||||
if (inv != null) {
|
if (inv != 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));
|
||||||
inv.replaceExistingItem(slot, null);
|
inv.replaceExistingItem(slot, null);
|
||||||
@ -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;
|
||||||
|
@ -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";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -109,7 +109,8 @@ 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()));
|
||||||
}
|
}
|
||||||
@ -174,7 +175,7 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
|
|||||||
else {
|
else {
|
||||||
Chunk chunk = b.getChunk();
|
Chunk chunk = b.getChunk();
|
||||||
|
|
||||||
for (OreGenResource resource: OreGenSystem.listResources()) {
|
for (OreGenResource resource : OreGenSystem.listResources()) {
|
||||||
if (!resource.isLiquid()) {
|
if (!resource.isLiquid()) {
|
||||||
if (!OreGenSystem.wasResourceGenerated(resource, chunk)) {
|
if (!OreGenSystem.wasResourceGenerated(resource, chunk)) {
|
||||||
SimpleHologram.update(b, "&4GEO-Scan required!");
|
SimpleHologram.update(b, "&4GEO-Scan required!");
|
||||||
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
@ -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);
|
||||||
|
@ -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 convert: RecipeType.getRecipeInputs(this)) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
|
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;
|
||||||
|
|
||||||
@ -66,7 +69,7 @@ public class Compressor extends MultiBlockMachine {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}, i*20L);
|
}, i * 20L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
@ -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,11 +93,12 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = "";
|
String id = "";
|
||||||
int size = ((SlimefunBackpack) sfItem).getSize();
|
int size = ((SlimefunBackpack) sfItem).getSize();
|
||||||
|
|
||||||
if (backpack != null) {
|
if (backpack != null) {
|
||||||
for (String line: backpack.getItemMeta().getLore()) {
|
for (String line : backpack.getItemMeta().getLore()) {
|
||||||
if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&7ID: ")) && line.contains("#")) {
|
if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&7ID: ")) && line.contains("#")) {
|
||||||
id = line.replace(ChatColor.translateAlternateColorCodes('&', "&7ID: "), "");
|
id = line.replace(ChatColor.translateAlternateColorCodes('&', "&7ID: "), "");
|
||||||
PlayerProfile.fromUUID(UUID.fromString(id.split("#")[0])).getBackpack(Integer.parseInt(id.split("#")[1])).setSize(size);
|
PlayerProfile.fromUUID(UUID.fromString(id.split("#")[0])).getBackpack(Integer.parseInt(id.split("#")[1])).setSize(size);
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ public class GrindStone extends MultiBlockMachine {
|
|||||||
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)) {
|
||||||
ItemStack output = RecipeType.getRecipeOutput(this, convert);
|
ItemStack output = RecipeType.getRecipeOutput(this, convert);
|
||||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
|
@ -43,8 +43,9 @@ 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 convert: RecipeType.getRecipeInputs(this)) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
|
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||||
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
||||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||||
|
@ -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");
|
||||||
|
|
||||||
@ -99,7 +101,7 @@ public class MagicWorkbench extends MultiBlockMachine {
|
|||||||
int size = ((SlimefunBackpack) sfItem).getSize();
|
int size = ((SlimefunBackpack) sfItem).getSize();
|
||||||
|
|
||||||
if (backpack != null) {
|
if (backpack != null) {
|
||||||
for (String line: backpack.getItemMeta().getLore()) {
|
for (String line : backpack.getItemMeta().getLore()) {
|
||||||
if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&7ID: ")) && line.contains("#")) {
|
if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&7ID: ")) && line.contains("#")) {
|
||||||
id = line.replace(ChatColor.translateAlternateColorCodes('&', "&7ID: "), "");
|
id = line.replace(ChatColor.translateAlternateColorCodes('&', "&7ID: "), "");
|
||||||
PlayerProfile.fromUUID(UUID.fromString(id.split("#")[0])).getBackpack(Integer.parseInt(id.split("#")[1])).setSize(size);
|
PlayerProfile.fromUUID(UUID.fromString(id.split("#")[0])).getBackpack(Integer.parseInt(id.split("#")[1])).setSize(size);
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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,8 +59,9 @@ 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 convert: RecipeType.getRecipeInputs(this)) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
|
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||||
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
||||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||||
|
@ -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);
|
||||||
@ -48,7 +55,7 @@ public class OreWasher extends MultiBlockMachine {
|
|||||||
Inventory inv = disp.getInventory();
|
Inventory inv = disp.getInventory();
|
||||||
ItemStack[] items = SlimefunPlugin.getUtilities().oreWasherOutputs;
|
ItemStack[] items = SlimefunPlugin.getUtilities().oreWasherOutputs;
|
||||||
|
|
||||||
for (ItemStack current: inv.getContents()) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
if (SlimefunManager.isItemSimilar(current, SlimefunItems.SIFTED_ORE, true)) {
|
if (SlimefunManager.isItemSimilar(current, SlimefunItems.SIFTED_ORE, true)) {
|
||||||
ItemStack adding = items[new Random().nextInt(items.length)];
|
ItemStack adding = items[new Random().nextInt(items.length)];
|
||||||
|
@ -33,7 +33,7 @@ public class TableSaw extends MultiBlockMachine {
|
|||||||
BlockFace.SELF
|
BlockFace.SELF
|
||||||
);
|
);
|
||||||
|
|
||||||
for (Material log: Tag.LOGS.getValues()) {
|
for (Material log : Tag.LOGS.getValues()) {
|
||||||
Optional<Material> planks = MaterialConverter.getPlanksFromLog(log);
|
Optional<Material> planks = MaterialConverter.getPlanksFromLog(log);
|
||||||
|
|
||||||
if (planks.isPresent()) {
|
if (planks.isPresent()) {
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
@ -2788,7 +2804,7 @@ public final class SlimefunSetup {
|
|||||||
.register(true);
|
.register(true);
|
||||||
|
|
||||||
new SlimefunItem(Categories.RESOURCES, (SlimefunItemStack) SlimefunItems.BLISTERING_INGOT_3, RecipeType.HEATED_PRESSURE_CHAMBER,
|
new SlimefunItem(Categories.RESOURCES, (SlimefunItemStack) SlimefunItems.BLISTERING_INGOT_3, RecipeType.HEATED_PRESSURE_CHAMBER,
|
||||||
new ItemStack[] {SlimefunItems.BLISTERING_INGOT_2,new ItemStack(Material.NETHER_STAR), null, null, null, null, null, null, null})
|
new ItemStack[] {SlimefunItems.BLISTERING_INGOT_2, new ItemStack(Material.NETHER_STAR), null, null, null, null, null, null, null})
|
||||||
.register(true);
|
.register(true);
|
||||||
|
|
||||||
new SlimefunItem(Categories.RESOURCES, (SlimefunItemStack) SlimefunItems.ENRICHED_NETHER_ICE, RecipeType.HEATED_PRESSURE_CHAMBER,
|
new SlimefunItem(Categories.RESOURCES, (SlimefunItemStack) SlimefunItems.ENRICHED_NETHER_ICE, RecipeType.HEATED_PRESSURE_CHAMBER,
|
||||||
@ -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) {
|
||||||
|
@ -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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -370,7 +348,7 @@ public final class SlimefunPlugin extends JavaPlugin {
|
|||||||
if (profile.isDirty()) profile.save();
|
if (profile.isDirty()) profile.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
for (World world: Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
try {
|
try {
|
||||||
BlockStorage storage = BlockStorage.getStorage(world);
|
BlockStorage storage = BlockStorage.getStorage(world);
|
||||||
|
|
||||||
@ -385,7 +363,7 @@ public final class SlimefunPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (UniversalBlockMenu menu: utilities.universalInventories.values()) {
|
for (UniversalBlockMenu menu : utilities.universalInventories.values()) {
|
||||||
menu.save();
|
menu.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +381,7 @@ public final class SlimefunPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
instance = null;
|
instance = null;
|
||||||
|
|
||||||
for (Player p: Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -102,7 +102,7 @@ public class AncientAltarListener implements Listener {
|
|||||||
|
|
||||||
if (catalyst.getType() != Material.AIR) {
|
if (catalyst.getType() != Material.AIR) {
|
||||||
List<ItemStack> input = new ArrayList<>();
|
List<ItemStack> input = new ArrayList<>();
|
||||||
for (Block pedestal: pedestals) {
|
for (Block pedestal : pedestals) {
|
||||||
Item stack = findItem(pedestal);
|
Item stack = findItem(pedestal);
|
||||||
if (stack != null) input.add(fixItemStack(stack.getItemStack(), stack.getCustomName()));
|
if (stack != null) input.add(fixItemStack(stack.getItemStack(), stack.getCustomName()));
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ public class AncientAltarListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Item findItem(Block b) {
|
public static Item findItem(Block b) {
|
||||||
for (Entity n: b.getChunk().getEntities()) {
|
for (Entity n : b.getChunk().getEntities()) {
|
||||||
if (n instanceof Item && b.getLocation().add(0.5, 1.2, 0.5).distanceSquared(n.getLocation()) < 0.5D && n.getCustomName() != null) return (Item) n;
|
if (n instanceof Item && b.getLocation().add(0.5, 1.2, 0.5).distanceSquared(n.getLocation()) < 0.5D && n.getCustomName() != null) return (Item) n;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -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);
|
||||||
@ -65,7 +66,7 @@ public final class Pedestals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack checkRecipe(ItemStack catalyst, List<ItemStack> items) {
|
private static ItemStack checkRecipe(ItemStack catalyst, List<ItemStack> items) {
|
||||||
for (AltarRecipe recipe: SlimefunPlugin.getUtilities().altarRecipes) {
|
for (AltarRecipe recipe : SlimefunPlugin.getUtilities().altarRecipes) {
|
||||||
if (SlimefunManager.isItemSimilar(catalyst, recipe.getCatalyst(), true)) {
|
if (SlimefunManager.isItemSimilar(catalyst, recipe.getCatalyst(), true)) {
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
if (SlimefunManager.isItemSimilar(items.get(i), recipe.getInput().get(0), true)) {
|
if (SlimefunManager.isItemSimilar(items.get(i), recipe.getInput().get(0), true)) {
|
||||||
|
@ -49,7 +49,7 @@ public class RitualAnimation implements Runnable {
|
|||||||
this.running = true;
|
this.running = true;
|
||||||
this.stage = 0;
|
this.stage = 0;
|
||||||
|
|
||||||
for (Block pedestal: this.pedestals) {
|
for (Block pedestal : this.pedestals) {
|
||||||
Item item = AncientAltarListener.findItem(pedestal);
|
Item item = AncientAltarListener.findItem(pedestal);
|
||||||
this.itemLock.put(item, item.getLocation().clone());
|
this.itemLock.put(item, item.getLocation().clone());
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public class RitualAnimation implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkLockedItems() {
|
private boolean checkLockedItems() {
|
||||||
for (Map.Entry<Item, Location> entry: itemLock.entrySet()) {
|
for (Map.Entry<Item, Location> entry : itemLock.entrySet()) {
|
||||||
if (entry.getKey().getLocation().distance(entry.getValue()) > 0.3) {
|
if (entry.getKey().getLocation().distance(entry.getValue()) > 0.3) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class BlockStorage {
|
|||||||
long totalBlocks = 0;
|
long totalBlocks = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (File file: f.listFiles()) {
|
for (File file : f.listFiles()) {
|
||||||
if (file.getName().equals("null.sfb")) {
|
if (file.getName().equals("null.sfb")) {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Corrupted file detected!");
|
Slimefun.getLogger().log(Level.WARNING, "Corrupted file detected!");
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Slimefun will simply skip this File, but you");
|
Slimefun.getLogger().log(Level.WARNING, "Slimefun will simply skip this File, but you");
|
||||||
@ -110,7 +110,7 @@ public class BlockStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||||
for (String key: cfg.getKeys(false)) {
|
for (String key : cfg.getKeys(false)) {
|
||||||
Location l = deserializeLocation(key);
|
Location l = deserializeLocation(key);
|
||||||
String chunkString = locationToChunkString(l);
|
String chunkString = locationToChunkString(l);
|
||||||
try {
|
try {
|
||||||
@ -158,9 +158,11 @@ 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])) {
|
||||||
SlimefunPlugin.getUtilities().mapChunks.put(key, new BlockInfoConfig(parseJSON(cfg.getString(key))));
|
SlimefunPlugin.getUtilities().mapChunks.put(key, new BlockInfoConfig(parseJSON(cfg.getString(key))));
|
||||||
@ -173,13 +175,14 @@ public class BlockStorage {
|
|||||||
|
|
||||||
SlimefunPlugin.getUtilities().worlds.put(world.getName(), this);
|
SlimefunPlugin.getUtilities().worlds.put(world.getName(), this);
|
||||||
|
|
||||||
for (File file: new File("data-storage/Slimefun/stored-inventories").listFiles()) {
|
for (File file : new File("data-storage/Slimefun/stored-inventories").listFiles()) {
|
||||||
if (file.getName().startsWith(w.getName()) && file.getName().endsWith(".sfi")) {
|
if (file.getName().startsWith(w.getName()) && file.getName().endsWith(".sfi")) {
|
||||||
Location l = deserializeLocation(file.getName().replace(".sfi", ""));
|
Location l = deserializeLocation(file.getName().replace(".sfi", ""));
|
||||||
Config cfg = new Config(file);
|
Config cfg = new Config(file);
|
||||||
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
@ -194,7 +197,7 @@ public class BlockStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (File file: new File("data-storage/Slimefun/universal-inventories").listFiles()) {
|
for (File file : new File("data-storage/Slimefun/universal-inventories").listFiles()) {
|
||||||
if (file.getName().endsWith(".sfi")) {
|
if (file.getName().endsWith(".sfi")) {
|
||||||
Config cfg = new Config(file);
|
Config cfg = new Config(file);
|
||||||
BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset"));
|
BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset"));
|
||||||
@ -213,12 +216,12 @@ public class BlockStorage {
|
|||||||
changes = blocksCache.size() + chunkChanges;
|
changes = blocksCache.size() + chunkChanges;
|
||||||
|
|
||||||
Map<Location, BlockMenu> inventories2 = new HashMap<>(inventories);
|
Map<Location, BlockMenu> inventories2 = new HashMap<>(inventories);
|
||||||
for (Map.Entry<Location, BlockMenu> entry: inventories2.entrySet()) {
|
for (Map.Entry<Location, BlockMenu> entry : inventories2.entrySet()) {
|
||||||
changes += entry.getValue().getUnsavedChanges();
|
changes += entry.getValue().getUnsavedChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, UniversalBlockMenu> universalInventories2 = new HashMap<>(SlimefunPlugin.getUtilities().universalInventories);
|
Map<String, UniversalBlockMenu> universalInventories2 = new HashMap<>(SlimefunPlugin.getUtilities().universalInventories);
|
||||||
for (Map.Entry<String, UniversalBlockMenu> entry: universalInventories2.entrySet()) {
|
for (Map.Entry<String, UniversalBlockMenu> entry : universalInventories2.entrySet()) {
|
||||||
changes += entry.getValue().getUnsavedChanges();
|
changes += entry.getValue().getUnsavedChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,7 +242,7 @@ public class BlockStorage {
|
|||||||
|
|
||||||
Map<String, Config> cache = new HashMap<>(blocksCache);
|
Map<String, Config> cache = new HashMap<>(blocksCache);
|
||||||
|
|
||||||
for (Map.Entry<String, Config> entry: cache.entrySet()) {
|
for (Map.Entry<String, Config> entry : cache.entrySet()) {
|
||||||
blocksCache.remove(entry.getKey());
|
blocksCache.remove(entry.getKey());
|
||||||
Config cfg = entry.getValue();
|
Config cfg = entry.getValue();
|
||||||
|
|
||||||
@ -263,13 +266,13 @@ public class BlockStorage {
|
|||||||
|
|
||||||
Map<Location, BlockMenu> inventories2 = new HashMap<>(inventories);
|
Map<Location, BlockMenu> inventories2 = new HashMap<>(inventories);
|
||||||
|
|
||||||
for (Map.Entry<Location, BlockMenu> entry: inventories2.entrySet()) {
|
for (Map.Entry<Location, BlockMenu> entry : inventories2.entrySet()) {
|
||||||
entry.getValue().save(entry.getKey());
|
entry.getValue().save(entry.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, UniversalBlockMenu> universalInventories2 = new HashMap<>(SlimefunPlugin.getUtilities().universalInventories);
|
Map<String, UniversalBlockMenu> universalInventories2 = new HashMap<>(SlimefunPlugin.getUtilities().universalInventories);
|
||||||
|
|
||||||
for (Map.Entry<String, UniversalBlockMenu> entry: universalInventories2.entrySet()) {
|
for (Map.Entry<String, UniversalBlockMenu> entry : universalInventories2.entrySet()) {
|
||||||
entry.getValue().save();
|
entry.getValue().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +280,7 @@ public class BlockStorage {
|
|||||||
File chunks = new File(path_chunks + "chunks.sfc");
|
File chunks = new File(path_chunks + "chunks.sfc");
|
||||||
Config cfg = new Config(path_chunks + "chunks.temp");
|
Config cfg = new Config(path_chunks + "chunks.temp");
|
||||||
|
|
||||||
for (Map.Entry<String, BlockInfoConfig> entry: SlimefunPlugin.getUtilities().mapChunks.entrySet()) {
|
for (Map.Entry<String, BlockInfoConfig> entry : SlimefunPlugin.getUtilities().mapChunks.entrySet()) {
|
||||||
cfg.setValue(entry.getKey(), entry.getValue().toJSON());
|
cfg.setValue(entry.getKey(), entry.getValue().toJSON());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +345,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -31,7 +31,7 @@ public class BlockAutoSaver implements Runnable {
|
|||||||
if (!worlds.isEmpty()) {
|
if (!worlds.isEmpty()) {
|
||||||
Slimefun.getLogger().log(Level.INFO, "Auto-Saving Block Data... (Next Auto-Save: " + SlimefunPlugin.getCfg().getInt("options.auto-save-delay-in-minutes") + "m)");
|
Slimefun.getLogger().log(Level.INFO, "Auto-Saving Block Data... (Next Auto-Save: " + SlimefunPlugin.getCfg().getInt("options.auto-save-delay-in-minutes") + "m)");
|
||||||
|
|
||||||
for (BlockStorage storage: worlds) {
|
for (BlockStorage storage : worlds) {
|
||||||
storage.save(false);
|
storage.save(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class SlimefunCommand implements CommandExecutor, Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (SubCommand command: commands) {
|
for (SubCommand command : commands) {
|
||||||
if (args[0].equalsIgnoreCase(command.getName())) {
|
if (args[0].equalsIgnoreCase(command.getName())) {
|
||||||
command.onExecute(sender, args);
|
command.onExecute(sender, args);
|
||||||
return true;
|
return true;
|
||||||
@ -110,7 +110,8 @@ 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -34,7 +34,7 @@ public class AutonomousToolsListener implements Listener {
|
|||||||
SlimefunItem machine = BlockStorage.check(dispenser);
|
SlimefunItem machine = BlockStorage.check(dispenser);
|
||||||
|
|
||||||
if (machine != null) {
|
if (machine != null) {
|
||||||
for (ItemHandler handler: SlimefunItem.getHandlers("AutonomousMachineHandler")) {
|
for (ItemHandler handler : SlimefunItem.getHandlers("AutonomousMachineHandler")) {
|
||||||
if (((AutonomousMachineHandler) handler).onBlockDispense(e, dispenser, d, block, chest, machine)) break;
|
if (((AutonomousMachineHandler) handler).onBlockDispense(e, dispenser, d, block, chest, machine)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class BlockListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonRetract(BlockPistonRetractEvent e) {
|
public void onPistonRetract(BlockPistonRetractEvent e) {
|
||||||
if (e.isSticky()) {
|
if (e.isSticky()) {
|
||||||
for (Block b: e.getBlocks()) {
|
for (Block b : e.getBlocks()) {
|
||||||
if (BlockStorage.hasBlockInfo(b) || b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection()))) {
|
if (BlockStorage.hasBlockInfo(b) || b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection()))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -75,7 +75,7 @@ public class BlockListener implements Listener {
|
|||||||
Block b = e.getClickedBlock();
|
Block b = e.getClickedBlock();
|
||||||
LinkedList<MultiBlock> multiblocks = new LinkedList<>();
|
LinkedList<MultiBlock> multiblocks = new LinkedList<>();
|
||||||
|
|
||||||
for (MultiBlock mb: MultiBlock.list()) {
|
for (MultiBlock mb : MultiBlock.list()) {
|
||||||
Block center = b.getRelative(mb.getTriggerBlock());
|
Block center = b.getRelative(mb.getTriggerBlock());
|
||||||
|
|
||||||
if (compareMaterials(center, mb.getBuild(), mb.isSymmetric())) {
|
if (compareMaterials(center, mb.getBuild(), mb.isSymmetric())) {
|
||||||
@ -87,7 +87,7 @@ public class BlockListener implements Listener {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
MultiBlock multiblock = multiblocks.getLast();
|
MultiBlock multiblock = multiblocks.getLast();
|
||||||
|
|
||||||
for (ItemHandler handler: SlimefunItem.getHandlers("MultiBlockInteractionHandler")) {
|
for (ItemHandler handler : SlimefunItem.getHandlers("MultiBlockInteractionHandler")) {
|
||||||
if (((MultiBlockInteractionHandler) handler).onInteract(p, multiblock, b)) break;
|
if (((MultiBlockInteractionHandler) handler).onInteract(p, multiblock, b)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,11 +62,11 @@ public class BowListener implements Listener {
|
|||||||
p.setVelocity(arrow.getLocation().toVector().subtract(p.getLocation().toVector()));
|
p.setVelocity(arrow.getLocation().toVector().subtract(p.getLocation().toVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entity n: SlimefunPlugin.getUtilities().remove.get(p.getUniqueId())) {
|
for (Entity n : SlimefunPlugin.getUtilities().remove.get(p.getUniqueId())) {
|
||||||
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);
|
||||||
@ -87,11 +91,11 @@ public class BowListener implements Listener {
|
|||||||
|
|
||||||
p.setVelocity(v);
|
p.setVelocity(v);
|
||||||
|
|
||||||
for (Entity n: SlimefunPlugin.getUtilities().remove.get(p.getUniqueId())) {
|
for (Entity n : SlimefunPlugin.getUtilities().remove.get(p.getUniqueId())) {
|
||||||
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);
|
||||||
@ -103,8 +107,10 @@ public class BowListener implements Listener {
|
|||||||
public void onArrowSuccessfulHit(EntityDamageByEntityEvent e) {
|
public void onArrowSuccessfulHit(EntityDamageByEntityEvent e) {
|
||||||
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());
|
||||||
|
@ -27,7 +27,7 @@ public class CoolerListener implements Listener {
|
|||||||
public void onStarve(FoodLevelChangeEvent e) {
|
public void onStarve(FoodLevelChangeEvent e) {
|
||||||
if (e.getFoodLevel() < ((Player) e.getEntity()).getFoodLevel()) {
|
if (e.getFoodLevel() < ((Player) e.getEntity()).getFoodLevel()) {
|
||||||
Player p = (Player) e.getEntity();
|
Player p = (Player) e.getEntity();
|
||||||
for (ItemStack item: p.getInventory().getContents()) {
|
for (ItemStack item : p.getInventory().getContents()) {
|
||||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.COOLER, false)) {
|
if (SlimefunManager.isItemSimilar(item, SlimefunItems.COOLER, false)) {
|
||||||
BackpackInventory backpack = PlayerProfile.getBackpack(item);
|
BackpackInventory backpack = PlayerProfile.getBackpack(item);
|
||||||
if (backpack != null) {
|
if (backpack != null) {
|
||||||
@ -45,7 +45,7 @@ public class CoolerListener implements Listener {
|
|||||||
if (slot >= 0) {
|
if (slot >= 0) {
|
||||||
PotionMeta im = (PotionMeta) inv.getItem(slot).getItemMeta();
|
PotionMeta im = (PotionMeta) inv.getItem(slot).getItemMeta();
|
||||||
|
|
||||||
for (PotionEffect effect: im.getCustomEffects()) {
|
for (PotionEffect effect : im.getCustomEffects()) {
|
||||||
p.addPotionEffect(effect);
|
p.addPotionEffect(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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));
|
||||||
@ -449,7 +449,7 @@ public class ItemListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemDrop(PlayerDropItemEvent e) {
|
public void onItemDrop(PlayerDropItemEvent e) {
|
||||||
for (ItemHandler handler: SlimefunItem.getHandlers("ItemDropHandler")) {
|
for (ItemHandler handler : SlimefunItem.getHandlers("ItemDropHandler")) {
|
||||||
if (((ItemDropHandler) handler).onItemDrop(e, e.getPlayer(), e.getItemDrop())) return;
|
if (((ItemDropHandler) handler).onItemDrop(e, e.getPlayer(), e.getItemDrop())) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
@ -81,7 +81,7 @@ public class TalismanListener implements Listener {
|
|||||||
|
|
||||||
// Did the tool in our hand broke or was it an Armorpiece?
|
// Did the tool in our hand broke or was it an Armorpiece?
|
||||||
if (!inv.getItem(inv.getHeldItemSlot()).equals(e.getBrokenItem())) {
|
if (!inv.getItem(inv.getHeldItemSlot()).equals(e.getBrokenItem())) {
|
||||||
for (int s: armorSlots) {
|
for (int s : armorSlots) {
|
||||||
if (inv.getItem(s).equals(e.getBrokenItem())) {
|
if (inv.getItem(s).equals(e.getBrokenItem())) {
|
||||||
slot = s;
|
slot = s;
|
||||||
break;
|
break;
|
||||||
@ -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
|
||||||
|
@ -35,7 +35,7 @@ public class TeleporterListener implements Listener {
|
|||||||
SlimefunItem teleporter = BlockStorage.check(e.getClickedBlock().getRelative(BlockFace.DOWN));
|
SlimefunItem teleporter = BlockStorage.check(e.getClickedBlock().getRelative(BlockFace.DOWN));
|
||||||
|
|
||||||
if (teleporter instanceof Teleporter) {
|
if (teleporter instanceof Teleporter) {
|
||||||
for (BlockFace face: faces) {
|
for (BlockFace face : faces) {
|
||||||
if (!BlockStorage.check(e.getClickedBlock().getRelative(BlockFace.DOWN).getRelative(face), "GPS_TELEPORTER_PYLON")) return;
|
if (!BlockStorage.check(e.getClickedBlock().getRelative(BlockFace.DOWN).getRelative(face), "GPS_TELEPORTER_PYLON")) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user