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.

72
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>
@ -27,34 +22,26 @@
<id>worldedit-worldguard-repo</id> <id>worldedit-worldguard-repo</id>
<url>http://maven.sk89q.com/repo/</url> <url>http://maven.sk89q.com/repo/</url>
</repository> </repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository> <repository>
<id>clearlag-repo</id> <id>jitpack.io</id>
<url>http://minebuilders.me:8080/job/Clearlag/lastSuccessfulBuild/maven-repository/repository/</url> <url>https://jitpack.io</url>
</repository> </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>
<directory>${project.basedir}/tests/resources</directory> <directory>${project.basedir}/tests/resources</directory>
</testResource> </testResource>
</testResources> </testResources>
<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>
@ -79,15 +64,17 @@
<version>6.1.1-SNAPSHOT</version> <version>6.1.1-SNAPSHOT</version>
</dependency> </dependency>
<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>
</dependency> <scope>system</scope>
<systemPath>${project.basedir}/lib/Clearlag.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>net.coreprotect</groupId> <groupId>net.coreprotect</groupId>
<artifactId>CoreProtect</artifactId> <artifactId>CoreProtect</artifactId>
@ -96,17 +83,16 @@
<dependency> <dependency>
<groupId>me.mrCookieSlime</groupId> <groupId>me.mrCookieSlime</groupId>
<artifactId>EmeraldEnchants</artifactId> <artifactId>EmeraldEnchants</artifactId>
<version>2.0</version> <version>2.0</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/EmeraldEnchants v2.0.jar</systemPath> <systemPath>${project.basedir}/lib/EmeraldEnchants v2.0.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.mrCookieSlime</groupId> <groupId>me.mrCookieSlime</groupId>
<artifactId>ExoticGarden</artifactId> <artifactId>ExoticGarden</artifactId>
<version>1.2.0</version> <version>1.2.0</version>
<scope>system</scope> <scope>system</scope>
<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) {
finish();
@Override return;
public void run() { }
idle(); if(this.stage > 0 && this.stage % 4 == 0) {
schedule(new Runnable() { checkPedestal(pedestals.get(this.stage / 4 - 1));
}
@Override this.stage += 1;
public void run() { SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, this, 8);
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();
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
} }
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);
for (int slot: getOutputSlots()) { if (inv != null) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv.getItemInSlot(43) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(43));
inv.replaceExistingItem(43, null);
}
for (int slot: getOutputSlots()) {
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"});
@ -234,25 +234,25 @@ public class SlimefunItems {
public static ItemStack WITHER_PROOF_GLASS = new CustomItem(new MaterialData(Material.STAINED_GLASS, (byte) 15), "&5Wither-Proof Glass", "", "&rWithstands Explosions", "&rWithstands Wither Bosses"); public static ItemStack WITHER_PROOF_GLASS = new CustomItem(new MaterialData(Material.STAINED_GLASS, (byte) 15), "&5Wither-Proof Glass", "", "&rWithstands Explosions", "&rWithstands Wither Bosses");
public static ItemStack REINFORCED_PLATE = new CustomItem(Material.PAPER, "&7Reinforced Plate", 0); public static ItemStack REINFORCED_PLATE = new CustomItem(Material.PAPER, "&7Reinforced Plate", 0);
public static ItemStack ANCIENT_PEDESTAL = new CustomItem(Material.DISPENSER, "&dAncient Pedestal", 0, new String[] {"", "&5Part of the Ancient Altar"}); public static ItemStack ANCIENT_PEDESTAL = new CustomItem(Material.DISPENSER, "&dAncient Pedestal", 0, new String[] {"", "&5Part of the Ancient Altar"});
public static ItemStack ANCIENT_ALTAR = new CustomItem(Material.ENCHANTMENT_TABLE, "&dAncient Altar", 0, new String[] {"", "&5Multi-Block Altar for", "&5magical Crafting Processes"}); public static ItemStack ANCIENT_ALTAR = new CustomItem(Material.ENCHANTMENT_TABLE, "&dAncient Altar", 0, new String[] {"", "&5Multi-Block Altar for", "&5magical Crafting Processes"});
public static ItemStack DUCT_TAPE = null; public static ItemStack DUCT_TAPE = null;
public static ItemStack RAINBOW_WOOL = new CustomItem(new MaterialData(Material.WOOL), "&5Rainbow Wool", "", "&dCycles through all Colors of the Rainbow!"); public static ItemStack RAINBOW_WOOL = new CustomItem(new MaterialData(Material.WOOL), "&5Rainbow Wool", "", "&dCycles through all Colors of the Rainbow!");
public static ItemStack RAINBOW_GLASS = new CustomItem(new MaterialData(Material.STAINED_GLASS), "&5Rainbow Glass", "", "&dCycles through all Colors of the Rainbow!"); public static ItemStack RAINBOW_GLASS = new CustomItem(new MaterialData(Material.STAINED_GLASS), "&5Rainbow Glass", "", "&dCycles through all Colors of the Rainbow!");
public static ItemStack RAINBOW_CLAY = new CustomItem(new MaterialData(Material.STAINED_CLAY), "&5Rainbow Clay", "", "&dCycles through all Colors of the Rainbow!"); public static ItemStack RAINBOW_CLAY = new CustomItem(new MaterialData(Material.STAINED_CLAY), "&5Rainbow Clay", "", "&dCycles through all Colors of the Rainbow!");
public static ItemStack RAINBOW_GLASS_PANE = new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE), "&5Rainbow Glass Pane", "", "&dCycles through all Colors of the Rainbow!"); public static ItemStack RAINBOW_GLASS_PANE = new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE), "&5Rainbow Glass Pane", "", "&dCycles through all Colors of the Rainbow!");
public static ItemStack RAINBOW_WOOL_XMAS = new CustomItem(new MaterialData(Material.WOOL), "&5Rainbow Wool &7(Christmas)", "", Christmas.color("< Christmas Edition >")); public static ItemStack RAINBOW_WOOL_XMAS = new CustomItem(new MaterialData(Material.WOOL), "&5Rainbow Wool &7(Christmas)", "", Christmas.color("< Christmas Edition >"));
public static ItemStack RAINBOW_GLASS_XMAS = new CustomItem(new MaterialData(Material.STAINED_GLASS), "&5Rainbow Glass &7(Christmas)", "", Christmas.color("< Christmas Edition >")); public static ItemStack RAINBOW_GLASS_XMAS = new CustomItem(new MaterialData(Material.STAINED_GLASS), "&5Rainbow Glass &7(Christmas)", "", Christmas.color("< Christmas Edition >"));
public static ItemStack RAINBOW_CLAY_XMAS = new CustomItem(new MaterialData(Material.STAINED_CLAY), "&5Rainbow Clay &7(Christmas)", "", Christmas.color("< Christmas Edition >")); public static ItemStack RAINBOW_CLAY_XMAS = new CustomItem(new MaterialData(Material.STAINED_CLAY), "&5Rainbow Clay &7(Christmas)", "", Christmas.color("< Christmas Edition >"));
public static ItemStack RAINBOW_GLASS_PANE_XMAS = new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE), "&5Rainbow Glass Pane &7(Christmas)", "", Christmas.color("< Christmas Edition >")); public static ItemStack RAINBOW_GLASS_PANE_XMAS = new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE), "&5Rainbow Glass Pane &7(Christmas)", "", Christmas.color("< Christmas Edition >"));
public static ItemStack RAINBOW_WOOL_VALENTINE = new CustomItem(new MaterialData(Material.WOOL), "&5Rainbow Wool &7(Valentine's Day)", "", "&d< Valentine's Day Edition >"); public static ItemStack RAINBOW_WOOL_VALENTINE = new CustomItem(new MaterialData(Material.WOOL), "&5Rainbow Wool &7(Valentine's Day)", "", "&d< Valentine's Day Edition >");
public static ItemStack RAINBOW_GLASS_VALENTINE = new CustomItem(new MaterialData(Material.STAINED_GLASS), "&5Rainbow Glass &7(Valentine's Day)", "", "&d< Valentine's Day Edition >"); public static ItemStack RAINBOW_GLASS_VALENTINE = new CustomItem(new MaterialData(Material.STAINED_GLASS), "&5Rainbow Glass &7(Valentine's Day)", "", "&d< Valentine's Day Edition >");
public static ItemStack RAINBOW_CLAY_VALENTINE = new CustomItem(new MaterialData(Material.STAINED_CLAY), "&5Rainbow Clay &7(Valentine's Day)", "", "&d< Valentine's Day Edition >"); public static ItemStack RAINBOW_CLAY_VALENTINE = new CustomItem(new MaterialData(Material.STAINED_CLAY), "&5Rainbow Clay &7(Valentine's Day)", "", "&d< Valentine's Day Edition >");
public static ItemStack RAINBOW_GLASS_PANE_VALENTINE = new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE), "&5Rainbow Glass Pane &7(Valentine's Day)", "", "&d< Valentine's Day Edition >"); public static ItemStack RAINBOW_GLASS_PANE_VALENTINE = new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE), "&5Rainbow Glass Pane &7(Valentine's Day)", "", "&d< Valentine's Day Edition >");
/* Ingots */ /* Ingots */
public static ItemStack COPPER_INGOT = new CustomItem(Material.CLAY_BRICK, "&bCopper Ingot", 0, new String[0]); public static ItemStack COPPER_INGOT = new CustomItem(Material.CLAY_BRICK, "&bCopper Ingot", 0, new String[0]);
public static ItemStack TIN_INGOT = new CustomItem(Material.IRON_INGOT, "&bTin Ingot", 0, new String[0]); public static ItemStack TIN_INGOT = new CustomItem(Material.IRON_INGOT, "&bTin Ingot", 0, new String[0]);
public static ItemStack SILVER_INGOT = new CustomItem(Material.IRON_INGOT, "&bSilver Ingot", 0, new String[0]); public static ItemStack SILVER_INGOT = new CustomItem(Material.IRON_INGOT, "&bSilver Ingot", 0, new String[0]);
@ -704,8 +704,8 @@ public class SlimefunItems {
BOOSTED_URANIUM = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjgzN2NhMTJmMjIyZjQ3ODcxOTZhMTdiOGFiNjU2OTg1Zjg0MDRjNTA3NjdhZGJjYjZlN2YxNDI1NGZlZSJ9fX0="), "&2Boosted Uranium", "", "&2Radiation Level: HIGH", "&4&oHazmat Suit required"); BOOSTED_URANIUM = new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjgzN2NhMTJmMjIyZjQ3ODcxOTZhMTdiOGFiNjU2OTg1Zjg0MDRjNTA3NjdhZGJjYjZlN2YxNDI1NGZlZSJ9fX0="), "&2Boosted Uranium", "", "&2Radiation Level: HIGH", "&4&oHazmat Suit required");
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) {
for (int slot: getInputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
} for (int slot: getInputSlots()) {
for (int slot: getOutputSlots()) { if (inv.getItemInSlot(slot) != null) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
}
for (int slot: getOutputSlots()) {
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) {
for (int slot: getOutputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
for (int slot: getOutputSlots()) {
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) {
for (int slot: getOutputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
for (int slot: getOutputSlots()) {
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) {
for (int slot: getInputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
for (int slot: getInputSlots()) {
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();
for (int slot: getInputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
for (int slot: getInputSlots()) {
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();
for (int slot: getInputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
for (int slot: getInputSlots()) {
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) {
for (int slot: getInputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
for (int slot: getInputSlots()) {
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) {
for (int slot: getInputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
for (int slot: getInputSlots()) {
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) {
for (int slot: getInputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
for (int slot: getInputSlots()) {
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();
for (int slot: getOutputSlots()) { BlockMenu inv = BlockStorage.getInventory(b);
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (inv != null) {
for (int slot: getOutputSlots()) {
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);

File diff suppressed because it is too large Load Diff

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); public static void _integrated_moveLocationInfo(Location from, Location to) {
if (storage.inventories.containsKey(block.getLocation())) { if (!hasBlockInfo(from)) return;
BlockMenu menu = storage.inventories.get(block.getLocation()); BlockStorage storage = getStorage(from.getWorld());
storage.inventories.put(newBlock.getLocation(), menu);
storage.clearInventory(block.getLocation()); setBlockInfo(to, getBlockInfo(from), true);
menu.move(newBlock); if (storage.inventories.containsKey(from)) {
BlockMenu menu = storage.inventories.get(from);
storage.inventories.put(to, menu);
storage.clearInventory(from);
menu.move(to);
} }
refreshCache(storage, block, getBlockInfo(block).getString("id"), null, true); refreshCache(storage, from, getBlockInfo(from).getString("id"), null, true);
storage.storage.remove(block.getLocation()); storage.storage.remove(from);
try { String chunk_string = locationToChunkString(from);
if (ticking_chunks.containsKey(block.getChunk().toString())) { if (ticking_chunks.containsKey(chunk_string)) {
Set<Block> blocks = ticking_chunks.get(block.getChunk().toString()); Set<Location> locations = ticking_chunks.get(chunk_string);
blocks.remove(block); locations.remove(from);
if (blocks.isEmpty()) { if (locations.isEmpty()) {
ticking_chunks.remove(block.getChunk().toString()); ticking_chunks.remove(chunk_string);
loaded_tickers.remove(block.getChunk().toString()); loaded_tickers.remove(chunk_string);
}
else ticking_chunks.put(block.getChunk().toString(), blocks);
} }
} 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,7 +21,15 @@ 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())) {
p.getInventory().addItem(item); 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);
}
} }
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) {
/*
Input/Output Nodes can be found here after a scan.
Input Nodes:
Location = The location of the node.
Integer = The frequency of the node.
Output Nodes:
Integer = The frequency of the node.
List<Location> = The locations of the corresponding input nodes
*/
final Map<Location, Integer> input = new HashMap<Location, Integer>();
final Map<Integer, List<Location>> output = new HashMap<Integer, List<Location>>();
//Chest Terminal Stuff public static CargoNet getNetworkFromLocation(Location l) {
final Set<Location> providers = new HashSet<Location>(); return getNetworkFromLocation(l, CargoNet.class);
final Set<Location> terminals = new HashSet<Location>(); }
final Set<Location> imports = new HashSet<Location>();
final Set<Location> exports = new HashSet<Location>();
final Set<Location> destinations = new HashSet<Location>();
final Set<Location> blocks = new HashSet<Location>(); public static CargoNet getNetworkFromLocationOrCreate(Location l) {
blocks.add(b.getLocation()); CargoNet cargo_network = getNetworkFromLocation(l);
if(cargo_network == null) {
cargo_network = new CargoNet(l);
registerNetwork(cargo_network);
}
return cargo_network;
}
final List<Location> visualizer1 = new ArrayList<Location>(); @Deprecated
final List<Location> visualizer2 = new ArrayList<Location>(); public static boolean isConnected(Block b) {
return getNetworkFromLocation(b.getLocation()) != null;
}
if (scan(b.getLocation(), blocks, visualizer1, visualizer2, Axis.UNKNOWN, input, output, terminals, providers, destinations, imports, exports).isEmpty()) { private Set<Location> inputNodes = new HashSet<Location>();
private Set<Location> outputNodes = new HashSet<Location>();
private Set<Location> advancedOutputNodes = new HashSet<Location>();
//Chest Terminal Stuff
final Set<Location> terminals = new HashSet<Location>();
final Set<Location> imports = new HashSet<Location>();
final Set<Location> exports = new HashSet<Location>();
protected CargoNet(Location l) {
super(l);
}
public int getRange() {
return RANGE;
}
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"));