Merge branch 'development' into 'master'

4-pre-release-7

See merge request Songoda/epichoppers!41
This commit is contained in:
Esophose 2019-06-05 16:09:07 +00:00
commit 75067932ba
6 changed files with 43 additions and 22 deletions

View File

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

View File

@ -103,5 +103,10 @@
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.brcdev</groupId>
<artifactId>ShopGUIPlus</artifactId>
<version>1.19.5</version>
</dependency>
</dependencies>
</project>

View File

@ -5,8 +5,10 @@ import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.tasks.HopTask;
import com.songoda.epichoppers.utils.Methods;
import com.songoda.epichoppers.utils.ServerVersion;
import com.songoda.epichoppers.utils.settings.Setting;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -46,23 +48,28 @@ public class ModuleAutoSell implements Module {
List<String> list = instance.getConfig().getStringList("Main.AutoSell Prices");
for (String line : list) {
try {
String[] split = line.split(",");
OfflinePlayer player = Bukkit.getOfflinePlayer(hopper.getPlacedBy());
Material material = Material.valueOf(split[0]);
double price = Double.valueOf(split[1]);
for (ItemStack itemStack : hopperInventory.getContents()) {
if (itemStack == null) continue;
for (ItemStack itemStack : hopperInventory.getContents()) {
if (itemStack == null || itemStack.getType() != material) continue;
instance.getEconomy().deposit(Bukkit.getOfflinePlayer(hopper.getPlacedBy()), price * itemStack.getAmount());
hopperInventory.removeItem(itemStack);
updateComparators = true;
double value;
if (Setting.AUTOSELL_SHOPGUIPLUS.getBoolean() && player.isOnline()) {
try {
value = net.brcdev.shopgui.ShopGuiPlusApi.getItemStackPriceSell(player.getPlayer(), itemStack);
} catch (Exception e){
value = 0;
}
} catch (Exception ignored) {
}
} else
value = list.stream().filter(line -> Material.valueOf(line.split(",")[0])
== itemStack.getType()).findFirst().map(s -> Double.valueOf(s.split(",")[1])).orElse(0.0);
if (value == 0) continue;
instance.getEconomy().deposit(player, value * itemStack.getAmount());
hopperInventory.removeItem(itemStack);
updateComparators = true;
}
hopper.setAutoSellTimer(timeOut);

View File

@ -3,14 +3,12 @@ package com.songoda.epichoppers.listeners;
import com.songoda.epichoppers.EpicHoppers;
import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.utils.HopperDirection;
import org.bukkit.Bukkit;
import com.songoda.epichoppers.utils.ServerVersion;
import org.bukkit.Location;
import org.bukkit.block.Chest;
import org.bukkit.block.DoubleChest;
import org.bukkit.block.ShulkerBox;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
@ -35,12 +33,19 @@ public class HopperListeners implements Listener {
// Hopper minecarts should be able to take care of themselves
// Let EpicHoppers take over if the hopper is pointing down though
if (destination.getHolder() instanceof HopperMinecart && (!(source.getHolder() instanceof org.bukkit.block.Hopper)
|| HopperDirection.getDirection(((org.bukkit.block.Hopper)destination.getHolder()).getRawData()) != HopperDirection.DOWN))
if (destination.getHolder() instanceof HopperMinecart
&& source.getHolder() instanceof org.bukkit.block.Hopper
&& HopperDirection.getDirection(((org.bukkit.block.Hopper)source.getHolder()).getRawData()) != HopperDirection.DOWN)
return;
// Shulker boxes have a mind of their own and relentlessly steal items from hoppers
if (destination.getHolder() instanceof ShulkerBox || !(source.getHolder() instanceof org.bukkit.block.Hopper)) {
if (this.instance.isServerVersionAtLeast(ServerVersion.V1_11) && destination.getHolder() instanceof org.bukkit.block.ShulkerBox || !(source.getHolder() instanceof org.bukkit.block.Hopper)) {
event.setCancelled(true);
return;
}
// Hopper going into minecarts
if (destination.getHolder() instanceof Minecart && source.getHolder() instanceof org.bukkit.block.Hopper) {
event.setCancelled(true);
return;
}

View File

@ -53,7 +53,6 @@ public class Serializers {
}
for (String str : strings) {
args = str.split(":", 2);
Bukkit.broadcastMessage(Arrays.toString(args));
if (isNumber(args[0])) item.setAmount(Integer.parseInt(args[0]));
if (args.length == 1) continue;
if (args[0].equalsIgnoreCase("name")) {

View File

@ -58,6 +58,11 @@ public enum Setting {
Arrays.asList("STONE,0.50", "COBBLESTONE,0.20", "IRON_ORE,0.35", "COAL_ORE,0.20"),
"These are the prices used by the auto sell module."),
AUTOSELL_SHOPGUIPLUS("Main.Use ShopGuiPlus for Prices", false,
"Should prices be grabbed from ShopGuiPlus?",
"If ShopGuiPlus is not enabled or the player is offline the default price list will be used.",
"If this is something that you do not want then you should empty the default list."),
VAULT_ECONOMY("Economy.Use Vault Economy", true,
"Should Vault be used?"),