mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-25 11:46:45 +01:00
Migrate API related classes into the new API module
It is not nicely capsuled and needs heavy refactoring!
This commit is contained in:
parent
4d3c4fca17
commit
68f1674fca
@ -58,10 +58,11 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- TODO: Downgrade to spigot-api 1.8 -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.8-R0.1-SNAPSHOT</version>
|
||||
<version>1.18-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -0,0 +1,73 @@
|
||||
package com.songoda.epichoppers;
|
||||
|
||||
import com.songoda.epichoppers.boost.BoostManager;
|
||||
import com.songoda.epichoppers.containers.ContainerManager;
|
||||
import com.songoda.epichoppers.database.DataManager;
|
||||
import com.songoda.epichoppers.hopper.levels.LevelManager;
|
||||
import com.songoda.epichoppers.hopper.teleport.TeleportHandler;
|
||||
import com.songoda.epichoppers.player.PlayerDataManager;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
public class EpicHoppersApi {
|
||||
private static EpicHoppersApi instance;
|
||||
|
||||
private final LevelManager levelManager;
|
||||
private final BoostManager boostManager;
|
||||
private final ContainerManager containerManager;
|
||||
private final TeleportHandler teleportHandler;
|
||||
private final PlayerDataManager playerDataManager;
|
||||
private final DataManager dataManager;
|
||||
|
||||
private EpicHoppersApi(LevelManager levelManager,
|
||||
BoostManager boostManager,
|
||||
ContainerManager containerManager,
|
||||
TeleportHandler teleportHandler,
|
||||
PlayerDataManager playerDataManager,
|
||||
DataManager dataManager) {
|
||||
this.levelManager = levelManager;
|
||||
this.boostManager = boostManager;
|
||||
this.containerManager = containerManager;
|
||||
this.teleportHandler = teleportHandler;
|
||||
this.playerDataManager = playerDataManager;
|
||||
this.dataManager = dataManager;
|
||||
}
|
||||
|
||||
public LevelManager getLevelManager() {
|
||||
return this.levelManager;
|
||||
}
|
||||
|
||||
public BoostManager getBoostManager() {
|
||||
return this.boostManager;
|
||||
}
|
||||
|
||||
public ContainerManager getContainerManager() {
|
||||
return this.containerManager;
|
||||
}
|
||||
|
||||
public TeleportHandler getTeleportHandler() {
|
||||
return this.teleportHandler;
|
||||
}
|
||||
|
||||
public PlayerDataManager getPlayerDataManager() {
|
||||
return this.playerDataManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: The DataManager probably shouldn't be exposed to the API.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public DataManager getDataManager() {
|
||||
return this.dataManager;
|
||||
}
|
||||
|
||||
public static EpicHoppersApi getApi() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void initApi(LevelManager levelManager, BoostManager boostManager, ContainerManager containerManager, TeleportHandler teleportHandler, PlayerDataManager playerDataManager, DataManager dataManager) {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException(EpicHoppersApi.class.getSimpleName() + " already initialized");
|
||||
}
|
||||
instance = new EpicHoppersApi(levelManager, boostManager, containerManager, teleportHandler, playerDataManager, dataManager);
|
||||
}
|
||||
}
|
@ -24,5 +24,4 @@ public abstract class HopperEvent extends PlayerEvent {
|
||||
public Hopper getHopper() {
|
||||
return this.hopper;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.songoda.epichoppers.boost;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface BoostManager {
|
||||
void addBoostToPlayer(BoostData data);
|
||||
|
||||
void removeBoostFromPlayer(BoostData data);
|
||||
|
||||
void addBoosts(List<BoostData> boosts);
|
||||
|
||||
Set<BoostData> getBoosts();
|
||||
|
||||
BoostData getBoost(UUID player);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.songoda.epichoppers.containers;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface ContainerManager {
|
||||
Set<IContainer> getCustomContainerImplementations();
|
||||
|
||||
void registerCustomContainerImplementation(String requiredPlugin, IContainer container);
|
||||
|
||||
void registerCustomContainerImplementation(IContainer container);
|
||||
|
||||
CustomContainer getCustomContainer(Block block);
|
||||
}
|
@ -1,15 +1,8 @@
|
||||
package com.songoda.epichoppers.containers;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class CustomContainer {
|
||||
private final Block block;
|
||||
|
||||
public CustomContainer(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public abstract boolean addToContainer(ItemStack itemToMove);
|
||||
|
||||
public abstract ItemStack[] getItems();
|
@ -0,0 +1,38 @@
|
||||
package com.songoda.epichoppers.database;
|
||||
|
||||
import com.songoda.epichoppers.boost.BoostData;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.ItemType;
|
||||
import com.songoda.epichoppers.hopper.LinkType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface DataManager {
|
||||
void createBoost(BoostData boostData);
|
||||
|
||||
void getBoosts(Consumer<List<BoostData>> callback);
|
||||
|
||||
void deleteBoost(BoostData boostData);
|
||||
|
||||
void createLink(Hopper hopper, Location location, LinkType type);
|
||||
|
||||
void updateItems(Hopper hopper, ItemType type, List<ItemStack> items);
|
||||
|
||||
void deleteLink(Hopper hopper, Location location);
|
||||
|
||||
void deleteLinks(Hopper hopper);
|
||||
|
||||
void createHoppers(List<Hopper> hoppers);
|
||||
|
||||
void createHopper(Hopper hopper);
|
||||
|
||||
void updateHopper(Hopper hopper);
|
||||
|
||||
void deleteHopper(Hopper hopper);
|
||||
|
||||
void getHoppers(Consumer<Map<Integer, Hopper>> callback);
|
||||
}
|
@ -15,65 +15,52 @@ public class Filter {
|
||||
private List<ItemStack> autoSellWhiteList = new ArrayList<>();
|
||||
private List<ItemStack> autoSellBlackList = new ArrayList<>();
|
||||
|
||||
|
||||
private Location endPoint;
|
||||
|
||||
|
||||
public List<ItemStack> getWhiteList() {
|
||||
return this.whiteList != null ? this.whiteList : Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
public void setWhiteList(List<ItemStack> whiteList) {
|
||||
this.whiteList = whiteList;
|
||||
}
|
||||
|
||||
|
||||
public List<ItemStack> getBlackList() {
|
||||
return this.blackList != null ? this.blackList : Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
public void setBlackList(List<ItemStack> blackList) {
|
||||
this.blackList = blackList;
|
||||
}
|
||||
|
||||
|
||||
public List<ItemStack> getVoidList() {
|
||||
return this.voidList != null ? this.voidList : Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
public void setVoidList(List<ItemStack> voidList) {
|
||||
this.voidList = voidList;
|
||||
}
|
||||
|
||||
|
||||
public List<ItemStack> getAutoSellWhiteList() {
|
||||
return this.autoSellWhiteList != null ? this.autoSellWhiteList : Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
public void setAutoSellWhiteList(List<ItemStack> autoSellWhiteList) {
|
||||
this.autoSellWhiteList = autoSellWhiteList;
|
||||
}
|
||||
|
||||
|
||||
public List<ItemStack> getAutoSellBlackList() {
|
||||
return this.autoSellBlackList != null ? this.autoSellBlackList : Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
public void setAutoSellBlackList(List<ItemStack> autoSellBlackList) {
|
||||
this.autoSellBlackList = autoSellBlackList;
|
||||
}
|
||||
|
||||
|
||||
public Location getEndPoint() {
|
||||
return this.endPoint;
|
||||
}
|
||||
|
||||
|
||||
public void setEndPoint(Location endPoint) {
|
||||
this.endPoint = endPoint;
|
||||
}
|
@ -1,17 +1,18 @@
|
||||
package com.songoda.epichoppers.hopper;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.compatibility.CompatibleParticleHandler;
|
||||
import com.craftaro.core.compatibility.CompatibleSound;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.core.hooks.EconomyManager;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersApi;
|
||||
import com.songoda.epichoppers.api.events.HopperAccessEvent;
|
||||
import com.songoda.epichoppers.gui.GUIOverview;
|
||||
import com.songoda.epichoppers.database.DataManager;
|
||||
import com.songoda.epichoppers.hopper.levels.Level;
|
||||
import com.songoda.epichoppers.hopper.levels.LevelManager;
|
||||
import com.songoda.epichoppers.hopper.teleport.TeleportTrigger;
|
||||
import com.songoda.epichoppers.player.PlayerData;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
import com.songoda.epichoppers.player.PlayerDataManager;
|
||||
import com.songoda.epichoppers.utils.CostType;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -24,6 +25,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -31,12 +33,15 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* FIXME: Needs heavy refactoring to only have one responsibility.
|
||||
*/
|
||||
public class Hopper {
|
||||
// Id for database use.
|
||||
private int id;
|
||||
|
||||
private final Location location;
|
||||
private Level level = EpicHoppers.getPlugin(EpicHoppers.class).getLevelManager().getLowestLevel();
|
||||
private Level level = getLevelManager().getLowestLevel();
|
||||
private UUID lastPlayerOpened = null;
|
||||
private UUID placedBy = null;
|
||||
private final List<Location> linkedBlocks = new ArrayList<>();
|
||||
@ -54,7 +59,8 @@ public class Hopper {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public void overview(GuiManager guiManager, Player player) {
|
||||
@ApiStatus.Internal
|
||||
public boolean prepareForOpeningOverviewGui(Player player) {
|
||||
if (this.lastPlayerOpened != null &&
|
||||
this.lastPlayerOpened != player.getUniqueId() &&
|
||||
Bukkit.getPlayer(this.lastPlayerOpened) != null) {
|
||||
@ -64,22 +70,22 @@ public class Hopper {
|
||||
HopperAccessEvent accessEvent = new HopperAccessEvent(player, this);
|
||||
Bukkit.getPluginManager().callEvent(accessEvent);
|
||||
if (accessEvent.isCancelled()) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.placedBy == null) {
|
||||
this.placedBy = player.getUniqueId();
|
||||
}
|
||||
|
||||
EpicHoppers instance = EpicHoppers.getPlugin(EpicHoppers.class);
|
||||
if (!player.hasPermission("epichoppers.overview")) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
setActivePlayer(player);
|
||||
guiManager.showGUI(player, new GUIOverview(instance, this, player));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void forceClose() {
|
||||
if (this.activePlayer != null) {
|
||||
this.activePlayer.closeInventory();
|
||||
@ -100,12 +106,11 @@ public class Hopper {
|
||||
}
|
||||
|
||||
public void upgrade(Player player, CostType type) {
|
||||
EpicHoppers plugin = EpicHoppers.getPlugin(EpicHoppers.class);
|
||||
if (!plugin.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) {
|
||||
if (!getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Level level = plugin.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
Level level = getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
int cost = type == CostType.ECONOMY ? level.getCostEconomy() : level.getCostExperience();
|
||||
|
||||
if (type == CostType.ECONOMY) {
|
||||
@ -114,7 +119,7 @@ public class Hopper {
|
||||
return;
|
||||
}
|
||||
if (!EconomyManager.hasBalance(player, cost)) {
|
||||
plugin.getLocale().getMessage("event.upgrade.cannotafford").sendPrefixedMessage(player);
|
||||
getPlugin().getLocale().getMessage("event.upgrade.cannotafford").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
EconomyManager.withdrawBalance(player, cost);
|
||||
@ -126,38 +131,37 @@ public class Hopper {
|
||||
}
|
||||
upgradeFinal(level, player);
|
||||
} else {
|
||||
plugin.getLocale().getMessage("event.upgrade.cannotafford").sendPrefixedMessage(player);
|
||||
getPlugin().getLocale().getMessage("event.upgrade.cannotafford").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void upgradeFinal(Level level, Player player) {
|
||||
EpicHoppers plugin = EpicHoppers.getPlugin(EpicHoppers.class);
|
||||
this.level = level;
|
||||
plugin.getDataManager().updateHopper(this);
|
||||
getDataManager().updateHopper(this);
|
||||
syncName();
|
||||
if (plugin.getLevelManager().getHighestLevel() != level) {
|
||||
plugin.getLocale().getMessage("event.upgrade.success")
|
||||
if (getLevelManager().getHighestLevel() != level) {
|
||||
getPlugin().getLocale().getMessage("event.upgrade.success")
|
||||
.processPlaceholder("level", level.getLevel()).sendPrefixedMessage(player);
|
||||
} else {
|
||||
plugin.getLocale().getMessage("event.upgrade.maxed")
|
||||
getPlugin().getLocale().getMessage("event.upgrade.maxed")
|
||||
.processPlaceholder("level", level.getLevel()).sendPrefixedMessage(player);
|
||||
}
|
||||
Location loc = this.location.clone().add(.5, .5, .5);
|
||||
|
||||
if (!Settings.UPGRADE_PARTICLE_TYPE.getString().trim().isEmpty()) {
|
||||
if (!getUpgradeParticleType().trim().isEmpty()) {
|
||||
CompatibleParticleHandler.spawnParticles(
|
||||
CompatibleParticleHandler.ParticleType.getParticle(Settings.UPGRADE_PARTICLE_TYPE.getString()),
|
||||
CompatibleParticleHandler.ParticleType.getParticle(getUpgradeParticleType()),
|
||||
loc, 100, .5, .5, .5);
|
||||
}
|
||||
|
||||
if (plugin.getLevelManager().getHighestLevel() != level) {
|
||||
if (getLevelManager().getHighestLevel() != level) {
|
||||
player.playSound(player.getLocation(), CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 0.6F, 15.0F);
|
||||
} else {
|
||||
player.playSound(player.getLocation(), CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 2F, 25.0F);
|
||||
player.playSound(player.getLocation(), CompatibleSound.BLOCK_NOTE_BLOCK_CHIME.getSound(), 2F, 25.0F);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> player.playSound(player.getLocation(), CompatibleSound.BLOCK_NOTE_BLOCK_CHIME.getSound(), 1.2F, 35.0F), 5L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> player.playSound(player.getLocation(), CompatibleSound.BLOCK_NOTE_BLOCK_CHIME.getSound(), 1.8F, 35.0F), 10L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> player.playSound(player.getLocation(), CompatibleSound.BLOCK_NOTE_BLOCK_CHIME.getSound(), 1.2F, 35.0F), 5L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> player.playSound(player.getLocation(), CompatibleSound.BLOCK_NOTE_BLOCK_CHIME.getSound(), 1.8F, 35.0F), 10L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,56 +174,53 @@ public class Hopper {
|
||||
}
|
||||
|
||||
public void timeout(Player player) {
|
||||
EpicHoppers instance = EpicHoppers.getPlugin(EpicHoppers.class);
|
||||
this.syncId = Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||
this.syncId = Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> {
|
||||
PlayerData playerData = getPlayerDataManager().getPlayerData(player);
|
||||
if (playerData.getSyncType() != null && playerData.getLastHopper() == this) {
|
||||
instance.getLocale().getMessage("event.hopper.synctimeout").sendPrefixedMessage(player);
|
||||
getPlugin().getLocale().getMessage("event.hopper.synctimeout").sendPrefixedMessage(player);
|
||||
playerData.setSyncType(null);
|
||||
}
|
||||
}, Settings.LINK_TIMEOUT.getLong() * this.level.getLinkAmount());
|
||||
}, getLinkTimeoutFromPluginConfig() * this.level.getLinkAmount());
|
||||
}
|
||||
|
||||
public void link(Block toLink, boolean filtered, Player player) {
|
||||
EpicHoppers instance = EpicHoppers.getPlugin(EpicHoppers.class);
|
||||
|
||||
if (this.location.getWorld().equals(toLink.getLocation().getWorld())
|
||||
&& !player.hasPermission("EpicHoppers.Override")
|
||||
&& !player.hasPermission("EpicHoppers.Admin")
|
||||
&& this.location.distance(toLink.getLocation()) > this.level.getRange()) {
|
||||
instance.getLocale().getMessage("event.hopper.syncoutofrange").sendPrefixedMessage(player);
|
||||
getPlugin().getLocale().getMessage("event.hopper.syncoutofrange").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.linkedBlocks.contains(toLink.getLocation())) {
|
||||
instance.getLocale().getMessage("event.hopper.already").sendPrefixedMessage(player);
|
||||
getPlugin().getLocale().getMessage("event.hopper.already").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!filtered) {
|
||||
this.linkedBlocks.add(toLink.getLocation());
|
||||
instance.getDataManager().createLink(this, toLink.getLocation(), LinkType.REGULAR);
|
||||
getDataManager().createLink(this, toLink.getLocation(), LinkType.REGULAR);
|
||||
} else {
|
||||
this.filter.setEndPoint(toLink.getLocation());
|
||||
instance.getDataManager().createLink(this, toLink.getLocation(), LinkType.REJECT);
|
||||
instance.getLocale().getMessage("event.hopper.syncsuccess").sendPrefixedMessage(player);
|
||||
instance.getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
getDataManager().createLink(this, toLink.getLocation(), LinkType.REJECT);
|
||||
getPlugin().getLocale().getMessage("event.hopper.syncsuccess").sendPrefixedMessage(player);
|
||||
getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
return;
|
||||
}
|
||||
this.lastPlayerOpened = player.getUniqueId();
|
||||
|
||||
if (this.level.getLinkAmount() > 1) {
|
||||
if (this.linkedBlocks.size() >= this.level.getLinkAmount()) {
|
||||
instance.getLocale().getMessage("event.hopper.syncdone").sendPrefixedMessage(player);
|
||||
getPlugin().getLocale().getMessage("event.hopper.syncdone").sendPrefixedMessage(player);
|
||||
cancelSync(player);
|
||||
return;
|
||||
}
|
||||
instance.getLocale().getMessage("event.hopper.syncsuccessmore")
|
||||
getPlugin().getLocale().getMessage("event.hopper.syncsuccessmore")
|
||||
.processPlaceholder("amount", this.level.getLinkAmount() - this.linkedBlocks.size())
|
||||
.sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
instance.getLocale().getMessage("event.hopper.syncsuccess").sendPrefixedMessage(player);
|
||||
getPlugin().getLocale().getMessage("event.hopper.syncsuccess").sendPrefixedMessage(player);
|
||||
cancelSync(player);
|
||||
}
|
||||
|
||||
@ -349,7 +350,7 @@ public class Hopper {
|
||||
|
||||
public void cancelSync(Player player) {
|
||||
Bukkit.getScheduler().cancelTask(this.syncId);
|
||||
EpicHoppers.getPlugin(EpicHoppers.class).getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@ -367,4 +368,43 @@ public class Hopper {
|
||||
public void setActivePlayer(Player activePlayer) {
|
||||
this.activePlayer = activePlayer;
|
||||
}
|
||||
|
||||
private LevelManager getLevelManager() {
|
||||
return EpicHoppersApi.getApi().getLevelManager();
|
||||
}
|
||||
|
||||
private PlayerDataManager getPlayerDataManager() {
|
||||
return EpicHoppersApi.getApi().getPlayerDataManager();
|
||||
}
|
||||
|
||||
private DataManager getDataManager() {
|
||||
return EpicHoppersApi.getApi().getDataManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The class needs refactoring to not even need the plugin.
|
||||
* This is just a temporary workaround to get a Minecraft 1.20-beta build ready
|
||||
*/
|
||||
@Deprecated
|
||||
private long getLinkTimeoutFromPluginConfig() {
|
||||
return getPlugin().getConfig().getLong("Main.Timeout When Syncing Hoppers");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The class needs refactoring to not even need the plugin.
|
||||
* This is just a temporary workaround to get a Minecraft 1.20-beta build ready
|
||||
*/
|
||||
@Deprecated
|
||||
private String getUpgradeParticleType() {
|
||||
return getPlugin().getConfig().getString("Main.Upgrade Particle Type");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The class needs refactoring to not even need the plugin.
|
||||
* This is just a temporary workaround to get a Minecraft 1.20-beta build ready
|
||||
*/
|
||||
@Deprecated
|
||||
private SongodaPlugin getPlugin() {
|
||||
return (SongodaPlugin) Bukkit.getPluginManager().getPlugin("EpicHoppers");
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package com.songoda.epichoppers.hopper.levels;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.songoda.epichoppers.hopper.levels.modules.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -24,34 +25,31 @@ public class Level {
|
||||
this.registeredModules = registeredModules;
|
||||
|
||||
buildDescription();
|
||||
|
||||
}
|
||||
|
||||
public void buildDescription() {
|
||||
EpicHoppers instance = EpicHoppers.getPlugin(EpicHoppers.class);
|
||||
|
||||
this.description.clear();
|
||||
|
||||
this.description.add(instance.getLocale().getMessage("interface.hopper.range")
|
||||
this.description.add(getPlugin().getLocale().getMessage("interface.hopper.range")
|
||||
.processPlaceholder("range", this.range).getMessage());
|
||||
this.description.add(instance.getLocale().getMessage("interface.hopper.amount")
|
||||
this.description.add(getPlugin().getLocale().getMessage("interface.hopper.amount")
|
||||
.processPlaceholder("amount", this.amount).getMessage());
|
||||
if (this.linkAmount != 1) {
|
||||
this.description.add(instance.getLocale().getMessage("interface.hopper.linkamount")
|
||||
this.description.add(getPlugin().getLocale().getMessage("interface.hopper.linkamount")
|
||||
.processPlaceholder("amount", this.linkAmount).getMessage());
|
||||
}
|
||||
if (this.filter) {
|
||||
this.description.add(instance.getLocale().getMessage("interface.hopper.filter")
|
||||
.processPlaceholder("enabled", instance.getLocale()
|
||||
this.description.add(getPlugin().getLocale().getMessage("interface.hopper.filter")
|
||||
.processPlaceholder("enabled", getPlugin().getLocale()
|
||||
.getMessage("general.word.enabled").getMessage()).getMessage());
|
||||
}
|
||||
if (this.teleport) {
|
||||
this.description.add(instance
|
||||
this.description.add(getPlugin()
|
||||
.getLocale()
|
||||
.getMessage("interface.hopper.teleport")
|
||||
.processPlaceholder(
|
||||
"enabled",
|
||||
instance
|
||||
getPlugin()
|
||||
.getLocale()
|
||||
.getMessage("general.word.enabled")
|
||||
.getMessage())
|
||||
@ -132,4 +130,13 @@ public class Level {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The class needs refactoring to not even need the plugin.
|
||||
* This is just a temporary workaround to get a Minecraft 1.20-beta build ready
|
||||
*/
|
||||
@Deprecated
|
||||
private SongodaPlugin getPlugin() {
|
||||
return (SongodaPlugin) Bukkit.getPluginManager().getPlugin("EpicHoppers");
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.songoda.epichoppers.hopper.levels;
|
||||
|
||||
import com.songoda.epichoppers.hopper.levels.modules.Module;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
public interface LevelManager {
|
||||
void addLevel(int level, int costExperience, int costEconomy, int range, int amount, boolean filter, boolean teleport, int linkAmount, ArrayList<Module> modules);
|
||||
|
||||
Level getLevel(int level);
|
||||
|
||||
Level getLevel(ItemStack item);
|
||||
|
||||
boolean isEpicHopper(ItemStack item);
|
||||
|
||||
Level getLowestLevel();
|
||||
|
||||
Level getHighestLevel();
|
||||
|
||||
boolean isLevel(int level);
|
||||
|
||||
Map<Integer, Level> getLevels();
|
||||
|
||||
void clear();
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import com.songoda.epichoppers.utils.StorageContainerCache;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@ -18,11 +19,14 @@ import java.util.Map;
|
||||
public abstract class Module {
|
||||
private static final Map<String, Config> CONFIGS = new HashMap<>();
|
||||
|
||||
protected final EpicHoppers plugin;
|
||||
protected final SongodaPlugin plugin;
|
||||
protected final GuiManager guiManager;
|
||||
private final Config config;
|
||||
|
||||
public Module(EpicHoppers plugin) {
|
||||
public Module(SongodaPlugin plugin, GuiManager guiManager) {
|
||||
this.plugin = plugin;
|
||||
this.guiManager = guiManager;
|
||||
|
||||
if (!CONFIGS.containsKey(getName())) {
|
||||
Config config = new Config(plugin, File.separator + "modules", getName() + ".yml");
|
||||
CONFIGS.put(getName(), config);
|
||||
@ -49,7 +53,7 @@ public abstract class Module {
|
||||
}
|
||||
|
||||
public void saveData(Hopper hopper, String setting, Object value, Object toCache) {
|
||||
this.config.set("data." + Methods.serializeLocation(hopper.getLocation()) + "." + setting, value);
|
||||
this.config.set("data." + serializeLocation(hopper.getLocation()) + "." + setting, value);
|
||||
modifyDataCache(hopper, setting, toCache);
|
||||
}
|
||||
|
||||
@ -63,17 +67,30 @@ public abstract class Module {
|
||||
return hopper.getDataFromModuleCache(cacheStr);
|
||||
}
|
||||
|
||||
Object data = this.config.get("data." + Methods.serializeLocation(hopper.getLocation()) + "." + setting);
|
||||
Object data = this.config.get("data." + serializeLocation(hopper.getLocation()) + "." + setting);
|
||||
modifyDataCache(hopper, setting, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
public void clearData(Hopper hopper) {
|
||||
this.config.set("data." + Methods.serializeLocation(hopper.getLocation()), null);
|
||||
this.config.set("data." + serializeLocation(hopper.getLocation()), null);
|
||||
hopper.clearModuleCache();
|
||||
}
|
||||
|
||||
public void saveDataToFile() {
|
||||
this.config.save();
|
||||
}
|
||||
|
||||
private static String serializeLocation(Location location) {
|
||||
if (location == null || location.getWorld() == null) {
|
||||
return "";
|
||||
}
|
||||
String w = location.getWorld().getName();
|
||||
double x = location.getX();
|
||||
double y = location.getY();
|
||||
double z = location.getZ();
|
||||
String str = w + ":" + x + ":" + y + ":" + z;
|
||||
str = str.replace(".0", "").replace(".", "/");
|
||||
return str;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.songoda.epichoppers.hopper.teleport;
|
||||
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public interface TeleportHandler {
|
||||
void tpEntity(Entity entity, Hopper hopper);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.songoda.epichoppers.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface PlayerDataManager {
|
||||
PlayerData getPlayerData(Player player);
|
||||
|
||||
Collection<PlayerData> getRegisteredPlayers();
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.songoda.epichoppers.player;
|
||||
|
||||
public enum SyncType {
|
||||
REGULAR,
|
||||
FILTERED
|
||||
REGULAR, FILTERED
|
||||
}
|
@ -1,15 +1,17 @@
|
||||
package com.songoda.epichoppers.utils;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class Methods {
|
||||
public static boolean isSimilarMaterial(ItemStack is1, ItemStack is2) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ||
|
||||
@ -75,8 +77,7 @@ public class Methods {
|
||||
}
|
||||
|
||||
public static String formatName(int level) {
|
||||
EpicHoppers instance = EpicHoppers.getPlugin(EpicHoppers.class);
|
||||
String name = instance.getLocale()
|
||||
String name = getPlugin().getLocale()
|
||||
.getMessage("general.nametag.nameformat")
|
||||
.processPlaceholder("level", level)
|
||||
.getMessage();
|
||||
@ -86,29 +87,18 @@ public class Methods {
|
||||
}
|
||||
|
||||
public static void doParticles(Entity entity, Location location) {
|
||||
EpicHoppers instance = EpicHoppers.getPlugin(EpicHoppers.class);
|
||||
location.setX(location.getX() + .5);
|
||||
location.setY(location.getY() + .5);
|
||||
location.setZ(location.getZ() + .5);
|
||||
entity.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), location, 200, .5, .5, .5);
|
||||
entity.getWorld().spawnParticle(org.bukkit.Particle.valueOf(getPlugin().getConfig().getString("Main.Upgrade Particle Type")), location, 200, .5, .5, .5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the location specified.
|
||||
*
|
||||
* @param location The location that is to be saved.
|
||||
* @return The serialized data.
|
||||
* @deprecated The class needs refactoring to not even need the plugin.
|
||||
* This is just a temporary workaround to get a Minecraft 1.20-beta build ready
|
||||
*/
|
||||
public static String serializeLocation(Location location) {
|
||||
if (location == null || location.getWorld() == null) {
|
||||
return "";
|
||||
}
|
||||
String w = location.getWorld().getName();
|
||||
double x = location.getX();
|
||||
double y = location.getY();
|
||||
double z = location.getZ();
|
||||
String str = w + ":" + x + ":" + y + ":" + z;
|
||||
str = str.replace(".0", "").replace(".", "/");
|
||||
return str;
|
||||
@Deprecated
|
||||
private static SongodaPlugin getPlugin() {
|
||||
return (SongodaPlugin) Bukkit.getPluginManager().getPlugin("EpicHoppers");
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import org.bukkit.block.data.type.Chest;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -21,6 +22,7 @@ import java.util.Map;
|
||||
* Persistent storage intended for streamlining read/write for storage
|
||||
* containers in large batches
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public class StorageContainerCache {
|
||||
private static final Map<Block, Cache> INVENTORY_CACHE = new HashMap<>();
|
||||
|
@ -4,6 +4,7 @@ import com.craftaro.core.SongodaCore;
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.commands.CommandManager;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.database.DataManagerAbstract;
|
||||
import com.craftaro.core.database.DataMigrationManager;
|
||||
import com.craftaro.core.database.DatabaseConnector;
|
||||
import com.craftaro.core.database.MySQLConnector;
|
||||
@ -15,16 +16,20 @@ import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.boost.BoostManager;
|
||||
import com.songoda.epichoppers.boost.BoostManagerImpl;
|
||||
import com.songoda.epichoppers.commands.CommandBoost;
|
||||
import com.songoda.epichoppers.commands.CommandGive;
|
||||
import com.songoda.epichoppers.commands.CommandReload;
|
||||
import com.songoda.epichoppers.commands.CommandSettings;
|
||||
import com.songoda.epichoppers.containers.ContainerManager;
|
||||
import com.songoda.epichoppers.containers.ContainerManagerImpl;
|
||||
import com.songoda.epichoppers.database.DataManager;
|
||||
import com.songoda.epichoppers.database.DataManagerImpl;
|
||||
import com.songoda.epichoppers.database.migrations._1_InitialMigration;
|
||||
import com.songoda.epichoppers.hopper.HopperManager;
|
||||
import com.songoda.epichoppers.hopper.levels.Level;
|
||||
import com.songoda.epichoppers.hopper.levels.LevelManager;
|
||||
import com.songoda.epichoppers.hopper.levels.LevelManagerImpl;
|
||||
import com.songoda.epichoppers.hopper.levels.modules.Module;
|
||||
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoCrafting;
|
||||
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoSell;
|
||||
@ -33,12 +38,14 @@ import com.songoda.epichoppers.hopper.levels.modules.ModuleBlockBreak;
|
||||
import com.songoda.epichoppers.hopper.levels.modules.ModuleMobHopper;
|
||||
import com.songoda.epichoppers.hopper.levels.modules.ModuleSuction;
|
||||
import com.songoda.epichoppers.hopper.teleport.TeleportHandler;
|
||||
import com.songoda.epichoppers.hopper.teleport.TeleportHandlerImpl;
|
||||
import com.songoda.epichoppers.listeners.BlockListeners;
|
||||
import com.songoda.epichoppers.listeners.EntityListeners;
|
||||
import com.songoda.epichoppers.listeners.HopperListeners;
|
||||
import com.songoda.epichoppers.listeners.InteractListeners;
|
||||
import com.songoda.epichoppers.listeners.InventoryListeners;
|
||||
import com.songoda.epichoppers.player.PlayerDataManager;
|
||||
import com.songoda.epichoppers.player.PlayerDataManagerImpl;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
import com.songoda.epichoppers.tasks.HopTask;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
@ -62,7 +69,7 @@ public class EpicHoppers extends SongodaPlugin {
|
||||
private HopperManager hopperManager;
|
||||
private CommandManager commandManager;
|
||||
private LevelManager levelManager;
|
||||
private BoostManager boostManager;
|
||||
private BoostManagerImpl boostManager;
|
||||
private PlayerDataManager playerDataManager;
|
||||
private ContainerManager containerManager;
|
||||
|
||||
@ -110,9 +117,9 @@ public class EpicHoppers extends SongodaPlugin {
|
||||
);
|
||||
|
||||
this.hopperManager = new HopperManager(this);
|
||||
this.playerDataManager = new PlayerDataManager();
|
||||
this.containerManager = new ContainerManager();
|
||||
this.boostManager = new BoostManager();
|
||||
this.playerDataManager = new PlayerDataManagerImpl();
|
||||
this.containerManager = new ContainerManagerImpl();
|
||||
this.boostManager = new BoostManagerImpl();
|
||||
|
||||
// Database stuff, go!
|
||||
try {
|
||||
@ -136,14 +143,16 @@ public class EpicHoppers extends SongodaPlugin {
|
||||
this.emergencyStop();
|
||||
}
|
||||
|
||||
this.dataManager = new DataManager(this.databaseConnector, this);
|
||||
DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager, new _1_InitialMigration(this));
|
||||
this.dataManager = new DataManagerImpl(this.databaseConnector, this);
|
||||
DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, (DataManagerAbstract) this.dataManager, new _1_InitialMigration(this));
|
||||
dataMigrationManager.runMigrations();
|
||||
|
||||
EpicHoppersApi.initApi(this.levelManager, this.boostManager, this.containerManager, this.teleportHandler, this.playerDataManager, this.dataManager);
|
||||
|
||||
this.loadLevelManager();
|
||||
|
||||
new HopTask(this);
|
||||
this.teleportHandler = new TeleportHandler(this);
|
||||
this.teleportHandler = new TeleportHandlerImpl(this);
|
||||
|
||||
// Register Listeners
|
||||
this.guiManager.init();
|
||||
@ -201,7 +210,7 @@ public class EpicHoppers extends SongodaPlugin {
|
||||
this.levelsConfig.load();
|
||||
|
||||
// Load an instance of LevelManager
|
||||
this.levelManager = new LevelManager();
|
||||
this.levelManager = new LevelManagerImpl();
|
||||
/*
|
||||
* Register Levels into LevelManager from configuration.
|
||||
*/
|
||||
@ -224,17 +233,17 @@ public class EpicHoppers extends SongodaPlugin {
|
||||
|
||||
for (String key : levels.getKeys(false)) {
|
||||
if (key.equals("Suction") && levels.getInt("Suction") != 0) {
|
||||
modules.add(new ModuleSuction(this, levels.getInt("Suction")));
|
||||
modules.add(new ModuleSuction(this, getGuiManager(), levels.getInt("Suction")));
|
||||
} else if (key.equals("BlockBreak") && levels.getInt("BlockBreak") != 0) {
|
||||
modules.add(new ModuleBlockBreak(this, levels.getInt("BlockBreak")));
|
||||
modules.add(new ModuleBlockBreak(this, getGuiManager(), levels.getInt("BlockBreak")));
|
||||
} else if (key.equals("AutoCrafting")) {
|
||||
modules.add(new ModuleAutoCrafting(this));
|
||||
modules.add(new ModuleAutoCrafting(this, getGuiManager()));
|
||||
} else if (key.equals("AutoSell")) {
|
||||
modules.add(new ModuleAutoSell(this, autoSell));
|
||||
modules.add(new ModuleAutoSell(this, getGuiManager(), autoSell));
|
||||
} else if (key.equals("MobHopper")) {
|
||||
modules.add(new ModuleMobHopper(this, levels.getInt("MobHopper")));
|
||||
modules.add(new ModuleMobHopper(this, getGuiManager(), levels.getInt("MobHopper")));
|
||||
} else if (key.equals("AutoSmelting")) {
|
||||
modules.add(new ModuleAutoSmelter(this, levels.getInt("AutoSmelting")));
|
||||
modules.add(new ModuleAutoSmelter(this, getGuiManager(), levels.getInt("AutoSmelting")));
|
||||
}
|
||||
}
|
||||
this.levelManager.addLevel(level, costExperience, costEconomy, radius, amount, filter, teleport, linkAmount, modules);
|
||||
|
@ -6,25 +6,30 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BoostManager {
|
||||
public class BoostManagerImpl implements BoostManager {
|
||||
private final Set<BoostData> registeredBoosts = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void addBoostToPlayer(BoostData data) {
|
||||
this.registeredBoosts.add(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBoostFromPlayer(BoostData data) {
|
||||
this.registeredBoosts.remove(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBoosts(List<BoostData> boosts) {
|
||||
this.registeredBoosts.addAll(boosts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<BoostData> getBoosts() {
|
||||
return Collections.unmodifiableSet(this.registeredBoosts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoostData getBoost(UUID player) {
|
||||
if (player == null) {
|
||||
return null;
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epichoppers.containers;
|
||||
|
||||
import com.songoda.epichoppers.containers.impl.AdvancedChestImplementation;
|
||||
import com.songoda.epichoppers.containers.impl.EpicFarmingImplementation;
|
||||
import com.songoda.epichoppers.containers.impl.FabledSkyBlockImplementation;
|
||||
import com.songoda.epichoppers.containers.impl.AdvancedChestImpl;
|
||||
import com.songoda.epichoppers.containers.impl.EpicFarmingImpl;
|
||||
import com.songoda.epichoppers.containers.impl.FabledSkyBlockImpl;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@ -11,21 +11,23 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ContainerManager {
|
||||
public class ContainerManagerImpl implements ContainerManager {
|
||||
private final Set<IContainer> customContainers;
|
||||
|
||||
public ContainerManager() {
|
||||
public ContainerManagerImpl() {
|
||||
this.customContainers = new HashSet<>();
|
||||
|
||||
registerCustomContainerImplementation("AdvancedChests", new AdvancedChestImplementation());
|
||||
registerCustomContainerImplementation("EpicFarming", new EpicFarmingImplementation());
|
||||
registerCustomContainerImplementation("FabledSkyBlock", new FabledSkyBlockImplementation());
|
||||
registerCustomContainerImplementation("AdvancedChests", new AdvancedChestImpl());
|
||||
registerCustomContainerImplementation("EpicFarming", new EpicFarmingImpl());
|
||||
registerCustomContainerImplementation("FabledSkyBlock", new FabledSkyBlockImpl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IContainer> getCustomContainerImplementations() {
|
||||
return Collections.unmodifiableSet(this.customContainers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCustomContainerImplementation(String requiredPlugin, IContainer container) {
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
if (requiredPlugin != null && pluginManager.isPluginEnabled(requiredPlugin)) {
|
||||
@ -33,10 +35,12 @@ public class ContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCustomContainerImplementation(IContainer container) {
|
||||
registerCustomContainerImplementation(null, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomContainer getCustomContainer(Block block) {
|
||||
for (IContainer container : this.customContainers) {
|
||||
CustomContainer customContainer = container.getCustomContainer(block);
|
@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import us.lynuxcraft.deadsilenceiv.advancedchests.AdvancedChestsAPI;
|
||||
import us.lynuxcraft.deadsilenceiv.advancedchests.chest.AdvancedChest;
|
||||
|
||||
public class AdvancedChestImplementation implements IContainer {
|
||||
public class AdvancedChestImpl implements IContainer {
|
||||
@Override
|
||||
public CustomContainer getCustomContainer(Block block) {
|
||||
return new Container(block);
|
||||
@ -17,7 +17,6 @@ public class AdvancedChestImplementation implements IContainer {
|
||||
private final AdvancedChest advancedChest;
|
||||
|
||||
public Container(Block block) {
|
||||
super(block);
|
||||
this.advancedChest = AdvancedChestsAPI.getChestManager().getAdvancedChest(block.getLocation());
|
||||
}
|
||||
|
||||
@ -41,8 +40,9 @@ public class AdvancedChestImplementation implements IContainer {
|
||||
if (itemToMove.getType() == item.getType()) {
|
||||
item.setAmount(item.getAmount() - amountToMove);
|
||||
|
||||
if (item.getAmount() <= 0)
|
||||
if (item.getAmount() <= 0) {
|
||||
this.advancedChest.getAllItems().remove(item);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import com.songoda.epichoppers.containers.IContainer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EpicFarmingImplementation implements IContainer {
|
||||
public class EpicFarmingImpl implements IContainer {
|
||||
@Override
|
||||
public CustomContainer getCustomContainer(Block block) {
|
||||
return new Container(block);
|
||||
@ -18,7 +18,6 @@ public class EpicFarmingImplementation implements IContainer {
|
||||
private final Farm farm;
|
||||
|
||||
public Container(Block block) {
|
||||
super(block);
|
||||
this.farm = EpicFarming.getInstance().getFarmManager().getFarm(block);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import com.songoda.skyblock.stackable.StackableManager;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class FabledSkyBlockImplementation implements IContainer {
|
||||
public class FabledSkyBlockImpl implements IContainer {
|
||||
@Override
|
||||
public CustomContainer getCustomContainer(Block block) {
|
||||
return new Container(block);
|
||||
@ -19,7 +19,7 @@ public class FabledSkyBlockImplementation implements IContainer {
|
||||
private final Stackable stackable;
|
||||
|
||||
public Container(Block block) {
|
||||
super(block);
|
||||
super();
|
||||
|
||||
StackableManager stackableManager = SkyBlock.getInstance().getStackableManager();
|
||||
CompatibleMaterial compatibleMaterial = CompatibleMaterial.getMaterial(block);
|
@ -33,11 +33,12 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class DataManager extends DataManagerAbstract {
|
||||
public DataManager(DatabaseConnector databaseConnector, Plugin plugin) {
|
||||
public class DataManagerImpl extends DataManagerAbstract implements DataManager {
|
||||
public DataManagerImpl(DatabaseConnector databaseConnector, Plugin plugin) {
|
||||
super(databaseConnector, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createBoost(BoostData boostData) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
@ -53,6 +54,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoosts(Consumer<List<BoostData>> callback) {
|
||||
List<BoostData> boosts = new ArrayList<>();
|
||||
this.runAsync(() -> {
|
||||
@ -74,6 +76,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBoost(BoostData boostData) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
@ -87,6 +90,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLink(Hopper hopper, Location location, LinkType type) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
@ -107,6 +111,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItems(Hopper hopper, ItemType type, List<ItemStack> items) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
@ -140,6 +145,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLink(Hopper hopper, Location location) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
@ -157,6 +163,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLinks(Hopper hopper) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
@ -170,12 +177,14 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createHoppers(List<Hopper> hoppers) {
|
||||
for (Hopper hopper : hoppers) {
|
||||
createHopper(hopper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createHopper(Hopper hopper) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
@ -274,6 +283,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHopper(Hopper hopper) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
@ -291,6 +301,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteHopper(Hopper hopper) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
@ -317,6 +328,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHoppers(Consumer<Map<Integer, Hopper>> callback) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
@ -1,10 +1,11 @@
|
||||
package com.songoda.epichoppers.gui;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.gui.CustomizableGui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersApi;
|
||||
import com.songoda.epichoppers.hopper.Filter;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.ItemType;
|
||||
@ -20,13 +21,13 @@ import java.util.List;
|
||||
public class GUIAutoSellFilter extends CustomizableGui {
|
||||
private static final List<GUIAutoSellFilter> OPEN_INVENTORIES = new ArrayList<>();
|
||||
|
||||
private final EpicHoppers plugin;
|
||||
private final SongodaPlugin plugin;
|
||||
private final Hopper hopper;
|
||||
|
||||
private final int[] whiteListSlots = {9, 10, 11, 18, 19, 20, 27, 28, 29, 36, 37, 38};
|
||||
private final int[] blackListSlots = {12, 13, 14, 21, 22, 23, 30, 31, 32, 39, 40, 41};
|
||||
|
||||
public GUIAutoSellFilter(EpicHoppers plugin, Hopper hopper) {
|
||||
public GUIAutoSellFilter(SongodaPlugin plugin, Hopper hopper) {
|
||||
super(plugin, "autosell");
|
||||
this.plugin = plugin;
|
||||
this.hopper = hopper;
|
||||
@ -63,7 +64,9 @@ public class GUIAutoSellFilter extends CustomizableGui {
|
||||
setButton("back", 8, GuiUtils.createButtonItem(XMaterial.ARROW.parseItem(),
|
||||
plugin.getLocale().getMessage("general.nametag.back").getMessage()),
|
||||
(event) -> {
|
||||
hopper.overview(this.guiManager, event.player);
|
||||
if (hopper.prepareForOpeningOverviewGui(event.player)) {
|
||||
this.guiManager.showGUI(event.player, new GUIOverview(plugin, hopper, event.player));
|
||||
}
|
||||
compile();
|
||||
});
|
||||
|
||||
@ -179,8 +182,8 @@ public class GUIAutoSellFilter extends CustomizableGui {
|
||||
|
||||
filter.setAutoSellWhiteList(whiteListItems);
|
||||
filter.setAutoSellBlackList(blackListItems);
|
||||
this.plugin.getDataManager().updateItems(this.hopper, ItemType.AUTO_SELL_WHITELIST, whiteListItems);
|
||||
this.plugin.getDataManager().updateItems(this.hopper, ItemType.AUTO_SELL_BLACKLIST, blackListItems);
|
||||
EpicHoppersApi.getApi().getDataManager().updateItems(this.hopper, ItemType.AUTO_SELL_WHITELIST, whiteListItems);
|
||||
EpicHoppersApi.getApi().getDataManager().updateItems(this.hopper, ItemType.AUTO_SELL_BLACKLIST, blackListItems);
|
||||
}
|
||||
|
||||
public static void compileOpenAutoSellFilter(Hopper hopper) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.epichoppers.gui;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.gui.CustomizableGui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoCrafting;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GUICrafting extends CustomizableGui {
|
||||
public GUICrafting(ModuleAutoCrafting module, EpicHoppers plugin, Hopper hopper, Player player) {
|
||||
public GUICrafting(ModuleAutoCrafting module, SongodaPlugin plugin, Hopper hopper, Player player) {
|
||||
super(plugin, "crafting");
|
||||
setRows(3);
|
||||
setTitle(Methods.formatName(hopper.getLevel().getLevel()) + TextUtils.formatText(" &8-&f Crafting"));
|
||||
@ -38,7 +38,9 @@ public class GUICrafting extends CustomizableGui {
|
||||
setButton("back", 8, GuiUtils.createButtonItem(XMaterial.ARROW.parseItem(),
|
||||
plugin.getLocale().getMessage("general.nametag.back").getMessage()),
|
||||
(event) -> {
|
||||
hopper.overview(this.guiManager, event.player);
|
||||
if (hopper.prepareForOpeningOverviewGui(event.player)) {
|
||||
this.guiManager.showGUI(event.player, new GUIOverview(plugin, hopper, event.player));
|
||||
}
|
||||
setItem(module, hopper, player);
|
||||
}
|
||||
);
|
||||
|
@ -1,10 +1,11 @@
|
||||
package com.songoda.epichoppers.gui;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.gui.CustomizableGui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersApi;
|
||||
import com.songoda.epichoppers.hopper.Filter;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.ItemType;
|
||||
@ -24,10 +25,10 @@ import java.util.List;
|
||||
public class GUIFilter extends CustomizableGui {
|
||||
private static final List<GUIFilter> OPEN_INVENTORIES = new ArrayList<>();
|
||||
|
||||
private final EpicHoppers plugin;
|
||||
private final SongodaPlugin plugin;
|
||||
private final Hopper hopper;
|
||||
|
||||
public GUIFilter(EpicHoppers plugin, Hopper hopper, Player player) {
|
||||
public GUIFilter(SongodaPlugin plugin, Hopper hopper, Player player) {
|
||||
super(plugin, "filter");
|
||||
this.plugin = plugin;
|
||||
this.hopper = hopper;
|
||||
@ -67,7 +68,9 @@ public class GUIFilter extends CustomizableGui {
|
||||
setButton("back", 8, GuiUtils.createButtonItem(XMaterial.ARROW.parseItem(),
|
||||
plugin.getLocale().getMessage("general.nametag.back").getMessage()),
|
||||
(event) -> {
|
||||
hopper.overview(this.guiManager, event.player);
|
||||
if (hopper.prepareForOpeningOverviewGui(event.player)) {
|
||||
this.guiManager.showGUI(event.player, new GUIOverview(plugin, hopper, event.player));
|
||||
}
|
||||
compile();
|
||||
});
|
||||
|
||||
@ -159,7 +162,7 @@ public class GUIFilter extends CustomizableGui {
|
||||
plugin.getLocale().getMessage("event.hopper.desync").sendPrefixedMessage(player);
|
||||
hopper.getFilter().setEndPoint(null);
|
||||
} else {
|
||||
plugin.getPlayerDataManager().getPlayerData(player).setSyncType(SyncType.FILTERED);
|
||||
EpicHoppersApi.getApi().getPlayerDataManager().getPlayerData(player).setSyncType(SyncType.FILTERED);
|
||||
plugin.getLocale().getMessage("event.hopper.syncnext").sendPrefixedMessage(player);
|
||||
hopper.timeout(player);
|
||||
}
|
||||
@ -232,9 +235,9 @@ public class GUIFilter extends CustomizableGui {
|
||||
filter.setWhiteList(owhite);
|
||||
filter.setBlackList(oblack);
|
||||
filter.setVoidList(ovoid);
|
||||
this.plugin.getDataManager().updateItems(this.hopper, ItemType.WHITELIST, owhite);
|
||||
this.plugin.getDataManager().updateItems(this.hopper, ItemType.BLACKLIST, oblack);
|
||||
this.plugin.getDataManager().updateItems(this.hopper, ItemType.VOID, ovoid);
|
||||
EpicHoppersApi.getApi().getDataManager().updateItems(this.hopper, ItemType.WHITELIST, owhite);
|
||||
EpicHoppersApi.getApi().getDataManager().updateItems(this.hopper, ItemType.BLACKLIST, oblack);
|
||||
EpicHoppersApi.getApi().getDataManager().updateItems(this.hopper, ItemType.VOID, ovoid);
|
||||
}
|
||||
|
||||
public static void compileOpenGuiFilter(Hopper hopper) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epichoppers.gui;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.gui.CustomizableGui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
@ -7,7 +8,7 @@ import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.NumberUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersApi;
|
||||
import com.songoda.epichoppers.boost.BoostData;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.levels.Level;
|
||||
@ -31,13 +32,13 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUIOverview extends CustomizableGui {
|
||||
private final EpicHoppers plugin;
|
||||
private final SongodaPlugin plugin;
|
||||
private final Hopper hopper;
|
||||
private final Player player;
|
||||
|
||||
private int task;
|
||||
|
||||
public GUIOverview(EpicHoppers plugin, Hopper hopper, Player player) {
|
||||
public GUIOverview(SongodaPlugin plugin, Hopper hopper, Player player) {
|
||||
super(plugin, "overview");
|
||||
this.plugin = plugin;
|
||||
this.hopper = hopper;
|
||||
@ -66,11 +67,11 @@ public class GUIOverview extends CustomizableGui {
|
||||
mirrorFill("mirrorfill_4", 1, 0, false, true, glass2);
|
||||
mirrorFill("mirrorfill_5", 1, 1, false, true, glass3);
|
||||
|
||||
this.plugin.getPlayerDataManager().getPlayerData(this.player).setLastHopper(this.hopper);
|
||||
EpicHoppersApi.getApi().getPlayerDataManager().getPlayerData(this.player).setLastHopper(this.hopper);
|
||||
|
||||
Level level = this.hopper.getLevel();
|
||||
|
||||
Level nextLevel = this.plugin.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? this.plugin.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||
Level nextLevel = EpicHoppersApi.getApi().getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? EpicHoppersApi.getApi().getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||
|
||||
ItemStack pearl = new ItemStack(Material.ENDER_PEARL, 1);
|
||||
ItemMeta pearlMeta = pearl.getItemMeta();
|
||||
@ -117,7 +118,7 @@ public class GUIOverview extends CustomizableGui {
|
||||
}
|
||||
}
|
||||
|
||||
BoostData boostData = this.plugin.getBoostManager().getBoost(this.hopper.getPlacedBy());
|
||||
BoostData boostData = EpicHoppersApi.getApi().getBoostManager().getBoost(this.hopper.getPlacedBy());
|
||||
if (boostData != null) {
|
||||
parts = this.plugin.getLocale().getMessage("interface.hopper.boostedstats")
|
||||
.processPlaceholder("amount", Integer.toString(boostData.getMultiplier()))
|
||||
@ -188,13 +189,13 @@ public class GUIOverview extends CustomizableGui {
|
||||
return;
|
||||
}
|
||||
this.hopper.clearLinkedBlocks();
|
||||
this.plugin.getDataManager().deleteLinks(this.hopper);
|
||||
EpicHoppersApi.getApi().getDataManager().deleteLinks(this.hopper);
|
||||
if (event.clickType == ClickType.RIGHT) {
|
||||
this.plugin.getLocale().getMessage("event.hopper.desync").sendPrefixedMessage(this.player);
|
||||
constructGUI();
|
||||
return;
|
||||
} else {
|
||||
this.plugin.getPlayerDataManager().getPlayerData(this.player).setSyncType(SyncType.REGULAR);
|
||||
EpicHoppersApi.getApi().getPlayerDataManager().getPlayerData(this.player).setSyncType(SyncType.REGULAR);
|
||||
this.plugin.getLocale().getMessage("event.hopper.syncnext").sendPrefixedMessage(this.player);
|
||||
|
||||
if (level.getLinkAmount() > 1) {
|
||||
@ -212,7 +213,7 @@ public class GUIOverview extends CustomizableGui {
|
||||
(event) -> {
|
||||
if (event.clickType == ClickType.LEFT) {
|
||||
if (this.hopper.getLinkedBlocks() != null) {
|
||||
this.plugin.getTeleportHandler().tpEntity(this.player, this.hopper);
|
||||
EpicHoppersApi.getApi().getTeleportHandler().tpEntity(this.player, this.hopper);
|
||||
this.player.closeInventory();
|
||||
}
|
||||
} else {
|
||||
@ -223,7 +224,7 @@ public class GUIOverview extends CustomizableGui {
|
||||
} else if (this.hopper.getTeleportTrigger() == TeleportTrigger.WALK_ON) {
|
||||
this.hopper.setTeleportTrigger(TeleportTrigger.DISABLED);
|
||||
}
|
||||
this.plugin.getDataManager().updateHopper(this.hopper);
|
||||
EpicHoppersApi.getApi().getDataManager().updateHopper(this.hopper);
|
||||
constructGUI();
|
||||
}
|
||||
});
|
||||
@ -258,7 +259,9 @@ public class GUIOverview extends CustomizableGui {
|
||||
: this.plugin.getLocale().getMessage("interface.hopper.alreadymaxed").getMessage()),
|
||||
(event) -> {
|
||||
this.hopper.upgrade(this.player, CostType.EXPERIENCE);
|
||||
this.hopper.overview(this.guiManager, this.player);
|
||||
if (this.hopper.prepareForOpeningOverviewGui(this.player)) {
|
||||
this.guiManager.showGUI(event.player, new GUIOverview(this.plugin, this.hopper, event.player));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (Settings.UPGRADE_WITH_ECONOMY.getBoolean()
|
||||
@ -273,7 +276,9 @@ public class GUIOverview extends CustomizableGui {
|
||||
: this.plugin.getLocale().getMessage("interface.hopper.alreadymaxed").getMessage()),
|
||||
(event) -> {
|
||||
this.hopper.upgrade(this.player, CostType.ECONOMY);
|
||||
this.hopper.overview(this.guiManager, this.player);
|
||||
if (this.hopper.prepareForOpeningOverviewGui(this.player)) {
|
||||
this.guiManager.showGUI(this.player, new GUIOverview(this.plugin, this.hopper, this.player));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.epichoppers.gui;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.gui.CustomizableGui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoSmelter;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
@ -18,7 +18,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUISmeltable extends CustomizableGui {
|
||||
private final EpicHoppers plugin;
|
||||
private final SongodaPlugin plugin;
|
||||
private final Hopper hopper;
|
||||
private final int maxPages;
|
||||
private final ModuleAutoSmelter moduleAutoSmelter;
|
||||
@ -28,7 +28,7 @@ public class GUISmeltable extends CustomizableGui {
|
||||
.filter(material -> CompatibleMaterial.getFurnaceResult(material) != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
public GUISmeltable(ModuleAutoSmelter moduleAutoSmelter, EpicHoppers plugin, Hopper hopper) {
|
||||
public GUISmeltable(ModuleAutoSmelter moduleAutoSmelter, SongodaPlugin plugin, Hopper hopper) {
|
||||
super(plugin, "smeltable");
|
||||
this.plugin = plugin;
|
||||
this.hopper = hopper;
|
||||
@ -102,7 +102,11 @@ public class GUISmeltable extends CustomizableGui {
|
||||
|
||||
setButton("exit", 49, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
|
||||
this.plugin.getLocale().getMessage("general.nametag.exit").getMessage()),
|
||||
(event) -> this.hopper.overview(this.plugin.getGuiManager(), event.player));
|
||||
(event) -> {
|
||||
if (this.hopper.prepareForOpeningOverviewGui(event.player)) {
|
||||
this.guiManager.showGUI(event.player, new GUIOverview(this.plugin, this.hopper, event.player));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(XMaterial material, boolean enabled) {
|
||||
|
@ -13,17 +13,20 @@ import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class LevelManager {
|
||||
public class LevelManagerImpl implements LevelManager {
|
||||
private final NavigableMap<Integer, Level> registeredLevels = new TreeMap<>();
|
||||
|
||||
@Override
|
||||
public void addLevel(int level, int costExperience, int costEconomy, int range, int amount, boolean filter, boolean teleport, int linkAmount, ArrayList<Module> modules) {
|
||||
this.registeredLevels.put(level, new Level(level, costExperience, costEconomy, range, amount, filter, teleport, linkAmount, modules));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getLevel(int level) {
|
||||
return this.registeredLevels.get(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getLevel(ItemStack item) {
|
||||
NBTItem nbtItem = new NBTItem(item);
|
||||
|
||||
@ -40,6 +43,7 @@ public class LevelManager {
|
||||
return getLowestLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEpicHopper(ItemStack item) {
|
||||
NBTCore nbt = NmsManager.getNbt();
|
||||
|
||||
@ -53,25 +57,30 @@ public class LevelManager {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Level getLowestLevel() {
|
||||
return this.registeredLevels.firstEntry().getValue();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Level getHighestLevel() {
|
||||
return this.registeredLevels.lastEntry().getValue();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLevel(int level) {
|
||||
return this.registeredLevels.containsKey(level);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<Integer, Level> getLevels() {
|
||||
return Collections.unmodifiableMap(this.registeredLevels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.registeredLevels.clear();
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.gui.GUICrafting;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
@ -37,8 +38,8 @@ public class ModuleAutoCrafting extends Module {
|
||||
|
||||
private final boolean crafterEjection;
|
||||
|
||||
public ModuleAutoCrafting(EpicHoppers plugin) {
|
||||
super(plugin);
|
||||
public ModuleAutoCrafting(SongodaPlugin plugin, GuiManager guiManager) {
|
||||
super(plugin, guiManager);
|
||||
this.crafterEjection = Settings.AUTOCRAFT_JAM_EJECT.getBoolean();
|
||||
}
|
||||
|
||||
@ -205,7 +206,7 @@ public class ModuleAutoCrafting extends Module {
|
||||
@Override
|
||||
public void runButtonPress(Player player, Hopper hopper, ClickType type) {
|
||||
hopper.setActivePlayer(player);
|
||||
this.plugin.getGuiManager().showGUI(player, new GUICrafting(this,this.plugin, hopper, player));
|
||||
this.guiManager.showGUI(player, new GUICrafting(this, this.plugin, hopper, player));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,11 @@
|
||||
package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.core.hooks.EconomyManager;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.NumberUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.gui.GUIAutoSellFilter;
|
||||
import com.songoda.epichoppers.hopper.Filter;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
@ -31,8 +32,8 @@ public class ModuleAutoSell extends Module {
|
||||
private final int timeOut;
|
||||
private final int hopperTickRate;
|
||||
|
||||
public ModuleAutoSell(EpicHoppers plugin, int timeOut) {
|
||||
super(plugin);
|
||||
public ModuleAutoSell(SongodaPlugin plugin, GuiManager guiManager, int timeOut) {
|
||||
super(plugin, guiManager);
|
||||
|
||||
this.timeOut = timeOut * 20;
|
||||
this.hopperTickRate = Settings.HOP_TICKS.getInt();
|
||||
@ -176,7 +177,7 @@ public class ModuleAutoSell extends Module {
|
||||
} else if (type == ClickType.SHIFT_LEFT || type == ClickType.SHIFT_RIGHT) {
|
||||
// Any shift click opens AutoSell filter configuration GUI
|
||||
hopper.setActivePlayer(player);
|
||||
this.plugin.getGuiManager().showGUI(player, new GUIAutoSellFilter(this.plugin, hopper));
|
||||
this.guiManager.showGUI(player, new GUIAutoSellFilter(this.plugin, hopper));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.gui.GUISmeltable;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
@ -22,8 +23,8 @@ public class ModuleAutoSmelter extends Module {
|
||||
private final int timeOut;
|
||||
private final int hopperTickRate;
|
||||
|
||||
public ModuleAutoSmelter(EpicHoppers plugin, int timeOut) {
|
||||
super(plugin);
|
||||
public ModuleAutoSmelter(SongodaPlugin plugin, GuiManager guiManager, int timeOut) {
|
||||
super(plugin, guiManager);
|
||||
this.timeOut = timeOut * 20;
|
||||
this.hopperTickRate = Settings.HOP_TICKS.getInt();
|
||||
}
|
||||
@ -103,7 +104,7 @@ public class ModuleAutoSmelter extends Module {
|
||||
public void runButtonPress(Player player, Hopper hopper, ClickType type) {
|
||||
if (type == ClickType.LEFT) {
|
||||
hopper.setActivePlayer(player);
|
||||
this.plugin.getGuiManager().showGUI(player, new GUISmeltable(this, this.plugin, hopper));
|
||||
this.guiManager.showGUI(player, new GUISmeltable(this, this.plugin, hopper));
|
||||
} else if (type == ClickType.RIGHT) {
|
||||
toggleEnabled(hopper);
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersApi;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
import com.songoda.epichoppers.utils.StorageContainerCache;
|
||||
@ -30,8 +32,8 @@ public class ModuleBlockBreak extends Module {
|
||||
private final int ticksPerBreak;
|
||||
private final Map<Hopper, Integer> blockTick = new HashMap<>();
|
||||
|
||||
public ModuleBlockBreak(EpicHoppers plugin, int amount) {
|
||||
super(plugin);
|
||||
public ModuleBlockBreak(SongodaPlugin plugin, GuiManager guiManager, int amount) {
|
||||
super(plugin, guiManager);
|
||||
this.ticksPerBreak = amount;
|
||||
}
|
||||
|
||||
@ -66,7 +68,7 @@ public class ModuleBlockBreak extends Module {
|
||||
Block above = hopper.getLocation().getBlock().getRelative(0, 1, 0);
|
||||
|
||||
// Don't break farm items from custom containers
|
||||
if (this.plugin.getContainerManager().getCustomContainer(above) != null) {
|
||||
if (EpicHoppersApi.getApi().getContainerManager().getCustomContainer(above) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.utils.StorageContainerCache;
|
||||
import org.bukkit.Location;
|
||||
@ -23,9 +24,8 @@ public class ModuleMobHopper extends Module {
|
||||
private final int amount;
|
||||
private final Map<Block, Integer> blockTick = new HashMap<>();
|
||||
|
||||
|
||||
public ModuleMobHopper(EpicHoppers plugin, int amount) {
|
||||
super(plugin);
|
||||
public ModuleMobHopper(SongodaPlugin plugin, GuiManager guiManager, int amount) {
|
||||
super(plugin, guiManager);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.bgsoftware.wildstacker.api.WildStackerAPI;
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.compatibility.CompatibleParticleHandler;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.core.locale.Locale;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
@ -38,8 +39,8 @@ public class ModuleSuction extends Module {
|
||||
|
||||
private final int maxSearchRadius;
|
||||
|
||||
public ModuleSuction(EpicHoppers plugin, int amount) {
|
||||
super(plugin);
|
||||
public ModuleSuction(SongodaPlugin plugin, GuiManager guiManager, int amount) {
|
||||
super(plugin, guiManager);
|
||||
this.maxSearchRadius = amount;
|
||||
}
|
||||
|
||||
|
@ -20,16 +20,17 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TeleportHandler {
|
||||
public class TeleportHandlerImpl implements TeleportHandler {
|
||||
private final Map<UUID, Long> lastTeleports = new HashMap<>();
|
||||
|
||||
private final EpicHoppers plugin;
|
||||
|
||||
public TeleportHandler(EpicHoppers plugin) {
|
||||
public TeleportHandlerImpl(EpicHoppers plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::teleportRunner, 0, Settings.TELEPORT_TICKS.getLong());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tpEntity(Entity entity, Hopper hopper) {
|
||||
if (hopper == null || !this.plugin.getHopperManager().isHopper(hopper.getLocation())) {
|
||||
return;
|
@ -3,6 +3,7 @@ package com.songoda.epichoppers.listeners;
|
||||
import com.craftaro.core.hooks.ProtectionManager;
|
||||
import com.craftaro.core.hooks.WorldGuardHook;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.gui.GUIOverview;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.teleport.TeleportTrigger;
|
||||
import com.songoda.epichoppers.player.PlayerData;
|
||||
@ -90,7 +91,9 @@ public class InteractListeners implements Listener {
|
||||
|
||||
Hopper hopper = this.plugin.getHopperManager().getHopper(event.getClickedBlock());
|
||||
if (!player.getInventory().getItemInHand().getType().name().contains("PICKAXE")) {
|
||||
hopper.overview(this.plugin.getGuiManager(), player);
|
||||
if (hopper.prepareForOpeningOverviewGui(player)) {
|
||||
this.plugin.getGuiManager().showGUI(player, new GUIOverview(this.plugin, hopper, player));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -8,17 +8,19 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerDataManager {
|
||||
public class PlayerDataManagerImpl implements PlayerDataManager {
|
||||
private final Map<UUID, PlayerData> registeredPlayers = new HashMap<>();
|
||||
|
||||
private PlayerData getPlayerData(UUID uuid) {
|
||||
return this.registeredPlayers.computeIfAbsent(uuid, u -> new PlayerData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerData getPlayerData(Player player) {
|
||||
return getPlayerData(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PlayerData> getRegisteredPlayers() {
|
||||
return Collections.unmodifiableCollection(this.registeredPlayers.values());
|
||||
}
|
Loading…
Reference in New Issue
Block a user