mirror of
https://github.com/songoda/EpicHoppers.git
synced 2025-01-26 09:31:25 +01:00
Cleaned up instance system.
Removed listeners from main class. Added better location methods for hoppers. Incremented version. Started work on a real API Removed sc alias for the main command.
This commit is contained in:
parent
470b19ade2
commit
c46972e3d3
23
EpicHoppers-API/EpicHoppers-API.iml
Normal file
23
EpicHoppers-API/EpicHoppers-API.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<output url="file://$MODULE_DIR$/../target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/../target/classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Lib1" level="project" />
|
||||
<orderEntry type="library" name="spigot-1.132" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,31 @@
|
||||
package com.songoda.epichoppers.api;
|
||||
|
||||
import com.songoda.epichoppers.api.hopper.HopperManager;
|
||||
import com.songoda.epichoppers.api.hopper.Level;
|
||||
import com.songoda.epichoppers.api.hopper.LevelManager;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* The main API class for the EpicHoppers plugin. This class will provide various
|
||||
* methods to access important features of the plugin's API. For static method
|
||||
* wrappers to all methods in this interface, see the {@link EpicHoppersAPI} class
|
||||
*/
|
||||
public interface EpicHoppers {
|
||||
|
||||
Level getLevelFromItem(ItemStack item);
|
||||
|
||||
/**
|
||||
* Get an instance of the {@link LevelManager}
|
||||
*
|
||||
* @return the level manager
|
||||
*/
|
||||
LevelManager getLevelManager();
|
||||
|
||||
|
||||
/**
|
||||
* Get an instance of the {@link HopperManager}
|
||||
*
|
||||
* @return the hopper manager
|
||||
*/
|
||||
HopperManager getHopperManager();
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.songoda.epichoppers.api;
|
||||
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* The access point of the EpicHoppersAPI, a class acting as a bridge between API
|
||||
* and plugin implementation. It is from here where developers should access the
|
||||
* important and core methods in the API. All static methods in this class will
|
||||
* call directly upon the implementation at hand (in most cases this will be the
|
||||
* EpicHoppers plugin itself), therefore a call to {@link #getImplementation()} is
|
||||
* not required and redundant in most situations. Method calls from this class are
|
||||
* preferred the majority of time, though an instance of {@link EpicHoppers} may
|
||||
* be passed if absolutely necessary.
|
||||
*
|
||||
* @see EpicHoppers
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class EpicHoppersAPI {
|
||||
|
||||
private static EpicHoppers implementation;
|
||||
|
||||
/**
|
||||
* Set the EpicHoppers implementation. Once called for the first time, this
|
||||
* method will throw an exception on any subsequent invocations. The implementation
|
||||
* may only be set a single time, presumably by the EpicHoppers plugin
|
||||
*
|
||||
* @param implementation the implementation to set
|
||||
*/
|
||||
public static void setImplementation(EpicHoppers implementation) {
|
||||
if (EpicHoppersAPI.implementation != null) {
|
||||
throw new IllegalArgumentException("Cannot set API implementation twice");
|
||||
}
|
||||
|
||||
EpicHoppersAPI.implementation = implementation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the EpicHoppers implementation. This method may be redundant in most
|
||||
* situations as all methods present in {@link EpicHoppers} will be mirrored
|
||||
* with static modifiers in the {@link EpicHoppersAPI} class
|
||||
*
|
||||
* @return the EpicHoppers implementation
|
||||
*/
|
||||
public static EpicHoppers getImplementation() {
|
||||
return implementation;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.songoda.epichoppers.api.hopper;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Filter {
|
||||
List<ItemStack> getWhiteList();
|
||||
|
||||
void setWhiteList(List<ItemStack> whiteList);
|
||||
|
||||
List<ItemStack> getBlackList();
|
||||
|
||||
void setBlackList(List<ItemStack> blackList);
|
||||
|
||||
List<ItemStack> getVoidList();
|
||||
|
||||
void setVoidList(List<ItemStack> voidList);
|
||||
|
||||
Block getEndPoint();
|
||||
|
||||
void setEndPoint(Block endPoint);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.songoda.epichoppers.api.hopper;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Hopper {
|
||||
void sync(Block toSync, boolean filtered, Player player);
|
||||
|
||||
Location getLocation();
|
||||
|
||||
int getX();
|
||||
|
||||
int getY();
|
||||
|
||||
int getZ();
|
||||
|
||||
Level getLevel();
|
||||
|
||||
UUID getLastPlayer();
|
||||
|
||||
boolean isWalkOnTeleport();
|
||||
|
||||
void setWalkOnTeleport(boolean walkOnTeleport);
|
||||
|
||||
Block getSyncedBlock();
|
||||
|
||||
void setSyncedBlock(Block syncedBlock);
|
||||
|
||||
Filter getFilter();
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.songoda.epichoppers.api.hopper;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface HopperManager {
|
||||
|
||||
void addHopper(Location location, Hopper hopper);
|
||||
|
||||
Hopper removeHopper(Location location);
|
||||
|
||||
Hopper getHopper(Location location);
|
||||
|
||||
Hopper getHopper(Block block);
|
||||
|
||||
boolean isHopper(Location location);
|
||||
|
||||
Map<Location, Hopper> getHoppers();
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.songoda.epichoppers.api.hopper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Level {
|
||||
List<String> getDescription();
|
||||
|
||||
int getLevel();
|
||||
|
||||
int getRange();
|
||||
|
||||
int getAmount();
|
||||
|
||||
int getBlockBreak();
|
||||
|
||||
int getSuction();
|
||||
|
||||
int getCostExperience();
|
||||
|
||||
int getCostEconomy();
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.songoda.epichoppers.api.hopper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface LevelManager {
|
||||
void addLevel(int level, int costExperiance, int costEconomy, int range, int amount, int suction, int blockBreak);
|
||||
|
||||
Level getLevel(int level);
|
||||
|
||||
Level getLowestLevel();
|
||||
|
||||
Level getHighestLevel();
|
||||
|
||||
Map<Integer, Level> getLevels();
|
||||
}
|
26
EpicHoppers-Plugin/EpicHoppers-Plugin.iml
Normal file
26
EpicHoppers-Plugin/EpicHoppers-Plugin.iml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<output url="file://$MODULE_DIR$/../target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/../target/classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Lib1" level="project" />
|
||||
<orderEntry type="library" name="spigot-1.131" level="project" />
|
||||
<orderEntry type="library" name="spigot-1.132" level="project" />
|
||||
<orderEntry type="module" module-name="EpicHoppers-API" />
|
||||
</component>
|
||||
</module>
|
@ -3,70 +3,66 @@ package com.songoda.epichoppers;
|
||||
import com.songoda.arconix.api.mcupdate.MCUpdate;
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.API.EpicHoppersAPI;
|
||||
import com.songoda.epichoppers.Events.*;
|
||||
import com.songoda.epichoppers.Handlers.*;
|
||||
import com.songoda.epichoppers.Hopper.Filter;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Hopper.HopperManager;
|
||||
import com.songoda.epichoppers.Hopper.LevelManager;
|
||||
import com.songoda.epichoppers.Utils.SettingsManager;
|
||||
import com.songoda.epichoppers.api.EpicHoppers;
|
||||
import com.songoda.epichoppers.api.EpicHoppersAPI;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.api.hopper.HopperManager;
|
||||
import com.songoda.epichoppers.api.hopper.Level;
|
||||
import com.songoda.epichoppers.api.hopper.LevelManager;
|
||||
import com.songoda.epichoppers.events.*;
|
||||
import com.songoda.epichoppers.handlers.*;
|
||||
import com.songoda.epichoppers.hopper.EFilter;
|
||||
import com.songoda.epichoppers.hopper.EHopper;
|
||||
import com.songoda.epichoppers.hopper.EHopperManager;
|
||||
import com.songoda.epichoppers.hopper.ELevelManager;
|
||||
import com.songoda.epichoppers.player.PlayerDataManager;
|
||||
import com.songoda.epichoppers.utils.SettingsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public final class EpicHoppers extends JavaPlugin implements Listener {
|
||||
public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
public static CommandSender console = Bukkit.getConsoleSender();
|
||||
|
||||
public Map<UUID, Hopper> inShow = new HashMap<>();
|
||||
public Map<UUID, Hopper> inFilter = new HashMap<>();
|
||||
private static EpicHoppersPlugin INSTANCE;
|
||||
|
||||
public HookHandler hooks;
|
||||
public SettingsManager sm;
|
||||
public SettingsManager settingsManager;
|
||||
|
||||
public References references = null;
|
||||
public ConfigWrapper dataFile = new ConfigWrapper(this, "", "data.yml");
|
||||
|
||||
public Map<Player, Block> sync = new HashMap<>();
|
||||
public Map<Player, Block> bsync = new HashMap<>();
|
||||
|
||||
public Map<Player, Date> lastTp = new HashMap<>();
|
||||
|
||||
public Map<Player, Block> lastBlock = new HashMap<>();
|
||||
|
||||
public EnchantmentHandler enchant;
|
||||
public EnchantmentHandler enchantmentHandler;
|
||||
|
||||
private Locale locale;
|
||||
|
||||
private HopperManager hopperManager;
|
||||
private LevelManager levelManager;
|
||||
private PlayerDataManager playerDataManager;
|
||||
|
||||
private TeleportHandler teleportHandler;
|
||||
|
||||
private EpicHoppersAPI api;
|
||||
|
||||
public void onEnable() {
|
||||
INSTANCE = this;
|
||||
EpicHoppersAPI.setImplementation(this);
|
||||
|
||||
Arconix.pl().hook(this);
|
||||
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7EpicHoppers " + this.getDescription().getVersion() + " by &5Brianna <3&7!"));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &aEnabling&7..."));
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
api = new EpicHoppersAPI();
|
||||
|
||||
sm = new SettingsManager(this);
|
||||
settingsManager = new SettingsManager(this);
|
||||
setupConfig();
|
||||
loadDataFile();
|
||||
enchant = new EnchantmentHandler();
|
||||
enchantmentHandler = new EnchantmentHandler();
|
||||
playerDataManager = new PlayerDataManager();
|
||||
|
||||
// Locales
|
||||
Locale.init(this);
|
||||
@ -75,7 +71,7 @@ public final class EpicHoppers extends JavaPlugin implements Listener {
|
||||
|
||||
loadLevelManager();
|
||||
|
||||
hopperManager = new HopperManager();
|
||||
hopperManager = new EHopperManager();
|
||||
|
||||
/*
|
||||
* Register hoppers into HopperManger from configuration
|
||||
@ -103,14 +99,14 @@ public final class EpicHoppers extends JavaPlugin implements Listener {
|
||||
String blackLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".black");
|
||||
Block black = blackLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".black")).getBlock();
|
||||
|
||||
Filter filter = new Filter();
|
||||
EFilter filter = new EFilter();
|
||||
|
||||
filter.setWhiteList(whiteList);
|
||||
filter.setBlackList(blackList);
|
||||
filter.setVoidList(voidList);
|
||||
filter.setEndPoint(black);
|
||||
|
||||
Hopper hopper = new Hopper(location, levelManager.getLevel(level), player, block, filter, walkOnTeleport);
|
||||
EHopper hopper = new EHopper(location, levelManager.getLevel(level), player, block, filter, walkOnTeleport);
|
||||
|
||||
hopperManager.addHopper(location, hopper);
|
||||
}
|
||||
@ -182,11 +178,11 @@ public final class EpicHoppers extends JavaPlugin implements Listener {
|
||||
|
||||
private void loadLevelManager() {
|
||||
// Load an instance of LevelManager
|
||||
levelManager = new LevelManager();
|
||||
levelManager = new ELevelManager();
|
||||
/*
|
||||
* Register Levels into LevelManager from configuration.
|
||||
*/
|
||||
levelManager.clear();
|
||||
((ELevelManager)levelManager).clear();
|
||||
for (String levelName : getConfig().getConfigurationSection("settings.levels").getKeys(false)) {
|
||||
int level = Integer.valueOf(levelName.split("-")[1]);
|
||||
int radius = getConfig().getInt("settings.levels." + levelName + ".Range");
|
||||
@ -200,7 +196,7 @@ public final class EpicHoppers extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
private void setupConfig() {
|
||||
sm.updateSettings();
|
||||
settingsManager.updateSettings();
|
||||
|
||||
if (!getConfig().contains("settings.levels.Level-1")) {
|
||||
getConfig().addDefault("settings.levels.Level-1.Range", 10);
|
||||
@ -256,6 +252,17 @@ public final class EpicHoppers extends JavaPlugin implements Listener {
|
||||
loadLevelManager();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Level getLevelFromItem(ItemStack item) {
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String arr[] = item.getItemMeta().getDisplayName().replace("§", "").split(":");
|
||||
return getLevelManager().getLevel(Integer.parseInt(arr[0]));
|
||||
} else {
|
||||
return getLevelManager().getLowestLevel();
|
||||
}
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
@ -264,19 +271,21 @@ public final class EpicHoppers extends JavaPlugin implements Listener {
|
||||
return teleportHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LevelManager getLevelManager() {
|
||||
return levelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HopperManager getHopperManager() {
|
||||
return hopperManager;
|
||||
}
|
||||
|
||||
public static EpicHoppers getInstance() {
|
||||
return (EpicHoppers) Bukkit.getServer().getPluginManager().getPlugin("EpicHoppers");
|
||||
public PlayerDataManager getPlayerDataManager() {
|
||||
return playerDataManager;
|
||||
}
|
||||
|
||||
public EpicHoppersAPI getApi() {
|
||||
return api;
|
||||
public static EpicHoppersPlugin getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ public class References {
|
||||
private String prefix;
|
||||
|
||||
public References() {
|
||||
prefix = EpicHoppers.getInstance().getLocale().getMessage("general.nametag.prefix") + " ";
|
||||
prefix = EpicHoppersPlugin.getInstance().getLocale().getMessage("general.nametag.prefix") + " ";
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
@ -1,21 +1,18 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
package com.songoda.epichoppers.events;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Filter;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.EFilter;
|
||||
import com.songoda.epichoppers.hopper.EHopper;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -25,16 +22,14 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class BlockListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
private EpicHoppersPlugin instance;
|
||||
|
||||
public BlockListeners(EpicHoppers instance) {
|
||||
public BlockListeners(EpicHoppersPlugin instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@ -62,7 +57,7 @@ public class BlockListeners implements Listener {
|
||||
e.getBlock().setType(Material.AIR);
|
||||
e.getBlock().getLocation().getBlock().setType(Material.HOPPER);
|
||||
|
||||
instance.getHopperManager().addHopper(e.getBlock().getLocation(), new Hopper(e.getBlock(), instance.getLevelManager().getLevel(instance.getApi().getILevel(item)), e.getPlayer().getUniqueId(), null, new Filter(), false));
|
||||
instance.getHopperManager().addHopper(e.getBlock().getLocation(), new EHopper(e.getBlock(), instance.getLevelFromItem(item), e.getPlayer().getUniqueId(), null, new EFilter(), false));
|
||||
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
@ -94,8 +89,9 @@ public class BlockListeners implements Listener {
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getPlayer().getItemInHand() == null) return;
|
||||
if (player.getInventory().getItemInMainHand() == null) return;
|
||||
|
||||
handleSyncTouch(event);
|
||||
|
||||
@ -131,7 +127,7 @@ public class BlockListeners implements Listener {
|
||||
}
|
||||
instance.getHopperManager().removeHopper(block.getLocation());
|
||||
|
||||
instance.sync.remove(event.getPlayer());
|
||||
instance.getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
|
||||
|
||||
} catch (Exception ee) {
|
||||
@ -142,7 +138,7 @@ public class BlockListeners implements Listener {
|
||||
private void handleSyncTouch(BlockBreakEvent e) {
|
||||
if (!Methods.isSync(e.getPlayer())) return;
|
||||
|
||||
ItemStack tool = e.getPlayer().getItemInHand();
|
||||
ItemStack tool = e.getPlayer().getInventory().getItemInMainHand();
|
||||
ItemMeta meta = tool.getItemMeta();
|
||||
if (tool.getItemMeta().getLore().size() != 2) return;
|
||||
|
||||
@ -150,22 +146,20 @@ public class BlockListeners implements Listener {
|
||||
|
||||
if (location.getBlock().getType() != Material.CHEST) return;
|
||||
|
||||
if (e.getBlock().getType() == Material.SPAWNER || e.getBlock().getType() == Material.HOPPER || e.getBlock().getType() == Material.DISPENSER) return;
|
||||
|
||||
try {
|
||||
if (e.getBlock().getType().name().contains("SHULKER") && e.getBlock().getType() != Material.SHULKER_SHELL) return;
|
||||
} catch (Exception ee) {
|
||||
|
||||
if (e.getBlock().getType() == Material.SHULKER_BOX
|
||||
|| e.getBlock().getType() == Material.SPAWNER
|
||||
|| e.getBlock().getType() == Material.HOPPER
|
||||
|| e.getBlock().getType() == Material.DISPENSER) {
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryHolder ih = (InventoryHolder) location.getBlock().getState();
|
||||
if (e.getPlayer().getItemInHand().getItemMeta().hasEnchant(Enchantment.SILK_TOUCH)) {
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasEnchant(Enchantment.SILK_TOUCH)) {
|
||||
ih.getInventory().addItem(new ItemStack(e.getBlock().getType(), 1, e.getBlock().getData()));
|
||||
} else {
|
||||
for (ItemStack is : e.getBlock().getDrops())
|
||||
ih.getInventory().addItem(is);
|
||||
}
|
||||
e.setDropItems(false);
|
||||
return;
|
||||
}
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
package com.songoda.epichoppers.events;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.EHopper;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Hopper;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -28,9 +29,9 @@ import java.util.UUID;
|
||||
*/
|
||||
public class HopperListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
private EpicHoppersPlugin instance;
|
||||
|
||||
public HopperListeners(EpicHoppers instance) {
|
||||
public HopperListeners(EpicHoppersPlugin instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@ -43,7 +44,7 @@ public class HopperListeners implements Listener {
|
||||
|
||||
if (!instance.getHopperManager().isHopper(e.getSource().getLocation())) return;
|
||||
|
||||
com.songoda.epichoppers.Hopper.Hopper hopper = instance.getHopperManager().getHopper(e.getSource().getLocation());
|
||||
Hopper hopper = instance.getHopperManager().getHopper(e.getSource().getLocation());
|
||||
|
||||
if (source.getHolder() instanceof Hopper && hopper.getSyncedBlock() != null) {
|
||||
e.setCancelled(true);
|
@ -1,9 +1,12 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
package com.songoda.epichoppers.events;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.EHopper;
|
||||
import com.songoda.epichoppers.player.PlayerData;
|
||||
import com.songoda.epichoppers.player.SyncType;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -18,9 +21,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class InteractListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
private EpicHoppersPlugin instance;
|
||||
|
||||
public InteractListeners(EpicHoppers instance) {
|
||||
public InteractListeners(EpicHoppersPlugin instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@ -41,58 +44,51 @@ public class InteractListeners implements Listener {
|
||||
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
|
||||
if (item.getItemMeta().getLore().size() == 2) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.desyncchest", item.getType().toString()));
|
||||
instance.enchant.createSyncTouch(item, null);
|
||||
instance.enchantmentHandler.createSyncTouch(item, null);
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncchest", item.getType().toString()));
|
||||
instance.enchant.createSyncTouch(item, e.getClickedBlock());
|
||||
instance.enchantmentHandler.createSyncTouch(item, e.getClickedBlock());
|
||||
}
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (!instance.sync.containsKey(player) && !instance.bsync.containsKey(player)) {
|
||||
if (playerData.getSyncType() == null) {
|
||||
if (e.getClickedBlock().getType() == Material.HOPPER) {
|
||||
instance.lastBlock.put(player, e.getClickedBlock());
|
||||
Hopper hopper = instance.getHopperManager().getHopper(e.getClickedBlock());
|
||||
if (instance.getConfig().getBoolean("Main.Allow Hopper Upgrading")) {
|
||||
if (!player.getInventory().getItemInMainHand().getType().name().contains("PICKAXE")) {
|
||||
hopper.overview(player);
|
||||
playerData.setLastHopper(hopper);
|
||||
if (instance.getConfig().getBoolean("Main.Allow hopper Upgrading")
|
||||
&& !player.getInventory().getItemInMainHand().getType().name().contains("PICKAXE")) {
|
||||
((EHopper)hopper).overview(player);
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else { //ToDO: What is this?
|
||||
|
||||
//ToDO: What is this?
|
||||
if (player.hasPermission("EpicHoppers.Admin")) {
|
||||
instance.sync.put(player, instance.lastBlock.get(player));
|
||||
playerData.setLastHopper(hopper);
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||
hopper.timeout(player);
|
||||
((EHopper)hopper).timeout(player);
|
||||
player.closeInventory();
|
||||
}
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getClickedBlock().getType() == Material.BREWING_STAND) return;
|
||||
|
||||
if (e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && instance.getConfig().getBoolean("Main.Support Enderchests")) {
|
||||
if (instance.sync.containsKey(player) && instance.sync.get(player).equals(e.getClickedBlock()) || instance.bsync.containsKey(player) && instance.bsync.get(player).equals(e.getClickedBlock())) {
|
||||
if (playerData.getSyncType() != null && e.getClickedBlock().getLocation().equals(playerData.getLastHopper().getLocation())) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncself"));
|
||||
} else {
|
||||
if (instance.sync.containsKey(player)) {
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.sync.get(player));
|
||||
hopper.sync(e.getClickedBlock(), false, player);
|
||||
} else if (instance.bsync.containsKey(player)) {
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.bsync.get(player));
|
||||
hopper.sync(e.getClickedBlock(), true, player);
|
||||
}
|
||||
} else if (playerData.getSyncType() != null) {
|
||||
playerData.getLastHopper().sync(e.getClickedBlock(), playerData.getSyncType() == SyncType.FILTERED, player);
|
||||
}
|
||||
e.setCancelled(true);
|
||||
instance.sync.remove(player);
|
||||
instance.bsync.remove(player);
|
||||
playerData.setSyncType(null);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
package com.songoda.epichoppers.events;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.EHopper;
|
||||
import com.songoda.epichoppers.player.MenuType;
|
||||
import com.songoda.epichoppers.player.PlayerData;
|
||||
import com.songoda.epichoppers.player.SyncType;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,59 +22,63 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class InventoryListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
private EpicHoppersPlugin instance;
|
||||
|
||||
public InventoryListeners(EpicHoppers instance) {
|
||||
public InventoryListeners(EpicHoppersPlugin instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
try {
|
||||
|
||||
Inventory inv = e.getInventory();
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (inv == null || e.getCurrentItem() == null) return;
|
||||
Inventory inv = event.getInventory();
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (inv == null || event.getCurrentItem() == null) return;
|
||||
|
||||
if (e.getCursor() != null && e.getCurrentItem() != null) {
|
||||
ItemStack c = e.getCursor();
|
||||
ItemStack item = e.getCurrentItem();
|
||||
|
||||
if (event.getRawSlot() > event.getView().getTopInventory().getSize() - 1) return;
|
||||
|
||||
if (event.getCursor() != null && event.getCurrentItem() != null) {
|
||||
ItemStack c = event.getCursor();
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (c.hasItemMeta()
|
||||
&& c.getItemMeta().hasLore()
|
||||
&& c.getType() == Material.ENCHANTED_BOOK
|
||||
&& (item.getType().name().toUpperCase().contains("AXE") || item.getType().name().toUpperCase().contains("SPADE") || item.getType().name().toUpperCase().contains("SWORD"))
|
||||
&& c.getItemMeta().getLore().equals(instance.enchant.getbook().getItemMeta().getLore())) {
|
||||
instance.enchant.createSyncTouch(item, null);
|
||||
e.setCancelled(true);
|
||||
&& c.getItemMeta().getLore().equals(instance.enchantmentHandler.getbook().getItemMeta().getLore())) {
|
||||
instance.enchantmentHandler.createSyncTouch(item, null);
|
||||
event.setCancelled(true);
|
||||
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (!e.getCurrentItem().hasItemMeta()) return;
|
||||
if (!event.getCurrentItem().hasItemMeta()) return;
|
||||
|
||||
if (doFilter(e)) return;
|
||||
if (doFilter(event)) return;
|
||||
|
||||
if (e.getSlot() != 64537
|
||||
&& e.getInventory().getType() == InventoryType.ANVIL
|
||||
&& e.getAction() != InventoryAction.NOTHING
|
||||
&& e.getCurrentItem().getType() != Material.AIR) {
|
||||
ItemStack item = e.getCurrentItem();
|
||||
if (event.getSlot() != 64537
|
||||
&& event.getInventory().getType() == InventoryType.ANVIL
|
||||
&& event.getAction() != InventoryAction.NOTHING
|
||||
&& event.getCurrentItem().getType() != Material.AIR) {
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (item.getType() == Material.HOPPER) {
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!instance.inShow.containsKey(player.getUniqueId()) || instance.inFilter.containsKey(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.lastBlock.get(player));
|
||||
if (e.getCurrentItem().getItemMeta().hasDisplayName()
|
||||
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.perltitle"))
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (playerData.getInMenu() != MenuType.OVERVIEW) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
Hopper hopper = playerData.getLastHopper();
|
||||
if (event.getCurrentItem().getItemMeta().hasDisplayName()
|
||||
&& event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.perltitle"))
|
||||
&& (instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || player.hasPermission("EpicHoppers.Teleport"))) {
|
||||
if (e.isLeftClick()) {
|
||||
if (event.isLeftClick()) {
|
||||
if (hopper.getSyncedBlock() != null) {
|
||||
instance.getTeleportHandler().tpPlayer(player, hopper);
|
||||
}
|
||||
@ -87,22 +94,22 @@ public class InventoryListeners implements Listener {
|
||||
player.closeInventory();
|
||||
|
||||
|
||||
} else if (e.getCurrentItem().getItemMeta().hasDisplayName() && e.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.filtertitle")) && player.hasPermission("EpicHoppers.Filter")) {
|
||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
hopper.filter(player);
|
||||
} else if (event.getCurrentItem().getItemMeta().hasDisplayName() && event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.filtertitle")) && player.hasPermission("EpicHoppers.Filter")) {
|
||||
if (!event.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
((EHopper)hopper).filter(player);
|
||||
}
|
||||
} else if (e.getSlot() == 11 && player.hasPermission("EpicHoppers.Upgrade.XP")) {
|
||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
hopper.upgrade("XP", player);
|
||||
} else if (event.getSlot() == 11 && player.hasPermission("EpicHoppers.Upgrade.XP")) {
|
||||
if (!event.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
((EHopper)hopper).upgrade("XP", player);
|
||||
player.closeInventory();
|
||||
}
|
||||
} else if (e.getSlot() == 15 && player.hasPermission("EpicHoppers.Upgrade.ECO")) {
|
||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
hopper.upgrade("ECO", player);
|
||||
} else if (event.getSlot() == 15 && player.hasPermission("EpicHoppers.Upgrade.ECO")) {
|
||||
if (!event.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
((EHopper)hopper).upgrade("ECO", player);
|
||||
player.closeInventory();
|
||||
}
|
||||
} else if (e.getSlot() == 22) {
|
||||
if (e.isRightClick()) {
|
||||
} else if (event.getSlot() == 22) {
|
||||
if (event.isRightClick()) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.desync"));
|
||||
hopper.setSyncedBlock(null);
|
||||
} else {
|
||||
@ -114,9 +121,9 @@ public class InventoryListeners implements Listener {
|
||||
}
|
||||
}
|
||||
if (can) {
|
||||
instance.sync.put(player, instance.lastBlock.get(player));
|
||||
playerData.setSyncType(SyncType.REGULAR);
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||
hopper.timeout(player);
|
||||
((EHopper)hopper).timeout(player);
|
||||
}
|
||||
}
|
||||
player.closeInventory();
|
||||
@ -128,7 +135,8 @@ public class InventoryListeners implements Listener {
|
||||
|
||||
private boolean doFilter(InventoryClickEvent e) {
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (!instance.inFilter.containsKey(player.getUniqueId())
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||
if (playerData.getInMenu() != MenuType.FILTER
|
||||
|| e.getInventory() == null
|
||||
|| !e.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
||||
return false;
|
||||
@ -138,12 +146,14 @@ public class InventoryListeners implements Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.lastBlock.get(player));
|
||||
hopper.compile(player);
|
||||
Hopper hopper = playerData.getLastHopper();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
((EHopper)hopper).compile(player);
|
||||
}, 1);
|
||||
if (e.getSlot() == 40) {
|
||||
instance.bsync.put(player, instance.lastBlock.get(player));
|
||||
playerData.setSyncType(SyncType.FILTERED);
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||
hopper.timeout(player);
|
||||
((EHopper)hopper).timeout(player);
|
||||
player.closeInventory();
|
||||
return true;
|
||||
}
|
||||
@ -198,12 +208,10 @@ public class InventoryListeners implements Listener {
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent event) {
|
||||
try {
|
||||
final Player player = (Player) event.getPlayer();
|
||||
instance.inShow.remove(player.getUniqueId());
|
||||
if (instance.inFilter.containsKey(player.getUniqueId())) {
|
||||
|
||||
instance.getHopperManager().getHopper(instance.lastBlock.get(player)).compile(player);
|
||||
instance.inFilter.remove(player.getUniqueId());
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData((Player)event.getPlayer());
|
||||
playerData.setInMenu(MenuType.NOT_IN);
|
||||
if (playerData.getSyncType() == SyncType.FILTERED) {
|
||||
((EHopper)playerData.getLastHopper()).compile((Player)event.getPlayer());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
package com.songoda.epichoppers.events;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -13,9 +13,9 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
*/
|
||||
public class LoginListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
private EpicHoppersPlugin instance;
|
||||
|
||||
public LoginListeners(EpicHoppers instance) {
|
||||
public LoginListeners(EpicHoppersPlugin instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
package com.songoda.epichoppers.handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -15,9 +15,9 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
|
||||
private final EpicHoppers plugin;
|
||||
private final EpicHoppersPlugin plugin;
|
||||
|
||||
public CommandHandler(final EpicHoppers plugin) {
|
||||
public CommandHandler(final EpicHoppersPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@ -38,11 +38,11 @@ public class CommandHandler implements CommandExecutor {
|
||||
} else {
|
||||
if (args.length == 1) {
|
||||
if (sender instanceof Player)
|
||||
((Player) sender).getInventory().addItem(plugin.enchant.getbook());
|
||||
((Player) sender).getInventory().addItem(plugin.enchantmentHandler.getbook());
|
||||
} else if (Bukkit.getPlayerExact(args[1]) == null) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cThat username does not exist, or the user is not online!"));
|
||||
} else {
|
||||
Bukkit.getPlayerExact(args[1]).getInventory().addItem(plugin.enchant.getbook());
|
||||
Bukkit.getPlayerExact(args[1]).getInventory().addItem(plugin.enchantmentHandler.getbook());
|
||||
}
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
@ -58,7 +58,7 @@ public class CommandHandler implements CommandExecutor {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
Player p = (Player) sender;
|
||||
plugin.sm.openSettingsManager(p);
|
||||
plugin.settingsManager.openSettingsManager(p);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
package com.songoda.epichoppers.handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -16,9 +16,9 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class EnchantmentHandler {
|
||||
|
||||
private EpicHoppers instance;
|
||||
private EpicHoppersPlugin instance;
|
||||
|
||||
public EnchantmentHandler(EpicHoppers instance) {
|
||||
public EnchantmentHandler(EpicHoppersPlugin instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
package com.songoda.epichoppers.handlers;
|
||||
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hooks.*;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.hooks.*;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,14 +17,14 @@ public class HookHandler {
|
||||
WorldGuardHook = null, GriefPreventionHook = null, PlotSquaredHook = null, KingdomsHook = null,
|
||||
TownyHook = null;
|
||||
|
||||
public ConfigWrapper hooksFile = new ConfigWrapper(EpicHoppers.getInstance(), "", "hooks.yml");
|
||||
public ConfigWrapper hooksFile = new ConfigWrapper(EpicHoppersPlugin.getInstance(), "", "hooks.yml");
|
||||
|
||||
public HookHandler() {
|
||||
}
|
||||
|
||||
public void hook() {
|
||||
try {
|
||||
hooksFile.createNewFile("Loading hooks File", EpicHoppers.getInstance().getDescription().getName() + " hooks File");
|
||||
hooksFile.createNewFile("Loading hooks File", EpicHoppersPlugin.getInstance().getDescription().getName() + " hooks File");
|
||||
|
||||
new FactionsHook();
|
||||
new RedProtectHook();
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
package com.songoda.epichoppers.handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.hopper.EHopper;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
@ -24,9 +24,9 @@ import java.util.*;
|
||||
*/
|
||||
public class HopHandler {
|
||||
|
||||
private EpicHoppers instance;
|
||||
private EpicHoppersPlugin instance;
|
||||
|
||||
public HopHandler(EpicHoppers instance) {
|
||||
public HopHandler(EpicHoppersPlugin instance) {
|
||||
try {
|
||||
this.instance = instance;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
@ -63,7 +63,7 @@ public class HopHandler {
|
||||
try {
|
||||
Set<Entity> metaItems = new HashSet<>();
|
||||
|
||||
for (com.songoda.epichoppers.Hopper.Hopper hopper : instance.getHopperManager().getHoppers().values()) {
|
||||
for (com.songoda.epichoppers.api.hopper.Hopper hopper : instance.getHopperManager().getHoppers().values()) {
|
||||
|
||||
Location location = hopper.getLocation();
|
||||
|
||||
@ -204,7 +204,7 @@ public class HopHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void doBlacklist(Hopper hopperBlock, com.songoda.epichoppers.Hopper.Hopper hopper, ItemStack item, ItemStack[] isS, int amt, int place) {
|
||||
private void doBlacklist(Hopper hopperBlock, com.songoda.epichoppers.api.hopper.Hopper hopper, ItemStack item, ItemStack[] isS, int amt, int place) {
|
||||
try {
|
||||
Location loc = hopperBlock.getLocation();
|
||||
Block b = loc.getBlock();
|
||||
@ -225,7 +225,7 @@ public class HopHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private int addItem(Hopper hopperBlock, com.songoda.epichoppers.Hopper.Hopper hopper, Block b2, ItemStack is, ItemStack[] isS, int amt, int place) {
|
||||
private int addItem(Hopper hopperBlock, com.songoda.epichoppers.api.hopper.Hopper hopper, Block b2, ItemStack is, ItemStack[] isS, int amt, int place) {
|
||||
try {
|
||||
ItemStack it = null;
|
||||
if (is != null) {
|
@ -1,9 +1,11 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
package com.songoda.epichoppers.handlers;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.EHopper;
|
||||
import com.songoda.epichoppers.player.PlayerData;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -20,9 +22,9 @@ public class TeleportHandler {
|
||||
//Teleport from - teleport 2
|
||||
private final Map<Location, Location> teleportFrom = new HashMap<>();
|
||||
|
||||
private EpicHoppers instance;
|
||||
private EpicHoppersPlugin instance;
|
||||
|
||||
public TeleportHandler(EpicHoppers instance) {
|
||||
public TeleportHandler(EpicHoppersPlugin instance) {
|
||||
try {
|
||||
this.instance = instance;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::teleportRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Teleport"));
|
||||
@ -47,21 +49,23 @@ public class TeleportHandler {
|
||||
|
||||
if (!hopper.isWalkOnTeleport()) continue;
|
||||
|
||||
if (instance.lastTp.containsKey(player)) {
|
||||
long duration = (new Date()).getTime() - instance.lastTp.get(player).getTime();
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (playerData.getLastTeleport() != null) {
|
||||
long duration = (new Date()).getTime() - playerData.getLastTeleport().getTime();
|
||||
if (duration <= 5 * 1000) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tpPlayer(player, hopper);
|
||||
instance.lastTp.put(player, new Date());
|
||||
playerData.setLastTeleport(new Date());
|
||||
}
|
||||
}
|
||||
|
||||
public void tpPlayer(Player player, Hopper hopper) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
Block next = hopper.getLocation().getBlock();
|
||||
int num = 1;
|
||||
while (instance.getHopperManager().isHopper(next.getLocation()) && instance.getHopperManager().getHopper(next.getLocation()).getSyncedBlock() != null && num != 15) {
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,7 +21,7 @@ public class ASkyBlockHook extends Hook {
|
||||
super("ASkyblock");
|
||||
if (isEnabled()) {
|
||||
as = ASkyBlockAPI.getInstance();
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||
plugin.hooks.ASkyBlockHook = this;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import me.markeh.factionsframework.entities.FPlayer;
|
||||
import me.markeh.factionsframework.entities.FPlayers;
|
||||
import me.markeh.factionsframework.entities.Faction;
|
||||
@ -16,7 +16,7 @@ public class FactionsHook extends Hook {
|
||||
|
||||
public FactionsHook() {
|
||||
super("Factions");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.GriefPreventionHook = this;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.bukkit.Location;
|
||||
@ -15,7 +15,7 @@ public class GriefPreventionHook extends Hook {
|
||||
|
||||
public GriefPreventionHook() {
|
||||
super("GriefPrevention");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.GriefPreventionHook = this;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -12,16 +12,16 @@ public abstract class Hook {
|
||||
protected Hook(String pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
if (isEnabled())
|
||||
EpicHoppers.getInstance().hooks.hooksFile.getConfig().addDefault("hooks." + pluginName, true);
|
||||
EpicHoppersPlugin.getInstance().hooks.hooksFile.getConfig().addDefault("hooks." + pluginName, true);
|
||||
}
|
||||
|
||||
protected boolean isEnabled() {
|
||||
return (Bukkit.getPluginManager().isPluginEnabled(pluginName)
|
||||
&& EpicHoppers.getInstance().hooks.hooksFile.getConfig().getBoolean("hooks." + pluginName, true));
|
||||
&& EpicHoppersPlugin.getInstance().hooks.hooksFile.getConfig().getBoolean("hooks." + pluginName, true));
|
||||
}
|
||||
|
||||
boolean hasBypass(Player p) {
|
||||
return p.hasPermission(EpicHoppers.getInstance().getDescription().getName() + ".bypass");
|
||||
return p.hasPermission(EpicHoppersPlugin.getInstance().getDescription().getName() + ".bypass");
|
||||
}
|
||||
|
||||
public abstract boolean canBuild(Player p, Location location);
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.kingdoms.constants.land.Land;
|
||||
@ -16,7 +16,7 @@ public class KingdomsHook extends Hook {
|
||||
|
||||
public KingdomsHook() {
|
||||
super("Kingdoms");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.KingdomsHook = this;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import com.intellectualcrafters.plot.api.PlotAPI;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -16,7 +16,7 @@ public class PlotSquaredHook extends Hook {
|
||||
public PlotSquaredHook() {
|
||||
super("PlotSquared");
|
||||
if (isEnabled()) {
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||
plugin.hooks.PlotSquaredHook = this;
|
||||
this.plotAPI = new PlotAPI();
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI;
|
||||
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -14,7 +14,7 @@ public class RedProtectHook extends Hook {
|
||||
|
||||
public RedProtectHook() {
|
||||
super("RedProtect");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.RedProtectHook = this;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -14,7 +14,7 @@ public class TownyHook extends Hook {
|
||||
|
||||
public TownyHook() {
|
||||
super("Towny");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.TownyHook = this;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,7 +17,7 @@ public class USkyBlockHook extends Hook {
|
||||
public USkyBlockHook() {
|
||||
super("USkyBlock");
|
||||
if (isEnabled()) {
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||
plugin.hooks.USkyBlockHook = this;
|
||||
this.usb = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin(pluginName);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
package com.songoda.epichoppers.hooks;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class WorldGuardHook extends Hook {
|
||||
|
||||
private EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
private EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||
|
||||
public WorldGuardHook() {
|
||||
super("WorldGuard");
|
@ -1,12 +1,13 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
package com.songoda.epichoppers.hopper;
|
||||
|
||||
import com.songoda.epichoppers.api.hopper.Filter;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Filter {
|
||||
public class EFilter implements Filter {
|
||||
|
||||
private List<ItemStack> whiteList = new ArrayList<>();
|
||||
private List<ItemStack> blackList = new ArrayList<>();
|
||||
@ -14,37 +15,45 @@ public class Filter {
|
||||
|
||||
private Block endPoint;
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getWhiteList() {
|
||||
if (whiteList == null) return new ArrayList<>();
|
||||
return whiteList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhiteList(List<ItemStack> whiteList) {
|
||||
this.whiteList = whiteList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getBlackList() {
|
||||
if (blackList == null) return new ArrayList<>();
|
||||
return blackList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlackList(List<ItemStack> blackList) {
|
||||
this.blackList = blackList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getVoidList() {
|
||||
if (voidList == null) return new ArrayList<>();
|
||||
return voidList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoidList(List<ItemStack> voidList) {
|
||||
this.voidList = voidList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getEndPoint() {
|
||||
return endPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEndPoint(Block endPoint) {
|
||||
this.endPoint = endPoint;
|
||||
}
|
@ -1,9 +1,14 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
package com.songoda.epichoppers.hopper;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Filter;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.api.hopper.Level;
|
||||
import com.songoda.epichoppers.player.MenuType;
|
||||
import com.songoda.epichoppers.player.PlayerData;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
@ -20,17 +25,17 @@ import java.util.UUID;
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class Hopper {
|
||||
public class EHopper implements Hopper {
|
||||
|
||||
private Location location;
|
||||
private Level level;
|
||||
private com.songoda.epichoppers.api.hopper.Level level;
|
||||
private UUID lastPlayer;
|
||||
private Block syncedBlock;
|
||||
private Filter filter;
|
||||
private boolean walkOnTeleport;
|
||||
|
||||
|
||||
public Hopper(Location location, Level level, UUID lastPlayer, Block syncedBlock, Filter filter, boolean walkOnTeleport) {
|
||||
public EHopper(Location location, com.songoda.epichoppers.api.hopper.Level level, UUID lastPlayer, Block syncedBlock, Filter filter, boolean walkOnTeleport) {
|
||||
this.location = location;
|
||||
this.level = level;
|
||||
this.syncedBlock = syncedBlock;
|
||||
@ -39,18 +44,18 @@ public class Hopper {
|
||||
this.walkOnTeleport = walkOnTeleport;
|
||||
}
|
||||
|
||||
public Hopper(Block block, Level level, UUID lastPlayer, Block syncedBlock, Filter filter, boolean walkOnTeleport) {
|
||||
public EHopper(Block block, com.songoda.epichoppers.api.hopper.Level level, UUID lastPlayer, Block syncedBlock, Filter filter, boolean walkOnTeleport) {
|
||||
this(block.getLocation(), level, lastPlayer, syncedBlock, filter, walkOnTeleport);
|
||||
}
|
||||
|
||||
public void overview(Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
if (!player.hasPermission("epichoppers.overview")) return;
|
||||
|
||||
instance.lastBlock.put(player, location.getBlock());
|
||||
instance.getPlayerDataManager().getPlayerData(player).setLastHopper(this);
|
||||
|
||||
Level nextLevel = instance.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? instance.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||
com.songoda.epichoppers.api.hopper.Level nextLevel = instance.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? instance.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||
|
||||
Inventory i = Bukkit.createInventory(null, 27, Methods.formatName(level.getLevel(), false));
|
||||
|
||||
@ -130,7 +135,7 @@ public class Hopper {
|
||||
nu++;
|
||||
}
|
||||
|
||||
boolean canFilter = instance.getConfig().getBoolean("Main.Allow Players To use The Hopper Filter") && player.hasPermission("EpicHoppers.Filter");
|
||||
boolean canFilter = instance.getConfig().getBoolean("Main.Allow Players To use The hopper Filter") && player.hasPermission("EpicHoppers.Filter");
|
||||
boolean canTeleport = instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") && player.hasPermission("EpicHoppers.Teleport");
|
||||
if (!canFilter && canTeleport)
|
||||
i.setItem(4, perl);
|
||||
@ -170,7 +175,7 @@ public class Hopper {
|
||||
i.setItem(26, Methods.getBackgroundGlass(true));
|
||||
|
||||
player.openInventory(i);
|
||||
instance.inShow.put(player.getUniqueId(), this);
|
||||
instance.getPlayerDataManager().getPlayerData(player).setInMenu(MenuType.OVERVIEW);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
@ -178,7 +183,7 @@ public class Hopper {
|
||||
|
||||
public void filter(Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
|
||||
Inventory i = Bukkit.createInventory(null, 54, Arconix.pl().getApi().format().formatText(Methods.formatName(level.getLevel(), false) + " &8-&f Filter"));
|
||||
|
||||
@ -296,7 +301,7 @@ public class Hopper {
|
||||
i.setItem(40, hook);
|
||||
|
||||
player.openInventory(i);
|
||||
instance.inFilter.put(player.getUniqueId(), this);
|
||||
instance.getPlayerDataManager().getPlayerData(player).setInMenu(MenuType.FILTER);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
@ -346,10 +351,10 @@ public class Hopper {
|
||||
|
||||
public void upgrade(String type, Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
if (instance.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) {
|
||||
|
||||
Level level = instance.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
com.songoda.epichoppers.api.hopper.Level level = instance.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
int cost;
|
||||
if (type.equals("XP")) {
|
||||
cost = level.getCostExperience();
|
||||
@ -386,9 +391,9 @@ public class Hopper {
|
||||
}
|
||||
}
|
||||
|
||||
public void upgradeFinal(Level level, Player player) {
|
||||
public void upgradeFinal(com.songoda.epichoppers.api.hopper.Level level, Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
this.level = level;
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.success", level.getLevel()));
|
||||
@ -417,12 +422,12 @@ public class Hopper {
|
||||
|
||||
public void timeout(Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (instance.sync.containsKey(player)) {
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||
if (playerData.getSyncType() != null) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.synctimeout"));
|
||||
instance.sync.remove(player);
|
||||
instance.bsync.remove(player);
|
||||
playerData.setSyncType(null);
|
||||
}
|
||||
}, instance.getConfig().getLong("Main.Timeout When Syncing Hoppers"));
|
||||
} catch (Exception e) {
|
||||
@ -430,56 +435,82 @@ public class Hopper {
|
||||
}
|
||||
}
|
||||
|
||||
public void sync(Block block2, boolean black, Player player) {
|
||||
@Override
|
||||
public void sync(Block toSync, boolean filtered, Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
|
||||
if (location.getWorld().equals(block2.getLocation().getWorld()) && !player.hasPermission("EpicHoppers.Override") && !player.hasPermission("EpicHoppers.Admin")) {
|
||||
if (location.distance(block2.getLocation()) > level.getRange() && !player.hasPermission("EpicHoppers.Override") && !player.hasPermission("EpicHoppers.Admin")) {
|
||||
|
||||
if (location.getWorld().equals(toSync.getLocation().getWorld())
|
||||
&& !player.hasPermission("EpicHoppers.Override")
|
||||
&& !player.hasPermission("EpicHoppers.Admin")
|
||||
&& location.distance(toSync.getLocation()) > level.getRange()) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncoutofrange"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncsuccess"));
|
||||
|
||||
if (!black)
|
||||
this.syncedBlock = block2;
|
||||
if (!filtered)
|
||||
this.syncedBlock = toSync;
|
||||
else
|
||||
this.filter.setEndPoint(block2);
|
||||
this.filter.setEndPoint(toSync);
|
||||
this.lastPlayer = player.getUniqueId();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return location.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return location.getBlockX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return location.getBlockY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return location.getBlockZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getLastPlayer() {
|
||||
return lastPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkOnTeleport() {
|
||||
return walkOnTeleport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWalkOnTeleport(boolean walkOnTeleport) {
|
||||
this.walkOnTeleport = walkOnTeleport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getSyncedBlock() {
|
||||
return syncedBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSyncedBlock(Block syncedBlock) {
|
||||
this.syncedBlock = syncedBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
package com.songoda.epichoppers.hopper;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Filter;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.api.hopper.HopperManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
@ -8,33 +11,39 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class HopperManager {
|
||||
public class EHopperManager implements HopperManager {
|
||||
|
||||
private final Map<Location, Hopper> registeredHoppers = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void addHopper(Location location, Hopper hopper) {
|
||||
registeredHoppers.put(roundLocation(location), hopper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hopper removeHopper(Location location) {
|
||||
return registeredHoppers.remove(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hopper getHopper(Location location) {
|
||||
if (!registeredHoppers.containsKey(roundLocation(location))) {
|
||||
addHopper(location, new Hopper(location, EpicHoppers.getInstance().getLevelManager().getLowestLevel(), null, null, new Filter(), false));
|
||||
addHopper(location, new EHopper(location, EpicHoppersPlugin.getInstance().getLevelManager().getLowestLevel(), null, null, new EFilter(), false));
|
||||
}
|
||||
return registeredHoppers.get(roundLocation(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hopper getHopper(Block block) {
|
||||
return getHopper(block.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHopper(Location location) {
|
||||
return registeredHoppers.containsKey(roundLocation(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Location, Hopper> getHoppers() {
|
||||
return Collections.unmodifiableMap(registeredHoppers);
|
||||
}
|
@ -1,17 +1,18 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
package com.songoda.epichoppers.hopper;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Level;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Level {
|
||||
public class ELevel implements Level {
|
||||
|
||||
private int level, costExperience, costEconomy, range, amount, blockBreak, suction;
|
||||
|
||||
private List<String> description = new ArrayList<>();
|
||||
|
||||
public Level(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
public ELevel(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
this.level = level;
|
||||
this.costExperience = costExperience;
|
||||
this.costEconomy = costEconomy;
|
||||
@ -20,7 +21,7 @@ public class Level {
|
||||
this.blockBreak = blockBreak;
|
||||
this.suction = suction;
|
||||
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
|
||||
description.add(instance.getLocale().getMessage("interface.hopper.range", range));
|
||||
description.add(instance.getLocale().getMessage("interface.hopper.amount", amount));
|
||||
@ -28,34 +29,42 @@ public class Level {
|
||||
if (blockBreak != 0) description.add(instance.getLocale().getMessage("interface.hopper.blockbreak", blockBreak));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDescription() {
|
||||
return new ArrayList<>(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockBreak() {
|
||||
return blockBreak;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSuction() {
|
||||
return suction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCostExperience() {
|
||||
return costExperience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCostEconomy() {
|
||||
return costEconomy;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.songoda.epichoppers.hopper;
|
||||
|
||||
import com.songoda.epichoppers.api.hopper.LevelManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ELevelManager implements LevelManager {
|
||||
|
||||
private final NavigableMap<Integer, ELevel> registeredLevels = new TreeMap<>();
|
||||
|
||||
@Override
|
||||
public void addLevel(int level, int costExperiance, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
registeredLevels.put(level, new ELevel(level, costExperiance, costEconomy, range, amount, suction, blockBreak));
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.songoda.epichoppers.api.hopper.Level getLevel(int level) {
|
||||
return registeredLevels.get(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.songoda.epichoppers.api.hopper.Level getLowestLevel() {
|
||||
return registeredLevels.firstEntry().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.songoda.epichoppers.api.hopper.Level getHighestLevel() {
|
||||
return registeredLevels.lastEntry().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, com.songoda.epichoppers.api.hopper.Level> getLevels() {
|
||||
return Collections.unmodifiableMap(registeredLevels);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
registeredLevels.clear();
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.songoda.epichoppers.player;
|
||||
|
||||
public enum MenuType {
|
||||
|
||||
NOT_IN,
|
||||
OVERVIEW,
|
||||
FILTER
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.songoda.epichoppers.player;
|
||||
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.EHopper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
private final UUID playerUUID;
|
||||
|
||||
private Hopper lastHopper = null;
|
||||
|
||||
private MenuType inMenu = MenuType.NOT_IN;
|
||||
|
||||
private SyncType syncType = null; // Null means off.
|
||||
|
||||
private Date lastTeleport = null; // Null means off.
|
||||
|
||||
public PlayerData(UUID playerUUID) {
|
||||
this.playerUUID = playerUUID;
|
||||
}
|
||||
|
||||
public UUID getPlayerUUID() {
|
||||
return playerUUID;
|
||||
}
|
||||
|
||||
public Hopper getLastHopper() {
|
||||
return lastHopper;
|
||||
}
|
||||
|
||||
public void setLastHopper(Hopper lastHopper) {
|
||||
this.lastHopper = lastHopper;
|
||||
}
|
||||
|
||||
public MenuType getInMenu() {
|
||||
return inMenu;
|
||||
}
|
||||
|
||||
public void setInMenu(MenuType inMenu) {
|
||||
this.inMenu = inMenu;
|
||||
}
|
||||
|
||||
public SyncType getSyncType() {
|
||||
return syncType;
|
||||
}
|
||||
|
||||
public void setSyncType(SyncType syncType) {
|
||||
this.syncType = syncType;
|
||||
}
|
||||
|
||||
public Date getLastTeleport() {
|
||||
return lastTeleport;
|
||||
}
|
||||
|
||||
public void setLastTeleport(Date lastTeleport) {
|
||||
this.lastTeleport = lastTeleport;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.songoda.epichoppers.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class PlayerDataManager {
|
||||
|
||||
private final Map<UUID, PlayerData> registeredPlayers = new HashMap<>();
|
||||
|
||||
public PlayerData getPlayerData(UUID uuid) {
|
||||
return (uuid != null) ? registeredPlayers.computeIfAbsent(uuid, PlayerData::new) : null;
|
||||
}
|
||||
|
||||
public PlayerData getPlayerData(Player player) {
|
||||
return getPlayerData(player.getUniqueId());
|
||||
}
|
||||
|
||||
public Collection<PlayerData> getRegisteredPlayers() {
|
||||
return Collections.unmodifiableCollection(registeredPlayers.values());
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.songoda.epichoppers.player;
|
||||
|
||||
public enum SyncType {
|
||||
|
||||
REGULAR,
|
||||
FILTERED
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epichoppers.Utils;
|
||||
package com.songoda.epichoppers.utils;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/21/2017.
|
||||
@ -24,7 +24,7 @@ public class Debugger {
|
||||
}
|
||||
|
||||
public static boolean isDebug() {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
return instance.getConfig().getBoolean("System.Debugger Enabled");
|
||||
}
|
||||
|
@ -1,21 +1,12 @@
|
||||
package com.songoda.epichoppers.Utils;
|
||||
package com.songoda.epichoppers.utils;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/24/2017.
|
||||
*/
|
||||
@ -40,7 +31,7 @@ public class Methods {
|
||||
|
||||
public static ItemStack getGlass() {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
return Arconix.pl().getApi().getGUI().getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
@ -50,7 +41,7 @@ public class Methods {
|
||||
|
||||
public static ItemStack getBackgroundGlass(boolean type) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
if (type)
|
||||
return Arconix.pl().getApi().getGUI().getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
|
||||
else
|
||||
@ -63,7 +54,7 @@ public class Methods {
|
||||
|
||||
public static String formatName(int level, boolean full) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
String name = instance.getLocale().getMessage("general.nametag.nameformat", level);
|
||||
|
||||
String info = "";
|
||||
@ -80,7 +71,7 @@ public class Methods {
|
||||
|
||||
public static void doParticles(Player p, Location location) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
location.setX(location.getX() + .5);
|
||||
location.setY(location.getY() + .5);
|
||||
location.setZ(location.getZ() + .5);
|
@ -1,9 +1,8 @@
|
||||
package com.songoda.epichoppers.Utils;
|
||||
package com.songoda.epichoppers.utils;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -34,9 +33,9 @@ public class SettingsManager implements Listener {
|
||||
|
||||
private Map<Player, String> cat = new HashMap<>();
|
||||
|
||||
private final EpicHoppers instance;
|
||||
private final EpicHoppersPlugin instance;
|
||||
|
||||
public SettingsManager(EpicHoppers plugin) {
|
||||
public SettingsManager(EpicHoppersPlugin plugin) {
|
||||
this.instance = plugin;
|
||||
|
||||
plugin.saveResource("SettingDefinitions.yml", true);
|
||||
@ -200,11 +199,11 @@ public class SettingsManager implements Listener {
|
||||
config.set("settings", null);
|
||||
}
|
||||
public enum Setting {
|
||||
o1("Upgrading-enabled", "Main.Allow Hopper Upgrading", true),
|
||||
o1("Upgrading-enabled", "Main.Allow hopper Upgrading", true),
|
||||
o2("Upgrade-with-eco", "Main.Upgrade With Economy", true),
|
||||
o3("Upgrade-with-xp", "Main.Upgrade With XP", true),
|
||||
o4("Teleport-hoppers", "Main.Allow Players To Teleport Through Hoppers", true),
|
||||
o5("Filter-hoppers", "Main.Allow Players To use The Hopper Filter", true),
|
||||
o5("Filter-hoppers", "Main.Allow Players To use The hopper Filter", true),
|
||||
o6("EnderChest-support", "Main.Support Enderchests", true),
|
||||
o7("Upgrade-particle-type", "Main.Upgrade Particle Type", "SPELL_WITCH"),
|
||||
o8("Hop-Tick", "Main.Amount of Ticks Between Hops", 8L),
|
@ -1,14 +1,14 @@
|
||||
name: EpicHoppers
|
||||
description: EpicHoppers
|
||||
main: com.songoda.epichoppers.EpicHoppers
|
||||
main: com.songoda.epichoppers.EpicHoppersPlugin
|
||||
depend: [Arconix]
|
||||
softdepend: [Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault]
|
||||
version: 2.4
|
||||
version: 3
|
||||
author: Songoda
|
||||
api-version: 1.13
|
||||
commands:
|
||||
epichoppers:
|
||||
description: View information on this plugin.
|
||||
default: true
|
||||
aliases: [sc, eh, synccraft]
|
||||
aliases: [eh, synccraft]
|
||||
usage: /eh
|
@ -1,19 +0,0 @@
|
||||
package com.songoda.epichoppers.API;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songo on 6/11/2017.
|
||||
*/
|
||||
public class EpicHoppersAPI {
|
||||
|
||||
public int getILevel(ItemStack item) {
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String arr[] = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
return Integer.parseInt(arr[0]);
|
||||
} else {
|
||||
return EpicHoppers.getInstance().getLevelManager().getLowestLevel().getLevel();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class LevelManager {
|
||||
|
||||
private final NavigableMap<Integer, Level> registeredLevels = new TreeMap<>();
|
||||
|
||||
public void addLevel(int level, int costExperiance, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
registeredLevels.put(level, new Level(level, costExperiance, costEconomy, range, amount, suction, blockBreak));
|
||||
}
|
||||
|
||||
public Level getLevel(int level) {
|
||||
return registeredLevels.get(level);
|
||||
}
|
||||
|
||||
public Level getLowestLevel() {
|
||||
return registeredLevels.firstEntry().getValue();
|
||||
}
|
||||
|
||||
public Level getHighestLevel() {
|
||||
return registeredLevels.lastEntry().getValue();
|
||||
}
|
||||
|
||||
public Map<Integer, Level> getLevels() {
|
||||
return Collections.unmodifiableMap(registeredLevels);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
registeredLevels.clear();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user