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

Merge pull request #12 from st392/master

Fixes Reactor Crash
This commit is contained in:
TheBusyBiscuit 2016-06-28 13:47:54 +02:00 committed by GitHub
commit 47f8ff019f

View File

@ -79,8 +79,11 @@ public class NuclearReactor extends SlimefunItem {
@Override @Override
public void newInstance(final BlockMenu menu, final Block b) { public void newInstance(final BlockMenu menu, final Block b) {
try { try {
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "reactor-mode") == null || BlockStorage.getBlockInfo(b, "reactor-mode").equals("generator")) { if (BlockStorage.getBlockInfo(b, "reactor-mode") == null){
menu.replaceExistingItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "§7Focus: §eElectricity", "", "§6Your Reactor will focus on Power Generation", "§6If your Energy Network doesn't need Power", "§6it will not produce any either", "", "§7> Click to change the Focus to §eProduction")); BlockStorage.addBlockInfo(b, "reactor-mode", "generator");
}
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "reactor-mode").equals("generator")) {
menu.replaceExistingItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "§7Focus: §eElectricity", "", "§6Your Reactor will focus on Power Generation", "§6If your Energy Network doesn't need Power", "§6it will not produce any either", "", "§7> Click to change the Focus to §eProduction"));
menu.addMenuClickHandler(4, new MenuClickHandler() { menu.addMenuClickHandler(4, new MenuClickHandler() {
@Override @Override
@ -92,7 +95,7 @@ public class NuclearReactor extends SlimefunItem {
}); });
} }
else { else {
menu.replaceExistingItem(4, new CustomItem(SlimefunItems.PLUTONIUM, "§7Focus: §eProduction", "", "§6Your Reactor will focus on producing goods", "§6If your Energy Network doesn't need Power", "§6it will continue to run and simply will", "§6not generate any Power in the mean time", "", "§7> Click to change the Focus to §ePower Generation")); menu.replaceExistingItem(4, new CustomItem(SlimefunItems.PLUTONIUM, "§7Focus: §eProduction", "", "§6Your Reactor will focus on producing goods", "§6If your Energy Network doesn't need Power", "§6it will continue to run and simply will", "§6not generate any Power in the mean time", "", "§7> Click to change the Focus to §ePower Generation"));
menu.addMenuClickHandler(4, new MenuClickHandler() { menu.addMenuClickHandler(4, new MenuClickHandler() {
@Override @Override
@ -208,7 +211,7 @@ public class NuclearReactor extends SlimefunItem {
}); });
preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "§7Fuel Slot", "", "§rThis Slot accepts radioactive Fuel such as:", "§2Uranium §ror §aNeptunium"), preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "§7Fuel Slot", "", "§rThis Slot accepts radioactive Fuel such as:", "§2Uranium §ror §aNeptunium"),
new MenuClickHandler() { new MenuClickHandler() {
@Override @Override
@ -218,7 +221,7 @@ public class NuclearReactor extends SlimefunItem {
}); });
preset.addItem(7, new CustomItem(SlimefunItems.REACTOR_COOLANT_CELL, "§bCoolant Slot", "", "§rThis Slot accepts Coolant Cells", "§4Without any Coolant Cells, your Reactor", "§4will explode"), preset.addItem(7, new CustomItem(SlimefunItems.REACTOR_COOLANT_CELL, "§bCoolant Slot", "", "§rThis Slot accepts Coolant Cells", "§4Without any Coolant Cells, your Reactor", "§4will explode"),
new MenuClickHandler() { new MenuClickHandler() {
@Override @Override
@ -230,7 +233,7 @@ public class NuclearReactor extends SlimefunItem {
} }
public String getInventoryTitle() { public String getInventoryTitle() {
return "§2Nuclear Reactor"; return "§2Nuclear Reactor";
} }
public void registerDefaultRecipes() { public void registerDefaultRecipes() {
@ -418,7 +421,7 @@ public class NuclearReactor extends SlimefunItem {
int size = BlockStorage.getInventory(l).toInventory().getSize(); int size = BlockStorage.getInventory(l).toInventory().getSize();
Inventory inv = Bukkit.createInventory(null, size); Inventory inv = Bukkit.createInventory(null, size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
inv.setItem(i, new CustomItem(Material.COMMAND, " §4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0)); inv.setItem(i, new CustomItem(Material.COMMAND, " §4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot)); inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));
@ -430,7 +433,7 @@ public class NuclearReactor extends SlimefunItem {
int size = BlockStorage.getInventory(l).toInventory().getSize(); int size = BlockStorage.getInventory(l).toInventory().getSize();
Inventory inv = Bukkit.createInventory(null, size); Inventory inv = Bukkit.createInventory(null, size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
inv.setItem(i, new CustomItem(Material.COMMAND, " §4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0)); inv.setItem(i, new CustomItem(Material.COMMAND, " §4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
} }
for (int slot: slots) { for (int slot: slots) {
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot)); inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));