mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
[CI skip] Some more refactoring
This commit is contained in:
parent
7cb0c521f6
commit
7268fb0505
@ -51,18 +51,7 @@ public class ErrorReport {
|
|||||||
List<String> plugins = new ArrayList<>();
|
List<String> plugins = new ArrayList<>();
|
||||||
List<String> addons = new ArrayList<>();
|
List<String> addons = new ArrayList<>();
|
||||||
|
|
||||||
for (Plugin p: Bukkit.getPluginManager().getPlugins()) {
|
scanPlugins(plugins, addons);
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled(p)) {
|
|
||||||
plugins.add(" + " + p.getName() + ' ' + p.getDescription().getVersion());
|
|
||||||
if (p.getDescription().getDepend().contains("Slimefun") || p.getDescription().getSoftDepend().contains("Slimefun"))
|
|
||||||
addons.add(" + " + p.getName() + ' ' + p.getDescription().getVersion());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.add(" - " + p.getName() + ' ' + p.getDescription().getVersion());
|
|
||||||
if (p.getDescription().getDepend().contains("Slimefun") || p.getDescription().getSoftDepend().contains("Slimefun"))
|
|
||||||
addons.add(" - " + p.getName() + ' ' + p.getDescription().getVersion());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stream.println("Installed Addons (" + addons.size() + ")");
|
stream.println("Installed Addons (" + addons.size() + ")");
|
||||||
addons.forEach(stream::println);
|
addons.forEach(stream::println);
|
||||||
@ -151,18 +140,35 @@ public class ErrorReport {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void scanPlugins(List<String> plugins, List<String> addons) {
|
||||||
|
String dependency = "Slimefun";
|
||||||
|
|
||||||
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled(plugin)) {
|
||||||
|
plugins.add(" + " + plugin.getName() + ' ' + plugin.getDescription().getVersion());
|
||||||
|
if (plugin.getDescription().getDepend().contains(dependency) || plugin.getDescription().getSoftDepend().contains(dependency))
|
||||||
|
addons.add(" + " + plugin.getName() + ' ' + plugin.getDescription().getVersion());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.add(" - " + plugin.getName() + ' ' + plugin.getDescription().getVersion());
|
||||||
|
if (plugin.getDescription().getDepend().contains(dependency) || plugin.getDescription().getSoftDepend().contains(dependency))
|
||||||
|
addons.add(" - " + plugin.getName() + ' ' + plugin.getDescription().getVersion());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private File getNewFile() {
|
private File getNewFile() {
|
||||||
String path = "plugins/Slimefun/error-reports/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date());
|
String path = "plugins/Slimefun/error-reports/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date());
|
||||||
File file = new File(path + ".err");
|
File newFile = new File(path + ".err");
|
||||||
|
|
||||||
if (file.exists()) {
|
if (newFile.exists()) {
|
||||||
IntStream stream = IntStream.iterate(1, i -> i + 1).filter(i -> !new File(path + " (" + i + ").err").exists());
|
IntStream stream = IntStream.iterate(1, i -> i + 1).filter(i -> !new File(path + " (" + i + ").err").exists());
|
||||||
int id = stream.findFirst().getAsInt();
|
int id = stream.findFirst().getAsInt();
|
||||||
|
|
||||||
file = new File(path + " (" + id + ").err");
|
newFile = new File(path + " (" + id + ").err");
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return newFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getFile() {
|
public File getFile() {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Events;
|
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import me.mrCookieSlime.Slimefun.androids.AndroidEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired before a miner android mines a block.
|
* This event is fired before a miner android mines a block.
|
||||||
* If this event is cancelled, the block will not be mined.
|
* If this event is cancelled, the block will not be mined.
|
||||||
@ -14,14 +16,14 @@ public class AndroidMineEvent extends Event implements Cancellable {
|
|||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private final Block block;
|
private final Block block;
|
||||||
private final Block android;
|
private final AndroidEntity android;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param block - mined block
|
* @param block - mined block
|
||||||
* @param android - the block of the android
|
* @param android - the block of the android
|
||||||
*/
|
*/
|
||||||
public AndroidMineEvent(Block block, Block android) {
|
public AndroidMineEvent(Block block, AndroidEntity android) {
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.android = android;
|
this.android = android;
|
||||||
}
|
}
|
||||||
@ -40,7 +42,7 @@ public class AndroidMineEvent extends Event implements Cancellable {
|
|||||||
* @return the mined block
|
* @return the mined block
|
||||||
*/
|
*/
|
||||||
public Block getBlock() {
|
public Block getBlock() {
|
||||||
return this.block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,18 +51,18 @@ public class AndroidMineEvent extends Event implements Cancellable {
|
|||||||
*
|
*
|
||||||
* @return the block of the android
|
* @return the block of the android
|
||||||
*/
|
*/
|
||||||
public Block getAndroid() {
|
public AndroidEntity getAndroid() {
|
||||||
return this.android;
|
return android;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return this.cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
this.cancelled = cancel;
|
cancelled = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Events;
|
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -14,6 +14,7 @@ public class AutoDisenchantEvent extends Event implements Cancellable {
|
|||||||
|
|
||||||
public AutoDisenchantEvent(ItemStack item) {
|
public AutoDisenchantEvent(ItemStack item) {
|
||||||
super(true);
|
super(true);
|
||||||
|
|
||||||
this.item = item;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Events;
|
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.MultiBlock;
|
import me.mrCookieSlime.Slimefun.Objects.MultiBlock;
|
||||||
|
|
||||||
@ -12,9 +12,9 @@ public class MultiBlockInteractEvent extends Event implements Cancellable {
|
|||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Player p;
|
private Player player;
|
||||||
private MultiBlock mb;
|
private MultiBlock multiBlock;
|
||||||
private Block b;
|
private Block clickedBlock;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
@ -26,21 +26,21 @@ public class MultiBlockInteractEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MultiBlockInteractEvent(Player p, MultiBlock mb, Block clicked) {
|
public MultiBlockInteractEvent(Player p, MultiBlock mb, Block clicked) {
|
||||||
this.p = p;
|
this.player = p;
|
||||||
this.mb = mb;
|
this.multiBlock = mb;
|
||||||
this.b = clicked;
|
this.clickedBlock = clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return this.p;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiBlock getMultiBlock() {
|
public MultiBlock getMultiBlock() {
|
||||||
return this.mb;
|
return this.multiBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getClickedBlock() {
|
public Block getClickedBlock() {
|
||||||
return this.b;
|
return this.clickedBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,4 +1,4 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Events;
|
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Research;
|
import me.mrCookieSlime.Slimefun.Objects.Research;
|
||||||
|
|
||||||
@ -11,8 +11,8 @@ public class ResearchUnlockEvent extends Event implements Cancellable {
|
|||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Player p;
|
private Player player;
|
||||||
private Research r;
|
private Research research;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
@ -23,17 +23,17 @@ public class ResearchUnlockEvent extends Event implements Cancellable {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResearchUnlockEvent(Player p, Research res) {
|
public ResearchUnlockEvent(Player p, Research research) {
|
||||||
this.p = p;
|
this.player = p;
|
||||||
this.r = res;
|
this.research = research;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return this.p;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Research getResearch() {
|
public Research getResearch() {
|
||||||
return this.r;
|
return this.research;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.core.utils;
|
package io.github.thebusybiscuit.slimefun4.core.utils;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
@ -15,4 +16,8 @@ public final class ChatUtils {
|
|||||||
p.sendMessage("");
|
p.sendMessage("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String christmas(String text) {
|
||||||
|
return ChatColors.alternating(text, ChatColor.GREEN, ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ package me.mrCookieSlime.Slimefun.Lists;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.utils.ChatUtils;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.LockedCategory;
|
import me.mrCookieSlime.Slimefun.Objects.LockedCategory;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SeasonalCategory;
|
import me.mrCookieSlime.Slimefun.Objects.SeasonalCategory;
|
||||||
import me.mrCookieSlime.Slimefun.utils.Christmas;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Built-in categories.
|
* Built-in categories.
|
||||||
@ -21,7 +21,7 @@ public final class Categories {
|
|||||||
|
|
||||||
private static final String LORE = "&a> Click to open";
|
private static final String LORE = "&a> Click to open";
|
||||||
|
|
||||||
public static final Category WEAPONS = new Category(new CustomItem(SlimefunItems.SWORD_OF_BEHEADING, "&7Weapons", "", LORE), 1);
|
public static final Category WEAPONS = new Category(new CustomItem(SlimefunItems.BLADE_OF_VAMPIRES, "&7Weapons", "", LORE), 1);
|
||||||
public static final Category TOOLS = new Category(new CustomItem(SlimefunItems.AUTO_SMELT_PICKAXE, "&7Tools", "", LORE), 1);
|
public static final Category TOOLS = new Category(new CustomItem(SlimefunItems.AUTO_SMELT_PICKAXE, "&7Tools", "", LORE), 1);
|
||||||
public static final Category PORTABLE = new Category(new CustomItem(SlimefunItems.BACKPACK_MEDIUM, "&7Items", "", LORE), 1);
|
public static final Category PORTABLE = new Category(new CustomItem(SlimefunItems.BACKPACK_MEDIUM, "&7Items", "", LORE), 1);
|
||||||
public static final Category FOOD = new Category(new CustomItem(SlimefunItems.FORTUNE_COOKIE, "&7Food", "", LORE), 2);
|
public static final Category FOOD = new Category(new CustomItem(SlimefunItems.FORTUNE_COOKIE, "&7Food", "", LORE), 2);
|
||||||
@ -41,9 +41,9 @@ public final class Categories {
|
|||||||
public static final LockedCategory TALISMANS_2 = new LockedCategory(new CustomItem(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II", "", LORE), 3, TALISMANS_1);
|
public static final LockedCategory TALISMANS_2 = new LockedCategory(new CustomItem(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II", "", LORE), 3, TALISMANS_1);
|
||||||
|
|
||||||
// Seasonal Categories
|
// Seasonal Categories
|
||||||
public static final SeasonalCategory CHRISTMAS = new SeasonalCategory(12, 1, new CustomItem(Material.NETHER_STAR, Christmas.color("Christmas"), "", "&c> Click to help &aSanta"));
|
public static final SeasonalCategory CHRISTMAS = new SeasonalCategory(12, 1, new CustomItem(Material.NETHER_STAR, ChatUtils.christmas("Christmas") + " &7(December)", "", "&c> Click to help &aSanta"));
|
||||||
public static final SeasonalCategory VALENTINES_DAY = new SeasonalCategory(2, 2, new CustomItem(Material.POPPY, "&dValentine's Day", "", "&d> Click to celebrate Love"));
|
public static final SeasonalCategory VALENTINES_DAY = new SeasonalCategory(2, 2, new CustomItem(Material.POPPY, "&dValentine's Day" + " &7(February)", "", "&d> Click to celebrate Love"));
|
||||||
public static final SeasonalCategory EASTER = new SeasonalCategory(4, 2, new CustomItem(Material.EGG, "&6Easter", "", "&a> Click to paint some Eggs"));
|
public static final SeasonalCategory EASTER = new SeasonalCategory(4, 2, new CustomItem(Material.EGG, "&6Easter" + " &7(April)", "", "&a> Click to paint some Eggs"));
|
||||||
public static final SeasonalCategory BIRTHDAY = new SeasonalCategory(10, 1, new CustomItem(Material.FIREWORK_ROCKET, "&a&lTheBusyBiscuit's Birthday &7(26th October)", "", "&a> Click to celebrate with me"));
|
public static final SeasonalCategory BIRTHDAY = new SeasonalCategory(10, 1, new CustomItem(Material.FIREWORK_ROCKET, "&a&lTheBusyBiscuit's Birthday &7(26th October)", "", "&a> Click to celebrate with me"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,9 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.FireworkShow;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.FireworkShow;
|
||||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Events.ResearchUnlockEvent;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Setup.ResearchSetup;
|
import me.mrCookieSlime.Slimefun.Setup.ResearchSetup;
|
||||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||||
|
@ -4,18 +4,18 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class MachineFuel {
|
public class MachineFuel {
|
||||||
|
|
||||||
private int seconds;
|
private int ticks;
|
||||||
private ItemStack fuel;
|
private ItemStack fuel;
|
||||||
private ItemStack output;
|
private ItemStack output;
|
||||||
|
|
||||||
public MachineFuel(int seconds, ItemStack fuel) {
|
public MachineFuel(int seconds, ItemStack fuel) {
|
||||||
this.seconds = seconds * 2;
|
this.ticks = seconds * 2;
|
||||||
this.fuel = fuel;
|
this.fuel = fuel;
|
||||||
this.output = null;
|
this.output = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MachineFuel(int seconds, ItemStack fuel, ItemStack output) {
|
public MachineFuel(int seconds, ItemStack fuel, ItemStack output) {
|
||||||
this.seconds = seconds * 2;
|
this.ticks = seconds * 2;
|
||||||
this.fuel = fuel;
|
this.fuel = fuel;
|
||||||
this.output = output;
|
this.output = output;
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ public class MachineFuel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getTicks() {
|
public int getTicks() {
|
||||||
return seconds;
|
return ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import java.util.HashSet;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Events.AutoDisenchantEvent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -32,6 +31,8 @@ import me.mrCookieSlime.Slimefun.utils.MachineHelper;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.Repairable;
|
import org.bukkit.inventory.meta.Repairable;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.AutoDisenchantEvent;
|
||||||
|
|
||||||
public class AutoDisenchanter extends AContainer {
|
public class AutoDisenchanter extends AContainer {
|
||||||
|
|
||||||
public AutoDisenchanter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public AutoDisenchanter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
|
@ -45,6 +45,7 @@ public abstract class BioGenerator extends AGenerator {
|
|||||||
registerFuel(new MachineFuel(20, new ItemStack(Material.DRIED_KELP_BLOCK)));
|
registerFuel(new MachineFuel(20, new ItemStack(Material.DRIED_KELP_BLOCK)));
|
||||||
registerFuel(new MachineFuel(1, new ItemStack(Material.SEAGRASS)));
|
registerFuel(new MachineFuel(1, new ItemStack(Material.SEAGRASS)));
|
||||||
registerFuel(new MachineFuel(2, new ItemStack(Material.SEA_PICKLE)));
|
registerFuel(new MachineFuel(2, new ItemStack(Material.SEA_PICKLE)));
|
||||||
|
registerFuel(new MachineFuel(2, new ItemStack(Material.SWEET_BERRIES)));
|
||||||
|
|
||||||
// Leaves
|
// Leaves
|
||||||
for(Material m : Tag.LEAVES.getValues()) {
|
for(Material m : Tag.LEAVES.getValues()) {
|
||||||
|
@ -18,6 +18,7 @@ import com.google.gson.JsonArray;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class CSCoreLibLoader {
|
public class CSCoreLibLoader {
|
||||||
|
|
||||||
private Plugin plugin;
|
private Plugin plugin;
|
||||||
|
@ -2,12 +2,12 @@ package me.mrCookieSlime.Slimefun.androids;
|
|||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
public class AndroidObject {
|
public class AndroidEntity {
|
||||||
|
|
||||||
private ProgrammableAndroid android;
|
private final ProgrammableAndroid android;
|
||||||
private Block b;
|
private final Block b;
|
||||||
|
|
||||||
public AndroidObject(ProgrammableAndroid android, Block b) {
|
public AndroidEntity(ProgrammableAndroid android, Block b) {
|
||||||
this.android = android;
|
this.android = android;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ import java.util.Optional;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -39,11 +40,13 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.blocks.Vein;
|
import io.github.thebusybiscuit.cscorelib2.blocks.Vein;
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
||||||
|
import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
|
||||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
||||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialConverter;
|
import io.github.thebusybiscuit.cscorelib2.materials.MaterialConverter;
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||||
@ -52,7 +55,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
|||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||||
import me.mrCookieSlime.ExoticGarden.ExoticGarden;
|
import me.mrCookieSlime.ExoticGarden.ExoticGarden;
|
||||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Events.AndroidMineEvent;
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
@ -75,26 +77,24 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
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};
|
||||||
|
|
||||||
private static final ItemStack[] fish = new ItemStack[] {new ItemStack(Material.COD), new ItemStack(Material.SALMON), new ItemStack(Material.PUFFERFISH), new ItemStack(Material.TROPICAL_FISH), new ItemStack(Material.STRING), new ItemStack(Material.BONE), new ItemStack(Material.STICK)};
|
private static final RandomizedSet<ItemStack> fishingLoot = new RandomizedSet<>();
|
||||||
|
|
||||||
private static final List<BlockFace> directions = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
|
|
||||||
private static final List<Material> blockblacklist = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
blockblacklist.add(Material.BEDROCK);
|
for (Material fish : MaterialCollections.getAllFishItems()) {
|
||||||
blockblacklist.add(Material.BARRIER);
|
fishingLoot.add(new ItemStack(fish), 20);
|
||||||
blockblacklist.add(Material.END_PORTAL_FRAME);
|
|
||||||
blockblacklist.add(Material.END_PORTAL);
|
|
||||||
blockblacklist.add(Material.NETHER_PORTAL);
|
|
||||||
blockblacklist.add(Material.COMMAND_BLOCK);
|
|
||||||
blockblacklist.add(Material.CHAIN_COMMAND_BLOCK);
|
|
||||||
blockblacklist.add(Material.REPEATING_COMMAND_BLOCK);
|
|
||||||
blockblacklist.add(Material.STRUCTURE_BLOCK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fishingLoot.add(new ItemStack(Material.BONE), 10);
|
||||||
|
fishingLoot.add(new ItemStack(Material.STRING), 10);
|
||||||
|
fishingLoot.add(new ItemStack(Material.STICK), 5);
|
||||||
|
fishingLoot.add(new ItemStack(Material.INK_SAC), 4);
|
||||||
|
fishingLoot.add(new ItemStack(Material.ROTTEN_FLESH), 3);
|
||||||
|
fishingLoot.add(new ItemStack(Material.LEATHER), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final List<BlockFace> directions = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
|
||||||
|
|
||||||
private final Set<MachineFuel> recipes = new HashSet<>();
|
private final Set<MachineFuel> recipes = new HashSet<>();
|
||||||
private final Random random = new Random();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getInputSlots() {
|
public int[] getInputSlots() {
|
||||||
@ -147,11 +147,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
try {
|
|
||||||
constructMenu(this);
|
constructMenu(this);
|
||||||
} catch (Exception x) {
|
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while constructing an Android Inventory for Slimefun " + Slimefun.getVersion(), x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -165,7 +161,6 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newInstance(BlockMenu menu, final Block b) {
|
public void newInstance(BlockMenu menu, final Block b) {
|
||||||
try {
|
|
||||||
menu.replaceExistingItem(15, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTAxYzdiNTcyNjE3ODk3NGIzYjNhMDFiNDJhNTkwZTU0MzY2MDI2ZmQ0MzgwOGYyYTc4NzY0ODg0M2E3ZjVhIn19fQ=="), "&aStart/Continue"));
|
menu.replaceExistingItem(15, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTAxYzdiNTcyNjE3ODk3NGIzYjNhMDFiNDJhNTkwZTU0MzY2MDI2ZmQ0MzgwOGYyYTc4NzY0ODg0M2E3ZjVhIn19fQ=="), "&aStart/Continue"));
|
||||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||||
SlimefunPlugin.getLocal().sendMessage(p, "robot.started", true);
|
SlimefunPlugin.getLocal().sendMessage(p, "robot.started", true);
|
||||||
@ -188,9 +183,6 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
openScriptEditor(p, b);
|
openScriptEditor(p, b);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
} catch (Exception x) {
|
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while creating a new Instance of an Android Inventory for Slimefun " + Slimefun.getVersion(), x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -210,6 +202,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
BlockStorage.addBlockInfo(b, "rotation", p.getFacing().getOppositeFace().toString());
|
BlockStorage.addBlockInfo(b, "rotation", p.getFacing().getOppositeFace().toString());
|
||||||
BlockStorage.addBlockInfo(b, "paused", "true");
|
BlockStorage.addBlockInfo(b, "paused", "true");
|
||||||
b.setType(Material.PLAYER_HEAD);
|
b.setType(Material.PLAYER_HEAD);
|
||||||
|
|
||||||
Rotatable blockData = (Rotatable) b.getBlockData();
|
Rotatable blockData = (Rotatable) b.getBlockData();
|
||||||
blockData.setRotation(p.getFacing());
|
blockData.setRotation(p.getFacing());
|
||||||
b.setBlockData(blockData);
|
b.setBlockData(blockData);
|
||||||
@ -221,11 +214,13 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
|
|
||||||
if (allow) {
|
if (allow) {
|
||||||
BlockMenu inv = BlockStorage.getInventory(b);
|
BlockMenu inv = BlockStorage.getInventory(b);
|
||||||
|
|
||||||
if (inv != null) {
|
if (inv != null) {
|
||||||
if (inv.getItemInSlot(43) != null) {
|
if (inv.getItemInSlot(43) != null) {
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(43));
|
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(43));
|
||||||
inv.replaceExistingItem(43, null);
|
inv.replaceExistingItem(43, 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));
|
||||||
@ -323,8 +318,8 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
Block water = b.getRelative(BlockFace.DOWN);
|
Block water = b.getRelative(BlockFace.DOWN);
|
||||||
if (water.getType() == Material.WATER) {
|
if (water.getType() == Material.WATER) {
|
||||||
water.getWorld().playSound(water.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
water.getWorld().playSound(water.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
||||||
if (random.nextInt(100) < 10 * getTier()) {
|
if (ThreadLocalRandom.current().nextInt(100) < 10 * getTier()) {
|
||||||
ItemStack drop = fish[random.nextInt(fish.length)];
|
ItemStack drop = fishingLoot.getRandom();
|
||||||
if (menu.fits(drop, getOutputSlots())) {
|
if (menu.fits(drop, getOutputSlots())) {
|
||||||
menu.pushItem(drop, getOutputSlots());
|
menu.pushItem(drop, getOutputSlots());
|
||||||
}
|
}
|
||||||
@ -344,6 +339,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
case INTERFACE_ITEMS:
|
case INTERFACE_ITEMS:
|
||||||
if (BlockStorage.check(b.getRelative(face), "ANDROID_INTERFACE_ITEMS") && b.getRelative(face).getState() instanceof Dispenser) {
|
if (BlockStorage.check(b.getRelative(face), "ANDROID_INTERFACE_ITEMS") && b.getRelative(face).getState() instanceof Dispenser) {
|
||||||
Dispenser d = (Dispenser) b.getRelative(face).getState();
|
Dispenser d = (Dispenser) b.getRelative(face).getState();
|
||||||
|
|
||||||
for (int slot : getOutputSlots()) {
|
for (int slot : getOutputSlots()) {
|
||||||
ItemStack stack = menu.getItemInSlot(slot);
|
ItemStack stack = menu.getItemInSlot(slot);
|
||||||
|
|
||||||
@ -387,16 +383,16 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FARM_FORWARD:
|
case FARM_FORWARD:
|
||||||
farm(b, menu, b.getRelative(face));
|
farm(menu, b.getRelative(face));
|
||||||
break;
|
break;
|
||||||
case FARM_DOWN:
|
case FARM_DOWN:
|
||||||
farm(b, menu, b.getRelative(BlockFace.DOWN));
|
farm(menu, b.getRelative(BlockFace.DOWN));
|
||||||
break;
|
break;
|
||||||
case FARM_EXOTIC_FORWARD:
|
case FARM_EXOTIC_FORWARD:
|
||||||
exoticFarm(b, menu, b.getRelative(face));
|
exoticFarm(menu, b.getRelative(face));
|
||||||
break;
|
break;
|
||||||
case FARM_EXOTIC_DOWN:
|
case FARM_EXOTIC_DOWN:
|
||||||
exoticFarm(b, menu, b.getRelative(BlockFace.DOWN));
|
exoticFarm(menu, b.getRelative(BlockFace.DOWN));
|
||||||
break;
|
break;
|
||||||
case CHOP_TREE:
|
case CHOP_TREE:
|
||||||
if (MaterialCollections.getAllLogs().contains(b.getRelative(face).getType())) {
|
if (MaterialCollections.getAllLogs().contains(b.getRelative(face).getType())) {
|
||||||
@ -470,8 +466,11 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attack) {
|
if (attack) {
|
||||||
if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunPlugin.instance);
|
if (n.hasMetadata("android_killer")) {
|
||||||
n.setMetadata("android_killer", new FixedMetadataValue(SlimefunPlugin.instance, new AndroidObject(this, b)));
|
n.removeMetadata("android_killer", SlimefunPlugin.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
n.setMetadata("android_killer", new FixedMetadataValue(SlimefunPlugin.instance, new AndroidEntity(this, b)));
|
||||||
|
|
||||||
((LivingEntity) n).damage(damage);
|
((LivingEntity) n).damage(damage);
|
||||||
break;
|
break;
|
||||||
@ -499,13 +498,15 @@ 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();
|
||||||
if (!blockblacklist.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);
|
||||||
AndroidMineEvent event = new AndroidMineEvent(block, b);
|
|
||||||
|
AndroidMineEvent event = new AndroidMineEvent(block, new AndroidEntity(this, b));
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
for (ItemStack drop : drops) {
|
for (ItemStack drop : drops) {
|
||||||
if (menu.fits(drop, getOutputSlots())) {
|
if (menu.fits(drop, getOutputSlots())) {
|
||||||
@ -532,13 +533,15 @@ 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();
|
||||||
if (!blockblacklist.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);
|
||||||
AndroidMineEvent event = new AndroidMineEvent(block, b);
|
|
||||||
|
AndroidMineEvent event = new AndroidMineEvent(block, new AndroidEntity(this, b));
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
for (ItemStack drop : drops) {
|
for (ItemStack drop : drops) {
|
||||||
if (menu.fits(drop, getOutputSlots())) {
|
if (menu.fits(drop, getOutputSlots())) {
|
||||||
@ -578,34 +581,9 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
return ageable.getAge() >= ageable.getMaximumAge();
|
return ageable.getAge() >= ageable.getMaximumAge();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void farm(Block b, BlockMenu menu, Block block) {
|
private void farm(BlockMenu menu, Block block) {
|
||||||
if (isFullGrown(block)) {
|
if (isFullGrown(block)) {
|
||||||
ItemStack drop = null;
|
ItemStack drop = getDropFromCrop(block.getType());
|
||||||
switch (block.getType()) {
|
|
||||||
case WHEAT:
|
|
||||||
drop = new ItemStack(Material.WHEAT, random.nextInt(2) + 1);
|
|
||||||
break;
|
|
||||||
case POTATOES:
|
|
||||||
drop = new ItemStack(Material.POTATO, random.nextInt(3) + 1);
|
|
||||||
break;
|
|
||||||
case CARROTS:
|
|
||||||
drop = new ItemStack(Material.CARROT, random.nextInt(3) + 1);
|
|
||||||
break;
|
|
||||||
case BEETROOTS:
|
|
||||||
drop = new ItemStack(Material.BEETROOT, random.nextInt(3) + 1);
|
|
||||||
break;
|
|
||||||
case COCOA:
|
|
||||||
drop = new ItemStack(Material.COCOA_BEANS, random.nextInt(3) + 1);
|
|
||||||
break;
|
|
||||||
case NETHER_WART:
|
|
||||||
drop = new ItemStack(Material.NETHER_WART, random.nextInt(3) + 1);
|
|
||||||
break;
|
|
||||||
case SWEET_BERRY_BUSH:
|
|
||||||
drop = new ItemStack(Material.SWEET_BERRIES, random.nextInt(3) + 1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drop != null && menu.fits(drop, getOutputSlots())) {
|
if (drop != null && menu.fits(drop, getOutputSlots())) {
|
||||||
menu.pushItem(drop, getOutputSlots());
|
menu.pushItem(drop, getOutputSlots());
|
||||||
@ -617,8 +595,32 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exoticFarm(Block b, BlockMenu menu, Block block) {
|
private ItemStack getDropFromCrop(Material crop) {
|
||||||
farm(b, menu, block);
|
Random random = ThreadLocalRandom.current();
|
||||||
|
|
||||||
|
switch (crop) {
|
||||||
|
case WHEAT:
|
||||||
|
return new ItemStack(Material.WHEAT, random.nextInt(2) + 1);
|
||||||
|
case POTATOES:
|
||||||
|
return new ItemStack(Material.POTATO, random.nextInt(3) + 1);
|
||||||
|
case CARROTS:
|
||||||
|
return new ItemStack(Material.CARROT, random.nextInt(3) + 1);
|
||||||
|
case BEETROOTS:
|
||||||
|
return new ItemStack(Material.BEETROOT, random.nextInt(3) + 1);
|
||||||
|
case COCOA:
|
||||||
|
return new ItemStack(Material.COCOA_BEANS, random.nextInt(3) + 1);
|
||||||
|
case NETHER_WART:
|
||||||
|
return new ItemStack(Material.NETHER_WART, random.nextInt(3) + 1);
|
||||||
|
case SWEET_BERRY_BUSH:
|
||||||
|
return new ItemStack(Material.SWEET_BERRIES, random.nextInt(3) + 1);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exoticFarm(BlockMenu menu, Block block) {
|
||||||
|
farm(menu, block);
|
||||||
|
|
||||||
if (SlimefunPlugin.getHooks().isExoticGardenInstalled()) {
|
if (SlimefunPlugin.getHooks().isExoticGardenInstalled()) {
|
||||||
ItemStack drop = ExoticGarden.harvestPlant(block);
|
ItemStack drop = ExoticGarden.harvestPlant(block);
|
||||||
if (drop != null && menu.fits(drop, getOutputSlots())) {
|
if (drop != null && menu.fits(drop, getOutputSlots())) {
|
||||||
@ -628,7 +630,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void constructMenu(BlockMenuPreset preset) throws Exception {
|
private void constructMenu(BlockMenuPreset preset) {
|
||||||
for (int i : border) {
|
for (int i : border) {
|
||||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false);
|
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package me.mrCookieSlime.Slimefun.androids;
|
package me.mrCookieSlime.Slimefun.androids;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
public enum ScriptPart {
|
public enum ScriptPart {
|
||||||
|
|
||||||
@ -62,12 +59,8 @@ public enum ScriptPart {
|
|||||||
private AndroidType type;
|
private AndroidType type;
|
||||||
|
|
||||||
private ScriptPart(AndroidType type, String name, String texture) {
|
private ScriptPart(AndroidType type, String name, String texture) {
|
||||||
try {
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.item = new CustomItem(SkullItem.fromBase64(texture), name);
|
this.item = new CustomItem(SkullItem.fromBase64(texture), name);
|
||||||
} catch(Exception x) {
|
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while initializing Android-Script Texture for Slimefun " + Slimefun.getVersion(), x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack toItemStack() {
|
public ItemStack toItemStack() {
|
||||||
|
@ -17,7 +17,7 @@ import org.bukkit.event.entity.EntityDeathEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.androids.AndroidObject;
|
import me.mrCookieSlime.Slimefun.androids.AndroidEntity;
|
||||||
|
|
||||||
public class AndroidKillingListener implements Listener {
|
public class AndroidKillingListener implements Listener {
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class AndroidKillingListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onDeath(final EntityDeathEvent e) {
|
public void onDeath(final EntityDeathEvent e) {
|
||||||
if (e.getEntity().hasMetadata("android_killer")) {
|
if (e.getEntity().hasMetadata("android_killer")) {
|
||||||
final AndroidObject obj = (AndroidObject) e.getEntity().getMetadata("android_killer").get(0).value();
|
final AndroidEntity obj = (AndroidEntity) e.getEntity().getMetadata("android_killer").get(0).value();
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> {
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> items = new ArrayList<>();
|
||||||
|
@ -18,8 +18,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockInteractEvent;
|
||||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Events.MultiBlockInteractEvent;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.MultiBlock;
|
import me.mrCookieSlime.Slimefun.Objects.MultiBlock;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||||
|
@ -3,7 +3,14 @@ package me.mrCookieSlime.Slimefun.utils;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.utils.ChatUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @deprecated This class will be deleted after X-Mas 2019. It will be replaced by {@link ChatUtils#christmas(String)}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public final class Christmas {
|
public final class Christmas {
|
||||||
|
|
||||||
private Christmas() {}
|
private Christmas() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user