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

Merge pull request #1 from TheBusyBiscuit/master

Updating my fork
This commit is contained in:
Anom Suryadinata 2018-05-09 11:09:26 +07:00 committed by GitHub
commit bfac1096a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 6458 additions and 6231 deletions

BIN
lib/Clearlag.jar Normal file

Binary file not shown.

26
pom.xml
View File

@ -1,19 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>me.mrCookieSlime</groupId> <groupId>me.mrCookieSlime</groupId>
<artifactId>Slimefun</artifactId> <artifactId>Slimefun</artifactId>
<version>4.1.13</version> <version>v4.1.15</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<repositories> <repositories>
<repository> <repository>
<id>paper-repo</id> <id>paper-repo</id>
@ -31,20 +26,13 @@
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
<repository>
<id>clearlag-repo</id>
<url>http://minebuilders.me:8080/job/Clearlag/lastSuccessfulBuild/maven-repository/repository/</url>
</repository>
<repository> <repository>
<id>robomwm-repo</id> <id>robomwm-repo</id>
<url>https://dl.bintray.com/robomwm/maven</url> <url>https://dl.bintray.com/robomwm/maven</url>
</repository> </repository>
</repositories> </repositories>
<build> <build>
<!--Maintain existing structure (as much as possible)-->
<sourceDirectory>${project.basedir}/src</sourceDirectory> <sourceDirectory>${project.basedir}/src</sourceDirectory>
<!--doesn't exist but here if you ever do make such a directory-->
<testSourceDirectory>${project.basedir}/tests/java</testSourceDirectory> <testSourceDirectory>${project.basedir}/tests/java</testSourceDirectory>
<testResources> <testResources>
<testResource> <testResource>
@ -54,7 +42,6 @@
<finalName>${project.name} v${project.version}</finalName> <finalName>${project.name} v${project.version}</finalName>
<resources> <resources>
<resource> <resource>
<!-- Use plugin.yml in the src directory-->
<directory>${basedir}/src</directory> <directory>${basedir}/src</directory>
<filtering>true</filtering> <filtering>true</filtering>
<includes> <includes>
@ -64,9 +51,7 @@
</resource> </resource>
</resources> </resources>
</build> </build>
<dependencies> <dependencies>
<!--Bukkit API-->
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
@ -81,12 +66,14 @@
<dependency> <dependency>
<groupId>com.github.TheBusyBiscuit</groupId> <groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>CS-CoreLib</artifactId> <artifactId>CS-CoreLib</artifactId>
<version>v1.5.16</version> <version>v1.5.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.minebuilders</groupId> <groupId>me.minebuilders</groupId>
<artifactId>clearlag-core</artifactId> <artifactId>clearlag-core</artifactId>
<version>2.9.0-SNAPSHOT</version> <version>2.9.7</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Clearlag.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.coreprotect</groupId> <groupId>net.coreprotect</groupId>
@ -108,5 +95,4 @@
<systemPath>${project.basedir}/lib/ExoticGarden v1.2.0.jar</systemPath> <systemPath>${project.basedir}/lib/ExoticGarden v1.2.0.jar</systemPath>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -12,6 +12,8 @@ options:
emerald-enchantment-limit: 2 emerald-enchantment-limit: 2
research-unlock-fireworks: true research-unlock-fireworks: true
research-give-fireworks: true research-give-fireworks: true
legacy-ore-washer: false
legacy-dust-washer: false
guide: guide:
default-view-book: false default-view-book: false
URID: URID:

View File

@ -1,11 +1,13 @@
package me.mrCookieSlime.Slimefun.AncientAltar; package me.mrCookieSlime.Slimefun.AncientAltar;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.MC_1_8.ParticleEffect; import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.MC_1_8.ParticleEffect;
import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.SlimefunStartup;
import me.mrCookieSlime.Slimefun.listeners.AncientAltarListener; import me.mrCookieSlime.Slimefun.listeners.AncientAltarListener;
import me.mrCookieSlime.Slimefun.Variables;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
@ -28,6 +30,7 @@ public class RitualAnimation implements Runnable {
List<Location> particles; List<Location> particles;
boolean running; boolean running;
int stage;
public RitualAnimation(List<Block> altars, Block altar, Location drop, ItemStack output, List<Block> pedestals, List<ItemStack> items) { public RitualAnimation(List<Block> altars, Block altar, Location drop, ItemStack output, List<Block> pedestals, List<ItemStack> items) {
this.l = drop; this.l = drop;
@ -39,209 +42,21 @@ public class RitualAnimation implements Runnable {
this.particles = new ArrayList<Location>(); this.particles = new ArrayList<Location>();
this.running = true; this.running = true;
this.stage = 0;
} }
@Override @Override
public void run() { public void run() {
idle(); idle();
schedule(new Runnable() { if(this.stage == 36) {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
checkPedestal(pedestals.get(0));
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
checkPedestal(pedestals.get(1));
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
checkPedestal(pedestals.get(2));
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
checkPedestal(pedestals.get(3));
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
checkPedestal(pedestals.get(4));
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
checkPedestal(pedestals.get(5));
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
checkPedestal(pedestals.get(6));
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
checkPedestal(pedestals.get(7));
schedule(new Runnable() {
@Override
public void run() {
idle();
schedule(new Runnable() {
@Override
public void run() {
idle();
finish(); finish();
return;
} }
}); if(this.stage > 0 && this.stage % 4 == 0) {
checkPedestal(pedestals.get(this.stage / 4 - 1));
} }
}); this.stage += 1;
} SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, this, 8);
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
} }
private void idle() { private void idle() {
@ -257,10 +72,6 @@ public class RitualAnimation implements Runnable {
} }
} }
private void schedule(Runnable runnable) {
if (running) SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, runnable, 8);
}
private void checkPedestal(Block pedestal) { private void checkPedestal(Block pedestal) {
Item item = AncientAltarListener.findItem(pedestal); Item item = AncientAltarListener.findItem(pedestal);
if (item == null) abort(); if (item == null) abort();
@ -283,9 +94,9 @@ public class RitualAnimation implements Runnable {
private void abort() { private void abort() {
running = false; running = false;
for (ItemStack stack: items) { // for (ItemStack stack: items) {
l.getWorld().dropItemNaturally(l, stack); // l.getWorld().dropItemNaturally(l, stack);
} // }
l.getWorld().playSound(l, Sound.BLOCK_NOTE_SNARE, 5F, 1F); l.getWorld().playSound(l, Sound.BLOCK_NOTE_SNARE, 5F, 1F);
altars.remove(altar); altars.remove(altar);
} }
@ -294,6 +105,12 @@ public class RitualAnimation implements Runnable {
l.getWorld().playSound(l, Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1F, 1F); l.getWorld().playSound(l, Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1F, 1F);
l.getWorld().playEffect(l, Effect.STEP_SOUND, Material.EMERALD_BLOCK); l.getWorld().playEffect(l, Effect.STEP_SOUND, Material.EMERALD_BLOCK);
l.getWorld().dropItemNaturally(l.add(0, 1, 0), output); l.getWorld().dropItemNaturally(l.add(0, 1, 0), output);
pedestals.forEach((pblock)->{
Variables.altarinuse.remove(pblock.getLocation());
});
Variables.altarinuse.remove(altar.getLocation()); // should re-enable altar blocks on craft completion.
altars.remove(altar); altars.remove(altar);
} }

View File

@ -211,9 +211,18 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
boolean allow = reason.equals(UnregisterReason.PLAYER_BREAK) && (BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass")); boolean allow = reason.equals(UnregisterReason.PLAYER_BREAK) && (BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass"));
if (allow) { if (allow) {
if (BlockStorage.getInventory(b).getItemInSlot(43) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(43)); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
if (inv.getItemInSlot(43) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(43));
inv.replaceExistingItem(43, null);
}
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
AndroidStatusHologram.remove(b); AndroidStatusHologram.remove(b);
} }

View File

@ -201,9 +201,9 @@ public class SlimefunCommand implements CommandExecutor, Listener {
if (args.length == 3) { if (args.length == 3) {
if (Players.isOnline(args[1])) { if (Players.isOnline(args[1])) {
if (Slimefun.listIDs().contains(args[2].toUpperCase())) { if (Slimefun.listIDs().contains(args[2].toUpperCase())) {
Messages.local.sendTranslation(Bukkit.getPlayer(args[1]), "messages.given-item", true, new Variable("%item%", SlimefunItem.getByName(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()), new Variable("%amount%", "1")); Messages.local.sendTranslation(Bukkit.getPlayer(args[1]), "messages.given-item", true, new Variable("%item%", SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()), new Variable("%amount%", "1"));
Bukkit.getPlayer(args[1]).getInventory().addItem(SlimefunItem.getByName(args[2].toUpperCase()).getItem()); Bukkit.getPlayer(args[1]).getInventory().addItem(SlimefunItem.getByID(args[2].toUpperCase()).getItem());
Messages.local.sendTranslation(sender, "messages.give-item", true, new Variable("%player%", args[1]), new Variable("%item%", SlimefunItem.getByName(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()), new Variable("%amount%", "1")); Messages.local.sendTranslation(sender, "messages.give-item", true, new Variable("%player%", args[1]), new Variable("%item%", SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()), new Variable("%amount%", "1"));
} }
else Messages.local.sendTranslation(sender, "messages.not-valid-item", true, new Variable("%item%", args[2])); else Messages.local.sendTranslation(sender, "messages.not-valid-item", true, new Variable("%item%", args[2]));
} }
@ -216,9 +216,9 @@ public class SlimefunCommand implements CommandExecutor, Listener {
int amount = Integer.parseInt(args[3]); int amount = Integer.parseInt(args[3]);
if (amount > 0) { if (amount > 0) {
Messages.local.sendTranslation(Bukkit.getPlayer(args[1]), "messages.given-item", true, new Variable("%item%", SlimefunItem.getByName(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()), new Variable("%amount%", String.valueOf(amount))); Messages.local.sendTranslation(Bukkit.getPlayer(args[1]), "messages.given-item", true, new Variable("%item%", SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()), new Variable("%amount%", String.valueOf(amount)));
Bukkit.getPlayer(args[1]).getInventory().addItem(new CustomItem(SlimefunItem.getByName(args[2].toUpperCase()).getItem(), amount)); Bukkit.getPlayer(args[1]).getInventory().addItem(new CustomItem(SlimefunItem.getByID(args[2].toUpperCase()).getItem(), amount));
Messages.local.sendTranslation(sender, "messages.give-item", true, new Variable("%player%", args[1]), new Variable("%item%", SlimefunItem.getByName(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()), new Variable("%amount%", String.valueOf(amount))); Messages.local.sendTranslation(sender, "messages.give-item", true, new Variable("%player%", args[1]), new Variable("%item%", SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()), new Variable("%amount%", String.valueOf(amount)));
} }
else Messages.local.sendTranslation(sender, "messages.not-valid-amount", true, new Variable("%amount%", String.valueOf(amount))); else Messages.local.sendTranslation(sender, "messages.not-valid-amount", true, new Variable("%amount%", String.valueOf(amount)));
} catch (NumberFormatException e){ } catch (NumberFormatException e){

View File

@ -10,6 +10,7 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.World.TitleBuilder.TitleType;
import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.SlimefunStartup;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -52,8 +53,8 @@ public class TeleportationSequence {
players.remove(uuid); players.remove(uuid);
if (p != null) { if (p != null) {
try { try {
TitleBuilder title = (TitleBuilder) new TitleBuilder(20, 60, 20).addText("&4Teleportation cancelled"); TitleBuilder title = (TitleBuilder) new TitleBuilder(20, 60, 20).addText(ChatColor.translateAlternateColorCodes('&', "&4Teleportation cancelled"));
TitleBuilder subtitle = (TitleBuilder) new TitleBuilder(20, 60, 20).addText("&40%"); TitleBuilder subtitle = (TitleBuilder) new TitleBuilder(20, 60, 20).addText(ChatColor.translateAlternateColorCodes('&', "&40%"));
title.send(TitleType.TITLE, p); title.send(TitleType.TITLE, p);
subtitle.send(TitleType.SUBTITLE, p); subtitle.send(TitleType.SUBTITLE, p);
@ -68,8 +69,8 @@ public class TeleportationSequence {
if (isValid(p, source)) { if (isValid(p, source)) {
try { try {
if (progress > 99) { if (progress > 99) {
TitleBuilder title = (TitleBuilder) new TitleBuilder(20, 60, 20).addText("&3Teleported!"); TitleBuilder title = (TitleBuilder) new TitleBuilder(20, 60, 20).addText(ChatColor.translateAlternateColorCodes('&', "&3Teleported!"));
TitleBuilder subtitle = (TitleBuilder) new TitleBuilder(20, 60, 20).addText("&b100%"); TitleBuilder subtitle = (TitleBuilder) new TitleBuilder(20, 60, 20).addText(ChatColor.translateAlternateColorCodes('&', "&b100%"));
title.send(TitleType.TITLE, p); title.send(TitleType.TITLE, p);
subtitle.send(TitleType.SUBTITLE, p); subtitle.send(TitleType.SUBTITLE, p);
@ -78,7 +79,7 @@ public class TeleportationSequence {
if (resistance) { if (resistance) {
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20)); p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20));
p.sendMessage("&b&lYou have been given 30 Seconds of Invulnerability!"); p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&b&lYou have been given 30 Seconds of Invulnerability!"));
} }
ParticleEffect.PORTAL.display(new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()), 0.2F, 0.8F, 0.2F, 1, progress * 2); ParticleEffect.PORTAL.display(new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()), 0.2F, 0.8F, 0.2F, 1, progress * 2);
@ -86,8 +87,8 @@ public class TeleportationSequence {
players.remove(uuid); players.remove(uuid);
} }
else { else {
TitleBuilder title = (TitleBuilder) new TitleBuilder(0, 60, 0).addText("&3Teleporting..."); TitleBuilder title = (TitleBuilder) new TitleBuilder(0, 60, 0).addText(ChatColor.translateAlternateColorCodes('&', "&3Teleporting..."));
TitleBuilder subtitle = (TitleBuilder) new TitleBuilder(0, 60, 0).addText("&b" + progress + "%"); TitleBuilder subtitle = (TitleBuilder) new TitleBuilder(0, 60, 0).addText(ChatColor.translateAlternateColorCodes('&', "&b" + progress + "%"));
title.send(TitleType.TITLE, p); title.send(TitleType.TITLE, p);
subtitle.send(TitleType.SUBTITLE, p); subtitle.send(TitleType.SUBTITLE, p);

View File

@ -38,7 +38,7 @@ public class ItemHash {
StringBuilder builder = new StringBuilder(LENGTH * 2); StringBuilder builder = new StringBuilder(LENGTH * 2);
for (char c: item.getHash().toCharArray()) { for (char c: item.getHash().toCharArray()) {
builder.append('§'); builder.append('§');
builder.append(c); builder.append(c);
} }
@ -47,7 +47,7 @@ public class ItemHash {
public static SlimefunItem fromString(String input) { public static SlimefunItem fromString(String input) {
if (input == null || input.length() != LENGTH * 2) return null; if (input == null || input.length() != LENGTH * 2) return null;
String hex = input.replaceAll("§", ""); String hex = input.replaceAll("§", "");
if (hex.length() != LENGTH || !map.containsKey(hex)) return null; if (hex.length() != LENGTH || !map.containsKey(hex)) return null;

View File

@ -99,26 +99,26 @@ public class SlimefunItems {
public static ItemStack MELON_JUICE = new CustomPotion("&cMelon Juice", 8197, new String[0], new PotionEffect(PotionEffectType.SATURATION, 10, 0)); public static ItemStack MELON_JUICE = new CustomPotion("&cMelon Juice", 8197, new String[0], new PotionEffect(PotionEffectType.SATURATION, 10, 0));
public static ItemStack CARROT_JUICE = new CustomPotion("&6Carrot Juice", 8195, new String[0], new PotionEffect(PotionEffectType.SATURATION, 10, 0)); public static ItemStack CARROT_JUICE = new CustomPotion("&6Carrot Juice", 8195, new String[0], new PotionEffect(PotionEffectType.SATURATION, 10, 0));
public static ItemStack PUMPKIN_JUICE = new CustomPotion("&6Pumpkin Juice", 8195, new String[0], new PotionEffect(PotionEffectType.SATURATION, 10, 0)); public static ItemStack PUMPKIN_JUICE = new CustomPotion("&6Pumpkin Juice", 8195, new String[0], new PotionEffect(PotionEffectType.SATURATION, 10, 0));
public static ItemStack GOLDE_APPLE_JUICE = new CustomPotion("&bGolden Apple Juice", 8195, new String[0], new PotionEffect(PotionEffectType.ABSORPTION, 20 * 20, 0)); public static ItemStack GOLDEN_APPLE_JUICE = new CustomPotion("&bGolden Apple Juice", 8195, new String[0], new PotionEffect(PotionEffectType.ABSORPTION, 20 * 20, 0));
/* Christmas */ /* Christmas */
public static ItemStack MILK = new CustomPotion("&6Glass of Milk", 8194, new String[0], new PotionEffect(PotionEffectType.SATURATION, 5, 0)); public static ItemStack CHRISTMAS_MILK = new CustomPotion("&6Glass of Milk", 8194, new String[0], new PotionEffect(PotionEffectType.SATURATION, 5, 0));
public static ItemStack CHOCOLATE_MILK = new CustomPotion("&6Chocolate Milk", 8201, new String[0], new PotionEffect(PotionEffectType.SATURATION, 12, 0)); public static ItemStack CHRISTMAS_CHOCOLATE_MILK = new CustomPotion("&6Chocolate Milk", 8201, new String[0], new PotionEffect(PotionEffectType.SATURATION, 12, 0));
public static ItemStack EGG_NOG = new CustomPotion("&aEgg Nog", 8194, new String[0], new PotionEffect(PotionEffectType.SATURATION, 7, 0)); public static ItemStack CHRISTMAS_EGG_NOG = new CustomPotion("&aEgg Nog", 8194, new String[0], new PotionEffect(PotionEffectType.SATURATION, 7, 0));
public static ItemStack APPLE_CIDER = new CustomPotion("&cApple Cider", 8197, new String[0], new PotionEffect(PotionEffectType.SATURATION, 14, 0)); public static ItemStack CHRISTMAS_APPLE_CIDER = new CustomPotion("&cApple Cider", 8197, new String[0], new PotionEffect(PotionEffectType.SATURATION, 14, 0));
public static ItemStack CHRISTMAS_COOKIE = new CustomItem(Material.COOKIE, Christmas.color("Christmas Cookie"), 0); public static ItemStack CHRISTMAS_COOKIE = new CustomItem(Material.COOKIE, Christmas.color("Christmas Cookie"), 0);
public static ItemStack FRUIT_CAKE = new CustomItem(Material.PUMPKIN_PIE, Christmas.color("Fruit Cake"), 0); public static ItemStack CHRISTMAS_FRUIT_CAKE = new CustomItem(Material.PUMPKIN_PIE, Christmas.color("Fruit Cake"), 0);
public static ItemStack APPLE_PIE = new CustomItem(Material.PUMPKIN_PIE, "&rApple Pie", 0); public static ItemStack CHRISTMAS_APPLE_PIE = new CustomItem(Material.PUMPKIN_PIE, "&rApple Pie", 0);
public static ItemStack HOT_CHOCOLATE = new CustomPotion("&6Hot Chocolate", 8201, new String[0], new PotionEffect(PotionEffectType.SATURATION, 14, 0)); public static ItemStack CHRISTMAS_HOT_CHOCOLATE = new CustomPotion("&6Hot Chocolate", 8201, new String[0], new PotionEffect(PotionEffectType.SATURATION, 14, 0));
public static ItemStack CHRISTMAS_CAKE = new CustomItem(Material.PUMPKIN_PIE, Christmas.color("Christmas Cake"), 0); public static ItemStack CHRISTMAS_CAKE = new CustomItem(Material.PUMPKIN_PIE, Christmas.color("Christmas Cake"), 0);
public static ItemStack CARAMEL = new CustomItem(Material.CLAY_BRICK, "&6Caramel", 0); public static ItemStack CHRISTMAS_CARAMEL = new CustomItem(Material.CLAY_BRICK, "&6Caramel", 0);
public static ItemStack CARAMEL_APPLE = new CustomItem(Material.APPLE, "&6Caramel Apple", 0); public static ItemStack CHRISTMAS_CARAMEL_APPLE = new CustomItem(Material.APPLE, "&6Caramel Apple", 0);
public static ItemStack CHOCOLATE_APPLE = new CustomItem(Material.APPLE, "&6Chocolate Apple", 0); public static ItemStack CHRISTMAS_CHOCOLATE_APPLE = new CustomItem(Material.APPLE, "&6Chocolate Apple", 0);
public static ItemStack PRESENT = new CustomItem(Material.CHEST, Christmas.color("Christmas Present"), 0, new String[] {"&7From: &emrCookieSlime", "&7To: &eYou", "", "&eRight Click&7 to open"}); public static ItemStack CHRISTMAS_PRESENT = new CustomItem(Material.CHEST, Christmas.color("Christmas Present"), 0, new String[] {"&7From: &emrCookieSlime", "&7To: &eYou", "", "&eRight Click&7 to open"});
/* Easter */ /* Easter */
public static ItemStack EASTER_EGG = new CustomItem(Material.EGG, "&rEaster Egg", 0, new String[] {"&bSurprise! Surprise!"}); public static ItemStack EASTER_EGG = new CustomItem(Material.EGG, "&rEaster Egg", 0, new String[] {"&bSurprise! Surprise!"});
public static ItemStack CARROT_PIE = new CustomItem(Material.PUMPKIN_PIE, "&6Carrot Pie", 0); public static ItemStack EASTER_CARROT_PIE = new CustomItem(Material.PUMPKIN_PIE, "&6Carrot Pie", 0);
/* Weapons */ /* Weapons */
public static ItemStack GRANDMAS_WALKING_STICK = new CustomItem(Material.STICK, "&7Grandmas Walking Stick", 0, new String[0], new String[] {"KNOCKBACK-2"}); public static ItemStack GRANDMAS_WALKING_STICK = new CustomItem(Material.STICK, "&7Grandmas Walking Stick", 0, new String[0], new String[] {"KNOCKBACK-2"});
@ -705,7 +705,7 @@ public class SlimefunItems {
PROGRAMMABLE_ANDROID = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzUwM2NiN2VkODQ1ZTdhNTA3ZjU2OWFmYzY0N2M0N2FjNDgzNzcxNDY1YzlhNjc5YTU0NTk0Yzc2YWZiYSJ9fX0="), "&cProgrammable Android &7(Normal)", "", "&8\u21E8 &7Function: None", "&8\u21E8 &7Fuel Efficiency: 1.0x"); PROGRAMMABLE_ANDROID = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzUwM2NiN2VkODQ1ZTdhNTA3ZjU2OWFmYzY0N2M0N2FjNDgzNzcxNDY1YzlhNjc5YTU0NTk0Yzc2YWZiYSJ9fX0="), "&cProgrammable Android &7(Normal)", "", "&8\u21E8 &7Function: None", "&8\u21E8 &7Fuel Efficiency: 1.0x");
PROGRAMMABLE_ANDROID_FARMER = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjlkMzMzNTdlODQxODgyM2JmNzgzZGU5MmRlODAyOTFiNGViZDM5MmFlYzg3MDY2OThlMDY4OTZkNDk4ZjYifX19"), "&cProgrammable Android &7(Farmer)", "", "&8\u21E8 &7Function: Farming", "&8\u21E8 &7Fuel Efficiency: 1.0x"); PROGRAMMABLE_ANDROID_FARMER = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjlkMzMzNTdlODQxODgyM2JmNzgzZGU5MmRlODAyOTFiNGViZDM5MmFlYzg3MDY2OThlMDY4OTZkNDk4ZjYifX19"), "&cProgrammable Android &7(Farmer)", "", "&8\u21E8 &7Function: Farming", "&8\u21E8 &7Fuel Efficiency: 1.0x");
PROGRAMMABLE_ANDROID_MINER = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTYzOGEyODU0MWFiM2FlMGE3MjNkNTU3ODczOGUwODc1ODM4OGVjNGMzMzI0N2JkNGNhMTM0ODJhZWYzMzQifX19"), "§cProgrammable Android &7(Miner)", "", "§8\u21E8 §7Function: Mining", "§8\u21E8 §7Fuel Efficiency: 1.0x"); PROGRAMMABLE_ANDROID_MINER = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTYzOGEyODU0MWFiM2FlMGE3MjNkNTU3ODczOGUwODc1ODM4OGVjNGMzMzI0N2JkNGNhMTM0ODJhZWYzMzQifX19"), "&cProgrammable Android &7(Miner)", "", "&8\u21E8 &7Function: Mining", "&8\u21E8 &7Fuel Efficiency: 1.0x");
PROGRAMMABLE_ANDROID_WOODCUTTER = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDMyYTgxNDUxMDE0MjIwNTE2OWExYWQzMmYwYTc0NWYxOGU5Y2I2YzY2ZWU2NGVjYTJlNjViYWJkZWY5ZmYifX19"), "&cProgrammable Android &7(Woodcutter)", "", "&8\u21E8 &7Function: Woodcutting", "&8\u21E8 &7Fuel Efficiency: 1.0x"); PROGRAMMABLE_ANDROID_WOODCUTTER = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDMyYTgxNDUxMDE0MjIwNTE2OWExYWQzMmYwYTc0NWYxOGU5Y2I2YzY2ZWU2NGVjYTJlNjViYWJkZWY5ZmYifX19"), "&cProgrammable Android &7(Woodcutter)", "", "&8\u21E8 &7Function: Woodcutting", "&8\u21E8 &7Fuel Efficiency: 1.0x");
PROGRAMMABLE_ANDROID_BUTCHER = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2I0NzJkZjBhZDlhM2JlODhmMmU1ZDVkNDIyZDAyYjExNmQ2NGQ4ZGYxNDc1ZWQzMmU1NDZhZmM4NGIzMSJ9fX0="), "&cProgrammable Android &7(Butcher)", "", "&8\u21E8 &7Function: Slaughtering", "&8\u21E8 &7Damage: 4", "&8\u21E8 &7Fuel Efficiency: 1.0x"); PROGRAMMABLE_ANDROID_BUTCHER = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2I0NzJkZjBhZDlhM2JlODhmMmU1ZDVkNDIyZDAyYjExNmQ2NGQ4ZGYxNDc1ZWQzMmU1NDZhZmM4NGIzMSJ9fX0="), "&cProgrammable Android &7(Butcher)", "", "&8\u21E8 &7Function: Slaughtering", "&8\u21E8 &7Damage: 4", "&8\u21E8 &7Fuel Efficiency: 1.0x");
PROGRAMMABLE_ANDROID_FISHERMAN = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzQ1ZTg3MzNhNzMxMTQzMzNiOThiMzYwMTc1MTI0MTcyMmY0NzEzZTFhMWE1ZDM2ZmJiMTMyNDkzZjFjNyJ9fX0="), "&cProgrammable Android &7(Fisherman)", "", "&8\u21E8 &7Function: Fishing", "&8\u21E8 &7Success Rate: 10%", "&8\u21E8 &7Fuel Efficiency: 1.0x"); PROGRAMMABLE_ANDROID_FISHERMAN = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzQ1ZTg3MzNhNzMxMTQzMzNiOThiMzYwMTc1MTI0MTcyMmY0NzEzZTFhMWE1ZDM2ZmJiMTMyNDkzZjFjNyJ9fX0="), "&cProgrammable Android &7(Fisherman)", "", "&8\u21E8 &7Function: Fishing", "&8\u21E8 &7Success Rate: 10%", "&8\u21E8 &7Fuel Efficiency: 1.0x");

View File

@ -11,6 +11,7 @@ import java.util.Set;
import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.SlimefunStartup;
import me.mrCookieSlime.Slimefun.AncientAltar.AltarRecipe; import me.mrCookieSlime.Slimefun.AncientAltar.AltarRecipe;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.Research; import me.mrCookieSlime.Slimefun.Objects.Research;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
@ -329,6 +330,8 @@ public class SlimefunItem {
public static SlimefunItem getByItem(ItemStack item) { public static SlimefunItem getByItem(ItemStack item) {
if (item == null) return null; if (item == null) return null;
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BROKEN_SPAWNER, false)) return getByID("BROKEN_SPAWNER");
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.REPAIRED_SPAWNER, false)) return getByID("REINFORCED_SPAWNER");
for (SlimefunItem sfi: items) { for (SlimefunItem sfi: items) {
if (sfi instanceof ChargableItem && SlimefunManager.isItemSimiliar(item, sfi.getItem(), false)) return sfi; if (sfi instanceof ChargableItem && SlimefunManager.isItemSimiliar(item, sfi.getItem(), false)) return sfi;
else if (sfi instanceof DamagableChargableItem && SlimefunManager.isItemSimiliar(item, sfi.getItem(), false)) return sfi; else if (sfi instanceof DamagableChargableItem && SlimefunManager.isItemSimiliar(item, sfi.getItem(), false)) return sfi;

View File

@ -84,10 +84,16 @@ public abstract class AContainer extends SlimefunItem {
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) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
progress.remove(b); progress.remove(b);
@ -134,11 +140,20 @@ public abstract class AContainer extends SlimefunItem {
@Override @Override
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);
if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
processing.remove(b); processing.remove(b);
progress.remove(b); progress.remove(b);

View File

@ -68,8 +68,14 @@ public abstract class AFarm extends SlimefunItem {
@Override @Override
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);
if (inv != null) {
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
return true; return true;
} }
@ -111,8 +117,14 @@ public abstract class AFarm extends SlimefunItem {
@Override @Override
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);
if (inv != null) {
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
return true; return true;
} }

View File

@ -88,10 +88,16 @@ public abstract class AGenerator extends SlimefunItem {
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) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
progress.remove(b.getLocation()); progress.remove(b.getLocation());
@ -141,10 +147,16 @@ public abstract class AGenerator extends SlimefunItem {
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) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
progress.remove(b.getLocation()); progress.remove(b.getLocation());

View File

@ -134,13 +134,22 @@ public abstract class AReactor extends SlimefunItem {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getFuelSlots()) { for (int slot: getFuelSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getCoolantSlots()) { for (int slot: getCoolantSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
progress.remove(b.getLocation()); progress.remove(b.getLocation());
@ -299,10 +308,11 @@ public abstract class AReactor extends SlimefunItem {
extraTick(l); extraTick(l);
int timeleft = progress.get(l); int timeleft = progress.get(l);
if (timeleft > 0) { if (timeleft > 0) {
if (ChargableBlock.getMaxCharge(l) - ChargableBlock.getCharge(l) >= getEnergyProduction()) { boolean should_charge = ChargableBlock.getMaxCharge(l) - ChargableBlock.getCharge(l) >= getEnergyProduction();
if (should_charge) {
ChargableBlock.addCharge(l, getEnergyProduction()); ChargableBlock.addCharge(l, getEnergyProduction());
} }
if (ChargableBlock.getMaxCharge(l) - ChargableBlock.getCharge(l) >= getEnergyProduction() || !BlockStorage.getBlockInfo(l, "reactor-mode").equals("generator")) { if (should_charge || !BlockStorage.getBlockInfo(l, "reactor-mode").equals("generator")) {
progress.put(l, timeleft - 1); progress.put(l, timeleft - 1);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {

View File

@ -210,8 +210,14 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
@Override @Override
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);
if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
return true; return true;
} }

View File

@ -70,8 +70,14 @@ public class AnimalGrowthAccelerator extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).remove(); me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).remove();
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
return true; return true;
} }

View File

@ -70,8 +70,14 @@ public class AutoBreeder extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).remove(); me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).remove();
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
return true; return true;
} }

View File

@ -97,7 +97,10 @@ public class AutoDisenchanter extends AContainer {
ItemStack item = BlockStorage.getInventory(b).getItemInSlot(slot); ItemStack item = BlockStorage.getInventory(b).getItemInSlot(slot);
// Check if disenchantable // Check if disenchantable
SlimefunItem sfItem = SlimefunItem.getByItem(item); SlimefunItem sfItem = null;
if ((item != null) && (item.getType() != Material.BOOK)) { // stops endless checks of getByItem for empty book stacks.
sfItem = SlimefunItem.getByItem(item);
}
if (sfItem != null && !sfItem.isDisenchantable()) return; if (sfItem != null && !sfItem.isDisenchantable()) return;
// Disenchant // Disenchant
@ -116,6 +119,7 @@ public class AutoDisenchanter extends AContainer {
} }
if (amount > 0) { if (amount > 0) {
ItemStack newItem = item.clone(); ItemStack newItem = item.clone();
newItem.setAmount(1);
ItemStack book = target.clone(); ItemStack book = target.clone();
book.setAmount(1); book.setAmount(1);
book.setType(Material.ENCHANTED_BOOK); book.setType(Material.ENCHANTED_BOOK);

View File

@ -119,10 +119,16 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem {
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) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
return true; return true;

View File

@ -105,8 +105,14 @@ public class CargoCraftingNode extends SlimefunItem {
@Override @Override
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);
if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
return true; return true;
} }

View File

@ -236,8 +236,14 @@ public class CargoInputNode extends SlimefunItem {
@Override @Override
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);
if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
return true; return true;
} }

View File

@ -80,8 +80,14 @@ public abstract class CropGrowthAccelerator extends SlimefunItem {
@Override @Override
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);
if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
return true; return true;
} }

View File

@ -42,6 +42,7 @@ public abstract class ElectricDustWasher extends AContainer {
public void registerDefaultRecipes() {} public void registerDefaultRecipes() {}
public abstract int getSpeed(); public abstract int getSpeed();
public static boolean legacy_dust_washer = false;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected void tick(Block b) { protected void tick(Block b) {
@ -82,6 +83,16 @@ public abstract class ElectricDustWasher extends AContainer {
else { else {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.SIFTED_ORE, true)) { if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.SIFTED_ORE, true)) {
if (!legacy_dust_washer) {
boolean empty_slot = false;
for (int output_slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(output_slot) == null) {
empty_slot = true;
break;
}
}
if (!empty_slot) return;
}
ItemStack adding = SlimefunItems.IRON_DUST; ItemStack adding = SlimefunItems.IRON_DUST;
if (SlimefunStartup.chance(100, 25)) adding = SlimefunItems.GOLD_DUST; if (SlimefunStartup.chance(100, 25)) adding = SlimefunItems.GOLD_DUST;
@ -94,7 +105,7 @@ public abstract class ElectricDustWasher extends AContainer {
else if (SlimefunStartup.chance(100, 25)) adding = SlimefunItems.SILVER_DUST; else if (SlimefunStartup.chance(100, 25)) adding = SlimefunItems.SILVER_DUST;
MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {adding}); MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {adding});
if (!fits(b, r.getOutput())) return; if (legacy_dust_washer && !fits(b, r.getOutput())) return;
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1)); BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
processing.put(b, r); processing.put(b, r);
progress.put(b, r.getTicks()); progress.put(b, r.getTicks());

View File

@ -102,10 +102,16 @@ public abstract class ElectricSmeltery extends AContainer {
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) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
progress.remove(b.getLocation()); progress.remove(b.getLocation());

View File

@ -81,13 +81,22 @@ public class ReactorAccessPort extends SlimefunItem {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getFuelSlots()) { for (int slot: getFuelSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getCoolantSlots()) { for (int slot: getCoolantSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
return true; return true;

View File

@ -130,10 +130,16 @@ public class WitherAssembler extends SlimefunItem {
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) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getWitherSkullSlots()) { for (int slot: getWitherSkullSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
return true; return true;

View File

@ -69,8 +69,14 @@ public class XPCollector extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).remove(); me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).remove();
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
} }
return true; return true;
} }

View File

@ -144,7 +144,7 @@ public class ResearchSetup {
Slimefun.registerResearch(new Research(145, "XP Storage", 13), SlimefunItems.FLASK_OF_KNOWLEDGE); Slimefun.registerResearch(new Research(145, "XP Storage", 13), SlimefunItems.FLASK_OF_KNOWLEDGE);
Slimefun.registerResearch(new Research(146, "Withstanding Explosions", 15), SlimefunItems.REINFORCED_PLATE, SlimefunItems.HARDENED_GLASS); Slimefun.registerResearch(new Research(146, "Withstanding Explosions", 15), SlimefunItems.REINFORCED_PLATE, SlimefunItems.HARDENED_GLASS);
Slimefun.registerResearch(new Research(148, "Happy Easter", 1)); Slimefun.registerResearch(new Research(148, "Happy Easter", 1));
Slimefun.registerResearch(new Research(149, "Golden potion", 24), SlimefunItems.GOLDE_APPLE_JUICE); Slimefun.registerResearch(new Research(149, "Golden potion", 24), SlimefunItems.GOLDEN_APPLE_JUICE);
Slimefun.registerResearch(new Research(150, "Portable Beverages", 24), SlimefunItems.COOLING_UNIT, SlimefunItems.COOLER); Slimefun.registerResearch(new Research(150, "Portable Beverages", 24), SlimefunItems.COOLING_UNIT, SlimefunItems.COOLER);
Slimefun.registerResearch(new Research(151, "Ancient Altar", 15), SlimefunItems.ANCIENT_PEDESTAL, SlimefunItems.ANCIENT_ALTAR); Slimefun.registerResearch(new Research(151, "Ancient Altar", 15), SlimefunItems.ANCIENT_PEDESTAL, SlimefunItems.ANCIENT_ALTAR);
Slimefun.registerResearch(new Research(152, "Wither-Proof Obsidian", 21), SlimefunItems.WITHER_PROOF_OBSIDIAN); Slimefun.registerResearch(new Research(152, "Wither-Proof Obsidian", 21), SlimefunItems.WITHER_PROOF_OBSIDIAN);

View File

@ -10,6 +10,7 @@ import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -157,6 +158,8 @@ import me.mrCookieSlime.Slimefun.listeners.AncientAltarListener;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class SlimefunSetup { public class SlimefunSetup {
public static boolean legacy_ore_washer = false;
public static void setupItems() throws Exception { public static void setupItems() throws Exception {
new SlimefunItem(Categories.WEAPONS, SlimefunItems.GRANDMAS_WALKING_STICK, "GRANDMAS_WALKING_STICK", RecipeType.ENHANCED_CRAFTING_TABLE, new SlimefunItem(Categories.WEAPONS, SlimefunItems.GRANDMAS_WALKING_STICK, "GRANDMAS_WALKING_STICK", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new ItemStack(Material.LOG), null, null, new ItemStack(Material.LOG), null, null, new ItemStack(Material.LOG), null}) new ItemStack[] {null, new ItemStack(Material.LOG), null, null, new ItemStack(Material.LOG), null, null, new ItemStack(Material.LOG), null})
@ -193,9 +196,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(Player p, MultiBlock mb, Block b) { public boolean onInteract(Player p, MultiBlock mb, Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("ENHANCED_CRAFTING_TABLE"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("ENHANCED_CRAFTING_TABLE");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) {
Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState();
@ -304,6 +308,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.pattern-not-found", true); Messages.local.sendTranslation(p, "machines.pattern-not-found", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -339,9 +344,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(Player p, MultiBlock mb, Block b) { public boolean onInteract(Player p, MultiBlock mb, Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("GRIND_STONE"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("GRIND_STONE");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) {
Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
@ -363,6 +369,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.unknown-material", true); Messages.local.sendTranslation(p, "machines.unknown-material", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -378,9 +385,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(final Player p, MultiBlock mb, Block b) { public boolean onInteract(final Player p, MultiBlock mb, Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("ARMOR_FORGE"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("ARMOR_FORGE");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) {
Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState();
final Inventory inv = disp.getInventory(); final Inventory inv = disp.getInventory();
@ -433,6 +441,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.pattern-not-found", true); Messages.local.sendTranslation(p, "machines.pattern-not-found", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -448,9 +457,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(Player p, MultiBlock mb, Block b) { public boolean onInteract(Player p, MultiBlock mb, Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("ORE_CRUSHER"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("ORE_CRUSHER");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) {
Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
@ -472,6 +482,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.unknown-material", true); Messages.local.sendTranslation(p, "machines.unknown-material", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -487,9 +498,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(final Player p, MultiBlock mb, Block b) { public boolean onInteract(final Player p, MultiBlock mb, Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("COMPRESSOR"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("COMPRESSOR");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) {
Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState();
final Inventory inv = disp.getInventory(); final Inventory inv = disp.getInventory();
@ -532,6 +544,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.unknown-material", true); Messages.local.sendTranslation(p, "machines.unknown-material", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -681,13 +694,14 @@ public class SlimefunSetup {
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) { public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.GOLD_PAN, true)) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.GOLD_PAN, true)) {
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.GRAVEL) { if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.GRAVEL) {
if (CSCoreLib.getLib().getProtectionManager().canBuild(p.getUniqueId(), e.getClickedBlock(), true)) {
List<ItemStack> drops = new ArrayList<ItemStack>(); List<ItemStack> drops = new ArrayList<ItemStack>();
if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.SIFTED_ORE"))) drops.add(SlimefunItems.SIFTED_ORE); if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.SIFTED_ORE"))) drops.add(SlimefunItems.SIFTED_ORE);
else if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.CLAY"))) drops.add(new ItemStack(Material.CLAY_BALL)); else if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.CLAY"))) drops.add(new ItemStack(Material.CLAY_BALL));
else if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.FLINT"))) drops.add(new ItemStack(Material.FLINT)); else if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.FLINT"))) drops.add(new ItemStack(Material.FLINT));
if (CSCoreLib.getLib().getProtectionManager().canBuild(p.getUniqueId(), e.getClickedBlock(), true)) {
e.getClickedBlock().getWorld().playEffect(e.getClickedBlock().getLocation(), Effect.STEP_SOUND, e.getClickedBlock().getType()); e.getClickedBlock().getWorld().playEffect(e.getClickedBlock().getLocation(), Effect.STEP_SOUND, e.getClickedBlock().getType());
e.getClickedBlock().setType(Material.AIR); e.getClickedBlock().setType(Material.AIR);
for (ItemStack drop: drops) { for (ItemStack drop: drops) {
@ -715,9 +729,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(Player p, MultiBlock mb, Block b) { public boolean onInteract(Player p, MultiBlock mb, Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("SMELTERY"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("SMELTERY");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) {
Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
@ -785,6 +800,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.pattern-not-found", true); Messages.local.sendTranslation(p, "machines.pattern-not-found", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -805,9 +821,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(final Player p, MultiBlock mb, final Block b) { public boolean onInteract(final Player p, MultiBlock mb, final Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("PRESSURE_CHAMBER"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("PRESSURE_CHAMBER");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) {
Dispenser disp = (Dispenser) b.getRelative(BlockFace.UP).getRelative(BlockFace.UP).getState(); Dispenser disp = (Dispenser) b.getRelative(BlockFace.UP).getRelative(BlockFace.UP).getState();
final Inventory inv = disp.getInventory(); final Inventory inv = disp.getInventory();
@ -862,6 +879,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.unknown-material", true); Messages.local.sendTranslation(p, "machines.unknown-material", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -1108,9 +1126,9 @@ public class SlimefunSetup {
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) { public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.GRAPPLING_HOOK, true)) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.GRAPPLING_HOOK, true)) {
if (e.getClickedBlock() == null && !Variables.jump.containsKey(p.getUniqueId())) { if (e.getClickedBlock() == null && !Variables.jump.containsKey(p.getUniqueId())) {
Variables.jump.put(p.getUniqueId(), p.getItemInHand().getType() != Material.SHEARS); Variables.jump.put(p.getUniqueId(), p.getInventory().getItemInMainHand().getType() != Material.SHEARS);
e.setCancelled(true); e.setCancelled(true);
if (p.getItemInHand().getType() == Material.LEASH) PlayerInventory.consumeItemInHand(p); if (p.getInventory().getItemInMainHand().getType() == Material.LEASH) PlayerInventory.consumeItemInHand(p);
Vector direction = p.getEyeLocation().getDirection().multiply(2.0); Vector direction = p.getEyeLocation().getDirection().multiply(2.0);
Projectile projectile = p.getWorld().spawn(p.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Arrow.class); Projectile projectile = p.getWorld().spawn(p.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Arrow.class);
@ -1139,9 +1157,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(final Player p, MultiBlock mb, final Block b) { public boolean onInteract(final Player p, MultiBlock mb, final Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("MAGIC_WORKBENCH"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("MAGIC_WORKBENCH");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) {
Dispenser disp = null; Dispenser disp = null;
@ -1157,10 +1176,18 @@ public class SlimefunSetup {
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.isItemSimiliar(inv.getContents()[j], inputs.get(i)[j], true)) { if (!SlimefunManager.isItemSimiliar(inv.getContents()[j], inputs.get(i)[j], true)) {
if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) {
if (!SlimefunManager.isItemSimiliar(inv.getContents()[j], inputs.get(i)[j], false)) {
craft = false; craft = false;
break; break;
} }
} }
else {
craft = false;
break;
}
}
}
if (craft) { if (craft) {
final ItemStack adding = RecipeType.getRecipeOutputList(machine, inputs.get(i)); final ItemStack adding = RecipeType.getRecipeOutputList(machine, inputs.get(i));
@ -1170,6 +1197,62 @@ public class SlimefunSetup {
inv2.setItem(j, inv.getContents()[j] != null ? (inv.getContents()[j].getAmount() > 1 ? new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1): null): null); inv2.setItem(j, inv.getContents()[j] != null ? (inv.getContents()[j].getAmount() > 1 ? new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1): null): null);
} }
if (InvUtils.fits(inv2, adding)) { if (InvUtils.fits(inv2, adding)) {
SlimefunItem sfItem = SlimefunItem.getByItem(adding);
if (sfItem instanceof SlimefunBackpack) {
ItemStack backpack = null;
for (int j = 0; j < 9; j++) {
if (inv.getContents()[j] != null) {
if (inv.getContents()[j].getType() != Material.AIR) {
if (SlimefunItem.getByItem(inv.getContents()[j]) instanceof SlimefunBackpack) {
backpack = inv.getContents()[j];
break;
}
}
}
}
String id = "";
int size = ((SlimefunBackpack) sfItem).size;
if (backpack != null) {
for (String line: backpack.getItemMeta().getLore()) {
if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&7ID: ")) && line.contains("#")) {
id = line.replace(ChatColor.translateAlternateColorCodes('&', "&7ID: "), "");
Config cfg = new Config(new File("data-storage/Slimefun/Players/" + id.split("#")[0] + ".yml"));
cfg.setValue("backpacks." + id.split("#")[1] + ".size", size);
cfg.save();
break;
}
}
}
if (id.equals("")) {
for (int line = 0; line < adding.getItemMeta().getLore().size(); line++) {
if (adding.getItemMeta().getLore().get(line).equals(ChatColor.translateAlternateColorCodes('&', "&7ID: <ID>"))) {
ItemMeta im = adding.getItemMeta();
List<String> lore = im.getLore();
lore.set(line, lore.get(line).replace("<ID>", Backpacks.createBackpack(p, size)));
im.setLore(lore);
adding.setItemMeta(im);
break;
}
}
}
else {
for (int line = 0; line < adding.getItemMeta().getLore().size(); line++) {
if (adding.getItemMeta().getLore().get(line).equals(ChatColor.translateAlternateColorCodes('&', "&7ID: <ID>"))) {
ItemMeta im = adding.getItemMeta();
List<String> lore = im.getLore();
lore.set(line, lore.get(line).replace("<ID>", id));
im.setLore(lore);
adding.setItemMeta(im);
break;
}
}
}
}
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
if (inv.getContents()[j] != null) { if (inv.getContents()[j] != null) {
if (inv.getContents()[j].getType() != Material.AIR) { if (inv.getContents()[j].getType() != Material.AIR) {
@ -1217,6 +1300,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.pattern-not-found", true); Messages.local.sendTranslation(p, "machines.pattern-not-found", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -1235,7 +1319,7 @@ public class SlimefunSetup {
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) { public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.STAFF_WIND, true)) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.STAFF_WIND, true)) {
if (p.getFoodLevel() >= 2) { if (p.getFoodLevel() >= 2) {
if (p.getItemInHand().getType() != Material.SHEARS) { if (p.getInventory().getItemInMainHand().getType() != Material.SHEARS && p.getGameMode() != GameMode.CREATIVE) {
FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 2); FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 2);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
p.setFoodLevel(event.getFoodLevel()); p.setFoodLevel(event.getFoodLevel());
@ -1313,9 +1397,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(Player p, MultiBlock mb, Block b) { public boolean onInteract(Player p, MultiBlock mb, Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("ORE_WASHER"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("ORE_WASHER");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, machine.getItem(), true)) { if (Slimefun.hasUnlocked(p, machine.getItem(), true)) {
Dispenser disp = (Dispenser) b.getRelative(BlockFace.UP).getState(); Dispenser disp = (Dispenser) b.getRelative(BlockFace.UP).getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
@ -1332,7 +1417,7 @@ public class SlimefunSetup {
else if (SlimefunStartup.chance(100, 25)) adding = SlimefunItems.LEAD_DUST; else if (SlimefunStartup.chance(100, 25)) adding = SlimefunItems.LEAD_DUST;
else if (SlimefunStartup.chance(100, 25)) adding = SlimefunItems.SILVER_DUST; else if (SlimefunStartup.chance(100, 25)) adding = SlimefunItems.SILVER_DUST;
if (inv.firstEmpty() != -1) { if (inv.firstEmpty() != -1 || (legacy_ore_washer && InvUtils.fits(inv, adding))) {
ItemStack removing = current.clone(); ItemStack removing = current.clone();
removing.setAmount(1); removing.setAmount(1);
inv.removeItem(removing); inv.removeItem(removing);
@ -1374,6 +1459,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.unknown-material", true); Messages.local.sendTranslation(p, "machines.unknown-material", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -1569,7 +1655,7 @@ public class SlimefunSetup {
@Override @Override
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
if (SlimefunManager.isItemSimiliar(e.getPlayer().getItemInHand(), SlimefunItems.LUMBER_AXE, true)) { if (SlimefunManager.isItemSimiliar(e.getPlayer().getInventory().getItemInMainHand(), SlimefunItems.LUMBER_AXE, true)) {
if (e.getBlock().getType() == Material.LOG || e.getBlock().getType() == Material.LOG_2) { if (e.getBlock().getType() == Material.LOG || e.getBlock().getType() == Material.LOG_2) {
List<Location> logs = new ArrayList<Location>(); List<Location> logs = new ArrayList<Location>();
TreeCalculator.getTree(e.getBlock().getLocation(), e.getBlock().getLocation(), logs); TreeCalculator.getTree(e.getBlock().getLocation(), e.getBlock().getLocation(), logs);
@ -1757,7 +1843,7 @@ public class SlimefunSetup {
@Override @Override
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
if (SlimefunManager.isItemSimiliar(e.getPlayer().getItemInHand(), SlimefunItems.PICKAXE_OF_CONTAINMENT, true)) { if (SlimefunManager.isItemSimiliar(e.getPlayer().getInventory().getItemInMainHand(), SlimefunItems.PICKAXE_OF_CONTAINMENT, true)) {
if (e.getBlock().getType() != Material.MOB_SPAWNER) return true; if (e.getBlock().getType() != Material.MOB_SPAWNER) return true;
ItemStack spawner = SlimefunItems.BROKEN_SPAWNER.clone(); ItemStack spawner = SlimefunItems.BROKEN_SPAWNER.clone();
ItemMeta im = spawner.getItemMeta(); ItemMeta im = spawner.getItemMeta();
@ -1781,7 +1867,7 @@ public class SlimefunSetup {
@Override @Override
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
if (SlimefunManager.isItemSimiliar(e.getPlayer().getItemInHand(), SlimefunItems.HERCULES_PICKAXE, true) && e.getBlock().getType().toString().endsWith("_ORE")) { if (SlimefunManager.isItemSimiliar(e.getPlayer().getInventory().getItemInMainHand(), SlimefunItems.HERCULES_PICKAXE, true) && e.getBlock().getType().toString().endsWith("_ORE")) {
if (e.getBlock().getType() == Material.IRON_ORE) drops.add(new CustomItem(SlimefunItems.IRON_DUST, 2)); if (e.getBlock().getType() == Material.IRON_ORE) drops.add(new CustomItem(SlimefunItems.IRON_DUST, 2));
else if (e.getBlock().getType() == Material.GOLD_ORE) drops.add(new CustomItem(SlimefunItems.GOLD_DUST, 2)); else if (e.getBlock().getType() == Material.GOLD_ORE) drops.add(new CustomItem(SlimefunItems.GOLD_DUST, 2));
else { else {
@ -1802,10 +1888,19 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(Player p, MultiBlock mb, Block b) { public boolean onInteract(Player p, MultiBlock mb, Block b) {
if (mb.isMultiBlock(SlimefunItem.getByName("SAW_MILL"))) { if (mb.isMultiBlock(SlimefunItem.getByID("SAW_MILL"))) {
if(CSCoreLib.getLib().getProtectionManager().canBuild(p.getUniqueId(), b.getRelative(BlockFace.UP), true)) {
if (Slimefun.hasUnlocked(p, SlimefunItems.SAW_MILL, true)) { if (Slimefun.hasUnlocked(p, SlimefunItems.SAW_MILL, true)) {
if (b.getRelative(BlockFace.UP).getType() == Material.LOG) BlockBreaker.breakBlock(p, b.getRelative(BlockFace.UP), Arrays.asList(new ItemStack[] {new CustomItem(Material.WOOD, b.getRelative(BlockFace.UP).getData() % 4, 8)}), true); if (b.getRelative(BlockFace.UP).getType() == Material.LOG || b.getRelative(BlockFace.UP).getType() == Material.LOG_2) {
else if (b.getRelative(BlockFace.UP).getType() == Material.LOG_2) BlockBreaker.breakBlock(p, b.getRelative(BlockFace.UP), Arrays.asList(new ItemStack[] {new CustomItem(Material.WOOD, (b.getRelative(BlockFace.UP).getData() % 2) + 4, 8)}), true); Block log = b.getRelative(BlockFace.UP);
if(!BlockStorage.hasBlockInfo(log)) {
ItemStack item = log.getType() == Material.LOG ? new CustomItem(Material.WOOD, log.getData() % 4, 8) : new CustomItem(Material.WOOD, (log.getData() % 2) + 4, 8);
log.getWorld().dropItemNaturally(log.getLocation(), item);
log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());
log.setType(Material.AIR);
}
}
}
} }
return true; return true;
} }
@ -1818,6 +1913,16 @@ public class SlimefunSetup {
new ItemStack[] {}, Material.WORKBENCH, true) new ItemStack[] {}, Material.WORKBENCH, true)
.register(true); .register(true);
new SlimefunMachine(Categories.MACHINES_1, new CustomItem(Material.FIRE, "&4Phantom Item", 0), "SAW_MILL3",
new ItemStack[] {null, null, null, new ItemStack(Material.IRON_FENCE), new ItemStack(Material.LOG), new ItemStack(Material.IRON_FENCE), new ItemStack(Material.LOG_2), new ItemStack(Material.WORKBENCH), new ItemStack(Material.LOG_2)},
new ItemStack[] {}, Material.WORKBENCH, true)
.register(true);
new SlimefunMachine(Categories.MACHINES_1, new CustomItem(Material.FIRE, "&4Phantom Item", 0), "SAW_MILL4",
new ItemStack[] {null, null, null, new ItemStack(Material.IRON_FENCE), new ItemStack(Material.LOG_2), new ItemStack(Material.IRON_FENCE), new ItemStack(Material.LOG_2), new ItemStack(Material.WORKBENCH), new ItemStack(Material.LOG_2)},
new ItemStack[] {}, Material.WORKBENCH, true)
.register(true);
new SlimefunItem(Categories.MAGIC_ARMOR, SlimefunItems.SLIME_HELMET_STEEL, "SLIME_STEEL_HELMET", RecipeType.ARMOR_FORGE, new SlimefunItem(Categories.MAGIC_ARMOR, SlimefunItems.SLIME_HELMET_STEEL, "SLIME_STEEL_HELMET", RecipeType.ARMOR_FORGE,
new ItemStack[] {new ItemStack(Material.SLIME_BALL), SlimefunItems.STEEL_PLATE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), null, null, null}) new ItemStack[] {new ItemStack(Material.SLIME_BALL), SlimefunItems.STEEL_PLATE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), null, null, null})
.register(true); .register(true);
@ -1847,7 +1952,8 @@ public class SlimefunSetup {
@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.getByName("DIGITAL_MINER"))) { if (mb.isMultiBlock(SlimefunItem.getByID("DIGITAL_MINER"))) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, SlimefunItems.DIGITAL_MINER, true)) { if (Slimefun.hasUnlocked(p, SlimefunItems.DIGITAL_MINER, true)) {
Chest chest = (Chest) b.getRelative(BlockFace.UP).getState(); Chest chest = (Chest) b.getRelative(BlockFace.UP).getState();
final Inventory inv = chest.getInventory(); final Inventory inv = chest.getInventory();
@ -1910,6 +2016,7 @@ public class SlimefunSetup {
} }
else Messages.local.sendTranslation(p, "miner.no-ores", true); else Messages.local.sendTranslation(p, "miner.no-ores", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -1923,7 +2030,8 @@ public class SlimefunSetup {
@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.getByName("ADVANCED_DIGITAL_MINER"))) { if (mb.isMultiBlock(SlimefunItem.getByID("ADVANCED_DIGITAL_MINER"))) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, SlimefunItems.ADVANCED_DIGITAL_MINER, true)) { if (Slimefun.hasUnlocked(p, SlimefunItems.ADVANCED_DIGITAL_MINER, true)) {
Chest chest = (Chest) b.getRelative(BlockFace.UP).getState(); Chest chest = (Chest) b.getRelative(BlockFace.UP).getState();
final Inventory inv = chest.getInventory(); final Inventory inv = chest.getInventory();
@ -1991,6 +2099,7 @@ public class SlimefunSetup {
} }
else Messages.local.sendTranslation(p, "miner.no-ores", true); else Messages.local.sendTranslation(p, "miner.no-ores", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -2010,8 +2119,9 @@ public class SlimefunSetup {
public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) { public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) {
if (e.getClickedBlock() != null) { if (e.getClickedBlock() != null) {
SlimefunItem machine = BlockStorage.check(e.getClickedBlock()); SlimefunItem machine = BlockStorage.check(e.getClickedBlock());
if (machine != null && machine.getName().equals("COMPOSTER")) { if (machine != null && machine.getID().equals("COMPOSTER")) {
final ItemStack input = p.getItemInHand(); if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) {
final ItemStack input = p.getInventory().getItemInMainHand();
final Block b = e.getClickedBlock(); final Block b = e.getClickedBlock();
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) { for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
if (convert != null && SlimefunManager.isItemSimiliar(input, convert, true)) { if (convert != null && SlimefunManager.isItemSimiliar(input, convert, true)) {
@ -2116,6 +2226,8 @@ public class SlimefunSetup {
Messages.local.sendTranslation(p, "machines.wrong-item", true); Messages.local.sendTranslation(p, "machines.wrong-item", true);
return true; return true;
} }
return true;
}
} }
return false; return false;
} }
@ -2186,8 +2298,9 @@ public class SlimefunSetup {
@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.getByName("AUTOMATED_PANNING_MACHINE"))) { if (mb.isMultiBlock(SlimefunItem.getByID("AUTOMATED_PANNING_MACHINE"))) {
final ItemStack input = p.getItemInHand(); if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
final ItemStack input = p.getInventory().getItemInMainHand();
ItemStack output = null; ItemStack output = null;
if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.SIFTED_ORE"))) output = SlimefunItems.SIFTED_ORE; if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.SIFTED_ORE"))) output = SlimefunItems.SIFTED_ORE;
else if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.CLAY"))) output = new ItemStack(Material.CLAY_BALL); else if (SlimefunStartup.chance(100, (Integer) Slimefun.getItemValue("GOLD_PAN", "chance.CLAY"))) output = new ItemStack(Material.CLAY_BALL);
@ -2246,6 +2359,8 @@ public class SlimefunSetup {
Messages.local.sendTranslation(p, "machines.wrong-item", true); Messages.local.sendTranslation(p, "machines.wrong-item", true);
return true; return true;
} }
return true;
}
else return false; else return false;
} }
}); });
@ -2289,8 +2404,8 @@ public class SlimefunSetup {
p.teleport(new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), yaw, pitch)); p.teleport(new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), yaw, pitch));
} }
if (e.getPlayer().getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY)) { if (e.getPlayer().getInventory().getItemInMainHand().getEnchantments().containsKey(Enchantment.DURABILITY)) {
if (SlimefunStartup.randomize(100) <= (60 + 40 / (e.getPlayer().getItemInHand().getEnchantmentLevel(Enchantment.DURABILITY) + 1))) PlayerInventory.damageItemInHand(e.getPlayer()); if (SlimefunStartup.randomize(100) <= (60 + 40 / (e.getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.DURABILITY) + 1))) PlayerInventory.damageItemInHand(e.getPlayer());
} }
else PlayerInventory.damageItemInHand(e.getPlayer()); else PlayerInventory.damageItemInHand(e.getPlayer());
@ -2326,8 +2441,9 @@ public class SlimefunSetup {
public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) { public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) {
if (e.getClickedBlock() != null) { if (e.getClickedBlock() != null) {
SlimefunItem machine = BlockStorage.check(e.getClickedBlock()); SlimefunItem machine = BlockStorage.check(e.getClickedBlock());
if (machine != null && machine.getName().equals("CRUCIBLE")) { if (machine != null && machine.getID().equals("CRUCIBLE")) {
final ItemStack input = p.getItemInHand(); if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) {
final ItemStack input = p.getInventory().getItemInMainHand();
final Block block = e.getClickedBlock().getRelative(BlockFace.UP); final Block block = e.getClickedBlock().getRelative(BlockFace.UP);
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) { for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
if (input != null) { if (input != null) {
@ -2472,6 +2588,8 @@ public class SlimefunSetup {
Messages.local.sendTranslation(p, "machines.wrong-item", true); Messages.local.sendTranslation(p, "machines.wrong-item", true);
return true; return true;
} }
return true;
}
} }
return false; return false;
} }
@ -2592,9 +2710,9 @@ public class SlimefunSetup {
} }
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (e.getPlayer().getItemInHand() != null) { if (e.getPlayer().getInventory().getItemInMainHand() != null) {
if (e.getPlayer().getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY)) { if (e.getPlayer().getInventory().getItemInMainHand().getEnchantments().containsKey(Enchantment.DURABILITY)) {
if (SlimefunStartup.randomize(100) <= (60 + 40 / (e.getPlayer().getItemInHand().getEnchantmentLevel(Enchantment.DURABILITY) + 1))) PlayerInventory.damageItemInHand(e.getPlayer()); if (SlimefunStartup.randomize(100) <= (60 + 40 / (e.getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.DURABILITY) + 1))) PlayerInventory.damageItemInHand(e.getPlayer());
} }
else PlayerInventory.damageItemInHand(e.getPlayer()); else PlayerInventory.damageItemInHand(e.getPlayer());
} }
@ -2611,7 +2729,7 @@ public class SlimefunSetup {
@Override @Override
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
if (SlimefunManager.isItemSimiliar(e.getPlayer().getItemInHand(), SlimefunItems.PICKAXE_OF_VEIN_MINING, true)) { if (SlimefunManager.isItemSimiliar(e.getPlayer().getInventory().getItemInMainHand(), SlimefunItems.PICKAXE_OF_VEIN_MINING, true)) {
if (e.getBlock().getType().toString().endsWith("_ORE")) { if (e.getBlock().getType().toString().endsWith("_ORE")) {
List<Location> blocks = new ArrayList<Location>(); List<Location> blocks = new ArrayList<Location>();
Vein.calculate(e.getBlock().getLocation(), e.getBlock().getLocation(), blocks, 16); Vein.calculate(e.getBlock().getLocation(), e.getBlock().getLocation(), blocks, 16);
@ -2682,9 +2800,10 @@ public class SlimefunSetup {
@Override @Override
public boolean onInteract(Player p, MultiBlock mb, Block b) { public boolean onInteract(Player p, MultiBlock mb, Block b) {
SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByName("JUICER"); SlimefunMachine machine = (SlimefunMachine) SlimefunItem.getByID("JUICER");
if (mb.isMultiBlock(machine)) { if (mb.isMultiBlock(machine)) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, SlimefunItems.JUICER, true)) { if (Slimefun.hasUnlocked(p, SlimefunItems.JUICER, true)) {
Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState(); Dispenser disp = (Dispenser) b.getRelative(BlockFace.DOWN).getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
@ -2707,6 +2826,7 @@ public class SlimefunSetup {
} }
Messages.local.sendTranslation(p, "machines.unknown-material", true); Messages.local.sendTranslation(p, "machines.unknown-material", true);
} }
}
return true; return true;
} }
else return false; else return false;
@ -2729,7 +2849,7 @@ public class SlimefunSetup {
new ItemStack[] {null, null, null, null, new ItemStack(Material.PUMPKIN), null, null, null, null}) new ItemStack[] {null, null, null, null, new ItemStack(Material.PUMPKIN), null, null, null, null})
.register(true); .register(true);
new Juice(Categories.FOOD, SlimefunItems.GOLDE_APPLE_JUICE, "GOLDE_APPLE_JUICE", RecipeType.JUICER, new Juice(Categories.FOOD, SlimefunItems.GOLDEN_APPLE_JUICE, "GOLDEN_APPLE_JUICE", RecipeType.JUICER,
new ItemStack[] {new ItemStack(Material.GOLDEN_APPLE), null, null, null, null, null, null, null, null}) new ItemStack[] {new ItemStack(Material.GOLDEN_APPLE), null, null, null, null, null, null, null, null})
.register(true); .register(true);
@ -2749,8 +2869,9 @@ public class SlimefunSetup {
if (ChatColor.stripColor(line).startsWith("Type: ")) type = EntityType.valueOf(ChatColor.stripColor(line).replace("Type: ", "").replace(" ", "_").toUpperCase()); if (ChatColor.stripColor(line).startsWith("Type: ")) type = EntityType.valueOf(ChatColor.stripColor(line).replace("Type: ", "").replace(" ", "_").toUpperCase());
} }
if (type != null) { if (type != null) {
((CreatureSpawner) e.getBlock().getState()).setSpawnedType(type); CreatureSpawner spawner = (CreatureSpawner) e.getBlock().getState();
e.getBlock().getState().update(true, false); spawner.setSpawnedType(type);
spawner.update(true, false);
} }
return true; return true;
} }
@ -2758,34 +2879,6 @@ public class SlimefunSetup {
} }
}); });
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.MILK, "MILK", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.MILK_BUCKET), new ItemStack(Material.GLASS_BOTTLE), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.MILK, 4))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHOCOLATE_MILK, "CHOCOLATE_MILK", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.MILK, new MaterialData(Material.INK_SACK, (byte) 3).toItemStack(1), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHOCOLATE_MILK, 2))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.EGG_NOG, "EGG_NOG", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.MILK, new ItemStack(Material.EGG), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.EGG_NOG, 2))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.APPLE_CIDER, "APPLE_CIDER", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.APPLE_JUICE, new ItemStack(Material.SUGAR), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.APPLE_CIDER, 2))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_COOKIE, "CHRISTMAS_COOKIE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.COOKIE), new ItemStack(Material.SUGAR), new MaterialData(Material.INK_SACK, (byte) 10).toItemStack(1), null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_COOKIE, 16))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.FRUIT_CAKE, "FRUIT_CAKE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.EGG), new ItemStack(Material.APPLE), new ItemStack(Material.MELON), new ItemStack(Material.SUGAR), null, null, null, null, null}, new CustomItem(SlimefunItems.FRUIT_CAKE, 4))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.APPLE_PIE, "APPLE_PIE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.SUGAR), new ItemStack(Material.APPLE), new ItemStack(Material.EGG), null, null, null, null, null, null}, new CustomItem(SlimefunItems.APPLE_PIE, 2))
.register(true);
new EnhancedFurnace(1, 1, 1, SlimefunItems.ENHANCED_FURNACE, "ENHANCED_FURNACE", new EnhancedFurnace(1, 1, 1, SlimefunItems.ENHANCED_FURNACE, "ENHANCED_FURNACE",
new ItemStack[] {null, SlimefunItems.BASIC_CIRCUIT_BOARD, null, SlimefunItems.HEATING_COIL, new ItemStack(Material.FURNACE), SlimefunItems.HEATING_COIL, null, SlimefunItems.ELECTRIC_MOTOR, null}) new ItemStack[] {null, SlimefunItems.BASIC_CIRCUIT_BOARD, null, SlimefunItems.HEATING_COIL, new ItemStack(Material.FURNACE), SlimefunItems.HEATING_COIL, null, SlimefunItems.ELECTRIC_MOTOR, null})
.register(true); .register(true);
@ -2860,7 +2953,7 @@ public class SlimefunSetup {
@Override @Override
public boolean onBlockDispense(final BlockDispenseEvent e, Block dispenser, final Dispenser d, Block block, Block chest, SlimefunItem machine) { public boolean onBlockDispense(final BlockDispenseEvent e, Block dispenser, final Dispenser d, Block block, Block chest, SlimefunItem machine) {
if (machine.getName().equalsIgnoreCase("BLOCK_PLACER")) { if (machine.getID().equalsIgnoreCase("BLOCK_PLACER")) {
e.setCancelled(true); e.setCancelled(true);
if ((block.getType() == null || block.getType() == Material.AIR) && e.getItem().getType().isBlock()) { if ((block.getType() == null || block.getType() == Material.AIR) && e.getItem().getType().isBlock()) {
for(String blockType : blockPlacerBlacklist) { for(String blockType : blockPlacerBlacklist) {
@ -2908,14 +3001,6 @@ public class SlimefunSetup {
} }
}); });
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.HOT_CHOCOLATE, "HOT_CHOCOLATE", RecipeType.SMELTERY,
new ItemStack[] {SlimefunItems.CHOCOLATE_MILK, null, null, null, null, null, null, null, null}, SlimefunItems.HOT_CHOCOLATE)
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_CAKE, "CHRISTMAS_CAKE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.EGG), new ItemStack(Material.SUGAR), SlimefunItems.WHEAT_FLOUR, new ItemStack(Material.MILK_BUCKET), null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_CAKE, 4))
.register(true);
new SlimefunItem(Categories.MAGIC, SlimefunItems.SCROLL_OF_DIMENSIONAL_TELEPOSITION, "SCROLL_OF_DIMENSIONAL_TELEPOSITION", RecipeType.MAGIC_WORKBENCH, new SlimefunItem(Categories.MAGIC, SlimefunItems.SCROLL_OF_DIMENSIONAL_TELEPOSITION, "SCROLL_OF_DIMENSIONAL_TELEPOSITION", RecipeType.MAGIC_WORKBENCH,
new ItemStack[] {null, SlimefunItems.ENDER_LUMP_3, SlimefunItems.MAGIC_EYE_OF_ENDER, SlimefunItems.ENDER_LUMP_3, SlimefunItems.MAGICAL_BOOK_COVER, SlimefunItems.ENDER_LUMP_3, SlimefunItems.MAGIC_EYE_OF_ENDER, SlimefunItems.ENDER_LUMP_3, null}) new ItemStack[] {null, SlimefunItems.ENDER_LUMP_3, SlimefunItems.MAGIC_EYE_OF_ENDER, SlimefunItems.ENDER_LUMP_3, SlimefunItems.MAGICAL_BOOK_COVER, SlimefunItems.ENDER_LUMP_3, SlimefunItems.MAGIC_EYE_OF_ENDER, SlimefunItems.ENDER_LUMP_3, null})
.register(true, new ItemInteractionHandler() { .register(true, new ItemInteractionHandler() {
@ -2936,22 +3021,6 @@ public class SlimefunSetup {
} }
}); });
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CARAMEL, "CARAMEL", RecipeType.SMELTERY,
new ItemStack[] {new ItemStack(Material.SUGAR), new ItemStack(Material.SUGAR), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.CARAMEL, 4))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CARAMEL_APPLE, "CARAMEL_APPLE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new ItemStack(Material.SUGAR), null, null, new ItemStack(Material.APPLE), null, null, new ItemStack(Material.STICK), null}, new CustomItem(SlimefunItems.CARAMEL_APPLE, 2))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHOCOLATE_APPLE, "CHOCOLATE_APPLE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new CustomItem(Material.INK_SACK, 3), null, null, new ItemStack(Material.APPLE), null, null, new ItemStack(Material.STICK), null}, new CustomItem(SlimefunItems.CARAMEL_APPLE, 2))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.PRESENT, "PRESENT", RecipeType.MAGIC_WORKBENCH,
new ItemStack[] {null, new ItemStack(Material.NAME_TAG), null, new CustomItem(new MaterialData(Material.WOOL, (byte) 14), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 13), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 14), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 14), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 13), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 14), 1)})
.register(true);
new SlimefunBow(SlimefunItems.EXPLOSIVE_BOW, "EXPLOSIVE_BOW", new SlimefunBow(SlimefunItems.EXPLOSIVE_BOW, "EXPLOSIVE_BOW",
new ItemStack[] {null, new ItemStack(Material.STICK), new ItemStack(Material.SULPHUR), SlimefunItems.STAFF_FIRE, null, SlimefunItems.SULFATE, null, new ItemStack(Material.STICK), new ItemStack(Material.SULPHUR)}) new ItemStack[] {null, new ItemStack(Material.STICK), new ItemStack(Material.SULPHUR), SlimefunItems.STAFF_FIRE, null, SlimefunItems.SULFATE, null, new ItemStack(Material.STICK), new ItemStack(Material.SULPHUR)})
.register(true, new BowShootHandler() { .register(true, new BowShootHandler() {
@ -3033,25 +3102,68 @@ public class SlimefunSetup {
} }
}); });
new SlimefunItem(Categories.MISC, SlimefunItems.REINFORCED_PLATE, "REINFORCED_PLATE", RecipeType.COMPRESSOR, new SlimefunItem(Categories.BIRTHDAY, new CustomItem(new MaterialData(Material.CAKE), "&bBirthday Cake"), "BIRTHDAY_CAKE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new CustomItem(SlimefunItems.REINFORCED_ALLOY_INGOT, 8), null, null, null, null, null, null, null, null}) new ItemStack[] {null, new ItemStack(Material.TORCH), null, new ItemStack(Material.SUGAR), new ItemStack(Material.CAKE), new ItemStack(Material.SUGAR), null, null, null})
.register(true); .register(true);
new SlimefunItem(Categories.TECH_MISC, SlimefunItems.HARDENED_GLASS, "HARDENED_GLASS", RecipeType.ENHANCED_CRAFTING_TABLE, new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_MILK, "CHRISTMAS_MILK", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), SlimefunItems.REINFORCED_PLATE, new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS)}, new ItemStack[] {new ItemStack(Material.MILK_BUCKET), new ItemStack(Material.GLASS_BOTTLE), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_MILK, 4))
new CustomItem(SlimefunItems.HARDENED_GLASS, 16))
.register(true); .register(true);
new SlimefunItem(Categories.TECH_MISC, SlimefunItems.SOLAR_ARRAY, "SOLAR_ARRAY", RecipeType.ENHANCED_CRAFTING_TABLE, new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_CHOCOLATE_MILK, "CHRISTMAS_CHOCOLATE_MILK", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.HARDENED_GLASS, SlimefunItems.HARDENED_GLASS, SlimefunItems.HARDENED_GLASS, SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.HARDENED_GLASS, SlimefunItems.HARDENED_GLASS, SlimefunItems.HARDENED_GLASS}) new ItemStack[] {SlimefunItems.CHRISTMAS_MILK, new MaterialData(Material.INK_SACK, (byte) 3).toItemStack(1), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_CHOCOLATE_MILK, 2))
.register(true); .register(true);
new SlimefunItem(Categories.EASTER, SlimefunItems.CARROT_PIE, "CARROT_PIE", RecipeType.ENHANCED_CRAFTING_TABLE, new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_EGG_NOG, "CHRISTMAS_EGG_NOG", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.SUGAR), new ItemStack(Material.CARROT_ITEM), new ItemStack(Material.EGG), null, null, null, null, null, null}, new CustomItem(SlimefunItems.CARROT_PIE, 2)) new ItemStack[] {SlimefunItems.CHRISTMAS_MILK, new ItemStack(Material.EGG), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_EGG_NOG, 2))
.register(true); .register(true);
new SlimefunItem(Categories.EASTER, SlimefunItems.APPLE_PIE, "APPLE_PIE", RecipeType.ENHANCED_CRAFTING_TABLE, new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_APPLE_CIDER, "CHRISTMAS_APPLE_CIDER", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.SUGAR), new ItemStack(Material.APPLE), new ItemStack(Material.EGG), null, null, null, null, null, null}, new CustomItem(SlimefunItems.APPLE_PIE, 2)) new ItemStack[] {SlimefunItems.APPLE_JUICE, new ItemStack(Material.SUGAR), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_APPLE_CIDER, 2))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_COOKIE, "CHRISTMAS_COOKIE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.COOKIE), new ItemStack(Material.SUGAR), new MaterialData(Material.INK_SACK, (byte) 10).toItemStack(1), null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_COOKIE, 16))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_FRUIT_CAKE, "CHRISTMAS_FRUIT_CAKE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.EGG), new ItemStack(Material.APPLE), new ItemStack(Material.MELON), new ItemStack(Material.SUGAR), null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_FRUIT_CAKE, 4))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_APPLE_PIE, "CHRISTMAS_APPLE_PIE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.SUGAR), new ItemStack(Material.APPLE), new ItemStack(Material.EGG), null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_APPLE_PIE, 2))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_HOT_CHOCOLATE, "CHRISTMAS_HOT_CHOCOLATE", RecipeType.SMELTERY,
new ItemStack[] {SlimefunItems.CHRISTMAS_CHOCOLATE_MILK, null, null, null, null, null, null, null, null}, SlimefunItems.CHRISTMAS_HOT_CHOCOLATE)
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_CAKE, "CHRISTMAS_CAKE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.EGG), new ItemStack(Material.SUGAR), SlimefunItems.WHEAT_FLOUR, new ItemStack(Material.MILK_BUCKET), null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_CAKE, 4))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_CARAMEL, "CHRISTMAS_CARAMEL", RecipeType.SMELTERY,
new ItemStack[] {new ItemStack(Material.SUGAR), new ItemStack(Material.SUGAR), null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_CARAMEL, 4))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_CARAMEL_APPLE, "CHRISTMAS_CARAMEL_APPLE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new ItemStack(Material.SUGAR), null, null, new ItemStack(Material.APPLE), null, null, new ItemStack(Material.STICK), null}, new CustomItem(SlimefunItems.CHRISTMAS_CARAMEL_APPLE, 2))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_CHOCOLATE_APPLE, "CHRISTMAS_CHOCOLATE_APPLE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new CustomItem(Material.INK_SACK, 3), null, null, new ItemStack(Material.APPLE), null, null, new ItemStack(Material.STICK), null}, new CustomItem(SlimefunItems.CHRISTMAS_CARAMEL_APPLE, 2))
.register(true);
new SlimefunItem(Categories.CHRISTMAS, SlimefunItems.CHRISTMAS_PRESENT, "CHRISTMAS_PRESENT", RecipeType.MAGIC_WORKBENCH,
new ItemStack[] {null, new ItemStack(Material.NAME_TAG), null, new CustomItem(new MaterialData(Material.WOOL, (byte) 14), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 13), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 14), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 14), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 13), 1), new CustomItem(new MaterialData(Material.WOOL, (byte) 14), 1)})
.register(true);
new SlimefunItem(Categories.EASTER, SlimefunItems.EASTER_CARROT_PIE, "EASTER_CARROT_PIE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.SUGAR), new ItemStack(Material.CARROT_ITEM), new ItemStack(Material.EGG), null, null, null, null, null, null}, new CustomItem(SlimefunItems.EASTER_CARROT_PIE, 2))
.register(true);
new SlimefunItem(Categories.EASTER, SlimefunItems.CHRISTMAS_APPLE_PIE, "EASTER_APPLE_PIE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.SUGAR), new ItemStack(Material.APPLE), new ItemStack(Material.EGG), null, null, null, null, null, null}, new CustomItem(SlimefunItems.CHRISTMAS_APPLE_PIE, 2))
.register(true); .register(true);
new SlimefunItem(Categories.EASTER, SlimefunItems.EASTER_EGG, "EASTER_EGG", RecipeType.ENHANCED_CRAFTING_TABLE, new SlimefunItem(Categories.EASTER, SlimefunItems.EASTER_EGG, "EASTER_EGG", RecipeType.ENHANCED_CRAFTING_TABLE,
@ -3067,8 +3179,8 @@ public class SlimefunSetup {
List<ItemStack> gifts = new ArrayList<ItemStack>(); List<ItemStack> gifts = new ArrayList<ItemStack>();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
gifts.add(new CustomItem(SlimefunItems.CARROT_PIE, 4)); gifts.add(new CustomItem(SlimefunItems.EASTER_CARROT_PIE, 4));
gifts.add(new CustomItem(SlimefunItems.APPLE_PIE, 4)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_APPLE_PIE, 4));
gifts.add(new CustomItem(SlimefunItems.CARROT_JUICE, 1)); gifts.add(new CustomItem(SlimefunItems.CARROT_JUICE, 1));
} }
@ -3088,6 +3200,19 @@ public class SlimefunSetup {
} }
}); });
new SlimefunItem(Categories.MISC, SlimefunItems.REINFORCED_PLATE, "REINFORCED_PLATE", RecipeType.COMPRESSOR,
new ItemStack[] {new CustomItem(SlimefunItems.REINFORCED_ALLOY_INGOT, 8), null, null, null, null, null, null, null, null})
.register(true);
new SlimefunItem(Categories.TECH_MISC, SlimefunItems.HARDENED_GLASS, "HARDENED_GLASS", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), SlimefunItems.REINFORCED_PLATE, new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS)},
new CustomItem(SlimefunItems.HARDENED_GLASS, 16))
.register(true);
new SlimefunItem(Categories.TECH_MISC, SlimefunItems.SOLAR_ARRAY, "SOLAR_ARRAY", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.HARDENED_GLASS, SlimefunItems.HARDENED_GLASS, SlimefunItems.HARDENED_GLASS, SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.HARDENED_GLASS, SlimefunItems.HARDENED_GLASS, SlimefunItems.HARDENED_GLASS})
.register(true);
new SlimefunItem(Categories.TECH_MISC, SlimefunItems.COOLING_UNIT, "COOLING_UNIT", RecipeType.ENHANCED_CRAFTING_TABLE, new SlimefunItem(Categories.TECH_MISC, SlimefunItems.COOLING_UNIT, "COOLING_UNIT", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.ICE), new ItemStack(Material.ICE), new ItemStack(Material.ICE), SlimefunItems.ALUMINUM_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.ALUMINUM_INGOT, new ItemStack(Material.ICE), new ItemStack(Material.ICE), new ItemStack(Material.ICE)}) new ItemStack[] {new ItemStack(Material.ICE), new ItemStack(Material.ICE), new ItemStack(Material.ICE), SlimefunItems.ALUMINUM_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.ALUMINUM_INGOT, new ItemStack(Material.ICE), new ItemStack(Material.ICE), new ItemStack(Material.ICE)})
.register(true); .register(true);
@ -3127,10 +3252,6 @@ public class SlimefunSetup {
new ItemStack[] {null, new ItemStack(Material.ENCHANTMENT_TABLE), null, SlimefunItems.MAGIC_LUMP_3, SlimefunItems.GOLD_8K, SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.OBSIDIAN), SlimefunItems.GOLD_8K, new ItemStack(Material.OBSIDIAN)}) new ItemStack[] {null, new ItemStack(Material.ENCHANTMENT_TABLE), null, SlimefunItems.MAGIC_LUMP_3, SlimefunItems.GOLD_8K, SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.OBSIDIAN), SlimefunItems.GOLD_8K, new ItemStack(Material.OBSIDIAN)})
.register(true); .register(true);
new SlimefunItem(Categories.BIRTHDAY, new CustomItem(new MaterialData(Material.CAKE), "&bBirthday Cake"), "BIRTHDAY_CAKE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new ItemStack(Material.TORCH), null, new ItemStack(Material.SUGAR), new ItemStack(Material.CAKE), new ItemStack(Material.SUGAR), null, null, null})
.register(true);
// Slimefun 4 // Slimefun 4
new SlimefunItem(Categories.ELECTRICITY, SlimefunItems.ENERGY_REGULATOR, "ENERGY_REGULATOR", RecipeType.ENHANCED_CRAFTING_TABLE, new SlimefunItem(Categories.ELECTRICITY, SlimefunItems.ENERGY_REGULATOR, "ENERGY_REGULATOR", RecipeType.ENHANCED_CRAFTING_TABLE,
@ -3148,7 +3269,7 @@ public class SlimefunSetup {
@Override @Override
public void tick(Block b, SlimefunItem item, Config data) { public void tick(Block b, SlimefunItem item, Config data) {
EnergyNet.tick(b); EnergyNet.getNetworkFromLocationOrCreate(b.getLocation()).tick(b);
} }
}); });
@ -3195,11 +3316,7 @@ public class SlimefunSetup {
@Override @Override
public double generateEnergy(Location l, SlimefunItem item, Config data) { public double generateEnergy(Location l, SlimefunItem item, Config data) {
try { if (!l.getWorld().isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() != 15) return 0D;
if (l.getBlock().getLightFromSky() != 15) return 0D;
} catch(IllegalStateException x) {
return 0D;
}
if (l.getWorld().getTime() < 12300 || l.getWorld().getTime() > 23850) return 2D; if (l.getWorld().getTime() < 12300 || l.getWorld().getTime() > 23850) return 2D;
return 0D; return 0D;
} }
@ -3216,11 +3333,7 @@ public class SlimefunSetup {
@Override @Override
public double generateEnergy(Location l, SlimefunItem item, Config data) { public double generateEnergy(Location l, SlimefunItem item, Config data) {
try { if (!l.getWorld().isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() != 15) return 0D;
if (l.getBlock().getLightFromSky() != 15) return 0D;
} catch(IllegalStateException x) {
return 0D;
}
if (l.getWorld().getTime() < 12300 || l.getWorld().getTime() > 23850) return 8; if (l.getWorld().getTime() < 12300 || l.getWorld().getTime() > 23850) return 8;
return 0D; return 0D;
} }
@ -3237,11 +3350,7 @@ public class SlimefunSetup {
@Override @Override
public double generateEnergy(Location l, SlimefunItem item, Config data) { public double generateEnergy(Location l, SlimefunItem item, Config data) {
try { if (!l.getWorld().isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() != 15) return 0D;
if (l.getBlock().getLightFromSky() != 15) return 0D;
} catch(IllegalStateException x) {
return 0D;
}
if (l.getWorld().getTime() < 12300 || l.getWorld().getTime() > 23850) return 32; if (l.getWorld().getTime() < 12300 || l.getWorld().getTime() > 23850) return 32;
return 0D; return 0D;
} }
@ -3258,11 +3367,7 @@ public class SlimefunSetup {
@Override @Override
public double generateEnergy(Location l, SlimefunItem item, Config data) { public double generateEnergy(Location l, SlimefunItem item, Config data) {
try { if (!l.getWorld().isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() != 15) return 0D;
if (l.getBlock().getLightFromSky() != 15) return 0D;
} catch(IllegalStateException x) {
return 0D;
}
if (l.getWorld().getTime() < 12300 || l.getWorld().getTime() > 23850) return 128; if (l.getWorld().getTime() < 12300 || l.getWorld().getTime() > 23850) return 128;
return 64D; return 64D;
} }
@ -4629,7 +4734,7 @@ public class SlimefunSetup {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
return BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()); return true;
} }
}); });
@ -4665,12 +4770,9 @@ public class SlimefunSetup {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
if (BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString())) {
Projector.getArmorStand(b).remove(); Projector.getArmorStand(b).remove();
return true; return true;
} }
else return false;
}
}); });
new SlimefunItem(Categories.MAGIC, SlimefunItems.INFUSED_HOPPER, "INFUSED_HOPPER", RecipeType.ANCIENT_ALTAR, new SlimefunItem(Categories.MAGIC, SlimefunItems.INFUSED_HOPPER, "INFUSED_HOPPER", RecipeType.ANCIENT_ALTAR,
@ -5154,7 +5256,7 @@ public class SlimefunSetup {
@Override @Override
public void tick(Block b, SlimefunItem item, Config data) { public void tick(Block b, SlimefunItem item, Config data) {
CargoNet.tick(b); CargoNet.getNetworkFromLocationOrCreate(b.getLocation()).tick(b);
} }
@Override @Override

View File

@ -111,6 +111,7 @@ public class SlimefunGuide {
public static void openSettings(Player p, final ItemStack guide) { public static void openSettings(Player p, final ItemStack guide) {
final ChestMenu menu = new ChestMenu("Settings / Info"); final ChestMenu menu = new ChestMenu("Settings / Info");
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(new MenuOpeningHandler() { menu.addMenuOpeningHandler(new MenuOpeningHandler() {
@Override @Override
@ -243,6 +244,7 @@ public class SlimefunGuide {
public static void openCredits(Player p, final ItemStack guide) { public static void openCredits(Player p, final ItemStack guide) {
final ChestMenu menu = new ChestMenu("Credits"); final ChestMenu menu = new ChestMenu("Credits");
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(new MenuOpeningHandler() { menu.addMenuOpeningHandler(new MenuOpeningHandler() {
@Override @Override
@ -493,6 +495,7 @@ public class SlimefunGuide {
else { else {
final ChestMenu menu = new ChestMenu("Slimefun Guide"); final ChestMenu menu = new ChestMenu("Slimefun Guide");
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(new MenuOpeningHandler() { menu.addMenuOpeningHandler(new MenuOpeningHandler() {
@Override @Override
@ -776,6 +779,7 @@ public class SlimefunGuide {
else { else {
final ChestMenu menu = new ChestMenu("Slimefun Guide"); final ChestMenu menu = new ChestMenu("Slimefun Guide");
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(new MenuOpeningHandler() { menu.addMenuOpeningHandler(new MenuOpeningHandler() {
@Override @Override
@ -968,6 +972,7 @@ public class SlimefunGuide {
ChestMenu menu = new ChestMenu("Slimefun Guide"); ChestMenu menu = new ChestMenu("Slimefun Guide");
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(new MenuOpeningHandler() { menu.addMenuOpeningHandler(new MenuOpeningHandler() {
@Override @Override

View File

@ -40,6 +40,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunArmorPiece;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.AutoEnchanter; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.AutoEnchanter;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.ElectricDustWasher;
import me.mrCookieSlime.Slimefun.Setup.Files; import me.mrCookieSlime.Slimefun.Setup.Files;
import me.mrCookieSlime.Slimefun.Setup.Messages; import me.mrCookieSlime.Slimefun.Setup.Messages;
import me.mrCookieSlime.Slimefun.Setup.MiscSetup; import me.mrCookieSlime.Slimefun.Setup.MiscSetup;
@ -202,6 +203,7 @@ public class SlimefunStartup extends JavaPlugin {
new FurnaceListener(this); new FurnaceListener(this);
new TeleporterListener(this); new TeleporterListener(this);
new AndroidKillingListener(this); new AndroidKillingListener(this);
new NetworkListener(this);
if (currentVersion.startsWith("v1_12_")) new ItemPickupListener_1_12(this); if (currentVersion.startsWith("v1_12_")) new ItemPickupListener_1_12(this);
else new ItemPickupListener(this); else new ItemPickupListener(this);
@ -273,7 +275,7 @@ public class SlimefunStartup extends JavaPlugin {
new BlockStorage(world); new BlockStorage(world);
} }
if (SlimefunItem.getByName("ANCIENT_ALTAR") != null) new AncientAltarListener((SlimefunStartup) instance); if (SlimefunItem.getByID("ANCIENT_ALTAR") != null) new AncientAltarListener((SlimefunStartup) instance);
} }
}, 0); }, 0);
@ -386,6 +388,9 @@ public class SlimefunStartup extends JavaPlugin {
AutoEnchanter.max_emerald_enchantments = config.getInt("options.emerald-enchantment-limit"); AutoEnchanter.max_emerald_enchantments = config.getInt("options.emerald-enchantment-limit");
SlimefunSetup.legacy_ore_washer = config.getBoolean("options.legacy-ore-washer");
ElectricDustWasher.legacy_dust_washer = config.getBoolean("options.legacy-dust-washer");
// Do not show /sf elevator command in our Log, it could get quite spammy // Do not show /sf elevator command in our Log, it could get quite spammy
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,})");
} }
@ -438,6 +443,7 @@ public class SlimefunStartup extends JavaPlugin {
Variables.jump = null; Variables.jump = null;
Variables.mode = null; Variables.mode = null;
SlimefunGuide.history = null; SlimefunGuide.history = null;
Variables.altarinuse = null;
Variables.enchanting = null; Variables.enchanting = null;
Variables.backpack = null; Variables.backpack = null;
Variables.soulbound = null; Variables.soulbound = null;

View File

@ -2,10 +2,12 @@ package me.mrCookieSlime.Slimefun;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -18,6 +20,7 @@ public class Variables {
public static Map<UUID, Integer> enchanting = new HashMap<UUID, Integer>(); public static Map<UUID, Integer> enchanting = new HashMap<UUID, Integer>();
public static Map<UUID, ItemStack> backpack = new HashMap<UUID, ItemStack>(); public static Map<UUID, ItemStack> backpack = new HashMap<UUID, ItemStack>();
public static HashSet<Location> altarinuse = new HashSet<Location>();
public static Map<UUID, List<ItemStack>> soulbound = new HashMap<UUID, List<ItemStack>>(); public static Map<UUID, List<ItemStack>> soulbound = new HashMap<UUID, List<ItemStack>>();
public static List<UUID> blocks = new ArrayList<UUID>(); public static List<UUID> blocks = new ArrayList<UUID>();

View File

@ -34,7 +34,7 @@ public class BlockStorage {
private static final String path_chunks = "data-storage/Slimefun/stored-chunks/"; private static final String path_chunks = "data-storage/Slimefun/stored-chunks/";
public static Map<String, BlockStorage> worlds = new HashMap<String, BlockStorage>(); public static Map<String, BlockStorage> worlds = new HashMap<String, BlockStorage>();
public static Map<String, Set<Block>> ticking_chunks = new HashMap<String, Set<Block>>(); public static Map<String, Set<Location>> ticking_chunks = new HashMap<String, Set<Location>>();
public static Set<String> loaded_tickers = new HashSet<String>(); public static Set<String> loaded_tickers = new HashSet<String>();
private World world; private World world;
@ -65,6 +65,10 @@ public class BlockStorage {
return chunk.getWorld().getName() + ";Chunk;" + chunk.getX() + ";" + chunk.getZ(); return chunk.getWorld().getName() + ";Chunk;" + chunk.getX() + ";" + chunk.getZ();
} }
private static String locationToChunkString(Location l) {
return l.getWorld().getName() + ";Chunk;" + (l.getBlockX() >> 4) + ";" + (l.getBlockZ() >> 4);
}
private static Location deserializeLocation(String l) { private static Location deserializeLocation(String l) {
try { try {
World w = Bukkit.getWorld(l.split(";")[0]); World w = Bukkit.getWorld(l.split(";")[0]);
@ -95,15 +99,17 @@ 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);
String chunk_string = locationToChunkString(l);
try { try {
totalBlocks++; totalBlocks++;
storage.put(deserializeLocation(key), cfg.getString(key)); storage.put(l, cfg.getString(key));
if (SlimefunItem.isTicking(file.getName().replace(".sfb", ""))) { if (SlimefunItem.isTicking(file.getName().replace(".sfb", ""))) {
Set<Block> blocks = ticking_chunks.containsKey(deserializeLocation(key).getChunk().toString()) ? ticking_chunks.get(deserializeLocation(key).getChunk().toString()): new HashSet<Block>(); Set<Location> locations = ticking_chunks.containsKey(chunk_string) ? ticking_chunks.get(chunk_string): new HashSet<Location>();
blocks.add(deserializeLocation(key).getBlock()); locations.add(l);
ticking_chunks.put(deserializeLocation(key).getChunk().toString(), blocks); ticking_chunks.put(chunk_string, locations);
if (!loaded_tickers.contains(deserializeLocation(key).getChunk().toString())) loaded_tickers.add(deserializeLocation(key).getChunk().toString()); if (!loaded_tickers.contains(chunk_string)) loaded_tickers.add(chunk_string);
} }
} catch(Exception x) { } catch(Exception x) {
System.err.println("[Slimefun] Failed to load " + file.getName() + "(ERR: " + key + ")"); System.err.println("[Slimefun] Failed to load " + file.getName() + "(ERR: " + key + ")");
@ -265,11 +271,17 @@ public class BlockStorage {
} }
} }
@Deprecated
public static Config getBlockInfo(Block block) { public static Config getBlockInfo(Block block) {
return getBlockInfo(block.getLocation()); return getLocationInfo(block.getLocation());
} }
@Deprecated
public static Config getBlockInfo(Location l) { public static Config getBlockInfo(Location l) {
return getLocationInfo(l);
}
public static Config getLocationInfo(Location l) {
try { try {
BlockStorage storage = getStorage(l.getWorld()); BlockStorage storage = getStorage(l.getWorld());
Config cfg = new Config("data-storage/Slimefun/temp.yml"); Config cfg = new Config("data-storage/Slimefun/temp.yml");
@ -325,11 +337,17 @@ public class BlockStorage {
return map_chunks.get(serializeChunk(chunk)); return map_chunks.get(serializeChunk(chunk));
} }
@Deprecated
public static String getBlockInfo(Block block, String key) { public static String getBlockInfo(Block block, String key) {
return getBlockInfo(block.getLocation(), key); return getBlockInfo(block.getLocation(), key);
} }
@Deprecated
public static String getBlockInfo(Location l, String key) { public static String getBlockInfo(Location l, String key) {
return getLocationInfo(l, key);
}
public static String getLocationInfo(Location l, String key) {
return parseJSON(getJSONData(l)).get(key); return parseJSON(getJSONData(l)).get(key);
} }
@ -428,52 +446,61 @@ public class BlockStorage {
storage.getUniversalInventory(l).close(); storage.getUniversalInventory(l).close();
storage.getUniversalInventory(l).save(); storage.getUniversalInventory(l).save();
} }
if (ticking_chunks.containsKey(l.getChunk().toString())) { String chunk_string = locationToChunkString(l);
Set<Block> blocks = ticking_chunks.get(l.getChunk().toString()); if (ticking_chunks.containsKey(chunk_string)) {
blocks.remove(l.getBlock()); Set<Location> locations = ticking_chunks.get(chunk_string);
if (blocks.isEmpty()) { locations.remove(l);
ticking_chunks.remove(l.getChunk().toString()); if (locations.isEmpty()) {
loaded_tickers.remove(l.getChunk().toString()); ticking_chunks.remove(chunk_string);
loaded_tickers.remove(chunk_string);
} }
else ticking_chunks.put(l.getChunk().toString(), blocks); else ticking_chunks.put(chunk_string, locations);
} }
} }
} }
@Deprecated
public static void moveBlockInfo(Block block, Block newBlock) { public static void moveBlockInfo(Block block, Block newBlock) {
SlimefunStartup.ticker.move.put(block, newBlock); moveBlockInfo(block.getLocation(), newBlock.getLocation());
} }
public static void moveBlockInfo(Location from, Location to) {
SlimefunStartup.ticker.move.put(from, to);
}
@Deprecated
public static void _integrated_moveBlockInfo(Block block, Block newBlock) { public static void _integrated_moveBlockInfo(Block block, Block newBlock) {
if (!hasBlockInfo(block)) return; _integrated_moveLocationInfo(block.getLocation(), newBlock.getLocation());
BlockStorage storage = getStorage(block.getWorld());
setBlockInfo(newBlock, getBlockInfo(block), true);
if (storage.inventories.containsKey(block.getLocation())) {
BlockMenu menu = storage.inventories.get(block.getLocation());
storage.inventories.put(newBlock.getLocation(), menu);
storage.clearInventory(block.getLocation());
menu.move(newBlock);
} }
refreshCache(storage, block, getBlockInfo(block).getString("id"), null, true); public static void _integrated_moveLocationInfo(Location from, Location to) {
storage.storage.remove(block.getLocation()); if (!hasBlockInfo(from)) return;
BlockStorage storage = getStorage(from.getWorld());
try { setBlockInfo(to, getBlockInfo(from), true);
if (ticking_chunks.containsKey(block.getChunk().toString())) { if (storage.inventories.containsKey(from)) {
Set<Block> blocks = ticking_chunks.get(block.getChunk().toString()); BlockMenu menu = storage.inventories.get(from);
blocks.remove(block); storage.inventories.put(to, menu);
if (blocks.isEmpty()) { storage.clearInventory(from);
ticking_chunks.remove(block.getChunk().toString()); menu.move(to);
loaded_tickers.remove(block.getChunk().toString());
} }
else ticking_chunks.put(block.getChunk().toString(), blocks);
refreshCache(storage, from, getBlockInfo(from).getString("id"), null, true);
storage.storage.remove(from);
String chunk_string = locationToChunkString(from);
if (ticking_chunks.containsKey(chunk_string)) {
Set<Location> locations = ticking_chunks.get(chunk_string);
locations.remove(from);
if (locations.isEmpty()) {
ticking_chunks.remove(chunk_string);
loaded_tickers.remove(chunk_string);
} }
} else ticking_chunks.put(chunk_string, locations);
catch(IllegalStateException x) {
} }
} }
@Deprecated
private static void refreshCache(BlockStorage storage, Block b, String key, String value, boolean updateTicker) { private static void refreshCache(BlockStorage storage, Block b, String key, String value, boolean updateTicker) {
refreshCache(storage, b.getLocation(), key, value, updateTicker); refreshCache(storage, b.getLocation(), key, value, updateTicker);
} }
@ -486,12 +513,12 @@ 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()) {
Chunk chunk = l.getChunk(); String chunk_string = locationToChunkString(l);
if (value != null) { if (value != null) {
Set<Block> blocks = ticking_chunks.containsKey(chunk.toString()) ? ticking_chunks.get(chunk.toString()): new HashSet<Block>(); Set<Location> locations = ticking_chunks.containsKey(chunk_string) ? ticking_chunks.get(chunk_string): new HashSet<Location>();
blocks.add(l.getBlock()); locations.add(l);
ticking_chunks.put(chunk.toString(), blocks); ticking_chunks.put(chunk_string, locations);
if (!loaded_tickers.contains(chunk.toString())) loaded_tickers.add(chunk.toString()); if (!loaded_tickers.contains(chunk_string)) loaded_tickers.add(chunk_string);
} }
} }
} }
@ -538,12 +565,26 @@ public class BlockStorage {
return new HashSet<String>(loaded_tickers); return new HashSet<String>(loaded_tickers);
} }
@Deprecated
public static Set<Block> getTickingBlocks(Chunk chunk) { public static Set<Block> getTickingBlocks(Chunk chunk) {
return getTickingBlocks(chunk.toString()); return getTickingBlocks(chunk.toString());
} }
public static Set<Location> getTickingLocations(Chunk chunk) {
return getTickingLocations(chunk.toString());
}
@Deprecated
public static Set<Block> getTickingBlocks(String chunk) { public static Set<Block> getTickingBlocks(String chunk) {
return new HashSet<Block>(ticking_chunks.get(chunk)); Set<Block> ret = new HashSet<Block>();
for(Location l: getTickingLocations(chunk)) {
ret.add(l.getBlock());
}
return ret;
}
public static Set<Location> getTickingLocations(String chunk) {
return new HashSet<Location>(ticking_chunks.get(chunk));
} }
public BlockMenu loadInventory(Location l, BlockMenuPreset preset) { public BlockMenu loadInventory(Location l, BlockMenuPreset preset) {

View File

@ -21,8 +21,16 @@ public class Soul {
public static void retrieveItems(Player p) { public static void retrieveItems(Player p) {
if (Variables.soulbound.containsKey(p.getUniqueId())) { if (Variables.soulbound.containsKey(p.getUniqueId())) {
for (ItemStack item: Variables.soulbound.get(p.getUniqueId())) { for (ItemStack item: Variables.soulbound.get(p.getUniqueId())) {
if (item.equals(p.getInventory().getHelmet())) continue;
if (item.equals(p.getInventory().getChestplate())) continue;
if (item.equals(p.getInventory().getLeggings())) continue;
if (item.equals(p.getInventory().getBoots())) continue;
if (item.equals(p.getInventory().getItemInOffHand())) continue;
if(!p.getInventory().contains(item)) {
p.getInventory().addItem(item); p.getInventory().addItem(item);
} }
}
Variables.soulbound.remove(p.getUniqueId()); Variables.soulbound.remove(p.getUniqueId());
} }
} }

View File

@ -23,7 +23,7 @@ public class TickerTask implements Runnable {
public boolean HALTED = false; public boolean HALTED = false;
public Map<Block, Block> move = new HashMap<Block, Block>(); public Map<Location, Location> move = new HashMap<Location, Location>();
public Map<Location, Boolean> delete = new HashMap<Location, Boolean>(); public Map<Location, Boolean> delete = new HashMap<Location, Boolean>();
private Set<BlockTicker> tickers = new HashSet<BlockTicker>(); private Set<BlockTicker> tickers = new HashSet<BlockTicker>();
@ -72,9 +72,9 @@ public class TickerTask implements Runnable {
chunks++; chunks++;
blocks: blocks:
for (final Block b: BlockStorage.getTickingBlocks(c)) { for (final Location l: BlockStorage.getTickingLocations(c)) {
if (b.getChunk().isLoaded()) { if (l.getWorld().isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4)) {
final Location l = b.getLocation(); final Block b = l.getBlock();
final SlimefunItem item = BlockStorage.check(l); final SlimefunItem item = BlockStorage.check(l);
if (item != null) { if (item != null) {
machines++; machines++;
@ -99,33 +99,11 @@ public class TickerTask implements Runnable {
errors++; errors++;
if (errors == 1) { if (errors == 1) {
int try_count = 1;
File file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + ".err"); File file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + ".err");
if (file.exists()) { while (file.exists()) {
file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(2).err"); try_count += 1;
if (file.exists()) { file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(" + try_count + ").err");
file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(3).err");
if (file.exists()) {
file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(4).err");
if (file.exists()) {
file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(5).err");
if (file.exists()) {
file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(6).err");
if (file.exists()) {
file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(7).err");
if (file.exists()) {
file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(8).err");
if (file.exists()) {
file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(9).err");
if (file.exists()) {
file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(10).err");
}
}
}
}
}
}
}
}
} }
try { try {
PrintStream stream = new PrintStream(file); PrintStream stream = new PrintStream(file);
@ -333,7 +311,7 @@ public class TickerTask implements Runnable {
else skipped++; else skipped++;
} }
else { else {
skipped += BlockStorage.getTickingBlocks(c).size(); skipped += BlockStorage.getTickingLocations(c).size();
skipped_chunks.add(c); skipped_chunks.add(c);
chunks--; chunks--;
break blocks; break blocks;
@ -344,8 +322,8 @@ public class TickerTask implements Runnable {
} }
} }
for (Map.Entry<Block, Block> entry: move.entrySet()) { for (Map.Entry<Location, Location> entry: move.entrySet()) {
BlockStorage._integrated_moveBlockInfo(entry.getKey(), entry.getValue()); BlockStorage._integrated_moveLocationInfo(entry.getKey(), entry.getValue());
} }
move.clear(); move.clear();

View File

@ -5,11 +5,13 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import me.mrCookieSlime.Slimefun.api.network.Network;
import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler; import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler;
import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.SlimefunStartup;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.TickerTask; import me.mrCookieSlime.Slimefun.api.TickerTask;
import me.mrCookieSlime.Slimefun.api.network.Network;
import me.mrCookieSlime.Slimefun.holograms.EnergyHologram; import me.mrCookieSlime.Slimefun.holograms.EnergyHologram;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -17,27 +19,12 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
public class EnergyNet { public class EnergyNet extends Network {
public enum Axis {
X_POSITIVE,
X_NEGATIVE,
Y_POSITIVE,
Y_NEGATIVE,
Z_POSITIVE,
Z_NEGATIVE,
UNKNOWN;
}
public enum NetworkComponent { public enum NetworkComponent {
SOURCE, SOURCE,
DISTRIBUTOR, DISTRIBUTOR,
CONSUMER, CONSUMER,
NONE; NONE;
} }
private static final int RANGE = 6; private static final int RANGE = 6;
@ -84,15 +71,72 @@ public class EnergyNet {
} }
} }
public static void tick(Block b) { public static EnergyNet getNetworkFromLocation(Location l) {
Set<Location> input = new HashSet<Location>(); return getNetworkFromLocation(l, EnergyNet.class);
Set<Location> storage = new HashSet<Location>(); }
Set<Location> output = new HashSet<Location>();
public static EnergyNet getNetworkFromLocationOrCreate(Location l) {
EnergyNet energy_network = getNetworkFromLocation(l);
if(energy_network == null) {
energy_network = new EnergyNet(l);
registerNetwork(energy_network);
}
return energy_network;
}
private Set<Location> input = new HashSet<Location>();
private Set<Location> storage = new HashSet<Location>();
private Set<Location> output = new HashSet<Location>();
protected EnergyNet(Location l) {
super(l);
}
public int getRange() {
return RANGE;
}
public Network.Component classifyLocation(Location l) {
if(regulator.equals(l)) return Network.Component.REGULATOR;
switch(getComponent(l)) {
case DISTRIBUTOR:
return Network.Component.CONNECTOR;
case CONSUMER:
case SOURCE:
return Network.Component.TERMINUS;
default:
return null;
}
}
public void locationClassificationChange(Location l, Network.Component from, Network.Component to) {
if(from == Network.Component.TERMINUS) {
input.remove(l);
output.remove(l);
}
switch(getComponent(l)) {
case DISTRIBUTOR:
if (ChargableBlock.isCapacitor(l)) storage.add(l);
break;
case CONSUMER:
output.add(l);
break;
case SOURCE:
input.add(l);
break;
}
}
public void tick(Block b) {
if(!regulator.equals(b.getLocation())) {
EnergyHologram.update(b, "&4Multiple Energy Regulators connected");
return;
}
super.tick();
double supply = 0.0D; double supply = 0.0D;
double demand = 0.0D; double demand = 0.0D;
if (scan(b.getLocation(), Axis.UNKNOWN, new HashSet<Location>(), input, storage, output, supply, demand).isEmpty()) { if (connectorNodes.isEmpty() && terminusNodes.isEmpty()) {
EnergyHologram.update(b, "&4No Energy Network found"); EnergyHologram.update(b, "&4No Energy Network found");
} }
else { else {
@ -114,9 +158,6 @@ public class EnergyNet {
} }
else { else {
supply = supply + energy; supply = supply + energy;
if (ChargableBlock.isChargable(source)) {
supply = DoubleHandler.fixDouble(supply + ChargableBlock.getCharge(source));
}
} }
TickerTask.block_timings.put(source, System.currentTimeMillis() - timestamp); TickerTask.block_timings.put(source, System.currentTimeMillis() - timestamp);
} }
@ -183,84 +224,4 @@ public class EnergyNet {
EnergyHologram.update(b, supply, demand); EnergyHologram.update(b, supply, demand);
} }
} }
public static Set<Location> scan(Location source, Axis exclude, Set<Location> sources, Set<Location> input, Set<Location> storage, Set<Location> output, double supply, double demand) {
sources.add(source);
Set<Location> blocks = new HashSet<Location>();
blocks.add(source);
if (!exclude.equals(Axis.X_POSITIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX() + i + 1, source.getY(), source.getZ());
if (!continueScan(l, Axis.X_NEGATIVE, blocks, sources, input, storage, output, supply, demand)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.X_NEGATIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX() - i - 1, source.getY(), source.getZ());
if (!continueScan(l, Axis.X_POSITIVE, blocks, sources, input, storage, output, supply, demand)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.Y_POSITIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY() + i + 1, source.getZ());
if (!continueScan(l, Axis.Y_NEGATIVE, blocks, sources, input, storage, output, supply, demand)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.Y_NEGATIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY() - i - 1, source.getZ());
if (!continueScan(l, Axis.Y_POSITIVE, blocks, sources, input, storage, output, supply, demand)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.Z_POSITIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY(), source.getZ() + i + 1);
if (!continueScan(l, Axis.Z_NEGATIVE, blocks, sources, input, storage, output, supply, demand)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.Z_NEGATIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY(), source.getZ() - i - 1);
if (!continueScan(l, Axis.Z_POSITIVE, blocks, sources, input, storage, output, supply, demand)) return new HashSet<Location>();
}
}
return blocks;
}
private static boolean continueScan(Location l, Axis axis, Set<Location> blocks, Set<Location> sources, Set<Location> input, Set<Location> storage, Set<Location> output, double supply, double demand) {
if (!sources.contains(l)) {
if (BlockStorage.check(l, "ENERGY_REGULATOR")) return false;
switch (getComponent(l)) {
case CONSUMER: {
blocks.add(l);
output.add(l);
break;
}
case DISTRIBUTOR: {
blocks.add(l);
if (ChargableBlock.isCapacitor(l)) storage.add(l);
Set<Location> nextBlocks = scan(l, axis, sources, input, storage, output, supply, demand);
if (nextBlocks.isEmpty()) return false;
for (Location sink: nextBlocks) {
blocks.add(sink);
}
break;
}
case SOURCE: {
blocks.add(l);
input.add(l);
break;
}
default:
break;
}
}
return true;
}
} }

View File

@ -77,11 +77,16 @@ public class BlockMenu extends ChestMenu {
changes = 0; changes = 0;
} }
@Deprecated
public void move(Block b) { public void move(Block b) {
move(b.getLocation());
}
public void move(Location l) {
this.delete(this.l); this.delete(this.l);
this.l = b.getLocation(); this.l = l;
this.preset.newInstance(this, b); this.preset.newInstance(this, l);
this.save(b.getLocation()); this.save(l);
} }
public Block getBlock() { public Block getBlock() {

View File

@ -33,20 +33,10 @@ import me.mrCookieSlime.Slimefun.Setup.SlimefunManager.DataType;
import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
import me.mrCookieSlime.Slimefun.api.network.Network;
import me.mrCookieSlime.Slimefun.holograms.CargoHologram; import me.mrCookieSlime.Slimefun.holograms.CargoHologram;
public class CargoNet { public class CargoNet extends Network {
public enum Axis {
X_POSITIVE,
X_NEGATIVE,
Y_POSITIVE,
Y_NEGATIVE,
Z_POSITIVE,
Z_NEGATIVE,
UNKNOWN;
}
public static boolean EXTRA_CHANNELS = false; public static boolean EXTRA_CHANNELS = false;
private static final int RANGE = 5; private static final int RANGE = 5;
@ -67,51 +57,151 @@ public class CargoNet {
return false; return false;
} }
}; };
public static void tick(final Block b) {
/* public static CargoNet getNetworkFromLocation(Location l) {
Input/Output Nodes can be found here after a scan. return getNetworkFromLocation(l, CargoNet.class);
Input Nodes: }
Location = The location of the node.
Integer = The frequency of the node. public static CargoNet getNetworkFromLocationOrCreate(Location l) {
Output Nodes: CargoNet cargo_network = getNetworkFromLocation(l);
Integer = The frequency of the node. if(cargo_network == null) {
List<Location> = The locations of the corresponding input nodes cargo_network = new CargoNet(l);
*/ registerNetwork(cargo_network);
final Map<Location, Integer> input = new HashMap<Location, Integer>(); }
final Map<Integer, List<Location>> output = new HashMap<Integer, List<Location>>(); return cargo_network;
}
@Deprecated
public static boolean isConnected(Block b) {
return getNetworkFromLocation(b.getLocation()) != null;
}
private Set<Location> inputNodes = new HashSet<Location>();
private Set<Location> outputNodes = new HashSet<Location>();
private Set<Location> advancedOutputNodes = new HashSet<Location>();
//Chest Terminal Stuff //Chest Terminal Stuff
final Set<Location> providers = new HashSet<Location>();
final Set<Location> terminals = new HashSet<Location>(); final Set<Location> terminals = new HashSet<Location>();
final Set<Location> imports = new HashSet<Location>(); final Set<Location> imports = new HashSet<Location>();
final Set<Location> exports = new HashSet<Location>(); final Set<Location> exports = new HashSet<Location>();
final Set<Location> destinations = new HashSet<Location>();
final Set<Location> blocks = new HashSet<Location>(); protected CargoNet(Location l) {
blocks.add(b.getLocation()); super(l);
}
final List<Location> visualizer1 = new ArrayList<Location>(); public int getRange() {
final List<Location> visualizer2 = new ArrayList<Location>(); return RANGE;
}
if (scan(b.getLocation(), blocks, visualizer1, visualizer2, Axis.UNKNOWN, input, output, terminals, providers, destinations, imports, exports).isEmpty()) { public Network.Component classifyLocation(Location l) {
String id = BlockStorage.checkID(l);
if(id == null) return null;
switch(id) {
case "CARGO_MANAGER":
return Component.REGULATOR;
case "CARGO_NODE":
return Component.CONNECTOR;
case "CARGO_NODE_INPUT":
case "CARGO_NODE_OUTPUT":
case "CARGO_NODE_OUTPUT_ADVANCED":
case "CT_IMPORT_BUS":
case "CT_EXPORT_BUS":
case "CHEST_TERMINAL":
return Component.TERMINUS;
default:
return null;
}
}
public void locationClassificationChange(Location l, Component from, Component to) {
if(from == Component.TERMINUS) {
inputNodes.remove(l);
outputNodes.remove(l);
advancedOutputNodes.remove(l);
terminals.remove(l);
imports.remove(l);
exports.remove(l);
}
if(to == Component.TERMINUS) {
switch(BlockStorage.checkID(l)) {
case "CARGO_NODE_INPUT":
inputNodes.add(l);
break;
case "CARGO_NODE_OUTPUT":
outputNodes.add(l);
break;
case "CARGO_NODE_OUTPUT_ADVANCED":
advancedOutputNodes.add(l);
break;
case "CHEST_TERMINAL":
terminals.add(l);
break;
case "CT_IMPORT_BUS":
imports.add(l);
break;
case "CT_EXPORT_BUS":
exports.add(l);
break;
}
}
}
public void tick(final Block b) {
if(!regulator.equals(b.getLocation())) {
CargoHologram.update(b, "&4Multiple Cargo Regulators connected");
return;
}
super.tick();
if (connectorNodes.isEmpty() && terminusNodes.isEmpty()) {
CargoHologram.update(b, "&7Status: &4&lOFFLINE"); CargoHologram.update(b, "&7Status: &4&lOFFLINE");
return;
} }
else { else {
CargoHologram.update(b, "&7Status: &a&lONLINE");
final Map<Integer, List<Location>> output = new HashMap<Integer, List<Location>>();
for(Location outputNode: outputNodes) {
Integer frequency = getFrequency(outputNode);
if(!output.containsKey(frequency)) {
output.put(frequency, new ArrayList<Location>());
}
output.get(frequency).add(outputNode);
}
for(Location outputNode: advancedOutputNodes) {
Integer frequency = getFrequency(outputNode);
if(!output.containsKey(frequency)) {
output.put(frequency, new ArrayList<Location>());
}
output.get(frequency).add(outputNode);
}
//Chest Terminal Stuff
final Set<Location> providers = new HashSet<Location>();
final Set<Location> destinations;
if(output.containsKey(16)) {
destinations = new HashSet<Location>(output.get(16));
} else {
destinations = new HashSet<Location>();
}
for(Location inputNode: inputNodes) {
int frequency = getFrequency(inputNode);
if(frequency == 16) {
providers.add(inputNode);
}
}
CargoNet self = this;
final BlockStorage storage = BlockStorage.getStorage(b.getWorld()); final BlockStorage storage = BlockStorage.getStorage(b.getWorld());
SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
@Override @Override
public void run() { public void run() {
if (BlockStorage.getBlockInfo(b, "visualizer") == null) { if (BlockStorage.getBlockInfo(b, "visualizer") == null) {
for (int i = 0; i < visualizer1.size(); i++) { self.display();
Location l1 = visualizer1.get(i);
Location l2 = visualizer2.get(i);
try {
ParticleEffect.REDSTONE.drawLine(new Location(l1.getWorld(), l1.getBlockX() + 0.5D, l1.getBlockY() + 0.5D, l1.getBlockZ() + 0.5D), new Location(l2.getWorld(), l2.getBlockX() + 0.5D, l2.getBlockY() + 0.5D, l2.getBlockZ() + 0.5D));
} catch (Exception e) {
e.printStackTrace();
}
}
} }
//Chest Terminal Code //Chest Terminal Code
if (EXTRA_CHANNELS) { if (EXTRA_CHANNELS) {
@ -236,30 +326,34 @@ public class CargoNet {
} }
} }
//All operations happen here: Everything gets iterated from the Input Nodes. (Apart from ChestTerminal Buses) //All operations happen here: Everything gets iterated from the Input Nodes. (Apart from ChestTerminal Buses)
for (Map.Entry<Location, Integer> entry: input.entrySet()) { for (Location input: inputNodes) {
Block inputTarget = getAttachedBlock(entry.getKey().getBlock()); Integer frequency = getFrequency(input);
if(frequency < 0 || frequency > 15) {
continue;
}
Block inputTarget = getAttachedBlock(input.getBlock());
ItemStack stack = null; ItemStack stack = null;
int previousSlot = -1; int previousSlot = -1;
boolean roundrobin = BlockStorage.getBlockInfo(entry.getKey(), "round-robin").equals("true"); boolean roundrobin = BlockStorage.getBlockInfo(input, "round-robin").equals("true");
if (inputTarget != null) { if (inputTarget != null) {
ItemSlot slot = CargoManager.withdraw(entry.getKey().getBlock(), storage, inputTarget, Integer.parseInt(BlockStorage.getBlockInfo(entry.getKey(), "index"))); ItemSlot slot = CargoManager.withdraw(input.getBlock(), storage, inputTarget, Integer.parseInt(BlockStorage.getBlockInfo(input, "index")));
if (slot != null) { if (slot != null) {
stack = slot.getItem(); stack = slot.getItem();
previousSlot = slot.getSlot(); previousSlot = slot.getSlot();
} }
} }
if (stack != null && output.containsKey(entry.getValue())) { if (stack != null && output.containsKey(frequency)) {
List<Location> outputlist = new ArrayList<Location>(output.get(entry.getValue())); List<Location> outputlist = new ArrayList<Location>(output.get(frequency));
if (roundrobin) { if (roundrobin) {
if (!round_robin.containsKey(entry.getKey())) { if (!round_robin.containsKey(input)) {
round_robin.put(entry.getKey(), 0); round_robin.put(input, 0);
} }
int c_index = round_robin.get(entry.getKey()); int c_index = round_robin.get(input);
if (c_index < outputlist.size()) { if (c_index < outputlist.size()) {
for (int i = 0; i < c_index; i++) { for (int i = 0; i < c_index; i++) {
@ -271,7 +365,7 @@ public class CargoNet {
} }
else c_index = 1; else c_index = 1;
round_robin.put(entry.getKey(), c_index); round_robin.put(input, c_index);
} }
destinations: destinations:
@ -437,7 +531,6 @@ public class CargoNet {
} }
} }
CargoHologram.update(b, "&7Status: &a&lONLINE");
} }
}); });
} }
@ -468,191 +561,4 @@ public class CargoNet {
} catch (Exception e) {} } catch (Exception e) {}
return freq; return freq;
} }
public static Set<Location> scan(Location source, Set<Location> blocks, List<Location> l1, List<Location> l2, Axis exclude, Map<Location, Integer> input, Map<Integer, List<Location>> output, Set<Location> terminals, Set<Location> providers, Set<Location> destinations, Set<Location> imports, Set<Location> exports) {
if (!exclude.equals(Axis.X_POSITIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX() + i + 1, source.getY(), source.getZ());
if (!continueScan(source, l, l1, l2, Axis.X_NEGATIVE, blocks, input, output, terminals, providers, destinations, imports, exports)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.X_NEGATIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX() - i - 1, source.getY(), source.getZ());
if (!continueScan(source, l, l1, l2, Axis.X_POSITIVE, blocks, input, output, terminals, providers, destinations, imports, exports)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.Y_POSITIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY() + i + 1, source.getZ());
if (!continueScan(source, l, l1, l2, Axis.Y_NEGATIVE, blocks, input, output, terminals, providers, destinations, imports, exports)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.Y_NEGATIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY() - i - 1, source.getZ());
if (!continueScan(source, l, l1, l2, Axis.Y_POSITIVE, blocks, input, output, terminals, providers, destinations, imports, exports)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.Z_POSITIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY(), source.getZ() + i + 1);
if (!continueScan(source, l, l1, l2, Axis.Z_NEGATIVE, blocks, input, output, terminals, providers, destinations, imports, exports)) return new HashSet<Location>();
}
}
if (!exclude.equals(Axis.Z_NEGATIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY(), source.getZ() - i - 1);
if (!continueScan(source, l, l1, l2, Axis.Z_POSITIVE, blocks, input, output, terminals, providers, destinations, imports, exports)) return new HashSet<Location>();
}
}
return blocks;
}
private static boolean continueScan(Location source, Location l, List<Location> l1, List<Location> l2, Axis axis, Set<Location> blocks, Map<Location, Integer> input, Map<Integer, List<Location>> output, Set<Location> terminals, Set<Location> providers, Set<Location> destinations, Set<Location> imports, Set<Location> exports) {
if (!blocks.contains(l)) {
String id = BlockStorage.checkID(l);
if (id == null) return true;
else if (id.equals("CARGO_MANAGER")) return false;
else if (id.equals("CARGO_NODE")) {
blocks.add(l);
l1.add(source);
l2.add(l);
scan(l, blocks, l1, l2, axis, input, output, terminals, providers, destinations, imports, exports);
if (blocks.isEmpty()) return false;
}
else if (id.equals("CARGO_NODE_INPUT")) {
blocks.add(l);
l1.add(source);
l2.add(l);
int freq = getFrequency(l);
if (freq == 16) providers.add(l);
else input.put(l, freq);
}
else if (id.equals("CHEST_TERMINAL")) {
blocks.add(l);
l1.add(source);
l2.add(l);
terminals.add(l);
}
else if (id.equals("CT_IMPORT_BUS")) {
blocks.add(l);
l1.add(source);
l2.add(l);
imports.add(l);
}
else if (id.equals("CT_EXPORT_BUS")) {
blocks.add(l);
l1.add(source);
l2.add(l);
exports.add(l);
}
else if (id.equals("CARGO_NODE_OUTPUT")) {
blocks.add(l);
l1.add(source);
l2.add(l);
int freq = getFrequency(l);
if (freq == 16) destinations.add(l);
else {
List<Location> list = output.containsKey(freq) ? output.get(freq): new ArrayList<Location>();
list.add(l);
output.put(freq, list);
}
}
else if (id.equals("CARGO_NODE_OUTPUT_ADVANCED")) {
blocks.add(l);
l1.add(source);
l2.add(l);
int freq = getFrequency(l);
if (freq == 16) destinations.add(l);
else {
List<Location> list = output.containsKey(freq) ? output.get(freq): new ArrayList<Location>();
list.add(l);
output.put(freq, list);
}
}
}
return true;
}
public static boolean isConnected(Block b) {
return passiveScan(b.getLocation(), Axis.UNKNOWN, new HashSet<Location>());
}
private static boolean passiveScan(Location source, Axis exclude, Set<Location> sources) {
sources.add(source);
Set<Location> blocks = new HashSet<Location>();
blocks.add(source);
if (!exclude.equals(Axis.X_POSITIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX() + i + 1, source.getY(), source.getZ());
if (continuePassiveScan(l, Axis.X_NEGATIVE, sources)) {
return true;
}
}
}
if (!exclude.equals(Axis.X_NEGATIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX() - i - 1, source.getY(), source.getZ());
if (continuePassiveScan(l, Axis.X_POSITIVE, sources)) {
return true;
}
}
}
if (!exclude.equals(Axis.Y_POSITIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY() + i + 1, source.getZ());
if (continuePassiveScan(l, Axis.Y_NEGATIVE, sources)) {
return true;
}
}
}
if (!exclude.equals(Axis.Y_NEGATIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY() - i - 1, source.getZ());
if (continuePassiveScan(l, Axis.Y_POSITIVE, sources)) {
return true;
}
}
}
if (!exclude.equals(Axis.Z_POSITIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY(), source.getZ() + i + 1);
if (continuePassiveScan(l, Axis.Z_NEGATIVE, sources)) {
return true;
}
}
}
if (!exclude.equals(Axis.Z_NEGATIVE)) {
for (int i = 0; i <= RANGE; i++) {
Location l = new Location(source.getWorld(), source.getX(), source.getY(), source.getZ() - i - 1);
if (continuePassiveScan(l, Axis.Z_POSITIVE, sources)) {
return true;
}
}
}
return false;
}
private static boolean continuePassiveScan(Location l, Axis axis, Set<Location> sources) {
if (!sources.contains(l)) {
String id = BlockStorage.checkID(l);
if (id == null) return false;
else if (id.equals("CARGO_MANAGER")) return true;
else if (id.equals("CARGO_NODE")) return passiveScan(l, axis, sources);
}
return false;
}
} }

View File

@ -0,0 +1,174 @@
package me.mrCookieSlime.Slimefun.api.network;
import java.util.Set;
import java.util.List;
import java.util.Queue;
import java.util.HashSet;
import java.util.ArrayDeque;
import java.util.ArrayList;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.Location;
import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.MC_1_8.ParticleEffect;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
public abstract class Network {
private static List<Network> NETWORK_LIST = new ArrayList<Network>();
public static<T extends Network> T getNetworkFromLocation(Location l, Class<T> type) {
for(Network n: NETWORK_LIST) {
if(type.isInstance(n) && n.connectsTo(l)) {
return type.cast(n);
}
}
return null;
}
public static<T extends Network> List<T> getNetworksFromLocation(Location l, Class<T> type) {
List<T> ret = new ArrayList<T>();
for(Network n: NETWORK_LIST) {
if(type.isInstance(n) && n.connectsTo(l)) {
ret.add(type.cast(n));
}
}
return ret;
}
public static void registerNetwork(Network n) {
NETWORK_LIST.add(n);
}
public static void unregisterNetwork(Network n) {
NETWORK_LIST.remove(n);
}
public static void handleAllNetworkLocationUpdate(Location l) {
for(Network n: getNetworksFromLocation(l, Network.class)) {
n.handleLocationUpdate(l);
}
}
public static enum Component {
CONNECTOR,
REGULATOR,
TERMINUS;
}
public abstract int getRange();
public abstract Component classifyLocation(Location l);
public abstract void locationClassificationChange(Location l, Component from, Component to);
protected Location regulator;
private Queue<Location> nodeQueue = new ArrayDeque<Location>();
protected Set<Location> connectedLocations = new HashSet<Location>();
protected Set<Location> regulatorNodes = new HashSet<Location>();
protected Set<Location> connectorNodes = new HashSet<Location>();
protected Set<Location> terminusNodes = new HashSet<Location>();
protected Network(Location regulator) {
this.regulator = regulator;
connectedLocations.add(regulator);
nodeQueue.add(regulator.clone());
}
protected void addLocationToNetwork(Location l) {
if(connectedLocations.contains(l)) {
return;
}
connectedLocations.add(l.clone());
handleLocationUpdate(l);
}
public void handleLocationUpdate(Location l) {
if(regulator.equals(l)) {
unregisterNetwork(this);
return;
}
nodeQueue.add(l.clone());
}
public boolean connectsTo(Location l) {
return connectedLocations.contains(l);
}
private Component getCurrentClassification(Location l) {
if(regulatorNodes.contains(l)) {
return Component.REGULATOR;
} else if(connectorNodes.contains(l)) {
return Component.CONNECTOR;
} else if(terminusNodes.contains(l)) {
return Component.TERMINUS;
}
return null;
}
private void discoverStep() {
int steps = 0;
while(nodeQueue.peek() != null) {
Location l = nodeQueue.poll();
Component currentAssignment = getCurrentClassification(l);
Component classification = classifyLocation(l);
if(classification != currentAssignment) {
if(currentAssignment == Component.REGULATOR || currentAssignment == Component.CONNECTOR) {
// Requires a complete rebuild of the network, so we just throw the current one away.
unregisterNetwork(this);
return;
} else if(currentAssignment == Component.TERMINUS) {
terminusNodes.remove(l);
}
if(classification == Component.REGULATOR) {
regulatorNodes.add(l);
discoverNeighbors(l);
} else if(classification == Component.CONNECTOR) {
connectorNodes.add(l);
discoverNeighbors(l);
} else if(classification == Component.TERMINUS) {
terminusNodes.add(l);
}
locationClassificationChange(l, currentAssignment, classification);
}
steps += 1;
// TODO: Consider making this a configuration option so that it can be increased for servers
// that can deal with the load.
if(steps == 500) break;
}
}
private void discoverNeighbors(Location l, int xDiff, int yDiff, int zDiff) {
for(int i = getRange() + 1; i > 0; i --) {
Location new_location = l.clone().add(i * xDiff, i * yDiff, i * zDiff);
addLocationToNetwork(new_location);
}
}
private void discoverNeighbors(Location l) {
discoverNeighbors(l, 1, 0, 0);
discoverNeighbors(l, -1, 0, 0);
discoverNeighbors(l, 0, 1, 0);
discoverNeighbors(l, 0, -1, 0);
discoverNeighbors(l, 0, 0, 1);
discoverNeighbors(l, 0, 0, -1);
}
public void display() {
SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
@Override
public void run() {
for(Location l: connectedLocations) {
try {
ParticleEffect.REDSTONE.display(l.clone().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1);
} catch(Exception e) {
}
}
}
});
}
public void tick() {
discoverStep();
}
}

View File

@ -16,6 +16,7 @@ import me.mrCookieSlime.Slimefun.AncientAltar.RitualAnimation;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Setup.Messages; import me.mrCookieSlime.Slimefun.Setup.Messages;
import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.Variables;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -51,6 +52,10 @@ public class AncientAltarListener implements Listener {
SlimefunItem item = BlockStorage.check(b); SlimefunItem item = BlockStorage.check(b);
if (item != null) { if (item != null) {
if (item.getID().equals("ANCIENT_PEDESTAL")) { if (item.getID().equals("ANCIENT_PEDESTAL")) {
if (Variables.altarinuse.contains(b.getLocation())) {
e.setCancelled(true);
return;
}
e.setCancelled(true); e.setCancelled(true);
Item stack = findItem(b); Item stack = findItem(b);
if (stack == null) { if (stack == null) {
@ -80,6 +85,11 @@ public class AncientAltarListener implements Listener {
} }
} }
else if (item.getID().equals("ANCIENT_ALTAR")) { else if (item.getID().equals("ANCIENT_ALTAR")) {
if (Variables.altarinuse.contains(b.getLocation())) {
e.setCancelled(true);
return;
}
Variables.altarinuse.add(b.getLocation()); // make altarinuse simply because that was the last block clicked.
e.setCancelled(true); e.setCancelled(true);
ItemStack catalyst = new CustomItem(e.getPlayer().getInventory().getItemInMainHand(), 1); ItemStack catalyst = new CustomItem(e.getPlayer().getInventory().getItemInMainHand(), 1);
@ -88,6 +98,9 @@ public class AncientAltarListener implements Listener {
if (!altars.contains(e.getClickedBlock())) { if (!altars.contains(e.getClickedBlock())) {
altars.add(e.getClickedBlock()); altars.add(e.getClickedBlock());
if (pedestals.size() == 8) { if (pedestals.size() == 8) {
pedestals.forEach((pblock)->{
Variables.altarinuse.add(pblock.getLocation());
});
if (catalyst != null && !catalyst.getType().equals(Material.AIR)) { if (catalyst != null && !catalyst.getType().equals(Material.AIR)) {
List<ItemStack> input = new ArrayList<ItemStack>(); List<ItemStack> input = new ArrayList<ItemStack>();
for (Block pedestal: pedestals) { for (Block pedestal: pedestals) {
@ -105,16 +118,25 @@ public class AncientAltarListener implements Listener {
else { else {
altars.remove(e.getClickedBlock()); altars.remove(e.getClickedBlock());
Messages.local.sendTranslation(e.getPlayer(), "machines.ANCIENT_ALTAR.unknown-recipe", true); Messages.local.sendTranslation(e.getPlayer(), "machines.ANCIENT_ALTAR.unknown-recipe", true);
pedestals.forEach((pblock)->{
Variables.altarinuse.remove(pblock.getLocation());
});
Variables.altarinuse.remove(b.getLocation()); // bad recipe, no longer in use.
} }
} }
else { else {
altars.remove(e.getClickedBlock()); altars.remove(e.getClickedBlock());
Messages.local.sendTranslation(e.getPlayer(), "machines.ANCIENT_ALTAR.unknown-catalyst", true); Messages.local.sendTranslation(e.getPlayer(), "machines.ANCIENT_ALTAR.unknown-catalyst", true);
pedestals.forEach((pblock)->{
Variables.altarinuse.remove(pblock.getLocation());
});
Variables.altarinuse.remove(b.getLocation()); // unkown catalyst, no longer in use
} }
} }
else { else {
altars.remove(e.getClickedBlock()); altars.remove(e.getClickedBlock());
Messages.local.sendTranslation(e.getPlayer(), "machines.ANCIENT_ALTAR.not-enough-pedestals", true, new Variable("%pedestals%", String.valueOf(pedestals.size()))); Messages.local.sendTranslation(e.getPlayer(), "machines.ANCIENT_ALTAR.not-enough-pedestals", true, new Variable("%pedestals%", String.valueOf(pedestals.size())));
Variables.altarinuse.remove(b.getLocation()); // not a valid altar so remove from inuse
} }
} }
} }

View File

@ -16,14 +16,17 @@ import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
public class BlockListener implements Listener { public class BlockListener implements Listener {
@ -31,6 +34,19 @@ public class BlockListener implements Listener {
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
@EventHandler
public void onBlockFall(EntityChangeBlockEvent event) {
if (event.getEntity() instanceof FallingBlock) {
if (BlockStorage.hasBlockInfo(event.getBlock())) {
event.setCancelled(true);
FallingBlock fb = (FallingBlock) event.getEntity();
if (fb.getDropItem()) {
fb.getWorld().dropItemNaturally(fb.getLocation(), new ItemStack(fb.getMaterial(), 1, fb.getBlockData()));
}
}
}
}
@EventHandler @EventHandler
public void onPistonExtend(BlockPistonExtendEvent e) { public void onPistonExtend(BlockPistonExtendEvent e) {
for (Block b : e.getBlocks()) { for (Block b : e.getBlocks()) {
@ -38,6 +54,10 @@ public class BlockListener implements Listener {
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
else if(b.getRelative(e.getDirection()) == null && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection()))) {
e.setCancelled(true);
return;
}
} }
} }
@ -49,6 +69,10 @@ public class BlockListener implements Listener {
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
else if(b.getRelative(e.getDirection()) == null && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection()))) {
e.setCancelled(true);
return;
}
} }
} }
} }

View File

@ -112,7 +112,7 @@ public class DamageListener implements Listener {
} }
} }
if (Talisman.checkFor(e, SlimefunItem.getByName("HUNTER_TALISMAN")) && !(e.getEntity() instanceof Player)) { if (!e.getEntity().getCanPickupItems() && Talisman.checkFor(e, SlimefunItem.getByID("HUNTER_TALISMAN")) && !(e.getEntity() instanceof Player)) {
List<ItemStack> newDrops = new ArrayList<ItemStack>(); List<ItemStack> newDrops = new ArrayList<ItemStack>();
for (ItemStack drop : e.getDrops()) { for (ItemStack drop : e.getDrops()) {
newDrops.add(drop); newDrops.add(drop);

View File

@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BrewingStand;
import org.bukkit.block.Hopper; import org.bukkit.block.Hopper;
import org.bukkit.block.Skull; import org.bukkit.block.Skull;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
@ -24,7 +25,9 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.BrewerInventory;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -216,7 +219,7 @@ public class ItemListener implements Listener {
float cost = 0.3F; float cost = 0.3F;
if (charge >= cost) { if (charge >= cost) {
p.setItemInHand(ItemEnergy.chargeItem(item, -cost)); p.setItemInHand(ItemEnergy.chargeItem(item, -cost));
Bukkit.getPluginManager().callEvent(new ItemUseEvent(e.getParentEvent(), SlimefunItem.getByName((String) Slimefun.getItemValue(SlimefunItem.getByItem(tool).getName(), "mode." + modes.get(index) + ".item")).getItem(), e.getClickedBlock())); Bukkit.getPluginManager().callEvent(new ItemUseEvent(e.getParentEvent(), SlimefunItem.getByID((String) Slimefun.getItemValue(SlimefunItem.getByItem(tool).getID(), "mode." + modes.get(index) + ".item")).getItem(), e.getClickedBlock()));
} }
} }
else { else {
@ -386,4 +389,12 @@ public class ItemListener implements Listener {
} }
} }
} }
@EventHandler (ignoreCancelled = true)
public void onPreBrew(InventoryClickEvent e) {
Inventory inventory = e.getInventory();
if (inventory instanceof BrewerInventory && inventory.getHolder() instanceof BrewingStand) {
if(e.getRawSlot() < inventory.getSize()) e.setCancelled(SlimefunItem.getByItem(e.getCursor()) != null);
}
}
} }

View File

@ -1,6 +1,8 @@
package me.mrCookieSlime.Slimefun.listeners; package me.mrCookieSlime.Slimefun.listeners;
import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.SlimefunStartup;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent;
@ -20,7 +22,7 @@ public class ItemPickupListener implements Listener {
@EventHandler @EventHandler
public void onPickup(PlayerPickupItemEvent e) { public void onPickup(PlayerPickupItemEvent e) {
if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true); if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) { else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ChatColor.translateAlternateColorCodes('&', "&5&dALTAR &3Probe - &e"))) {
e.setCancelled(true); e.setCancelled(true);
e.getItem().remove(); e.getItem().remove();
} }
@ -29,7 +31,7 @@ public class ItemPickupListener implements Listener {
@EventHandler @EventHandler
public void onMinecartPickup(InventoryPickupItemEvent e) { public void onMinecartPickup(InventoryPickupItemEvent e) {
if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true); if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) { else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ChatColor.translateAlternateColorCodes('&', "&5&dALTAR &3Probe - &e"))) {
e.setCancelled(true); e.setCancelled(true);
e.getItem().remove(); e.getItem().remove();
} }

View File

@ -1,6 +1,8 @@
package me.mrCookieSlime.Slimefun.listeners; package me.mrCookieSlime.Slimefun.listeners;
import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.SlimefunStartup;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.EntityPickupItemEvent;
@ -22,7 +24,7 @@ public class ItemPickupListener_1_12 implements Listener {
@EventHandler @EventHandler
public void onPickup(EntityPickupItemEvent e) { public void onPickup(EntityPickupItemEvent e) {
if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true); if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) { else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ChatColor.translateAlternateColorCodes('&', "&5&dALTAR &3Probe - &e"))) {
e.setCancelled(true); e.setCancelled(true);
e.getItem().remove(); e.getItem().remove();
} }
@ -31,7 +33,7 @@ public class ItemPickupListener_1_12 implements Listener {
@EventHandler @EventHandler
public void onMinecartPickup(InventoryPickupItemEvent e) { public void onMinecartPickup(InventoryPickupItemEvent e) {
if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true); if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) { else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ChatColor.translateAlternateColorCodes('&', "&5&dALTAR &3Probe - &e"))) {
e.setCancelled(true); e.setCancelled(true);
e.getItem().remove(); e.getItem().remove();
} }

View File

@ -0,0 +1,26 @@
package me.mrCookieSlime.Slimefun.listeners;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
import me.mrCookieSlime.Slimefun.api.network.Network;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
public class NetworkListener implements Listener {
public NetworkListener(SlimefunStartup plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
Network.handleAllNetworkLocationUpdate(e.getBlock().getLocation());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlaceBreak(BlockPlaceEvent e) {
Network.handleAllNetworkLocationUpdate(e.getBlock().getLocation());
}
}

View File

@ -100,23 +100,23 @@ public class ToolListener implements Listener {
e.setCancelled(true); e.setCancelled(true);
Slimefun.getGPSNetwork().addWaypoint(e.getPlayer(), e.getBlock().getLocation()); Slimefun.getGPSNetwork().addWaypoint(e.getPlayer(), e.getBlock().getLocation());
} }
else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.PRESENT, false)) { else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.CHRISTMAS_PRESENT, false)) {
e.setCancelled(true); e.setCancelled(true);
PlayerInventory.consumeItemInHand(e.getPlayer()); PlayerInventory.consumeItemInHand(e.getPlayer());
FireworkShow.launchRandom(e.getPlayer(), 3); FireworkShow.launchRandom(e.getPlayer(), 3);
List<ItemStack> gifts = new ArrayList<ItemStack>(); List<ItemStack> gifts = new ArrayList<ItemStack>();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
gifts.add(new CustomItem(SlimefunItems.HOT_CHOCOLATE, 1)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_HOT_CHOCOLATE, 1));
gifts.add(new CustomItem(SlimefunItems.CHOCOLATE_APPLE, 4)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_CHOCOLATE_APPLE, 4));
gifts.add(new CustomItem(SlimefunItems.CARAMEL_APPLE, 4)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_CARAMEL_APPLE, 4));
gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_CAKE, 4)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_CAKE, 4));
gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_COOKIE, 8)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_COOKIE, 8));
gifts.add(new CustomItem(SlimefunItems.PRESENT, 1)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_PRESENT, 1));
gifts.add(new CustomItem(SlimefunItems.EGG_NOG, 1)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_EGG_NOG, 1));
gifts.add(new CustomItem(SlimefunItems.MILK, 1)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_MILK, 1));
gifts.add(new CustomItem(SlimefunItems.APPLE_CIDER, 1)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_APPLE_CIDER, 1));
gifts.add(new CustomItem(SlimefunItems.FRUIT_CAKE, 4)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_FRUIT_CAKE, 4));
gifts.add(new CustomItem(SlimefunItems.APPLE_PIE, 4)); gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_APPLE_PIE, 4));
} }
gifts.add(new SkullItem("mrCookieSlime")); gifts.add(new SkullItem("mrCookieSlime"));
gifts.add(new SkullItem("timtower")); gifts.add(new SkullItem("timtower"));