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

Update ProgrammableAndroid.java

This commit is contained in:
a 2021-04-26 18:43:10 -05:00
parent 757d7613ac
commit a1a6253961

View File

@ -243,7 +243,11 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
menu.addItem(0, new CustomItem(Instruction.START.getItem(), SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions.START"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface")); menu.addItem(0, new CustomItem(Instruction.START.getItem(), SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions.START"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface"));
menu.addMenuClickHandler(0, (pl, slot, item, action) -> { menu.addMenuClickHandler(0, (pl, slot, item, action) -> {
BlockStorage.getInventory(b).open(pl); BlockMenu inv = BlockStorage.getInventory(b);
// Fixes #2937
if (inv != null) {
inv.open(pl);
}
return false; return false;
}); });
@ -266,7 +270,11 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
int slot = i + (hasFreeSlot ? 1 : 0); int slot = i + (hasFreeSlot ? 1 : 0);
menu.addItem(slot, new CustomItem(Instruction.REPEAT.getItem(), SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions.REPEAT"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface")); menu.addItem(slot, new CustomItem(Instruction.REPEAT.getItem(), SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions.REPEAT"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface"));
menu.addMenuClickHandler(slot, (pl, s, item, action) -> { menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
BlockStorage.getInventory(b).open(pl); BlockMenu inv = BlockStorage.getInventory(b);
// Fixes #2937
if (inv != null) {
inv.open(pl);
}
return false; return false;
}); });
} else { } else {
@ -482,12 +490,16 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
menu.addItem(1, new CustomItem(HeadTexture.SCRIPT_FORWARD.getAsItemStack(), "&2> Edit Script", "", "&aEdits your current Script")); menu.addItem(1, new CustomItem(HeadTexture.SCRIPT_FORWARD.getAsItemStack(), "&2> Edit Script", "", "&aEdits your current Script"));
menu.addMenuClickHandler(1, (pl, slot, item, action) -> { menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
if (PatternUtils.DASH.split(BlockStorage.getLocationInfo(b.getLocation()).getString("script")).length <= MAX_SCRIPT_LENGTH) { String script = BlockStorage.getLocationInfo(b.getLocation()).getString("script");
// Fixes #2937
if (script != null) {
if (PatternUtils.DASH.split(script).length <= MAX_SCRIPT_LENGTH) {
openScript(pl, b, getScript(b.getLocation())); openScript(pl, b, getScript(b.getLocation()));
} else { } else {
pl.closeInventory(); pl.closeInventory();
SlimefunPlugin.getLocalization().sendMessage(pl, "android.scripts.too-long"); SlimefunPlugin.getLocalization().sendMessage(pl, "android.scripts.too-long");
} }
}
return false; return false;
}); });
@ -505,7 +517,11 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
menu.addItem(8, new CustomItem(HeadTexture.SCRIPT_LEFT.getAsItemStack(), "&6> Back", "", "&7Return to the Android's interface")); menu.addItem(8, new CustomItem(HeadTexture.SCRIPT_LEFT.getAsItemStack(), "&6> Back", "", "&7Return to the Android's interface"));
menu.addMenuClickHandler(8, (pl, slot, item, action) -> { menu.addMenuClickHandler(8, (pl, slot, item, action) -> {
BlockStorage.getInventory(b).open(p); BlockMenu inv = BlockStorage.getInventory(b);
// Fixes #2937
if (inv != null) {
inv.open(pl);
}
return false; return false;
}); });
@ -660,6 +676,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
if ("false".equals(data.getString("paused"))) { if ("false".equals(data.getString("paused"))) {
BlockMenu menu = BlockStorage.getInventory(b); BlockMenu menu = BlockStorage.getInventory(b);
String fuelData = data.getString("fuel"); String fuelData = data.getString("fuel");
float fuel = fuelData == null ? 0 : Float.parseFloat(fuelData); float fuel = fuelData == null ? 0 : Float.parseFloat(fuelData);