mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-26 04:05:48 +01:00
Merge branch 'development' into 'master'
4-pre-release-7 See merge request Songoda/epichoppers!41
This commit is contained in:
commit
75067932ba
@ -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
|
||||
|
5
pom.xml
5
pom.xml
@ -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>
|
||||
|
@ -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,24 +48,29 @@ public class ModuleAutoSell implements Module {
|
||||
|
||||
List<String> list = instance.getConfig().getStringList("Main.AutoSell Prices");
|
||||
|
||||
for (String line : list) {
|
||||
try {
|
||||
String[] split = line.split(",");
|
||||
|
||||
Material material = Material.valueOf(split[0]);
|
||||
double price = Double.valueOf(split[1]);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(hopper.getPlacedBy());
|
||||
|
||||
for (ItemStack itemStack : hopperInventory.getContents()) {
|
||||
if (itemStack == null || itemStack.getType() != material) continue;
|
||||
if (itemStack == null) continue;
|
||||
|
||||
instance.getEconomy().deposit(Bukkit.getOfflinePlayer(hopper.getPlacedBy()), price * itemStack.getAmount());
|
||||
double value;
|
||||
if (Setting.AUTOSELL_SHOPGUIPLUS.getBoolean() && player.isOnline()) {
|
||||
try {
|
||||
value = net.brcdev.shopgui.ShopGuiPlusApi.getItemStackPriceSell(player.getPlayer(), itemStack);
|
||||
} catch (Exception e){
|
||||
value = 0;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
hopper.setAutoSellTimer(timeOut);
|
||||
|
||||
if (updateComparators)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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")) {
|
||||
|
@ -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?"),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user