Added toggle for blockbreaking & replaced true and false...

with enabled and disabled.
This commit is contained in:
Brianna 2019-04-09 19:01:25 -04:00
parent d811a00e63
commit aab912e9f5
6 changed files with 40 additions and 4 deletions

View File

@ -90,6 +90,17 @@ public class GUIHoppperOverview extends AbstractGUI {
sellmeta.setLore(loresell);
sell.setItemMeta(sellmeta);
ItemStack block = new ItemStack(Material.IRON_ORE, 1);
ItemMeta blockmeta = block.getItemMeta();
blockmeta.setDisplayName(plugin.getLocale().getMessage("interface.hopper.blocktitle"));
ArrayList<String> loreblock = new ArrayList<>();
parts = plugin.getLocale().getMessage("interface.hopper.blocklore", hopper.isAutoBreaking() ? plugin.getLocale().getMessage("general.word.enabled") : plugin.getLocale().getMessage("general.word.disabled")).split("\\|");
for (String line : parts) {
loreblock.add(Methods.formatText(line));
}
blockmeta.setLore(loreblock);
block.setItemMeta(blockmeta);
ItemStack item = new ItemStack(Material.HOPPER, 1);
ItemMeta itemmeta = item.getItemMeta();
@ -160,6 +171,7 @@ public class GUIHoppperOverview extends AbstractGUI {
layouts.put(3, new Integer[]{22, 3, 5});
layouts.put(4, new Integer[]{23, 3, 5, 21});
layouts.put(5, new Integer[]{23, 3, 5, 21, 22});
layouts.put(6, new Integer[]{23, 3, 4, 5, 21, 22});
int amount = 1;
@ -167,10 +179,12 @@ public class GUIHoppperOverview extends AbstractGUI {
boolean canTeleport = level.isTeleport() || player.hasPermission("EpicHoppers.Teleport");
boolean canCraft = level.getRegisteredModules().removeIf(e -> e.getName().equals("AutoCrafting"));
boolean canAutoSell = level.getAutoSell() != 0;
boolean canBreak = level.getRegisteredModules().removeIf(e -> e.getName().equals("BlockBreak"));
if (canFilter) amount++;
if (canTeleport) amount++;
if (canAutoSell) amount++;
if (canCraft) amount++;
if (canBreak) amount++;
Integer[] layout = layouts.get(amount);
@ -191,6 +205,9 @@ public class GUIHoppperOverview extends AbstractGUI {
} else if (canAutoSell) {
inventory.setItem(slot, sell);
canAutoSell = false;
} else if (canBreak) {
inventory.setItem(slot, block);
canBreak = false;
}
}
@ -254,9 +271,13 @@ public class GUIHoppperOverview extends AbstractGUI {
} else {
hopper.setAutoSellTimer(-9999);
}
} else if (inventory.getItem(slot).getItemMeta()
.getDisplayName().equals(plugin.getLocale().getMessage("interface.hopper.craftingtitle"))) {
new GUICrafting(plugin, hopper, player);
} else if (inventory.getItem(slot).getItemMeta()
.getDisplayName().equals(plugin.getLocale().getMessage("interface.hopper.blocktitle"))) {
hopper.toggleAutoBreaking();
} else if (inventory.getItem(slot).getItemMeta()
.getDisplayName().equals(plugin.getLocale().getMessage("interface.hopper.filtertitle"))) {
new GUIFilter(plugin, hopper, player);

View File

@ -34,6 +34,7 @@ public class EHopper implements Hopper {
private TeleportTrigger teleportTrigger;
private Material autoCrafting;
private int autoSellTimer = 0;
private boolean autoBreaking = true;
public EHopper(Location location, Level level, UUID lastPlayer, UUID placedBy, List<Location> linkedBlocks, Filter filter, TeleportTrigger teleportTrigger, Material autoCrafting) {
this.location = location;
@ -269,6 +270,14 @@ public class EHopper implements Hopper {
this.autoSellTimer = autoSellTimer;
}
public boolean isAutoBreaking() {
return autoBreaking;
}
public void toggleAutoBreaking() {
this.autoBreaking = !autoBreaking;
}
@Override
public List<Location> getLinkedBlocks() {
return new ArrayList<>(linkedBlocks);

View File

@ -32,8 +32,8 @@ public class ELevel implements Level {
description.add(instance.getLocale().getMessage("interface.hopper.amount", amount));
if (linkAmount != 1)
description.add(instance.getLocale().getMessage("interface.hopper.linkamount", linkAmount));
if (filter) description.add(instance.getLocale().getMessage("interface.hopper.filter", true));
if (teleport) description.add(instance.getLocale().getMessage("interface.hopper.teleport", true));
if (filter) description.add(instance.getLocale().getMessage("interface.hopper.filter", EpicHoppersPlugin.getInstance().getLocale().getMessage("general.word.enabled")));
if (teleport) description.add(instance.getLocale().getMessage("interface.hopper.teleport", EpicHoppersPlugin.getInstance().getLocale().getMessage("general.word.enabled")));
for (Module module : registeredModules) {
description.add(module.getDescription());

View File

@ -131,7 +131,7 @@ public class ModuleAutoCrafting implements Module {
@Override
public String getDescription() {
return EpicHoppersPlugin.getInstance().getLocale().getMessage("interface.hopper.crafting", true);
return EpicHoppersPlugin.getInstance().getLocale().getMessage("interface.hopper.crafting", EpicHoppersPlugin.getInstance().getLocale().getMessage("general.word.enabled"));
}
private boolean canMove(Inventory inventory, ItemStack item) {

View File

@ -3,6 +3,7 @@ package com.songoda.epichoppers.hopper.levels.modules;
import com.songoda.epichoppers.EpicHoppersPlugin;
import com.songoda.epichoppers.api.hopper.Hopper;
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
import com.songoda.epichoppers.hopper.EHopper;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
@ -31,6 +32,8 @@ public class ModuleBlockBreak implements Module {
public void run(Hopper hopper, org.bukkit.block.Hopper hopperBlock) {
Block block = hopper.getLocation().getBlock();
if (!((EHopper)hopper).isAutoBreaking()) return;
if (!blockTick.containsKey(block)) {
blockTick.put(block, 1);
return;

View File

@ -6,6 +6,7 @@ general.nametag.back = "&9Back"
general.nametag.nameformat = "&eLevel %level% &fHopper"
general.nametag.lore = ""
general.word.disabled = "DISABLED"
general.word.enabled = "ENABLED"
#Interface Messages
@ -32,9 +33,11 @@ interface.hopper.perllore2 = "|&7Left-Click to teleport to|&7the end of the chai
interface.hopper.filtertitle = "&cClick to Filter"
interface.hopper.filterlore = "|&7This allows you to choose|&7which items go where."
interface.hopper.craftingtitle = "&cClick to Setup AutoCrafting"
interface.hopper.craftinglore = "|&7This allows you to choose|&7which item this hopper|&7will automaticly craft."
interface.hopper.craftinglore = "|&7This allows you to choose|&7which item this hopper|&7will automatically craft."
interface.hopper.selltitle = "&6Click to Toggle AutoSelling"
interface.hopper.selllore = "|&7Selling in &6%timeleft%s&7."
interface.hopper.blocktitle = "&6Click to Toggle BlockBreak"
interface.hopper.blocklore = "|&7BlockBreak is set to &6%enabled%&7."
interface.hopper.synchopper = "&6Click to Link This hopper"
interface.hopper.rejectsync = "&6Click to Link Rejected Items"
interface.filter.infotitle = "&aFilter Guide"