Merge branch 'development'

This commit is contained in:
Brianna 2019-10-13 18:51:17 -04:00
commit a0abaa6618
7 changed files with 86 additions and 19 deletions

View File

@ -4,7 +4,7 @@ stages:
variables:
name: "EpicHoppers"
path: "/builds/$CI_PROJECT_PATH"
version: "4.3.2"
version: "4.3.3"
build:
stage: build

View File

@ -142,6 +142,8 @@ public class GUIOverview extends Gui {
layouts.put(6, new Integer[]{23, 3, 4, 5, 21, 22});
layouts.put(7, new Integer[]{23, 3, 4, 5, 21, 22, 12});
layouts.put(8, new Integer[]{23, 3, 4, 5, 21, 22, 12, 14});
layouts.put(9, new Integer[]{23, 3, 4, 5, 21, 22, 12, 14, 20});
layouts.put(10, new Integer[]{23, 3, 4, 5, 21, 22, 12, 14, 20, 24});
int amount = 1;
@ -174,6 +176,12 @@ public class GUIOverview extends Gui {
plugin.getPlayerDataManager().getPlayerData(player).setSyncType(SyncType.REGULAR);
hopper.clearLinkedBlocks();
plugin.getLocale().getMessage("event.hopper.syncnext").sendPrefixedMessage(player);
if (level.getLinkAmount() > 1)
plugin.getLocale().getMessage("event.hopper.syncstart")
.processPlaceholder("amount", level.getLinkAmount())
.sendPrefixedMessage(player);
hopper.timeout(player);
}
player.closeInventory();

View File

@ -30,6 +30,8 @@ public class Hopper {
private TeleportTrigger teleportTrigger = TeleportTrigger.DISABLED;
private int transferTick = 0;
private int syncId = -1;
private final Map<String, Object> moduleCache = new HashMap<>();
public Hopper(Location location) {
@ -118,7 +120,7 @@ public class Hopper {
public void timeout(Player player) {
EpicHoppers instance = EpicHoppers.getInstance();
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
syncId = Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
if (playerData.getSyncType() != null && playerData.getLastHopper() == this) {
instance.getLocale().getMessage("event.hopper.synctimeout").sendPrefixedMessage(player);
@ -164,7 +166,7 @@ public class Hopper {
return;
}
instance.getLocale().getMessage("event.hopper.syncsuccess").sendPrefixedMessage(player);
instance.getPlayerDataManager().getPlayerData(player).setSyncType(null);
cancelSync(player);
}
/**
@ -286,4 +288,9 @@ public class Hopper {
public void clearModuleCache() {
this.moduleCache.clear();
}
public void cancelSync(Player player) {
Bukkit.getScheduler().cancelTask(syncId);
EpicHoppers.getInstance().getPlayerDataManager().getPlayerData(player).setSyncType(null);
}
}

View File

@ -1,7 +1,9 @@
package com.songoda.epichoppers.hopper.levels.modules;
import com.bgsoftware.wildstacker.api.WildStackerAPI;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.locale.Locale;
import com.songoda.epichoppers.EpicHoppers;
import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.utils.Methods;
@ -15,6 +17,7 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -25,9 +28,9 @@ import java.util.stream.Collectors;
public class ModuleSuction extends Module {
private final int searchRadius;
private final int maxSearchRadius;
public static List<UUID> blacklist = new ArrayList<>();
private static List<UUID> blacklist = new ArrayList<>();
private final static boolean wildStacker = Bukkit.getPluginManager().isPluginEnabled("WildStacker");
private final static boolean ultimateStacker = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker");
@ -48,7 +51,7 @@ public class ModuleSuction extends Module {
public ModuleSuction(EpicHoppers plugin, int amount) {
super(plugin);
this.searchRadius = amount;
this.maxSearchRadius = amount;
}
@Override
@ -58,7 +61,9 @@ public class ModuleSuction extends Module {
@Override
public void run(Hopper hopper, StorageContainerCache.Cache hopperCache) {
double radius = searchRadius + .5;
double radius = getRadius(hopper) + .5;
if (!isEnabled(hopper)) return;
Set<Item> itemsToSuck = hopper.getLocation().getWorld().getNearbyEntities(hopper.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius)
.stream()
@ -162,8 +167,7 @@ public class ModuleSuction extends Module {
} else if (wildStacker)
WildStackerAPI.getStackedItem(item).setStackAmount(amount, true);
else
item.getItemStack().setAmount(amount > item.getItemStack().getMaxStackSize()
? item.getItemStack().getMaxStackSize() : amount);
item.getItemStack().setAmount(Math.min(amount, item.getItemStack().getMaxStackSize()));
}
public static boolean isBlacklisted(UUID uuid) {
@ -172,11 +176,53 @@ public class ModuleSuction extends Module {
@Override
public ItemStack getGUIButton(Hopper hopper) {
return null;
Locale locale = EpicHoppers.getInstance().getLocale();
ItemStack item = CompatibleMaterial.CAULDRON.getItem();
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(locale.getMessage("interface.hopper.suctiontitle").getMessage());
List<String> lore = new ArrayList<>();
String[] parts = locale.getMessage("interface.hopper.suctionlore")
.processPlaceholder("status", isEnabled(hopper) ? locale.getMessage("general.word.enabled").getMessage() : locale.getMessage("general.word.disabled"))
.processPlaceholder("radius", getRadius(hopper)).getMessage().split("\\|");
for (String line : parts) {
lore.add(Methods.formatText(line));
}
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
@Override
public void runButtonPress(Player player, Hopper hopper, ClickType type) {
if (type == ClickType.LEFT) {
toggleEnabled(hopper);
} else if (type == ClickType.RIGHT) {
int setRadius = getRadius(hopper);
if (setRadius >= maxSearchRadius) {
setRadius(hopper, 1);
} else {
setRadius(hopper, ++setRadius);
}
}
}
private boolean isEnabled(Hopper hopper) {
Object obj = getData(hopper, "enabled");
return obj == null || (boolean) obj;
}
private void toggleEnabled(Hopper hopper) {
saveData(hopper, "enabled", !isEnabled(hopper));
}
private int getRadius(Hopper hopper) {
Object foundRadius = getData(hopper, "radius");
return foundRadius == null ? maxSearchRadius : (int) foundRadius;
}
private void setRadius(Hopper hopper, int radius) {
saveData(hopper, "radius", radius);
}
@Override
@ -187,6 +233,6 @@ public class ModuleSuction extends Module {
@Override
public String getDescription() {
return EpicHoppers.getInstance().getLocale().getMessage("interface.hopper.suction")
.processPlaceholder("suction", searchRadius).getMessage();
.processPlaceholder("suction", maxSearchRadius).getMessage();
}
}

View File

@ -102,7 +102,11 @@ public class InteractListeners implements Listener {
if (e.getClickedBlock().getState() instanceof InventoryHolder || (e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && instance.getConfig().getBoolean("Main.Support Enderchests"))) {
Hopper hopper = playerData.getLastHopper();
if (playerData.getSyncType() != null && e.getClickedBlock().getLocation().equals(playerData.getLastHopper().getLocation())) {
instance.getLocale().getMessage("event.hopper.syncself").sendPrefixedMessage(player);
if (hopper.getLinkedBlocks().size() != 0)
instance.getLocale().getMessage("event.hopper.syncfinish").sendPrefixedMessage(player);
else
instance.getLocale().getMessage("event.hopper.synccanceled").sendPrefixedMessage(player);
hopper.cancelSync(player);
} else if (playerData.getSyncType() != null) {
hopper.link(e.getClickedBlock(), playerData.getSyncType() == SyncType.FILTERED, player);
}

View File

@ -94,7 +94,6 @@ public class StorageYaml extends Storage {
}
for (Map.Entry<String, Object> entry : toSave.entrySet()) {
System.out.println(entry.getKey());
dataFile.set(entry.getKey(), entry.getValue());
}

View File

@ -1,4 +1,4 @@
#General Messages
# General Messages
general.nametag.prefix = "&7[&6EpicHoppers&7]"
general.nametag.next = "&9Next"
@ -8,7 +8,7 @@ general.nametag.lore = ""
general.word.disabled = "DISABLED"
general.word.enabled = "ENABLED"
#Interface Messages
# Interface Messages
interface.hopper.boostedstats = "&a&lCurrently boosted!|&7Item transfer rate multiplied by &6%amount%x&7.|&7Expires in &6%time%&7."
interface.hopper.upgradewithxp = "&aUpgrade with XP"
@ -38,6 +38,8 @@ interface.hopper.selltitle = "&6Left-Click to Toggle AutoSelling"
interface.hopper.selllore = "&6Right-Click to Toggle Notifications||&7Selling in &6%timeleft%s&7.|&7Notifications: &6%state%&7."
interface.hopper.blocktitle = "&6Click to Toggle BlockBreak"
interface.hopper.blocklore = "|&7BlockBreak is set to &6%enabled%&7."
interface.hopper.suctiontitle = "&6Suction"
interface.hopper.suctionlore = "|&7Left-Click to toggle suction |&7(&6%status%&7).||&7Right-Click to set radius |&7(&6%radius%&7)."
interface.hopper.synchopper = "&6Click to Link This hopper"
interface.hopper.rejectsync = "&6Click to Link Rejected Items"
interface.filter.infotitle = "&aFilter Guide"
@ -46,11 +48,11 @@ interface.filter.whitelist = "&f&lWhite List"
interface.filter.blacklist = "&8&lBlack List"
interface.filter.void = "&c&lVoid"
#Command Messages
# Command Messages
command.give.success = "&7You have been given a &6level %level% &7Hopper."
#Event Messages
# Event Messages
event.general.nopermission = "&cYou do not have permission to do that."
event.upgrade.cannotafford = "&cYou cannot afford this upgrade."
@ -61,10 +63,12 @@ event.hopper.syncsuccess = "&aLink Successful."
event.hopper.syncsuccessmore = "&7You have &6%amount% &7more link(s) left."
event.hopper.desync = "&7You have unlinked this hopper."
event.hopper.syncnext = "&7Click another hopper or container to link."
event.hopper.syncself = "&cYou can't link a hopper to itself."
event.hopper.syncdone = "&aYou have maxed out your links."
event.hopper.already = "&cThis hopper is already linked."
event.hopper.synctimeout = "&cLinking timed out."
event.hopper.synccanceled = "&cLinking canceled."
event.hopper.syncstart = "&7You have &6%amount% &7links available. When finished click the original hopper."
event.hopper.syncfinish = "&7Linking completed."
event.hopper.syncoutofrange = "&cThis block is out of your hoppers range."
event.hopper.syncdidnotplace = "&cSorry! You need to have placed this hopper to link things to it."
event.hopper.toomany = "&cYou can only place %amount% hoppers per chunk..."
@ -73,5 +77,4 @@ event.hopper.walkteledisabled = "Walk on teleporting has been disabled for this
event.hopper.onlyone = "&cYou may only place a single item at a time."
event.hopper.syncchest = "&7You have linked your &9%name% &7with this chest."
event.hopper.desyncchest = "&7You have unlinked your &9%name% &7with this chest."
event.hopper.autosell = "&7Your hopper sold &6%items% &7item(s) worth &6$%amount%&7."