mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Even more lambdas expressions
This commit is contained in:
parent
77654eb23c
commit
385edf3cd7
@ -41,12 +41,9 @@ import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Block.TreeCalculator;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuOpeningHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuHelper;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuHelper.ChatHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.ExoticGarden.ExoticGarden;
|
||||
@ -161,33 +158,22 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
public void newInstance(BlockMenu menu, final Block b) {
|
||||
try {
|
||||
menu.replaceExistingItem(15, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTAxYzdiNTcyNjE3ODk3NGIzYjNhMDFiNDJhNTkwZTU0MzY2MDI2ZmQ0MzgwOGYyYTc4NzY0ODg0M2E3ZjVhIn19fQ=="), "&aStart/Continue"));
|
||||
menu.addMenuClickHandler(15, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||
Messages.local.sendTranslation(p, "robot.started", true);
|
||||
BlockStorage.addBlockInfo(b, "paused", "false");
|
||||
p.closeInventory();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.replaceExistingItem(17, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYxMzlmZDFjNTY1NGU1NmU5ZTRlMmM4YmU3ZWIyYmQ1YjQ5OWQ2MzM2MTY2NjNmZWVlOTliNzQzNTJhZDY0In19fQ=="), "&4Pause"));
|
||||
menu.addMenuClickHandler(17, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(17, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "paused", "true");
|
||||
Messages.local.sendTranslation(p, "robot.stopped", true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.replaceExistingItem(16, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "&bMemory Core", "", "&8\u21E8 &7Click to open the Script Editor"));
|
||||
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
||||
try {
|
||||
BlockStorage.addBlockInfo(b, "paused", "true");
|
||||
Messages.local.sendTranslation(p, "robot.stopped", true);
|
||||
@ -196,7 +182,6 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -485,7 +470,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
break;
|
||||
}
|
||||
case ATTACK_MOBS_ANIMALS: {
|
||||
double damage = getTier() < 2 ? 20D: 4D * getTier();
|
||||
double damage = getTier() < 2 ? 20D : 4D * getTier();
|
||||
|
||||
entities:
|
||||
for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
|
||||
@ -537,7 +522,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
break;
|
||||
}
|
||||
case ATTACK_MOBS: {
|
||||
double damage = getTier() < 2 ? 20D: 4D * getTier();
|
||||
double damage = getTier() < 2 ? 20D : 4D * getTier();
|
||||
|
||||
entities:
|
||||
for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
|
||||
@ -591,7 +576,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
}
|
||||
|
||||
case ATTACK_ANIMALS: {
|
||||
double damage = getTier() < 2 ? 20D: 4D * getTier();
|
||||
double damage = getTier() < 2 ? 20D : 4D * getTier();
|
||||
|
||||
entities:
|
||||
for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
|
||||
@ -645,7 +630,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
}
|
||||
|
||||
case ATTACK_ANIMALS_ADULT: {
|
||||
double damage = getTier() < 2 ? 20D: 4D * getTier();
|
||||
double damage = getTier() < 2 ? 20D : 4D * getTier();
|
||||
|
||||
entities:
|
||||
for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
|
||||
@ -805,7 +790,6 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
private void farm(Block b, Block block) {
|
||||
switch (block.getType()) {
|
||||
case WHEAT: {
|
||||
|
||||
if (isFullGrown(block)) {
|
||||
ItemStack drop = new ItemStack(Material.WHEAT, CSCoreLib.randomizer().nextInt(3) + 1);
|
||||
if (fits(b, drop)) {
|
||||
@ -900,30 +884,18 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
}
|
||||
|
||||
private void constructMenu(BlockMenuPreset preset) throws Exception {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_out) {
|
||||
for (int i : border_out) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: getOutputSlots()) {
|
||||
for (int i : getOutputSlots()) {
|
||||
preset.addMenuClickHandler(i, new AdvancedMenuClickHandler() {
|
||||
|
||||
@Override
|
||||
@ -940,33 +912,18 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
|
||||
if (getTier() == 1) {
|
||||
preset.addItem(34, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "&8\u21E9 &cFuel Input &8\u21E9", "", "&rThis Android runs on solid Fuel", "&re.g. Coal, Wood, etc..."),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
else if (getTier() == 2){
|
||||
preset.addItem(34, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "&8\u21E9 &cFuel Input &8\u21E9", "", "&rThis Android runs on liquid Fuel", "&re.g. Lava, Oil, Fuel, etc..."),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
else {
|
||||
preset.addItem(34, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "&8\u21E9 &cFuel Input &8\u21E9", "", "&rThis Android runs on radioactive Fuel", "&re.g. Uranium, Neptunium or Boosted Uranium"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -974,46 +931,37 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
ChestMenu menu = new ChestMenu("&eScript Editor");
|
||||
|
||||
menu.addItem(2, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDliZjZkYjRhZWRhOWQ4ODIyYjlmNzM2NTM4ZThjMThiOWE0ODQ0Zjg0ZWI0NTUwNGFkZmJmZWU4N2ViIn19fQ=="), "&2> Edit Script", "", "&aEdits your current Script"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) {
|
||||
(pl, slot, item, action) -> {
|
||||
try {
|
||||
openScript(p, b, BlockStorage.getLocationInfo(b.getLocation(), "script"));
|
||||
openScript(pl, b, BlockStorage.getLocationInfo(b.getLocation(), "script"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
menu.addItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTcxZDg5NzljMTg3OGEwNTk4N2E3ZmFmMjFiNTZkMWI3NDRmOWQwNjhjNzRjZmZjZGUxZWExZWRhZDU4NTIifX19"), "&4> Create new Script", "", "&cDeletes your current Script", "&cand creates a blank one"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) {
|
||||
(pl, slot, item, action) -> {
|
||||
try {
|
||||
openScript(p, b, "START-TURN_LEFT-REPEAT");
|
||||
openScript(pl, b, "START-TURN_LEFT-REPEAT");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
menu.addItem(6, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzAxNTg2ZTM5ZjZmZmE2M2I0ZmIzMDFiNjVjYTdkYThhOTJmNzM1M2FhYWI4OWQzODg2NTc5MTI1ZGZiYWY5In19fQ=="), "&6> Download a Script", "", "&eDownload a Script from the Server", "&eYou can edit or simply use it"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) {
|
||||
(pl, slot, item, action) -> {
|
||||
try {
|
||||
openScriptDownloader(p, b, 1);
|
||||
openScriptDownloader(pl, b, 1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
menu.open(p);
|
||||
}
|
||||
@ -1023,13 +971,9 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
final String[] commands = script.split("-");
|
||||
|
||||
menu.addItem(0, ScriptPart.START.toItemStack());
|
||||
menu.addMenuClickHandler(0, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(0,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
|
||||
for (int i = 1; i < commands.length; i++) {
|
||||
final int index = i;
|
||||
@ -1038,84 +982,72 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
|
||||
if (additional == 1) {
|
||||
menu.addItem(i, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTcxZDg5NzljMTg3OGEwNTk4N2E3ZmFmMjFiNTZkMWI3NDRmOWQwNjhjNzRjZmZjZGUxZWExZWRhZDU4NTIifX19"), "&7> Add new Command"));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(i, (pl, slot, item, action) -> {
|
||||
try {
|
||||
openScriptComponentEditor(p, b, script, index);
|
||||
openScriptComponentEditor(pl, b, script, index);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
menu.addItem(i + additional, ScriptPart.REPEAT.toItemStack());
|
||||
menu.addMenuClickHandler(i + additional, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i + additional,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
else {
|
||||
ItemStack stack = ScriptPart.valueOf(commands[i]).toItemStack();
|
||||
menu.addItem(i, new CustomItem(stack, stack.getItemMeta().getDisplayName(), "", "&7\u21E8 &eLeft Click &7to edit", "&7\u21E8 &eRight Click &7to delete", "&7\u21E8 &eShift + Right Click &7to duplicate"));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction action) {
|
||||
menu.addMenuClickHandler(i, (pl, slot, item, action) -> {
|
||||
if (action.isRightClicked() && action.isShiftClicked()) {
|
||||
if (commands.length == 54) return false;
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
StringBuilder builder = new StringBuilder("START-");
|
||||
for (String command: commands) {
|
||||
if (i > 0) {
|
||||
if (i == index) {
|
||||
builder.append(commands[i] + "-");
|
||||
builder.append(commands[i] + "-");
|
||||
for (String command : commands) {
|
||||
if (j > 0) {
|
||||
if (j == index) {
|
||||
builder.append(commands[j] + "-");
|
||||
builder.append(commands[j] + "-");
|
||||
}
|
||||
else if (i < commands.length - 1) builder.append(command + "-");
|
||||
else if (j < commands.length - 1) builder.append(command + "-");
|
||||
}
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
builder.append("REPEAT");
|
||||
BlockStorage.addBlockInfo(b, "script", builder.toString());
|
||||
|
||||
try {
|
||||
openScript(p, b, builder.toString());
|
||||
openScript(pl, b, builder.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (action.isRightClicked()) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
StringBuilder builder = new StringBuilder("START-");
|
||||
for (String command: commands) {
|
||||
if (i != index && i > 0 && i < commands.length - 1) builder.append(command + "-");
|
||||
i++;
|
||||
for (String command : commands) {
|
||||
if (j != index && j > 0 && j < commands.length - 1) builder.append(command + "-");
|
||||
j++;
|
||||
}
|
||||
builder.append("REPEAT");
|
||||
BlockStorage.addBlockInfo(b, "script", builder.toString());
|
||||
try {
|
||||
openScript(p, b, builder.toString());
|
||||
openScript(pl, b, builder.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
openScriptComponentEditor(p, b, script, index);
|
||||
openScriptComponentEditor(pl, b, script, index);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1126,13 +1058,9 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
private void openScriptDownloader(final Player p, final Block b, final int page) throws Exception {
|
||||
final ChestMenu menu = new ChestMenu("Slimefun Guide");
|
||||
|
||||
menu.addMenuOpeningHandler(new MenuOpeningHandler() {
|
||||
|
||||
@Override
|
||||
public void onOpen(Player p) {
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_HAT, 0.7F, 0.7F);
|
||||
}
|
||||
});
|
||||
menu.addMenuOpeningHandler(
|
||||
(pl) -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HAT, 0.7F, 0.7F)
|
||||
);
|
||||
|
||||
List<Config> scripts = getUploadedScripts();
|
||||
|
||||
@ -1141,62 +1069,48 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
|
||||
for (int i = 45; i < 54; i++) {
|
||||
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.addItem(46, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), "&r\u21E6 Previous Page", "", "&7(" + page + " / " + pages + ")"));
|
||||
menu.addMenuClickHandler(46, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
|
||||
int next = page - 1;
|
||||
if (next < 1) next = pages;
|
||||
if (next != page) {
|
||||
try {
|
||||
openScriptDownloader(p, b, next);
|
||||
openScriptDownloader(pl, b, next);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(49, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTA1YTJjYWI4YjY4ZWE1N2UzYWY5OTJhMzZlNDdjOGZmOWFhODdjYzg3NzYyODE5NjZmOGMzY2YzMWEzOCJ9fX0="), "&eUpload a Script", "", "&6Click &7to upload your Android's Script", "&7to the Database"));
|
||||
menu.addMenuClickHandler(49, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(49, (pl, slot, item, action) -> {
|
||||
final String code = BlockStorage.getLocationInfo(b.getLocation(), "script");
|
||||
int num = 1;
|
||||
|
||||
for (Config script: getUploadedScripts()) {
|
||||
if (script.getString("author").equals(p.getUniqueId().toString())) num++;
|
||||
if (script.getString("author").equals(pl.getUniqueId().toString())) num++;
|
||||
if (script.getString("code").equals(code)) {
|
||||
Messages.local.sendTranslation(p, "android.scripts.already-uploaded", true);
|
||||
Messages.local.sendTranslation(pl, "android.scripts.already-uploaded", true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final int id = num;
|
||||
|
||||
p.closeInventory();
|
||||
Messages.local.sendTranslation(p, "android.scripts.enter-name", true);
|
||||
pl.closeInventory();
|
||||
Messages.local.sendTranslation(pl, "android.scripts.enter-name", true);
|
||||
|
||||
MenuHelper.awaitChatInput(p, new ChatHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onChat(Player p, String message) {
|
||||
MenuHelper.awaitChatInput(pl, (player, message) -> {
|
||||
Config script = new Config("plugins/Slimefun/scripts/" + getAndroidType().toString() + "/" + p.getName() + " " + id + ".sfs");
|
||||
|
||||
script.setValue("author", p.getUniqueId().toString());
|
||||
script.setValue("author_name", p.getName());
|
||||
script.setValue("author", player.getUniqueId().toString());
|
||||
script.setValue("author_name", player.getName());
|
||||
script.setValue("name", ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', message)));
|
||||
script.setValue("code", code);
|
||||
script.setValue("downloads", 0);
|
||||
@ -1206,35 +1120,29 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
script.save();
|
||||
|
||||
try {
|
||||
Messages.local.sendTranslation(p, "android.uploaded", true);
|
||||
openScriptDownloader(p, b, page);
|
||||
Messages.local.sendTranslation(player, "android.uploaded", true);
|
||||
openScriptDownloader(player, b, page);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(52, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), "&rNext Page \u21E8", "", "&7(" + page + " / " + pages + ")"));
|
||||
menu.addMenuClickHandler(52, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(52, (pl, slot, item, action) -> {
|
||||
int next = page + 1;
|
||||
if (next > pages) next = 1;
|
||||
if (next != page) {
|
||||
try {
|
||||
openScriptDownloader(p, b, next);
|
||||
openScriptDownloader(pl, b, next);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int category_index = 45 * (page - 1);
|
||||
@ -1254,18 +1162,15 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
menu.addItem(index, new CustomItem(this.getItem(), "&b" + script.getString("name"), "&7by &r" + author, "", "&7Downloads: &r" + script.getInt("downloads"), "&7Rating: " + getScriptRatingPercentage(script), "&a" + getScriptRating(script, true) + " \u263A &7- &4\u2639 " + getScriptRating(script, false), "", "&eLeft Click &rto download this Script", "&4(This will override your current Script)", "&eShift + Left Click &rto leave a positive Rating", "&eShift + Right Click &rto leave a negative Rating"));
|
||||
}
|
||||
|
||||
menu.addMenuClickHandler(index, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) {
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
|
||||
Config script2 = new Config(script.getFile());
|
||||
|
||||
if (action.isShiftClicked()) {
|
||||
if (script2.getString("author").equals(p.getUniqueId().toString())) {
|
||||
Messages.local.sendTranslation(p, "android.scripts.rating.own", true);
|
||||
if (script2.getString("author").equals(pl.getUniqueId().toString())) {
|
||||
Messages.local.sendTranslation(pl, "android.scripts.rating.own", true);
|
||||
}
|
||||
else if (action.isRightClicked()) {
|
||||
if (!script2.getStringList("rating.negative").contains(p.getUniqueId().toString()) && !script2.getStringList("rating.positive").contains(p.getUniqueId().toString())) {
|
||||
if (!script2.getStringList("rating.negative").contains(pl.getUniqueId().toString()) && !script2.getStringList("rating.positive").contains(pl.getUniqueId().toString())) {
|
||||
List<String> list = script2.getStringList("rating.negative");
|
||||
list.add(p.getUniqueId().toString());
|
||||
|
||||
@ -1273,31 +1178,31 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
script2.save();
|
||||
|
||||
try {
|
||||
openScriptDownloader(p, b, page);
|
||||
openScriptDownloader(pl, b, page);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Messages.local.sendTranslation(p, "android.scripts.rating.already", true);
|
||||
Messages.local.sendTranslation(pl, "android.scripts.rating.already", true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!script2.getStringList("rating.negative").contains(p.getUniqueId().toString()) && !script2.getStringList("rating.positive").contains(p.getUniqueId().toString())) {
|
||||
if (!script2.getStringList("rating.negative").contains(pl.getUniqueId().toString()) && !script2.getStringList("rating.positive").contains(pl.getUniqueId().toString())) {
|
||||
List<String> list = script2.getStringList("rating.positive");
|
||||
list.add(p.getUniqueId().toString());
|
||||
list.add(pl.getUniqueId().toString());
|
||||
|
||||
script2.setValue("rating.positive", list);
|
||||
script2.save();
|
||||
|
||||
try {
|
||||
openScriptDownloader(p, b, page);
|
||||
openScriptDownloader(pl, b, page);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Messages.local.sendTranslation(p, "android.scripts.rating.already", true);
|
||||
Messages.local.sendTranslation(pl, "android.scripts.rating.already", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1307,13 +1212,12 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
script2.save();
|
||||
|
||||
BlockStorage.addBlockInfo(b, "script", script2.getString("code"));
|
||||
openScriptEditor(p, b);
|
||||
openScriptEditor(pl, b);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
index++;
|
||||
@ -1351,24 +1255,15 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.addItem(9, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYxMzlmZDFjNTY1NGU1NmU5ZTRlMmM4YmU3ZWIyYmQ1YjQ5OWQ2MzM2MTY2NjNmZWVlOTliNzQzNTJhZDY0In19fQ=="), "&rDo nothing"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
(pl, slot, item, action) -> {
|
||||
int i = 0;
|
||||
StringBuilder builder = new StringBuilder("START-");
|
||||
for (String command: commands) {
|
||||
for (String command : commands) {
|
||||
if (i != index && i > 0 && i < commands.length - 1) builder.append(command + "-");
|
||||
i++;
|
||||
}
|
||||
@ -1381,35 +1276,32 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
int i = 10;
|
||||
for (final ScriptPart part: getAccessibleScriptParts()) {
|
||||
for (final ScriptPart part : getAccessibleScriptParts()) {
|
||||
menu.addItem(i, part.toItemStack(),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
int i = 0;
|
||||
(pl, slot, item, action) -> {
|
||||
int j = 0;
|
||||
StringBuilder builder = new StringBuilder("START-");
|
||||
for (String command: commands) {
|
||||
if (i > 0) {
|
||||
if (i == index) builder.append(part.toString() + "-");
|
||||
else if (i < commands.length - 1) builder.append(command + "-");
|
||||
for (String command : commands) {
|
||||
if (j > 0) {
|
||||
if (j == index) builder.append(part.toString() + "-");
|
||||
else if (j < commands.length - 1) builder.append(command + "-");
|
||||
}
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
builder.append("REPEAT");
|
||||
BlockStorage.addBlockInfo(b, "script", builder.toString());
|
||||
|
||||
try {
|
||||
openScript(p, b, builder.toString());
|
||||
openScript(pl, b, builder.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
);
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -1436,7 +1328,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
Inventory inv = inject(b);
|
||||
inv.addItem(items);
|
||||
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, inv.getItem(slot));
|
||||
}
|
||||
}
|
||||
@ -1477,7 +1369,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
File directory = new File("plugins/Slimefun/scripts/" + this.getAndroidType().toString());
|
||||
if (!directory.exists()) directory.mkdirs();
|
||||
|
||||
for (File script: directory.listFiles()) {
|
||||
for (File script : directory.listFiles()) {
|
||||
if (script.getName().endsWith("sfs")) scripts.add(new Config(script));
|
||||
}
|
||||
|
||||
@ -1485,7 +1377,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
File directory2 = new File("plugins/Slimefun/scripts/NONE");
|
||||
if (!directory2.exists()) directory2.mkdirs();
|
||||
|
||||
for (File script: directory2.listFiles()) {
|
||||
for (File script : directory2.listFiles()) {
|
||||
if (script.getName().endsWith("sfs")) scripts.add(new Config(script));
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage.HoverAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.CustomBookOverlay;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuHelper;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuHelper.ChatHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Setup.Messages;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
@ -30,34 +27,26 @@ public class Elevator {
|
||||
ChestMenu menu = new ChestMenu("Elevator Settings");
|
||||
|
||||
menu.addItem(4, new CustomItem(new ItemStack(Material.NAME_TAG), "&7Floor Name &e(Click to edit)", "", "&r" + ChatColor.translateAlternateColorCodes('&', BlockStorage.getLocationInfo(b.getLocation(), "floor"))));
|
||||
menu.addMenuClickHandler(4, new MenuClickHandler() {
|
||||
menu.addMenuClickHandler(4, (pl, slot, item, action) -> {
|
||||
pl.closeInventory();
|
||||
pl.sendMessage("");
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &ePlease enter a Name for this Floor in your Chat!"));
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &e(Chat Colors are supported!"));
|
||||
pl.sendMessage("");
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.closeInventory();
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &ePlease enter a Name for this Floor in your Chat!"));
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &e(Chat Colors are supported!"));
|
||||
p.sendMessage("");
|
||||
|
||||
MenuHelper.awaitChatInput(p, new ChatHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onChat(Player p, String message) {
|
||||
MenuHelper.awaitChatInput(pl, (player, message) -> {
|
||||
BlockStorage.addBlockInfo(b, "floor", message.replaceAll("&", "&"));
|
||||
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &eSuccessfully named this Floor:"));
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &r" + ChatColor.translateAlternateColorCodes('&', message)));
|
||||
p.sendMessage("");
|
||||
player.sendMessage("");
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &eSuccessfully named this Floor:"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &r" + ChatColor.translateAlternateColorCodes('&', message)));
|
||||
player.sendMessage("");
|
||||
|
||||
openEditor(p, b);
|
||||
openEditor(player, b);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.open(p);
|
||||
|
@ -20,11 +20,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Variable;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuCloseHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuHelper;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuHelper.ChatHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
@ -57,7 +53,7 @@ public class GPSNetwork {
|
||||
public int getNetworkComplexity(UUID uuid) {
|
||||
if (!transmitters.containsKey(uuid)) return 0;
|
||||
int level = 0;
|
||||
for (Location l: transmitters.get(uuid)) {
|
||||
for (Location l : transmitters.get(uuid)) {
|
||||
level = level + l.getBlockY();
|
||||
}
|
||||
return level;
|
||||
@ -71,63 +67,41 @@ public class GPSNetwork {
|
||||
public void openTransmitterControlPanel(Player p) throws Exception {
|
||||
ChestMenu menu = new ChestMenu("&9Control Panel");
|
||||
|
||||
for (int slot: border) {
|
||||
for (int slot : border) {
|
||||
menu.addItem(slot, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(pl, slotn, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.addItem(2, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBjOWMxYTAyMmY0MGI3M2YxNGI0Y2JhMzdjNzE4YzZhNTMzZjNhMjg2NGI2NTM2ZDVmNDU2OTM0Y2MxZiJ9fX0="), "&7Transmitter Overview &e(Selected)"));
|
||||
menu.addMenuClickHandler(2, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(2,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
|
||||
menu.addItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGRjZmJhNThmYWYxZjY0ODQ3ODg0MTExODIyYjY0YWZhMjFkN2ZjNjJkNDQ4MWYxNGYzZjNiY2I2MzMwIn19fQ=="), "&7Network Info", "", "&8\u21E8 &7Status: " + (getNetworkComplexity(p.getUniqueId()) > 0 ? "&2&lONLINE": "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &r" + getNetworkComplexity(p.getUniqueId())));
|
||||
menu.addMenuClickHandler(4, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(4,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
|
||||
menu.addItem(6, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0="), "&7Waypoint Overview &r(Select)"));
|
||||
menu.addMenuClickHandler(6, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(6, (pl, slot, item, action) -> {
|
||||
try {
|
||||
openWaypointControlPanel(arg0);
|
||||
openWaypointControlPanel(pl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int index = 0;
|
||||
for (Location l: getTransmitters(p.getUniqueId())) {
|
||||
for (Location l : getTransmitters(p.getUniqueId())) {
|
||||
if (index >= inventory.length) break;
|
||||
int slot = inventory[index];
|
||||
|
||||
menu.addItem(slot, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBjOWMxYTAyMmY0MGI3M2YxNGI0Y2JhMzdjNzE4YzZhNTMzZjNhMjg2NGI2NTM2ZDVmNDU2OTM0Y2MxZiJ9fX0="), "&bGPS Transmitter", "&8\u21E8 &7World: &r" + l.getWorld().getName(), "&8\u21E8 &7X: &r" + l.getX(), "&8\u21E8 &7Y: &r" + l.getY(), "&8\u21E8 &7Z: &r" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &r" + l.getBlockY(), "&8\u21E8 &7Ping: &r" + DoubleHandler.fixDouble(1000D / l.getY()) + "ms"));
|
||||
menu.addMenuClickHandler(slot, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(slot,
|
||||
(pl, slotn, item, action) -> false
|
||||
);
|
||||
|
||||
index++;
|
||||
}
|
||||
@ -156,50 +130,32 @@ public class GPSNetwork {
|
||||
|
||||
for (int slot: border) {
|
||||
menu.addItem(slot, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(pl, slotn, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.addItem(2, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBjOWMxYTAyMmY0MGI3M2YxNGI0Y2JhMzdjNzE4YzZhNTMzZjNhMjg2NGI2NTM2ZDVmNDU2OTM0Y2MxZiJ9fX0="), "&7Transmitter Overview &r(Select)"));
|
||||
menu.addMenuClickHandler(2, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(2, (pl, slot, item, action) -> {
|
||||
try {
|
||||
openTransmitterControlPanel(arg0);
|
||||
openTransmitterControlPanel(pl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGRjZmJhNThmYWYxZjY0ODQ3ODg0MTExODIyYjY0YWZhMjFkN2ZjNjJkNDQ4MWYxNGYzZjNiY2I2MzMwIn19fQ=="), "&7Network Info", "", "&8\u21E8 &7Status: " + (getNetworkComplexity(p.getUniqueId()) > 0 ? "&2&lONLINE": "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &r" + getNetworkComplexity(p.getUniqueId())));
|
||||
menu.addMenuClickHandler(4, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(4,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
|
||||
menu.addItem(6, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0="), "&7Waypoint Overview &e(Selected)"));
|
||||
menu.addMenuClickHandler(6, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(6,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
|
||||
int index = 0;
|
||||
for (final Map.Entry<String, Location> entry: getWaypoints(p.getUniqueId()).entrySet()) {
|
||||
for (final Map.Entry<String, Location> entry : getWaypoints(p.getUniqueId()).entrySet()) {
|
||||
if (index >= inventory.length) break;
|
||||
int slot = inventory[index];
|
||||
|
||||
@ -207,22 +163,18 @@ public class GPSNetwork {
|
||||
ItemStack globe = getPlanet(entry);
|
||||
|
||||
menu.addItem(slot, new CustomItem(globe, entry.getKey(), "&8\u21E8 &7World: &r" + l.getWorld().getName(), "&8\u21E8 &7X: &r" + l.getX(), "&8\u21E8 &7Y: &r" + l.getY(), "&8\u21E8 &7Z: &r" + l.getZ(), "", "&8\u21E8 &cClick to delete"));
|
||||
menu.addMenuClickHandler(slot, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(slot, (pl, slotn, item, action) -> {
|
||||
String id = ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', entry.getKey())).toUpperCase().replace(" ", "_");
|
||||
Config cfg = new Config("data-storage/Slimefun/waypoints/" + arg0.getUniqueId().toString() + ".yml");
|
||||
Config cfg = new Config("data-storage/Slimefun/waypoints/" + pl.getUniqueId().toString() + ".yml");
|
||||
cfg.setValue(id, null);
|
||||
cfg.save();
|
||||
arg0.playSound(arg0.getLocation(), Sound.UI_BUTTON_CLICK, 1F, 1F);
|
||||
pl.playSound(pl.getLocation(), Sound.UI_BUTTON_CLICK, 1F, 1F);
|
||||
try {
|
||||
openWaypointControlPanel(arg0);
|
||||
openWaypointControlPanel(pl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
index++;
|
||||
@ -249,13 +201,9 @@ public class GPSNetwork {
|
||||
}
|
||||
Messages.local.sendTranslation(p, "gps.waypoint.new", true);
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.5F, 1F);
|
||||
MenuHelper.awaitChatInput(p, new ChatHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onChat(Player p, String message) {
|
||||
addWaypoint(p, message, l);
|
||||
MenuHelper.awaitChatInput(p, (pl, message) -> {
|
||||
addWaypoint(pl, message, l);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -290,13 +238,8 @@ public class GPSNetwork {
|
||||
int supply = OreGenSystem.getSupplies(resource, chunk, true);
|
||||
|
||||
menu.addItem(index, new CustomItem(resource.getIcon(), "&7Resource: &e" + resource.getName(), "", "&7Scanned Chunk:", "&8\u21E8 &7X: " + chunk.getX() + " Z: " + chunk.getZ(), "", "&7Result: &e" + supply + " " + resource.getMeasurementUnit()),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
index++;
|
||||
}
|
||||
|
||||
@ -314,34 +257,20 @@ public class GPSNetwork {
|
||||
|
||||
ChestMenu menu = new ChestMenu("&3Teleporter");
|
||||
|
||||
menu.addMenuCloseHandler(new MenuCloseHandler() {
|
||||
menu.addMenuCloseHandler(
|
||||
pl -> TeleportationSequence.players.remove(pl.getUniqueId())
|
||||
);
|
||||
|
||||
@Override
|
||||
public void onClose(Player p) {
|
||||
TeleportationSequence.players.remove(p.getUniqueId());
|
||||
}
|
||||
});
|
||||
|
||||
for (int slot: teleporter_border) {
|
||||
for (int slot : teleporter_border) {
|
||||
menu.addItem(slot, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(pl, slotn, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.addItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0="), "&7Waypoint Overview &e(Select a Destination)"));
|
||||
menu.addMenuClickHandler(4, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(4,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
|
||||
final Location source = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + 2D, b.getZ() + 0.5D);
|
||||
int index = 0;
|
||||
@ -353,14 +282,10 @@ public class GPSNetwork {
|
||||
ItemStack globe = getPlanet(entry);
|
||||
|
||||
menu.addItem(slot, new CustomItem(globe, entry.getKey(), "&8\u21E8 &7World: &r" + l.getWorld().getName(), "&8\u21E8 &7X: &r" + l.getX(), "&8\u21E8 &7Y: &r" + l.getY(), "&8\u21E8 &7Z: &r" + l.getZ(), "&8\u21E8 &7Estimated Teleportation Time: &r" + (50 / TeleportationSequence.getSpeed(Slimefun.getGPSNetwork().getNetworkComplexity(uuid), source, l)) + "s", "", "&8\u21E8 &cClick to select"));
|
||||
menu.addMenuClickHandler(slot, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.closeInventory();
|
||||
TeleportationSequence.start(p.getUniqueId(), complexity, source, l, false);
|
||||
menu.addMenuClickHandler(slot, (pl, slotn, item, action) -> {
|
||||
pl.closeInventory();
|
||||
TeleportationSequence.start(pl.getUniqueId(), complexity, source, l, false);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
index++;
|
||||
|
@ -18,7 +18,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
@ -76,20 +75,19 @@ public abstract class AContainer extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (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));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -165,51 +163,27 @@ public abstract class AContainer extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_in) {
|
||||
for (int i : border_in) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_out) {
|
||||
for (int i : border_out) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for (int i: getOutputSlots()) {
|
||||
for (int i : getOutputSlots()) {
|
||||
preset.addMenuClickHandler(i, new AdvancedMenuClickHandler() {
|
||||
|
||||
@Override
|
||||
@ -261,9 +235,9 @@ public abstract class AContainer extends SlimefunItem {
|
||||
int size = BlockStorage.getInventory(b).toInventory().getSize();
|
||||
Inventory inv = Bukkit.createInventory(null, size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
|
||||
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, "&4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
|
||||
}
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
inv.setItem(slot, BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
}
|
||||
return inv;
|
||||
@ -277,7 +251,7 @@ public abstract class AContainer extends SlimefunItem {
|
||||
Inventory inv = inject(b);
|
||||
inv.addItem(items);
|
||||
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, inv.getItem(slot));
|
||||
}
|
||||
}
|
||||
|
@ -46,38 +46,20 @@ public abstract class ADrill extends AContainer {
|
||||
}
|
||||
|
||||
private void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_out) {
|
||||
for (int i : border_out) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
for (int i: getOutputSlots()) {
|
||||
preset.addMenuClickHandler(i, new AdvancedMenuClickHandler() {
|
||||
|
@ -1,9 +1,17 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -18,15 +26,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class AFarm extends SlimefunItem {
|
||||
|
||||
private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 36, 37, 38, 39, 40, 41, 42, 43, 44};
|
||||
@ -62,14 +61,13 @@ public abstract class AFarm extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -111,7 +109,6 @@ public abstract class AFarm extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,40 +128,22 @@ public abstract class AFarm extends SlimefunItem {
|
||||
}
|
||||
|
||||
private void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_out) {
|
||||
for (int i : border_out) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for (int i: getOutputSlots()) {
|
||||
for (int i : getOutputSlots()) {
|
||||
preset.addMenuClickHandler(i, new AdvancedMenuClickHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -7,10 +7,20 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
@ -28,17 +38,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public abstract class AGenerator extends SlimefunItem {
|
||||
|
||||
public static Map<Location, MachineFuel> processing = new HashMap<Location, MachineFuel>();
|
||||
@ -80,20 +79,19 @@ public abstract class AGenerator extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (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));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -139,20 +137,19 @@ public abstract class AGenerator extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (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));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -169,38 +166,20 @@ public abstract class AGenerator extends SlimefunItem {
|
||||
}
|
||||
|
||||
private void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_in) {
|
||||
for (int i : border_in) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
for (int i: border_out) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
for (int i: getOutputSlots()) {
|
||||
@ -219,14 +198,8 @@ public abstract class AGenerator extends SlimefunItem {
|
||||
}
|
||||
|
||||
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
public abstract String getInventoryTitle();
|
||||
@ -357,8 +330,9 @@ public abstract class AGenerator extends SlimefunItem {
|
||||
Inventory inv = inject(l);
|
||||
inv.addItem(items);
|
||||
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,8 +19,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
@ -84,26 +82,18 @@ public abstract class AReactor extends SlimefunItem {
|
||||
}
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "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() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(4, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "reactor-mode", "production");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
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.addMenuClickHandler(4, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(4, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "reactor-mode", "generator");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch(Exception x) {
|
||||
@ -125,26 +115,25 @@ public abstract class AReactor extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getFuelSlots()) {
|
||||
for (int slot : getFuelSlots()) {
|
||||
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));
|
||||
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));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -162,72 +151,36 @@ public abstract class AReactor extends SlimefunItem {
|
||||
}
|
||||
|
||||
private void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: border_1) {
|
||||
for (int i : border_1) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: border_3) {
|
||||
for (int i : border_3) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GREEN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
for (int i : border_2) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
if (needsCooling()) {
|
||||
@ -238,13 +191,8 @@ public abstract class AReactor extends SlimefunItem {
|
||||
|
||||
for (int i : border_4) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.BARRIER), "&cNo Coolant Required"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player player, int i, ItemStack itemStack, ClickAction clickAction) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -449,7 +397,7 @@ public abstract class AReactor extends SlimefunItem {
|
||||
for (int i = 0; i < size; i++) {
|
||||
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
|
||||
}
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));
|
||||
}
|
||||
return inv;
|
||||
@ -461,7 +409,7 @@ public abstract class AReactor extends SlimefunItem {
|
||||
for (int i = 0; i < size; i++) {
|
||||
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
|
||||
}
|
||||
for (int slot: slots) {
|
||||
for (int slot : slots) {
|
||||
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));
|
||||
}
|
||||
return inv;
|
||||
@ -480,11 +428,11 @@ public abstract class AReactor extends SlimefunItem {
|
||||
Inventory inv = inject(l, slots);
|
||||
Map<Integer, ItemStack> map = inv.addItem(item);
|
||||
|
||||
for (int slot: slots) {
|
||||
for (int slot : slots) {
|
||||
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot));
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, ItemStack> entry: map.entrySet()) {
|
||||
for (Map.Entry<Integer, ItemStack> entry : map.entrySet()) {
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
@ -502,4 +450,5 @@ public abstract class AReactor extends SlimefunItem {
|
||||
if (BlockStorage.check(portL, "REACTOR_ACCESS_PORT")) return BlockStorage.getInventory(portL);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -43,84 +41,57 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
||||
try {
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) {
|
||||
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.WHITE_WOOL), "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist"));
|
||||
menu.addMenuClickHandler(15, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-type", "blacklist");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.BLACK_WOOL), "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist"));
|
||||
menu.addMenuClickHandler(15, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability").equals("false")) {
|
||||
menu.replaceExistingItem(16, new CustomItem(new ItemStack(Material.STONE_SWORD, (byte) 20), "&7Include Sub-IDs/Durability: &4\u2718", "", "&e> Click to toggle whether the Durability has to match"));
|
||||
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-durability", "true");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(16, new CustomItem(new ItemStack(Material.GOLDEN_SWORD, (byte) 20), "&7Include Sub-IDs/Durability: &2\u2714", "", "&e> Click to toggle whether the Durability has to match"));
|
||||
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore").equals("true")) {
|
||||
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match"));
|
||||
menu.addMenuClickHandler(25, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-lore", "false");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match"));
|
||||
menu.addMenuClickHandler(25, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "&bChannel", "", "&e> Click to decrease the Channel ID by 1"));
|
||||
menu.addMenuClickHandler(41, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(41, (p, slot, item, action) -> {
|
||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1;
|
||||
if (channel < 0) {
|
||||
if (CargoNet.EXTRA_CHANNELS) channel = 16;
|
||||
@ -129,50 +100,37 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency"))));
|
||||
|
||||
if (channel == 16) {
|
||||
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1)));
|
||||
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(42,
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(42, new CustomItem(new ItemStack(MaterialHelper.WoolColours[channel]), "&bChannel ID: &3" + (channel + 1)));
|
||||
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(42,
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "&bChannel", "", "&e> Click to increase the Channel ID by 1"));
|
||||
menu.addMenuClickHandler(43, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
||||
menu.addMenuClickHandler(43, (p, slot, item, action) -> {
|
||||
int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
||||
|
||||
if (CargoNet.EXTRA_CHANNELS) {
|
||||
if (channel > 16) channel = 0;
|
||||
if (channeln > 16) channeln = 0;
|
||||
}
|
||||
else {
|
||||
if (channel > 15) channel = 0;
|
||||
if (channeln > 15) channeln = 0;
|
||||
}
|
||||
|
||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channeln));
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -224,30 +182,19 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(2, new CustomItem(new ItemStack(Material.PAPER), "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
public int[] getInputSlots() {
|
||||
return new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -71,7 +69,7 @@ public class AnimalGrowthAccelerator extends SlimefunItem {
|
||||
me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).remove();
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -84,16 +82,10 @@ public class AnimalGrowthAccelerator extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +124,7 @@ public class AnimalGrowthAccelerator extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void tick(Block b) throws Exception {
|
||||
for (Entity n: me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).getNearbyEntities(3D, 3D, 3D)) {
|
||||
for (Entity n : me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).getNearbyEntities(3D, 3D, 3D)) {
|
||||
if (n instanceof Ageable && !((Ageable) n).isAdult()) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
|
||||
|
@ -1,9 +1,15 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.Animals;
|
||||
@ -21,14 +27,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class AutoBreeder extends SlimefunItem {
|
||||
|
||||
private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
|
||||
@ -63,7 +61,6 @@ public class AutoBreeder extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,7 +68,7 @@ public class AutoBreeder extends SlimefunItem {
|
||||
me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).remove();
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -84,16 +81,10 @@ public class AutoBreeder extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,9 +123,9 @@ public class AutoBreeder extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void tick(Block b) throws Exception {
|
||||
for (Entity n: me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).getNearbyEntities(4D, 2D, 4D)) {
|
||||
for (Entity n : me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).getNearbyEntities(4D, 2D, 4D)) {
|
||||
if (Animals.isFeedable(n)) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
|
||||
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
|
||||
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
||||
|
@ -17,7 +17,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
@ -58,26 +57,18 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem {
|
||||
public void newInstance(final BlockMenu menu, final Block b) {
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) {
|
||||
menu.replaceExistingItem(6, new CustomItem(new ItemStack(Material.GUNPOWDER), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
|
||||
menu.addMenuClickHandler(6, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(6, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "enabled", "true");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(6, new CustomItem(new ItemStack(Material.REDSTONE), "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
|
||||
menu.addMenuClickHandler(6, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(6, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "enabled", "false");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -97,7 +88,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem {
|
||||
if (flow.equals(ItemTransportFlow.WITHDRAW)) return getOutputSlots();
|
||||
|
||||
List<Integer> slots = new ArrayList<Integer>();
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (menu.getItemInSlot(slot) != null) slots.add(slot);
|
||||
}
|
||||
Collections.sort(slots, new RecipeSorter(menu));
|
||||
@ -142,41 +133,23 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_in) {
|
||||
for (int i : border_in) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.BLUE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_out) {
|
||||
for (int i : border_out) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: getOutputSlots()) {
|
||||
for (int i : getOutputSlots()) {
|
||||
preset.addMenuClickHandler(i, new AdvancedMenuClickHandler() {
|
||||
|
||||
@Override
|
||||
@ -192,14 +165,8 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem {
|
||||
}
|
||||
|
||||
preset.addItem(2, new CustomItem(new ItemStack(Material.CRAFTING_TABLE), "&eRecipe", "", "&bPut in the Recipe you want to craft", "&4Enhanced Crafting Table Recipes ONLY"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
public abstract int getEnergyConsumption();
|
||||
@ -218,7 +185,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem {
|
||||
for (int i = 0; i < size; i++) {
|
||||
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
|
||||
}
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
inv.setItem(slot, BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
}
|
||||
return inv;
|
||||
@ -232,7 +199,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem {
|
||||
Inventory inv = inject(b);
|
||||
inv.addItem(items);
|
||||
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, inv.getItem(slot));
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -40,38 +38,26 @@ public class CargoCraftingNode extends SlimefunItem {
|
||||
public void newInstance(final BlockMenu menu, final Block b) {
|
||||
try {
|
||||
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "&bChannel", "", "&e> Click to decrease the Channel ID by 1"));
|
||||
menu.addMenuClickHandler(41, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(41, (p, slot, item, action) -> {
|
||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1;
|
||||
if (channel < 0) channel = 15;
|
||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.replaceExistingItem(42, new CustomItem(new ItemStack(((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? Material.WHITE_WOOL: MaterialHelper.WoolColours[(Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")))])), "&bChannel ID: &3" + (((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")))) + 1)));
|
||||
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.replaceExistingItem(42, new CustomItem(new ItemStack(((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? Material.WHITE_WOOL : MaterialHelper.WoolColours[(Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")))])), "&bChannel ID: &3" + (((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")))) + 1)));
|
||||
menu.addMenuClickHandler(42,
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "&bChannel", "", "&e> Click to increase the Channel ID by 1"));
|
||||
menu.addMenuClickHandler(43, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(43, (p, slot, item, action) -> {
|
||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
||||
if (channel > 15) channel = 0;
|
||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -106,7 +92,7 @@ public class CargoCraftingNode extends SlimefunItem {
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -119,30 +105,19 @@ public class CargoCraftingNode extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(2, new CustomItem(new ItemStack(Material.CRAFTING_TABLE), "&eRecipe", "", "&bPut in the Recipe you want to craft"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
public int[] getInputSlots() {
|
||||
return new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -43,109 +41,74 @@ public class CargoInputNode extends SlimefunItem {
|
||||
try {
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) {
|
||||
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.WHITE_WOOL), "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist"));
|
||||
menu.addMenuClickHandler(15, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-type", "blacklist");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.BLACK_WOOL), "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist"));
|
||||
menu.addMenuClickHandler(15, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability").equals("false")) {
|
||||
menu.replaceExistingItem(16, new CustomItem(new ItemStack(Material.STONE_SWORD, (byte) 20), "&7Include Sub-IDs/Durability: &4\u2718", "", "&e> Click to toggle whether the Durability has to match"));
|
||||
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-durability", "true");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(16, new CustomItem(new ItemStack(Material.GOLDEN_SWORD, (byte) 20), "&7Include Sub-IDs/Durability: &2\u2714", "", "&e> Click to toggle whether the Durability has to match"));
|
||||
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "round-robin") == null || BlockStorage.getLocationInfo(b.getLocation(), "round-robin").equals("false")) {
|
||||
menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "&7Round-Robin Mode: &4\u2718", "", "&e> Click to enable Round Robin Mode", "&e(Items will be equally distributed on the Channel)"));
|
||||
menu.addMenuClickHandler(24, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(24, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "round-robin", "true");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "&7Round-Robin Mode: &2\u2714", "", "&e> Click to disable Round Robin Mode", "&e(Items will be equally distributed on the Channel)"));
|
||||
menu.addMenuClickHandler(24, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(24, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "round-robin", "false");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore").equals("true")) {
|
||||
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match"));
|
||||
menu.addMenuClickHandler(25, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-lore", "false");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match"));
|
||||
menu.addMenuClickHandler(25, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "&bChannel", "", "&e> Click to decrease the Channel ID by 1"));
|
||||
menu.addMenuClickHandler(41, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(41, (p, slot, item, action) -> {
|
||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1;
|
||||
if (channel < 0) {
|
||||
if (CargoNet.EXTRA_CHANNELS) channel = 16;
|
||||
@ -154,50 +117,37 @@ public class CargoInputNode extends SlimefunItem {
|
||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency"))));
|
||||
|
||||
if (channel == 16) {
|
||||
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1)));
|
||||
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(42,
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(42, new CustomItem(new ItemStack(MaterialHelper.WoolColours[channel]), "&bChannel ID: &3" + (channel + 1)));
|
||||
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(42,
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "&bChannel", "", "&e> Click to increase the Channel ID by 1"));
|
||||
menu.addMenuClickHandler(43, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
||||
menu.addMenuClickHandler(43, (p, slot, item, action) -> {
|
||||
int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
||||
|
||||
if (CargoNet.EXTRA_CHANNELS) {
|
||||
if (channel > 16) channel = 0;
|
||||
if (channeln > 16) channeln = 0;
|
||||
}
|
||||
else {
|
||||
if (channel > 15) channel = 0;
|
||||
if (channeln > 15) channeln = 0;
|
||||
}
|
||||
|
||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -237,7 +187,7 @@ public class CargoInputNode extends SlimefunItem {
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -250,30 +200,19 @@ public class CargoInputNode extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(2, new CustomItem(new ItemStack(Material.PAPER), "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
public int[] getInputSlots() {
|
||||
return new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -44,10 +42,7 @@ public class CargoOutputNode extends SlimefunItem {
|
||||
try {
|
||||
|
||||
menu.replaceExistingItem(12, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "&bChannel", "", "&e> Click to decrease the Channel ID by 1"));
|
||||
menu.addMenuClickHandler(12, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(12, (p, slot, item, action) -> {
|
||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1;
|
||||
if (channel < 0) {
|
||||
if (CargoNet.EXTRA_CHANNELS) channel = 16;
|
||||
@ -56,50 +51,37 @@ public class CargoOutputNode extends SlimefunItem {
|
||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency"))));
|
||||
|
||||
if (channel == 16) {
|
||||
menu.replaceExistingItem(13, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1)));
|
||||
menu.addMenuClickHandler(13, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(13,
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(13, new CustomItem(new ItemStack(MaterialHelper.WoolColours[channel]), "&bChannel ID: &3" + (channel + 1)));
|
||||
menu.addMenuClickHandler(13, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(13,
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.replaceExistingItem(14, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "&bChannel", "", "&e> Click to increase the Channel ID by 1"));
|
||||
menu.addMenuClickHandler(14, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
||||
menu.addMenuClickHandler(14, (p, slot, item, action) -> {
|
||||
int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
||||
|
||||
if (CargoNet.EXTRA_CHANNELS) {
|
||||
if (channel > 16) channel = 0;
|
||||
if (channeln > 16) channeln = 0;
|
||||
}
|
||||
else {
|
||||
if (channel > 15) channel = 0;
|
||||
if (channeln > 15) channeln = 0;
|
||||
}
|
||||
|
||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -138,16 +120,11 @@ public class CargoOutputNode extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,15 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -23,13 +28,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class CropGrowthAccelerator extends SlimefunItem {
|
||||
|
||||
private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
|
||||
@ -75,7 +73,6 @@ public abstract class CropGrowthAccelerator extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -95,16 +92,10 @@ public abstract class CropGrowthAccelerator extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +162,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem {
|
||||
}
|
||||
|
||||
if (work > 0) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.FERTILIZER, false)) {
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
|
||||
break;
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -72,7 +71,7 @@ public abstract class ElectricSmeltery extends AContainer {
|
||||
|
||||
List<Integer> slots = new ArrayList<Integer>();
|
||||
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), item, true)) {
|
||||
slots.add(slot);
|
||||
}
|
||||
@ -99,20 +98,19 @@ public abstract class ElectricSmeltery extends AContainer {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (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));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -129,51 +127,27 @@ public abstract class ElectricSmeltery extends AContainer {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_in) {
|
||||
for (int i : border_in) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_out) {
|
||||
for (int i : border_out) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for (int i: getOutputSlots()) {
|
||||
for (int i : getOutputSlots()) {
|
||||
preset.addMenuClickHandler(i, new AdvancedMenuClickHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -5,11 +5,20 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Block.Vein;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
@ -25,16 +34,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class FluidPump extends SlimefunItem{
|
||||
|
||||
public static Map<Block, MachineRecipe> processing = new HashMap<Block, MachineRecipe>();
|
||||
@ -72,41 +71,23 @@ public class FluidPump extends SlimefunItem{
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_in) {
|
||||
for (int i : border_in) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (int i: border_out) {
|
||||
for (int i : border_out) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: getOutputSlots()) {
|
||||
for (int i : getOutputSlots()) {
|
||||
preset.addMenuClickHandler(i, new AdvancedMenuClickHandler() {
|
||||
|
||||
@Override
|
||||
@ -137,7 +118,7 @@ public class FluidPump extends SlimefunItem{
|
||||
protected void tick(Block b) {
|
||||
Block fluid = b.getRelative(BlockFace.DOWN);
|
||||
if (fluid.getType().equals(Material.LAVA)) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) {
|
||||
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
|
||||
|
||||
@ -159,7 +140,7 @@ public class FluidPump extends SlimefunItem{
|
||||
}
|
||||
}
|
||||
else if (fluid.getType().equals(Material.WATER)) {
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) {
|
||||
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
|
||||
|
||||
@ -211,7 +192,7 @@ public class FluidPump extends SlimefunItem{
|
||||
for (int i = 0; i < size; i++) {
|
||||
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
|
||||
}
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
inv.setItem(slot, BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
}
|
||||
return inv;
|
||||
|
@ -2,9 +2,15 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
@ -18,14 +24,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ReactorAccessPort extends SlimefunItem {
|
||||
|
||||
private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 21, 23};
|
||||
@ -72,26 +70,25 @@ public class ReactorAccessPort extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getFuelSlots()) {
|
||||
for (int slot : getFuelSlots()) {
|
||||
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));
|
||||
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));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -104,93 +101,45 @@ public class ReactorAccessPort extends SlimefunItem {
|
||||
}
|
||||
|
||||
private void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: border_1) {
|
||||
for (int i : border_1) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: border_2) {
|
||||
for (int i : border_2) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: border_3) {
|
||||
for (int i : border_3) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GREEN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
preset.addItem(22, new CustomItem(SlimefunItems.PLUTONIUM, "&7Byproduct Slot", "", "&rThis Slot contains the Reactor's Byproduct", "&rsuch as &aNeptunium &ror &7Plutonium"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
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() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
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() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
public String getInventoryTitle() {
|
||||
@ -219,7 +168,7 @@ public class ReactorAccessPort extends SlimefunItem {
|
||||
for (int i = 0; i < size; i++) {
|
||||
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
|
||||
}
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));
|
||||
}
|
||||
return inv;
|
||||
@ -238,4 +187,5 @@ public class ReactorAccessPort extends SlimefunItem {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -13,11 +16,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class TrashCan extends SlimefunItem {
|
||||
|
||||
private static final int[] border = {0, 1, 2, 3, 5, 4, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
|
||||
@ -50,16 +48,10 @@ public class TrashCan extends SlimefunItem {
|
||||
}
|
||||
|
||||
private void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.RED_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,4 +87,5 @@ public class TrashCan extends SlimefunItem {
|
||||
|
||||
super.register(slimefun);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,8 +10,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler;
|
||||
@ -53,41 +51,29 @@ public class WitherAssembler extends SlimefunItem {
|
||||
try {
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) {
|
||||
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.GUNPOWDER), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
|
||||
menu.addMenuClickHandler(22, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "enabled", "true");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.REDSTONE), "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
|
||||
menu.addMenuClickHandler(22, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "enabled", "false");
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "offset") == null) ? 3.0F: Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
|
||||
|
||||
menu.replaceExistingItem(31, new CustomItem(new ItemStack(Material.PISTON), "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
|
||||
menu.addMenuClickHandler(31, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
double offset = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (arg3.isRightClicked() ? -0.1F: 0.1F));
|
||||
BlockStorage.addBlockInfo(b, "offset", String.valueOf(offset));
|
||||
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
|
||||
double offsetv = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (action.isRightClicked() ? -0.1F : 0.1F));
|
||||
BlockStorage.addBlockInfo(b, "offset", String.valueOf(offsetv));
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch(Exception x) {
|
||||
x.printStackTrace();
|
||||
@ -134,7 +120,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
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));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
@ -147,71 +133,35 @@ public class WitherAssembler extends SlimefunItem {
|
||||
}
|
||||
|
||||
private void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: border_1) {
|
||||
for (int i : border_1) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
for (int i: border_2) {
|
||||
for (int i : border_2) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.BROWN_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
preset.addItem(1, new CustomItem(new ItemStack(Material.WITHER_SKELETON_SKULL, (byte) 1), "&7Wither Skull Slot", "", "&rThis Slot accepts Wither Skeleton Skulls"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
preset.addItem(7, new CustomItem(new ItemStack(Material.SOUL_SAND), "&7Soul Sand Slot", "", "&rThis Slot accepts Soul Sand"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
|
||||
preset.addItem(13, new CustomItem(new ItemStack(Material.CLOCK), "&7Cooldown: &b30 Seconds", "", "&rThis Machine takes up to half a Minute to operate", "&rso give it some Time!"),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
public String getInventoryTitle() {
|
||||
@ -243,7 +193,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
int soulsand = 0;
|
||||
int skulls = 0;
|
||||
|
||||
for (int slot: getSoulSandSlots()) {
|
||||
for (int slot : getSoulSandSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true, DataType.ALWAYS)) {
|
||||
soulsand = soulsand + BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
|
||||
if (soulsand > 3) {
|
||||
@ -253,7 +203,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
}
|
||||
}
|
||||
|
||||
for (int slot: getWitherSkullSlots()) {
|
||||
for (int slot : getWitherSkullSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true, DataType.ALWAYS)) {
|
||||
skulls = skulls + BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
|
||||
if (skulls > 2) {
|
||||
@ -264,7 +214,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
}
|
||||
|
||||
if (soulsand > 3 && skulls > 2) {
|
||||
for (int slot: getSoulSandSlots()) {
|
||||
for (int slot : getSoulSandSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true, DataType.ALWAYS)) {
|
||||
final int amount = BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
|
||||
if (amount >= soulsand) {
|
||||
@ -278,7 +228,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
}
|
||||
}
|
||||
|
||||
for (int slot: getWitherSkullSlots()) {
|
||||
for (int slot : getWitherSkullSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true, DataType.ALWAYS)) {
|
||||
final int amount = BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
|
||||
if (amount >= skulls) {
|
||||
@ -322,4 +272,5 @@ public class WitherAssembler extends SlimefunItem {
|
||||
public int getEnergyConsumption() {
|
||||
return 4096;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,17 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -19,15 +26,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class XPCollector extends SlimefunItem {
|
||||
|
||||
private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
|
||||
@ -88,7 +86,7 @@ public class XPCollector extends SlimefunItem {
|
||||
for (int i = 0; i < size; i++) {
|
||||
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US", 0));
|
||||
}
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
inv.setItem(slot, BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
}
|
||||
return inv;
|
||||
@ -102,7 +100,7 @@ public class XPCollector extends SlimefunItem {
|
||||
Inventory inv = inject(b);
|
||||
inv.addItem(items);
|
||||
|
||||
for (int slot: getOutputSlots()) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, inv.getItem(slot));
|
||||
}
|
||||
}
|
||||
@ -112,16 +110,10 @@ public class XPCollector extends SlimefunItem {
|
||||
}
|
||||
|
||||
protected void constructMenu(BlockMenuPreset preset) {
|
||||
for (int i: border) {
|
||||
for (int i : border) {
|
||||
preset.addItem(i, new CustomItem(new ItemStack(Material.PURPLE_STAINED_GLASS_PANE), " "),
|
||||
new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
(p, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage.HoverAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuOpeningHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.CustomBookOverlay;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.SkullItem;
|
||||
@ -110,129 +107,89 @@ public class SlimefunGuide {
|
||||
final ChestMenu menu = new ChestMenu("Settings / Info");
|
||||
|
||||
menu.setEmptySlotsClickable(false);
|
||||
menu.addMenuOpeningHandler(new MenuOpeningHandler() {
|
||||
|
||||
@Override
|
||||
public void onOpen(Player p) {
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F);
|
||||
}
|
||||
});
|
||||
menu.addMenuOpeningHandler(
|
||||
pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F)
|
||||
);
|
||||
|
||||
for (int i: slots) {
|
||||
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (SlimefunManager.isItemSimiliar(guide, getItem(BookDesign.CHEST), true)) {
|
||||
if (p.hasPermission("slimefun.cheat.items")) {
|
||||
menu.addItem(19, new CustomItem(new ItemStack(Material.CHEST), "&7Guide Layout: &eChest GUI", "", "&aChest GUI", "&7Book GUI", "&7Cheat Sheet", "", "&e Click &8\u21E8 &7Change Layout"));
|
||||
menu.addMenuClickHandler(19, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.getInventory().setItemInMainHand(getItem(BookDesign.BOOK));
|
||||
openSettings(p, p.getInventory().getItemInMainHand());
|
||||
menu.addMenuClickHandler(19, (pl, slot, item, action) -> {
|
||||
pl.getInventory().setItemInMainHand(getItem(BookDesign.BOOK));
|
||||
openSettings(pl, pl.getInventory().getItemInMainHand());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.addItem(19, new CustomItem(new ItemStack(Material.CHEST), "&7Guide Layout: &eChest GUI", "", "&aChest GUI", "&7Book GUI", "", "&e Click &8\u21E8 &7Change Layout"));
|
||||
menu.addMenuClickHandler(19, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.getInventory().setItemInMainHand(getItem(BookDesign.BOOK));
|
||||
openSettings(p, p.getInventory().getItemInMainHand());
|
||||
menu.addMenuClickHandler(19, (pl, slot, item, action) -> {
|
||||
pl.getInventory().setItemInMainHand(getItem(BookDesign.BOOK));
|
||||
openSettings(pl, pl.getInventory().getItemInMainHand());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (SlimefunManager.isItemSimiliar(guide, getItem(BookDesign.BOOK), true)) {
|
||||
if (p.hasPermission("slimefun.cheat.items")) {
|
||||
menu.addItem(19, new CustomItem(new ItemStack(Material.CHEST), "&7Guide Layout: &eBook GUI", "", "&7Chest GUI", "&aBook GUI", "&7Cheat Sheet", "", "&e Click &8\u21E8 &7Change Layout"));
|
||||
menu.addMenuClickHandler(19, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.getInventory().setItemInMainHand(getItem(BookDesign.CHEAT_SHEET));
|
||||
openSettings(p, p.getInventory().getItemInMainHand());
|
||||
menu.addMenuClickHandler(19, (pl, slot, item, action) -> {
|
||||
pl.getInventory().setItemInMainHand(getItem(BookDesign.CHEAT_SHEET));
|
||||
openSettings(pl, pl.getInventory().getItemInMainHand());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.addItem(19, new CustomItem(new ItemStack(Material.CHEST), "&7Guide Layout: &eBook GUI", "", "&7Chest GUI", "&aBook GUI", "", "&e Click &8\u21E8 &7Change Layout"));
|
||||
menu.addMenuClickHandler(19, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.getInventory().setItemInMainHand(getItem(BookDesign.CHEST));
|
||||
openSettings(p, p.getInventory().getItemInMainHand());
|
||||
menu.addMenuClickHandler(19, (pl, slot, item, action) -> {
|
||||
pl.getInventory().setItemInMainHand(getItem(BookDesign.CHEST));
|
||||
openSettings(pl, pl.getInventory().getItemInMainHand());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (SlimefunManager.isItemSimiliar(guide, getItem(BookDesign.CHEAT_SHEET), true)) {
|
||||
menu.addItem(19, new CustomItem(new ItemStack(Material.CHEST), "&7Guide Layout: &eCheat Sheet", "", "&7Chest GUI", "&7Book GUI", "&aCheat Sheet", "", "&e Click &8\u21E8 &7Change Layout"));
|
||||
menu.addMenuClickHandler(19, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.getInventory().setItemInMainHand(getItem(BookDesign.CHEST));
|
||||
openSettings(p, p.getInventory().getItemInMainHand());
|
||||
menu.addMenuClickHandler(19, (pl, slot, item, action) -> {
|
||||
pl.getInventory().setItemInMainHand(getItem(BookDesign.CHEST));
|
||||
openSettings(pl, pl.getInventory().getItemInMainHand());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
menu.addItem(1, new CustomItem(new ItemStack(Material.WRITABLE_BOOK), "&aCredits", "", "&7Version: &a" + SlimefunStartup.instance.getDescription().getVersion(), "&7Contributors: &e" + contributors.size(), "", "&7\u21E8 Click to see the people behind this Plugin"));
|
||||
menu.addMenuClickHandler(1, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
openCredits(p, guide);
|
||||
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
|
||||
openCredits(pl, guide);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
menu.addItem(4, new CustomItem(new ItemStack(Material.COMPARATOR), "&eSource Code", "", "&7Bytes of Code: &6" + IntegerFormat.formatBigNumber(code_bytes), "&7Last Update: &a" + IntegerFormat.timeDelta(last_update) + " ago", "&7Forks: &e" + forks, "&7Stars: &e" + stars, "", "&7&oSlimefun 4 is a community project,", "&7&othe source code is available on GitHub", "&7&oand if you want to keep this Plugin alive,", "&7&othen please consider contributing to it", "", "&7\u21E8 Click to go to GitHub"));
|
||||
menu.addMenuClickHandler(4, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.closeInventory();
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&ohttps://github.com/TheBusyBiscuit/Slimefun4"));
|
||||
p.sendMessage("");
|
||||
menu.addMenuClickHandler(4, (pl, slot, item, action) -> {
|
||||
pl.closeInventory();
|
||||
pl.sendMessage("");
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&ohttps://github.com/TheBusyBiscuit/Slimefun4"));
|
||||
pl.sendMessage("");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
menu.addItem(7, new CustomItem(new ItemStack(Material.REDSTONE), "&4Bug Tracker", "", "&7Unsolved Issues: &a" + issues, "", "&7\u21E8 Click to go to the Slimefun Bug Tracker"));
|
||||
menu.addMenuClickHandler(7, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.closeInventory();
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&ohttps://github.com/TheBusyBiscuit/Slimefun4/issues"));
|
||||
p.sendMessage("");
|
||||
menu.addMenuClickHandler(7, (pl, slot, item, action) -> {
|
||||
pl.closeInventory();
|
||||
pl.sendMessage("");
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&ohttps://github.com/TheBusyBiscuit/Slimefun4/issues"));
|
||||
pl.sendMessage("");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.open(p);
|
||||
@ -242,34 +199,22 @@ public class SlimefunGuide {
|
||||
final ChestMenu menu = new ChestMenu("Credits");
|
||||
|
||||
menu.setEmptySlotsClickable(false);
|
||||
menu.addMenuOpeningHandler(new MenuOpeningHandler() {
|
||||
|
||||
@Override
|
||||
public void onOpen(Player p) {
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F);
|
||||
}
|
||||
});
|
||||
menu.addMenuOpeningHandler(
|
||||
pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F)
|
||||
);
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (i != 4) {
|
||||
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
else {
|
||||
menu.addItem(4, new CustomItem(new ItemStack(Material.EMERALD), "&7\u21E6 Back to Settings"));
|
||||
menu.addMenuClickHandler(4, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
openSettings(p, guide);
|
||||
menu.addMenuClickHandler(4, (pl, slot, item, action) -> {
|
||||
openSettings(pl, guide);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -278,7 +223,7 @@ public class SlimefunGuide {
|
||||
|
||||
double total = 0;
|
||||
|
||||
for (Contributor contributor: contributors) {
|
||||
for (Contributor contributor : contributors) {
|
||||
total += contributor.getCommits();
|
||||
}
|
||||
|
||||
@ -299,18 +244,14 @@ public class SlimefunGuide {
|
||||
skull.setItemMeta(meta);
|
||||
|
||||
menu.addItem(index, skull);
|
||||
menu.addMenuClickHandler(index, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
|
||||
if (contributor.getCommits() > 0) {
|
||||
p.closeInventory();
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + contributor.getProfile()));
|
||||
p.sendMessage("");
|
||||
pl.closeInventory();
|
||||
pl.sendMessage("");
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + contributor.getProfile()));
|
||||
pl.sendMessage("");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
index++;
|
||||
@ -318,13 +259,9 @@ public class SlimefunGuide {
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
menu.addItem(36 + i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
|
||||
menu.addMenuClickHandler(36 + i, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(36 + i,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.open(p);
|
||||
@ -482,13 +419,9 @@ public class SlimefunGuide {
|
||||
final ChestMenu menu = new ChestMenu("Slimefun Guide");
|
||||
|
||||
menu.setEmptySlotsClickable(false);
|
||||
menu.addMenuOpeningHandler(new MenuOpeningHandler() {
|
||||
|
||||
@Override
|
||||
public void onOpen(Player p) {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 0.7F);
|
||||
}
|
||||
});
|
||||
menu.addMenuOpeningHandler(
|
||||
pl -> pl.playSound(pl.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 0.7F)
|
||||
);
|
||||
|
||||
List<Category> categories = Slimefun.current_categories;
|
||||
List<GuideHandler> handlers = Slimefun.guide_handlers2;
|
||||
@ -498,24 +431,16 @@ public class SlimefunGuide {
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
for (int i = 45; i < 54; i++) {
|
||||
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
int target = (category_size * (selected_page - 1)) - 1;
|
||||
@ -550,24 +475,18 @@ public class SlimefunGuide {
|
||||
else if (!(category instanceof LockedCategory)) {
|
||||
if (!(category instanceof SeasonCategory)) {
|
||||
menu.addItem(index, category.getItem());
|
||||
menu.addMenuClickHandler(index, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
openCategory(p, category, survival, 1, book);
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
|
||||
openCategory(pl, category, survival, 1, book);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
index++;
|
||||
}
|
||||
else {
|
||||
if (((SeasonCategory) category).isUnlocked()) {
|
||||
menu.addItem(index, category.getItem());
|
||||
menu.addMenuClickHandler(index, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
openCategory(p, category, survival, 1, book);
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
|
||||
openCategory(pl, category, survival, 1, book);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
index++;
|
||||
}
|
||||
@ -575,12 +494,9 @@ public class SlimefunGuide {
|
||||
}
|
||||
else if (((LockedCategory) category).hasUnlocked(p)) {
|
||||
menu.addItem(index, category.getItem());
|
||||
menu.addMenuClickHandler(index, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
openCategory(p, category, survival, 1, book);
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
|
||||
openCategory(pl, category, survival, 1, book);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
index++;
|
||||
}
|
||||
@ -590,16 +506,13 @@ public class SlimefunGuide {
|
||||
parents.add(ChatColor.translateAlternateColorCodes('&', "&rYou need to unlock all Items"));
|
||||
parents.add(ChatColor.translateAlternateColorCodes('&', "&rfrom the following Categories first:"));
|
||||
parents.add("");
|
||||
for (Category parent: ((LockedCategory) category).getParents()) {
|
||||
for (Category parent : ((LockedCategory) category).getParents()) {
|
||||
parents.add(parent.getItem().getItemMeta().getDisplayName());
|
||||
}
|
||||
menu.addItem(index, new CustomItem(Material.BARRIER, "&4LOCKED &7- &r" + category.getItem().getItemMeta().getDisplayName(), 0, parents.toArray(new String[parents.size()])));
|
||||
menu.addMenuClickHandler(index, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(index,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@ -608,25 +521,19 @@ public class SlimefunGuide {
|
||||
final int finalPages = pages;
|
||||
|
||||
menu.addItem(46, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), "&r\u21E6 Previous Page", "", "&7(" + selected_page + " / " + pages + ")"));
|
||||
menu.addMenuClickHandler(46, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
|
||||
int next = selected_page - 1;
|
||||
if (next < 1) next = finalPages;
|
||||
if (next != selected_page) openMainMenu(p, survival, book, next);
|
||||
if (next != selected_page) openMainMenu(pl, survival, book, next);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(52, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), "&rNext Page \u21E8", "", "&7(" + selected_page + " / " + pages + ")"));
|
||||
menu.addMenuClickHandler(52, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(52, (pl, slot, item, action) -> {
|
||||
int next = selected_page + 1;
|
||||
if (next > finalPages) next = 1;
|
||||
if (next != selected_page) openMainMenu(p, survival, book, next);
|
||||
if (next != selected_page) openMainMenu(pl, survival, book, next);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.open(p);
|
||||
@ -692,7 +599,7 @@ public class SlimefunGuide {
|
||||
tooltip.append(StringUtils.formatItemName(item.getItem(), false));
|
||||
|
||||
if (item.getItem().hasItemMeta() && item.getItem().getItemMeta().hasLore()) {
|
||||
for (String line: item.getItem().getItemMeta().getLore()) {
|
||||
for (String line : item.getItem().getItemMeta().getLore()) {
|
||||
tooltip.append("\n" + line);
|
||||
}
|
||||
}
|
||||
@ -745,74 +652,53 @@ public class SlimefunGuide {
|
||||
final ChestMenu menu = new ChestMenu("Slimefun Guide");
|
||||
|
||||
menu.setEmptySlotsClickable(false);
|
||||
menu.addMenuOpeningHandler(new MenuOpeningHandler() {
|
||||
@Override
|
||||
public void onOpen(Player p) {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 0.7F);
|
||||
}
|
||||
});
|
||||
menu.addMenuOpeningHandler(
|
||||
pl -> pl.playSound(pl.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 0.7F)
|
||||
);
|
||||
|
||||
int index = 9;
|
||||
final int pages = (category.getItems().size() - 1) / category_size + 1;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.addItem(4, new CustomItem(new ItemStack(Material.ENCHANTED_BOOK), "&7\u21E6 Back"));
|
||||
menu.addMenuClickHandler(4, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
openMainMenu(p, survival, book, 1);
|
||||
menu.addMenuClickHandler(4, (pl, slot, item, action) -> {
|
||||
openMainMenu(pl, survival, book, 1);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 5; i < 9; i++) {
|
||||
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
for (int i = 45; i < 54; i++) {
|
||||
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
menu.addItem(46, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), "&r\u21E6 Previous Page", "", "&7(" + selected_page + " / " + pages + ")"));
|
||||
menu.addMenuClickHandler(46, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
|
||||
int next = selected_page - 1;
|
||||
if (next < 1) next = pages;
|
||||
if (next != selected_page) openCategory(p, category, survival, next, book);
|
||||
if (next != selected_page) openCategory(pl, category, survival, next, book);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(52, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), "&rNext Page \u21E8", "", "&7(" + selected_page + " / " + pages + ")"));
|
||||
menu.addMenuClickHandler(52, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
menu.addMenuClickHandler(52, (pl, slot, item, action) -> {
|
||||
int next = selected_page + 1;
|
||||
if (next > pages) next = 1;
|
||||
if (next != selected_page) openCategory(p, category, survival, next, book);
|
||||
if (next != selected_page) openCategory(pl, category, survival, next, book);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int category_index = category_size * (selected_page - 1);
|
||||
@ -825,55 +711,46 @@ public class SlimefunGuide {
|
||||
if (Slimefun.hasPermission(p, sfitem, false)) {
|
||||
final Research research = sfitem.getResearch();
|
||||
menu.addItem(index, new CustomItem(Material.BARRIER, "&r" + StringUtils.formatItemName(sfitem.getItem(), false), 0, new String[] {"&4&lLOCKED", "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level"}));
|
||||
menu.addMenuClickHandler(index, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(final Player p, int slot, ItemStack item, ClickAction action) {
|
||||
if (!Research.isResearching(p)) {
|
||||
if (research.canUnlock(p)) {
|
||||
if (research.hasUnlocked(p))
|
||||
openCategory(p, category, true, selected_page, book);
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
|
||||
if (!Research.isResearching(pl)) {
|
||||
if (research.canUnlock(pl)) {
|
||||
if (research.hasUnlocked(pl))
|
||||
openCategory(pl, category, true, selected_page, book);
|
||||
else {
|
||||
if (!(p.getGameMode() == GameMode.CREATIVE && Research.creative_research)) {
|
||||
p.setLevel(p.getLevel() - research.getCost());
|
||||
if (!(pl.getGameMode() == GameMode.CREATIVE && Research.creative_research)) {
|
||||
pl.setLevel(pl.getLevel() - research.getCost());
|
||||
}
|
||||
|
||||
if (p.getGameMode() == GameMode.CREATIVE) {
|
||||
research.unlock(p, Research.creative_research);
|
||||
openCategory(p, category, survival, selected_page, book);
|
||||
if (pl.getGameMode() == GameMode.CREATIVE) {
|
||||
research.unlock(pl, Research.creative_research);
|
||||
openCategory(pl, category, survival, selected_page, book);
|
||||
} else {
|
||||
research.unlock(p, false);
|
||||
research.unlock(pl, false);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, () -> {
|
||||
openCategory(p, category, survival, selected_page, book);
|
||||
openCategory(pl, category, survival, selected_page, book);
|
||||
}, 103L);
|
||||
}
|
||||
}
|
||||
} else Messages.local.sendTranslation(p, "messages.not-enough-xp", true);
|
||||
} else Messages.local.sendTranslation(pl, "messages.not-enough-xp", true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
index++;
|
||||
}
|
||||
else {
|
||||
menu.addItem(index, new CustomItem(Material.BARRIER, StringUtils.formatItemName(sfitem.getItem(), false), 0, new String[] {"", "&rYou do not have Permission", "&rto access this Item"}));
|
||||
menu.addMenuClickHandler(index, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(index,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
menu.addItem(index, sfitem.getItem());
|
||||
menu.addMenuClickHandler(index, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
if (survival) displayItem(p, item, true, book, 0);
|
||||
else p.getInventory().addItem(item);
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
|
||||
if (survival) displayItem(pl, item, true, book, 0);
|
||||
else pl.getInventory().addItem(item);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
index++;
|
||||
}
|
||||
@ -923,12 +800,9 @@ public class SlimefunGuide {
|
||||
ChestMenu menu = new ChestMenu("Slimefun Guide");
|
||||
|
||||
menu.setEmptySlotsClickable(false);
|
||||
menu.addMenuOpeningHandler(new MenuOpeningHandler() {
|
||||
@Override
|
||||
public void onOpen(Player p) {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 0.7F);
|
||||
}
|
||||
});
|
||||
menu.addMenuOpeningHandler(
|
||||
pl -> pl.playSound(pl.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 0.7F)
|
||||
);
|
||||
|
||||
if (sfItem != null) {
|
||||
recipe = sfItem.getRecipe();
|
||||
@ -948,12 +822,9 @@ public class SlimefunGuide {
|
||||
|
||||
if (recipes.size() > page + 1) {
|
||||
menu.addItem(1, new CustomItem(new ItemStack(Material.ENCHANTED_BOOK), "&7Next \u21E8", "", "&e&l! &rThere are multiple recipes for this Item"));
|
||||
menu.addMenuClickHandler(1, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) {
|
||||
displayItem(p, item, false, book, page + 1);
|
||||
menu.addMenuClickHandler(1, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, false, book, page + 1);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -989,72 +860,54 @@ public class SlimefunGuide {
|
||||
|
||||
if (history.containsKey(p.getUniqueId()) && history.get(p.getUniqueId()).size() > 1) {
|
||||
menu.addItem(0, new CustomItem(new ItemStack(Material.ENCHANTED_BOOK), "&7\u21E6 Back", "", "&rLeft Click: &7Go back to previous Page", "&rShift + left Click: &7Go back to Main Menu"));
|
||||
menu.addMenuClickHandler(0, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
menu.addMenuClickHandler(0, (pl, slot, itemstack, action) -> {
|
||||
if (action.isShiftClicked()) openMainMenu(p, true, book, 1);
|
||||
else {
|
||||
URID last = getLastEntry(p, true);
|
||||
if (URID.decode(last) instanceof Category) openCategory(p, (Category) URID.decode(last), true, 1, book);
|
||||
else if (URID.decode(last) instanceof SlimefunItem) displayItem(p, ((SlimefunItem) URID.decode(last)).getItem(), false, book, 0);
|
||||
else if (URID.decode(last) instanceof GuideHandler) ((GuideHandler) URID.decode(last)).run(p, true, book);
|
||||
else displayItem(p, (ItemStack) URID.decode(last), false, book, 0);
|
||||
URID last = getLastEntry(pl, true);
|
||||
if (URID.decode(last) instanceof Category) openCategory(pl, (Category) URID.decode(last), true, 1, book);
|
||||
else if (URID.decode(last) instanceof SlimefunItem) displayItem(pl, ((SlimefunItem) URID.decode(last)).getItem(), false, book, 0);
|
||||
else if (URID.decode(last) instanceof GuideHandler) ((GuideHandler) URID.decode(last)).run(pl, true, book);
|
||||
else displayItem(pl, (ItemStack) URID.decode(last), false, book, 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.addItem(0, new CustomItem(new ItemStack(Material.ENCHANTED_BOOK), "&7\u21E6 Back", "", "&rLeft Click: &7Go back to Main Menu"));
|
||||
menu.addMenuClickHandler(0, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
openMainMenu(p, true, book, 1);
|
||||
menu.addMenuClickHandler(0, (pl, slot, itemstack, action) -> {
|
||||
openMainMenu(pl, true, book, 1);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
menu.addItem(3, Slimefun.hasUnlocked(p, recipe[0], false) ? recipe[0]: new CustomItem(Material.BARRIER, StringUtils.formatItemName(recipe[0], false), 0, new String[] {"&4&lLOCKED", "", Slimefun.hasPermission(p, SlimefunItem.getByItem(recipe[0]), false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission"}));
|
||||
menu.addMenuClickHandler(3, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(3, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(4, Slimefun.hasUnlocked(p, recipe[1], false) ? recipe[1]: new CustomItem(Material.BARRIER, StringUtils.formatItemName(recipe[1], false), 0, new String[] {"&4&lLOCKED", "", Slimefun.hasPermission(p, SlimefunItem.getByItem(recipe[1]), false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission"}));
|
||||
menu.addMenuClickHandler(4, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(4, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(5, Slimefun.hasUnlocked(p, recipe[2], false) ? recipe[2]: new CustomItem(Material.BARRIER, StringUtils.formatItemName(recipe[2], false), 0, new String[] {"&4&lLOCKED", "", Slimefun.hasPermission(p, SlimefunItem.getByItem(recipe[2]), false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission"}));
|
||||
menu.addMenuClickHandler(5, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(5, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (sfItem != null) {
|
||||
if (Slimefun.getItemConfig().contains(sfItem.getID() + ".wiki")) {
|
||||
try {
|
||||
menu.addItem(8, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzY2OTJmOTljYzZkNzgyNDIzMDQxMTA1NTM1ODk0ODQyOThiMmU0YTAyMzNiNzY3NTNmODg4ZTIwN2VmNSJ9fX0="), "&rView this Item in our Wiki &7(Slimefun Wiki)", "", "&7\u21E8 Click to open"));
|
||||
menu.addMenuClickHandler(8, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
p.closeInventory();
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(sfItem.getID() + ".wiki")));
|
||||
p.sendMessage("");
|
||||
menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> {
|
||||
pl.closeInventory();
|
||||
pl.sendMessage("");
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(sfItem.getID() + ".wiki")));
|
||||
pl.sendMessage("");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -1063,15 +916,12 @@ public class SlimefunGuide {
|
||||
if (Slimefun.getItemConfig().contains(sfItem.getID() + ".youtube")) {
|
||||
try {
|
||||
menu.addItem(7, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzNTNmZDBmODYzMTQzNTM4NzY1ODYwNzViOWJkZjBjNDg0YWFiMDMzMWI4NzJkZjExYmQ1NjRmY2IwMjllZCJ9fX0="), "&rDemonstration Video &7(Youtube)", "", "&7\u21E8 Click to watch"));
|
||||
menu.addMenuClickHandler(7, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
p.closeInventory();
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(sfItem.getID() + ".youtube")));
|
||||
p.sendMessage("");
|
||||
menu.addMenuClickHandler(7, (pl, slot, itemstack, action) -> {
|
||||
pl.closeInventory();
|
||||
pl.sendMessage("");
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(sfItem.getID() + ".youtube")));
|
||||
pl.sendMessage("");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -1080,88 +930,61 @@ public class SlimefunGuide {
|
||||
}
|
||||
|
||||
menu.addItem(10, recipeType);
|
||||
menu.addMenuClickHandler(10, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(10,
|
||||
(pl, slot, itemstack, action) -> false
|
||||
);
|
||||
|
||||
menu.addItem(12, Slimefun.hasUnlocked(p, recipe[3], false) ? recipe[3]: new CustomItem(Material.BARRIER, StringUtils.formatItemName(recipe[3], false), 0, new String[] {"&4&lLOCKED", "", Slimefun.hasPermission(p, SlimefunItem.getByItem(recipe[3]), false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission"}));
|
||||
menu.addMenuClickHandler(12, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(12, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(13, Slimefun.hasUnlocked(p, recipe[4], false) ? recipe[4]: new CustomItem(Material.BARRIER, StringUtils.formatItemName(recipe[4], false), 0, new String[] {"&4&lLOCKED", "", Slimefun.hasPermission(p, SlimefunItem.getByItem(recipe[4]), false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission"}));
|
||||
menu.addMenuClickHandler(13, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(13, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(14, Slimefun.hasUnlocked(p, recipe[5], false) ? recipe[5]: new CustomItem(Material.BARRIER, StringUtils.formatItemName(recipe[5], false), 0, new String[] {"&4&lLOCKED", "", Slimefun.hasPermission(p, SlimefunItem.getByItem(recipe[5]), false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission"}));
|
||||
menu.addMenuClickHandler(14, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(14, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(16, recipeOutput);
|
||||
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(16,
|
||||
(pl, slot, itemstack, action) -> false
|
||||
);
|
||||
|
||||
menu.addItem(21, Slimefun.hasUnlocked(p, recipe[6], false) ? recipe[6]: new CustomItem(Material.BARRIER, StringUtils.formatItemName(recipe[6], false), 0, new String[] {"&4&lLOCKED", "", Slimefun.hasPermission(p, SlimefunItem.getByItem(recipe[6]), false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission"}));
|
||||
menu.addMenuClickHandler(21, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(21, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(22, Slimefun.hasUnlocked(p, recipe[7], false) ? recipe[7]: new CustomItem(Material.BARRIER, StringUtils.formatItemName(recipe[7], false), 0, new String[] {"&4&lLOCKED", "", Slimefun.hasPermission(p, SlimefunItem.getByItem(recipe[7]), false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission"}));
|
||||
menu.addMenuClickHandler(22, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(22, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(23, Slimefun.hasUnlocked(p, recipe[8], false) ? recipe[8]: new CustomItem(Material.BARRIER, StringUtils.formatItemName(recipe[8], false), 0, new String[] {"&4&lLOCKED", "", Slimefun.hasPermission(p, SlimefunItem.getByItem(recipe[8]), false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission"}));
|
||||
menu.addMenuClickHandler(23, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(23, (pl, slot, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (sfItem != null) {
|
||||
if ((sfItem instanceof SlimefunMachine && ((SlimefunMachine) sfItem).getDisplayRecipes().size() > 0) || (sfItem instanceof SlimefunGadget && ((SlimefunGadget) sfItem).getRecipes().size() > 0)) {
|
||||
for (int i = 27; i < 36; i++) {
|
||||
menu.addItem(i, new CustomItem(Material.LIME_STAINED_GLASS_PANE, SlimefunItem.getByItem(item) instanceof SlimefunMachine ? "&7\u21E9 Recipes made in this Machine \u21E9": " ", 7));
|
||||
menu.addMenuClickHandler(i, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(i,
|
||||
(pl, slot, itemstack, action) -> false
|
||||
);
|
||||
}
|
||||
|
||||
List<ItemStack> recipes = SlimefunItem.getByItem(item) instanceof SlimefunMachine ? ((SlimefunMachine) SlimefunItem.getByItem(item)).getDisplayRecipes(): ((SlimefunGadget) SlimefunItem.getByItem(item)).getDisplayRecipes();
|
||||
List<ItemStack> recipes = SlimefunItem.getByItem(item) instanceof SlimefunMachine ? ((SlimefunMachine) SlimefunItem.getByItem(item)).getDisplayRecipes() : ((SlimefunGadget) SlimefunItem.getByItem(item)).getDisplayRecipes();
|
||||
int recipe_size = recipes.size();
|
||||
if (recipe_size > 18) recipe_size = 18;
|
||||
int inputs = -1, outputs = -1;
|
||||
@ -1177,12 +1000,9 @@ public class SlimefunGuide {
|
||||
int addition = (i % 2 == 0 ? inputs: outputs);
|
||||
|
||||
menu.addItem(slot + addition, recipes.get(i));
|
||||
menu.addMenuClickHandler(slot + addition, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
displayItem(p, item, true, book, 0);
|
||||
menu.addMenuClickHandler(slot + addition, (pl, slotn, itemstack, action) -> {
|
||||
displayItem(pl, itemstack, true, book, 0);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1199,12 +1019,9 @@ public class SlimefunGuide {
|
||||
im.setLore(lore);
|
||||
fItem.setItemMeta(im);
|
||||
menu.addItem(slot, fItem);
|
||||
menu.addMenuClickHandler(slot, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
menu.addMenuClickHandler(slot,
|
||||
(pl, slotn, itemstack, action) -> false
|
||||
);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
@ -1221,11 +1038,8 @@ public class SlimefunGuide {
|
||||
im.setLore(lore);
|
||||
fItem.setItemMeta(im);
|
||||
menu.addItem(slot, fItem);
|
||||
menu.addMenuClickHandler(slot, new MenuClickHandler() {
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) {
|
||||
menu.addMenuClickHandler(slot, (pl, slotn, itemstack, action) -> {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
slot++;
|
||||
}
|
||||
|
@ -16,14 +16,12 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunStartup;
|
||||
@ -49,13 +47,7 @@ public class CargoNet extends Network {
|
||||
private static final ChestTerminalSorter sorter = new ChestTerminalSorter();
|
||||
public static final int[] terminal_slots = new int[] {0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42};
|
||||
private static final ItemStack terminal_noitem_item = new CustomItem(new ItemStack(Material.BARRIER), "&4No Item cached");
|
||||
private static final MenuClickHandler terminal_noitem_handler = new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
private static final MenuClickHandler terminal_noitem_handler = (p, slot, item, action) -> false;
|
||||
|
||||
public static CargoNet getNetworkFromLocation(Location l) {
|
||||
return getNetworkFromLocation(l, CargoNet.class);
|
||||
@ -201,7 +193,7 @@ public class CargoNet extends Network {
|
||||
}
|
||||
//Chest Terminal Code
|
||||
if (EXTRA_CHANNELS) {
|
||||
for (Location bus: imports) {
|
||||
for (Location bus : imports) {
|
||||
BlockMenu menu = BlockStorage.getInventory(bus);
|
||||
|
||||
if (menu.getItemInSlot(17) == null) {
|
||||
@ -218,7 +210,7 @@ public class CargoNet extends Network {
|
||||
}
|
||||
}
|
||||
|
||||
for (Location bus: exports) {
|
||||
for (Location bus : exports) {
|
||||
BlockMenu menu = BlockStorage.getInventory(bus);
|
||||
|
||||
if (menu.getItemInSlot(17) != null) {
|
||||
@ -284,7 +276,7 @@ public class CargoNet extends Network {
|
||||
ItemStack stack = null;
|
||||
ItemStack requested = request.getItem();
|
||||
nodes:
|
||||
for (Location l: providers) {
|
||||
for (Location l : providers) {
|
||||
Block target = getAttachedBlock(l.getBlock());
|
||||
ItemStack is = CargoManager.withdraw(l.getBlock(), storage, target, requested);
|
||||
if (is != null) {
|
||||
@ -365,7 +357,7 @@ public class CargoNet extends Network {
|
||||
}
|
||||
|
||||
destinations:
|
||||
for (Location out: outputlist) {
|
||||
for (Location out : outputlist) {
|
||||
Block target = getAttachedBlock(out.getBlock());
|
||||
if (target != null) {
|
||||
stack = CargoManager.insert(out.getBlock(), storage, target, stack, -1);
|
||||
@ -504,13 +496,9 @@ public class CargoNet extends Network {
|
||||
im.setLore(lore);
|
||||
stack.setItemMeta(im);
|
||||
menu.replaceExistingItem(slot, stack);
|
||||
menu.addMenuClickHandler(slot, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int slot, ItemStack is, ClickAction action) {
|
||||
menu.addMenuClickHandler(slot, (p, sl, is, action) -> {
|
||||
requests.add(new ItemRequest(l, 44, new CustomItem(item.getItem(), action.isRightClicked() ? (item.getAmount() > item.getItem().getMaxStackSize() ? item.getItem().getMaxStackSize(): item.getAmount()): 1), ItemTransportFlow.WITHDRAW));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@ -544,4 +532,5 @@ public class CargoNet extends Network {
|
||||
} catch (Exception e) {}
|
||||
return freq;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,10 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuHelper;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuHelper.ChatHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.ArmorStandFactory;
|
||||
@ -27,7 +24,7 @@ public class Projector {
|
||||
double offset = Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), "offset"));
|
||||
Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5);
|
||||
|
||||
for (Entity n: l.getChunk().getEntities()) {
|
||||
for (Entity n : l.getChunk().getEntities()) {
|
||||
if (n instanceof ArmorStand) {
|
||||
if (n.getCustomName() != null && n.getCustomName().equals(nametag) && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
|
||||
}
|
||||
@ -42,40 +39,28 @@ public class Projector {
|
||||
ChestMenu menu = new ChestMenu("Hologram Settings");
|
||||
|
||||
menu.addItem(0, new CustomItem(new ItemStack(Material.NAME_TAG), "&7Text &e(Click to edit)", "", "&r" + ChatColor.translateAlternateColorCodes('&', BlockStorage.getLocationInfo(projector.getLocation(), "text"))));
|
||||
menu.addMenuClickHandler(0, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
p.closeInventory();
|
||||
Messages.local.sendTranslation(p, "machines.HOLOGRAM_PROJECTOR.enter-text", true);
|
||||
MenuHelper.awaitChatInput(p, new ChatHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onChat(Player p, String message) {
|
||||
menu.addMenuClickHandler(0, (pl, slot, item, action) -> {
|
||||
pl.closeInventory();
|
||||
Messages.local.sendTranslation(pl, "machines.HOLOGRAM_PROJECTOR.enter-text", true);
|
||||
MenuHelper.awaitChatInput(pl, (player, message) -> {
|
||||
ArmorStand hologram = getArmorStand(projector);
|
||||
hologram.setCustomName(ChatColor.translateAlternateColorCodes('&', message));
|
||||
BlockStorage.addBlockInfo(projector, "text", message);
|
||||
openEditor(p, projector);
|
||||
openEditor(player, projector);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.addItem(1, new CustomItem(new ItemStack(Material.CLOCK), "&7Offset: &e" + DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), "offset")) + 1.0D), "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
|
||||
menu.addMenuClickHandler(1, new MenuClickHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
double offset = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), "offset")) + (arg3.isRightClicked() ? -0.1F: 0.1F));
|
||||
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
|
||||
double offset = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), "offset")) + (action.isRightClicked() ? -0.1F : 0.1F));
|
||||
ArmorStand hologram = getArmorStand(projector);
|
||||
Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5);
|
||||
hologram.teleport(l);
|
||||
BlockStorage.addBlockInfo(projector, "offset", String.valueOf(offset));
|
||||
openEditor(p, projector);
|
||||
openEditor(pl, projector);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
menu.open(p);
|
||||
|
Loading…
Reference in New Issue
Block a user