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>
|
@ -1,282 +1,291 @@
|
|||||||
package com.songoda.epichoppers;
|
package com.songoda.epichoppers;
|
||||||
|
|
||||||
import com.songoda.arconix.api.mcupdate.MCUpdate;
|
import com.songoda.arconix.api.mcupdate.MCUpdate;
|
||||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||||
import com.songoda.arconix.plugin.Arconix;
|
import com.songoda.arconix.plugin.Arconix;
|
||||||
import com.songoda.epichoppers.API.EpicHoppersAPI;
|
import com.songoda.epichoppers.api.EpicHoppers;
|
||||||
import com.songoda.epichoppers.Events.*;
|
import com.songoda.epichoppers.api.EpicHoppersAPI;
|
||||||
import com.songoda.epichoppers.Handlers.*;
|
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||||
import com.songoda.epichoppers.Hopper.Filter;
|
import com.songoda.epichoppers.api.hopper.HopperManager;
|
||||||
import com.songoda.epichoppers.Hopper.Hopper;
|
import com.songoda.epichoppers.api.hopper.Level;
|
||||||
import com.songoda.epichoppers.Hopper.HopperManager;
|
import com.songoda.epichoppers.api.hopper.LevelManager;
|
||||||
import com.songoda.epichoppers.Hopper.LevelManager;
|
import com.songoda.epichoppers.events.*;
|
||||||
import com.songoda.epichoppers.Utils.SettingsManager;
|
import com.songoda.epichoppers.handlers.*;
|
||||||
import org.bukkit.Bukkit;
|
import com.songoda.epichoppers.hopper.EFilter;
|
||||||
import org.bukkit.Location;
|
import com.songoda.epichoppers.hopper.EHopper;
|
||||||
import org.bukkit.block.Block;
|
import com.songoda.epichoppers.hopper.EHopperManager;
|
||||||
import org.bukkit.command.CommandSender;
|
import com.songoda.epichoppers.hopper.ELevelManager;
|
||||||
import org.bukkit.entity.Player;
|
import com.songoda.epichoppers.player.PlayerDataManager;
|
||||||
import org.bukkit.event.Listener;
|
import com.songoda.epichoppers.utils.SettingsManager;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import java.util.*;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
public final class EpicHoppers extends JavaPlugin implements Listener {
|
|
||||||
public static CommandSender console = Bukkit.getConsoleSender();
|
import java.util.*;
|
||||||
|
|
||||||
public Map<UUID, Hopper> inShow = new HashMap<>();
|
|
||||||
public Map<UUID, Hopper> inFilter = new HashMap<>();
|
public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||||
|
public static CommandSender console = Bukkit.getConsoleSender();
|
||||||
public HookHandler hooks;
|
|
||||||
public SettingsManager sm;
|
private static EpicHoppersPlugin INSTANCE;
|
||||||
|
|
||||||
public References references = null;
|
public HookHandler hooks;
|
||||||
public ConfigWrapper dataFile = new ConfigWrapper(this, "", "data.yml");
|
public SettingsManager settingsManager;
|
||||||
|
|
||||||
public Map<Player, Block> sync = new HashMap<>();
|
public References references = null;
|
||||||
public Map<Player, Block> bsync = new HashMap<>();
|
public ConfigWrapper dataFile = new ConfigWrapper(this, "", "data.yml");
|
||||||
|
|
||||||
public Map<Player, Date> lastTp = new HashMap<>();
|
public EnchantmentHandler enchantmentHandler;
|
||||||
|
|
||||||
public Map<Player, Block> lastBlock = new HashMap<>();
|
private Locale locale;
|
||||||
|
|
||||||
public EnchantmentHandler enchant;
|
private HopperManager hopperManager;
|
||||||
|
private LevelManager levelManager;
|
||||||
private Locale locale;
|
private PlayerDataManager playerDataManager;
|
||||||
|
|
||||||
private HopperManager hopperManager;
|
private TeleportHandler teleportHandler;
|
||||||
private LevelManager levelManager;
|
|
||||||
|
public void onEnable() {
|
||||||
private TeleportHandler teleportHandler;
|
INSTANCE = this;
|
||||||
|
EpicHoppersAPI.setImplementation(this);
|
||||||
private EpicHoppersAPI api;
|
|
||||||
|
Arconix.pl().hook(this);
|
||||||
public void onEnable() {
|
|
||||||
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("&a============================="));
|
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &aEnabling&7..."));
|
||||||
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..."));
|
settingsManager = new SettingsManager(this);
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
setupConfig();
|
||||||
|
loadDataFile();
|
||||||
api = new EpicHoppersAPI();
|
enchantmentHandler = new EnchantmentHandler();
|
||||||
|
playerDataManager = new PlayerDataManager();
|
||||||
sm = new SettingsManager(this);
|
|
||||||
setupConfig();
|
// Locales
|
||||||
loadDataFile();
|
Locale.init(this);
|
||||||
enchant = new EnchantmentHandler();
|
Locale.saveDefaultLocale("en_US");
|
||||||
|
this.locale = Locale.getLocale(this.getConfig().getString("Locale", "en_US"));
|
||||||
// Locales
|
|
||||||
Locale.init(this);
|
loadLevelManager();
|
||||||
Locale.saveDefaultLocale("en_US");
|
|
||||||
this.locale = Locale.getLocale(this.getConfig().getString("Locale", "en_US"));
|
hopperManager = new EHopperManager();
|
||||||
|
|
||||||
loadLevelManager();
|
/*
|
||||||
|
* Register hoppers into HopperManger from configuration
|
||||||
hopperManager = new HopperManager();
|
*/
|
||||||
|
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||||
/*
|
if (dataFile.getConfig().contains("data.sync")) {
|
||||||
* Register hoppers into HopperManger from configuration
|
for (String locationStr : dataFile.getConfig().getConfigurationSection("data.sync").getKeys(false)) {
|
||||||
*/
|
Location location = Arconix.pl().getApi().serialize().unserializeLocation(locationStr);
|
||||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
if (location == null || location.getBlock() == null) return;
|
||||||
if (dataFile.getConfig().contains("data.sync")) {
|
|
||||||
for (String locationStr : dataFile.getConfig().getConfigurationSection("data.sync").getKeys(false)) {
|
int level = dataFile.getConfig().getInt("data.sync." + locationStr + ".level");
|
||||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(locationStr);
|
|
||||||
if (location == null || location.getBlock() == null) return;
|
String blockLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".block");
|
||||||
|
Block block = blockLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".block")).getBlock();
|
||||||
int level = dataFile.getConfig().getInt("data.sync." + locationStr + ".level");
|
|
||||||
|
boolean walkOnTeleport = dataFile.getConfig().getBoolean("data.sync." + locationStr + ".walkOnTeleport");
|
||||||
String blockLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".block");
|
|
||||||
Block block = blockLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".block")).getBlock();
|
String playerStr = dataFile.getConfig().getString("data.sync." + locationStr + ".player");
|
||||||
|
UUID player = playerStr == null ? null : UUID.fromString(playerStr);
|
||||||
boolean walkOnTeleport = dataFile.getConfig().getBoolean("data.sync." + locationStr + ".walkOnTeleport");
|
|
||||||
|
List<ItemStack> whiteList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".whitelist");
|
||||||
String playerStr = dataFile.getConfig().getString("data.sync." + locationStr + ".player");
|
List<ItemStack> blackList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".blacklist");
|
||||||
UUID player = playerStr == null ? null : UUID.fromString(playerStr);
|
List<ItemStack> voidList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".void");
|
||||||
|
|
||||||
List<ItemStack> whiteList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".whitelist");
|
String blackLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".black");
|
||||||
List<ItemStack> blackList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".blacklist");
|
Block black = blackLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".black")).getBlock();
|
||||||
List<ItemStack> voidList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".void");
|
|
||||||
|
EFilter filter = new EFilter();
|
||||||
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.setWhiteList(whiteList);
|
||||||
|
filter.setBlackList(blackList);
|
||||||
Filter filter = new Filter();
|
filter.setVoidList(voidList);
|
||||||
|
filter.setEndPoint(black);
|
||||||
filter.setWhiteList(whiteList);
|
|
||||||
filter.setBlackList(blackList);
|
EHopper hopper = new EHopper(location, levelManager.getLevel(level), player, block, filter, walkOnTeleport);
|
||||||
filter.setVoidList(voidList);
|
|
||||||
filter.setEndPoint(black);
|
hopperManager.addHopper(location, hopper);
|
||||||
|
}
|
||||||
Hopper hopper = new Hopper(location, levelManager.getLevel(level), player, block, filter, walkOnTeleport);
|
}
|
||||||
|
|
||||||
hopperManager.addHopper(location, hopper);
|
}, 10);
|
||||||
}
|
|
||||||
}
|
references = new References();
|
||||||
|
|
||||||
}, 10);
|
hooks = new HookHandler();
|
||||||
|
hooks.hook();
|
||||||
references = new References();
|
|
||||||
|
new HopHandler(this);
|
||||||
hooks = new HookHandler();
|
teleportHandler = new TeleportHandler(this);
|
||||||
hooks.hook();
|
|
||||||
|
new MCUpdate(this, true);
|
||||||
new HopHandler(this);
|
//new MassiveStats(this, 9000);
|
||||||
teleportHandler = new TeleportHandler(this);
|
|
||||||
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
|
||||||
new MCUpdate(this, true);
|
|
||||||
//new MassiveStats(this, 9000);
|
this.getCommand("EpicHoppers").setExecutor(new CommandHandler(this));
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
|
getServer().getPluginManager().registerEvents(new HopperListeners(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new BlockListeners(this), this);
|
||||||
this.getCommand("EpicHoppers").setExecutor(new CommandHandler(this));
|
getServer().getPluginManager().registerEvents(new InteractListeners(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new InventoryListeners(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new HopperListeners(this), this);
|
getServer().getPluginManager().registerEvents(new LoginListeners(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new BlockListeners(this), this);
|
|
||||||
getServer().getPluginManager().registerEvents(new InteractListeners(this), this);
|
|
||||||
getServer().getPluginManager().registerEvents(new InventoryListeners(this), this);
|
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||||
getServer().getPluginManager().registerEvents(new LoginListeners(this), this);
|
}
|
||||||
|
|
||||||
|
public void onDisable() {
|
||||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
saveToFile();
|
||||||
}
|
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||||
|
console.sendMessage(Arconix.pl().getApi().format().formatText("&7EpicHoppers " + this.getDescription().getVersion() + " by &5Brianna <3!"));
|
||||||
public void onDisable() {
|
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &cDisabling&7..."));
|
||||||
saveToFile();
|
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
dataFile.saveConfig();
|
||||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7EpicHoppers " + this.getDescription().getVersion() + " by &5Brianna <3!"));
|
}
|
||||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &cDisabling&7..."));
|
|
||||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
/*
|
||||||
dataFile.saveConfig();
|
* Saves registered hopper to file.
|
||||||
}
|
*/
|
||||||
|
private void saveToFile() {
|
||||||
/*
|
|
||||||
* Saves registered hopper to file.
|
// Wipe old hopper information
|
||||||
*/
|
dataFile.getConfig().set("data.sync", null);
|
||||||
private void saveToFile() {
|
|
||||||
|
/*
|
||||||
// Wipe old hopper information
|
* Dump HopperManager to file.
|
||||||
dataFile.getConfig().set("data.sync", null);
|
*/
|
||||||
|
for (Hopper hopper : hopperManager.getHoppers().values()) {
|
||||||
/*
|
if (hopper.getLevel() == null || hopper.getLocation() == null || hopper.getLocation().getChunk() == null) continue;
|
||||||
* Dump HopperManager to file.
|
String locationStr = Arconix.pl().getApi().serialize().serializeLocation(hopper.getLocation());
|
||||||
*/
|
dataFile.getConfig().set("data.sync." + locationStr + ".level", hopper.getLevel().getLevel());
|
||||||
for (Hopper hopper : hopperManager.getHoppers().values()) {
|
dataFile.getConfig().set("data.sync." + locationStr + ".block", hopper.getSyncedBlock() == null ? null : Arconix.pl().getApi().serialize().serializeLocation(hopper.getSyncedBlock().getLocation()));
|
||||||
if (hopper.getLevel() == null || hopper.getLocation() == null || hopper.getLocation().getChunk() == null) continue;
|
dataFile.getConfig().set("data.sync." + locationStr + ".player", hopper.getLastPlayer() == null ? null : hopper.getLastPlayer().toString());
|
||||||
String locationStr = Arconix.pl().getApi().serialize().serializeLocation(hopper.getLocation());
|
dataFile.getConfig().set("data.sync." + locationStr + ".walkOnTeleport", hopper.isWalkOnTeleport());
|
||||||
dataFile.getConfig().set("data.sync." + locationStr + ".level", hopper.getLevel().getLevel());
|
dataFile.getConfig().set("data.sync." + locationStr + ".whitelist", hopper.getFilter().getWhiteList());
|
||||||
dataFile.getConfig().set("data.sync." + locationStr + ".block", hopper.getSyncedBlock() == null ? null : Arconix.pl().getApi().serialize().serializeLocation(hopper.getSyncedBlock().getLocation()));
|
dataFile.getConfig().set("data.sync." + locationStr + ".blacklist", hopper.getFilter().getBlackList());
|
||||||
dataFile.getConfig().set("data.sync." + locationStr + ".player", hopper.getLastPlayer() == null ? null : hopper.getLastPlayer().toString());
|
dataFile.getConfig().set("data.sync." + locationStr + ".void", hopper.getFilter().getVoidList());
|
||||||
dataFile.getConfig().set("data.sync." + locationStr + ".walkOnTeleport", hopper.isWalkOnTeleport());
|
dataFile.getConfig().set("data.sync." + locationStr + ".black", hopper.getFilter().getEndPoint() == null ? null : Arconix.pl().getApi().serialize().serializeLocation(hopper.getFilter().getEndPoint().getLocation()));
|
||||||
dataFile.getConfig().set("data.sync." + locationStr + ".whitelist", hopper.getFilter().getWhiteList());
|
}
|
||||||
dataFile.getConfig().set("data.sync." + locationStr + ".blacklist", hopper.getFilter().getBlackList());
|
|
||||||
dataFile.getConfig().set("data.sync." + locationStr + ".void", hopper.getFilter().getVoidList());
|
//Save to file
|
||||||
dataFile.getConfig().set("data.sync." + locationStr + ".black", hopper.getFilter().getEndPoint() == null ? null : Arconix.pl().getApi().serialize().serializeLocation(hopper.getFilter().getEndPoint().getLocation()));
|
dataFile.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save to file
|
private void loadLevelManager() {
|
||||||
dataFile.saveConfig();
|
// Load an instance of LevelManager
|
||||||
}
|
levelManager = new ELevelManager();
|
||||||
|
/*
|
||||||
private void loadLevelManager() {
|
* Register Levels into LevelManager from configuration.
|
||||||
// Load an instance of LevelManager
|
*/
|
||||||
levelManager = new LevelManager();
|
((ELevelManager)levelManager).clear();
|
||||||
/*
|
for (String levelName : getConfig().getConfigurationSection("settings.levels").getKeys(false)) {
|
||||||
* Register Levels into LevelManager from configuration.
|
int level = Integer.valueOf(levelName.split("-")[1]);
|
||||||
*/
|
int radius = getConfig().getInt("settings.levels." + levelName + ".Range");
|
||||||
levelManager.clear();
|
int amount = getConfig().getInt("settings.levels." + levelName + ".Amount");
|
||||||
for (String levelName : getConfig().getConfigurationSection("settings.levels").getKeys(false)) {
|
int suction = getConfig().getInt("settings.levels." + levelName + ".Suction");
|
||||||
int level = Integer.valueOf(levelName.split("-")[1]);
|
int blockBreak = getConfig().getInt("settings.levels." + levelName + ".BlockBreak");
|
||||||
int radius = getConfig().getInt("settings.levels." + levelName + ".Range");
|
int costExperiance = getConfig().getInt("settings.levels." + levelName + ".Cost-xp");
|
||||||
int amount = getConfig().getInt("settings.levels." + levelName + ".Amount");
|
int costEconomy = getConfig().getInt("settings.levels." + levelName + ".Cost-eco");
|
||||||
int suction = getConfig().getInt("settings.levels." + levelName + ".Suction");
|
levelManager.addLevel(level, costExperiance, costEconomy, radius, amount, suction, blockBreak);
|
||||||
int blockBreak = getConfig().getInt("settings.levels." + levelName + ".BlockBreak");
|
}
|
||||||
int costExperiance = getConfig().getInt("settings.levels." + levelName + ".Cost-xp");
|
}
|
||||||
int costEconomy = getConfig().getInt("settings.levels." + levelName + ".Cost-eco");
|
|
||||||
levelManager.addLevel(level, costExperiance, costEconomy, radius, amount, suction, blockBreak);
|
private void setupConfig() {
|
||||||
}
|
settingsManager.updateSettings();
|
||||||
}
|
|
||||||
|
if (!getConfig().contains("settings.levels.Level-1")) {
|
||||||
private void setupConfig() {
|
getConfig().addDefault("settings.levels.Level-1.Range", 10);
|
||||||
sm.updateSettings();
|
getConfig().addDefault("settings.levels.Level-1.Amount", 1);
|
||||||
|
getConfig().addDefault("settings.levels.Level-1.Cost-xp", 20);
|
||||||
if (!getConfig().contains("settings.levels.Level-1")) {
|
getConfig().addDefault("settings.levels.Level-1.Cost-eco", 5000);
|
||||||
getConfig().addDefault("settings.levels.Level-1.Range", 10);
|
|
||||||
getConfig().addDefault("settings.levels.Level-1.Amount", 1);
|
getConfig().addDefault("settings.levels.Level-2.Range", 20);
|
||||||
getConfig().addDefault("settings.levels.Level-1.Cost-xp", 20);
|
getConfig().addDefault("settings.levels.Level-2.Amount", 2);
|
||||||
getConfig().addDefault("settings.levels.Level-1.Cost-eco", 5000);
|
getConfig().addDefault("settings.levels.Level-2.Cost-xp", 25);
|
||||||
|
getConfig().addDefault("settings.levels.Level-2.Cost-eco", 7500);
|
||||||
getConfig().addDefault("settings.levels.Level-2.Range", 20);
|
|
||||||
getConfig().addDefault("settings.levels.Level-2.Amount", 2);
|
getConfig().addDefault("settings.levels.Level-3.Range", 30);
|
||||||
getConfig().addDefault("settings.levels.Level-2.Cost-xp", 25);
|
getConfig().addDefault("settings.levels.Level-3.Amount", 3);
|
||||||
getConfig().addDefault("settings.levels.Level-2.Cost-eco", 7500);
|
getConfig().addDefault("settings.levels.Level-3.Suction", 1);
|
||||||
|
getConfig().addDefault("settings.levels.Level-3.Cost-xp", 30);
|
||||||
getConfig().addDefault("settings.levels.Level-3.Range", 30);
|
getConfig().addDefault("settings.levels.Level-3.Cost-eco", 10000);
|
||||||
getConfig().addDefault("settings.levels.Level-3.Amount", 3);
|
|
||||||
getConfig().addDefault("settings.levels.Level-3.Suction", 1);
|
getConfig().addDefault("settings.levels.Level-4.Range", 40);
|
||||||
getConfig().addDefault("settings.levels.Level-3.Cost-xp", 30);
|
getConfig().addDefault("settings.levels.Level-4.Amount", 4);
|
||||||
getConfig().addDefault("settings.levels.Level-3.Cost-eco", 10000);
|
getConfig().addDefault("settings.levels.Level-4.Suction", 2);
|
||||||
|
|
||||||
getConfig().addDefault("settings.levels.Level-4.Range", 40);
|
getConfig().addDefault("settings.levels.Level-4.BlockBreak", 4);
|
||||||
getConfig().addDefault("settings.levels.Level-4.Amount", 4);
|
getConfig().addDefault("settings.levels.Level-4.Cost-xp", 35);
|
||||||
getConfig().addDefault("settings.levels.Level-4.Suction", 2);
|
getConfig().addDefault("settings.levels.Level-4.Cost-eco", 12000);
|
||||||
|
|
||||||
getConfig().addDefault("settings.levels.Level-4.BlockBreak", 4);
|
getConfig().addDefault("settings.levels.Level-5.Range", 50);
|
||||||
getConfig().addDefault("settings.levels.Level-4.Cost-xp", 35);
|
getConfig().addDefault("settings.levels.Level-5.Amount", 5);
|
||||||
getConfig().addDefault("settings.levels.Level-4.Cost-eco", 12000);
|
getConfig().addDefault("settings.levels.Level-5.Suction", 3);
|
||||||
|
|
||||||
getConfig().addDefault("settings.levels.Level-5.Range", 50);
|
getConfig().addDefault("settings.levels.Level-5.BlockBreak", 2);
|
||||||
getConfig().addDefault("settings.levels.Level-5.Amount", 5);
|
getConfig().addDefault("settings.levels.Level-5.Cost-xp", 40);
|
||||||
getConfig().addDefault("settings.levels.Level-5.Suction", 3);
|
getConfig().addDefault("settings.levels.Level-5.Cost-eco", 15000);
|
||||||
|
}
|
||||||
getConfig().addDefault("settings.levels.Level-5.BlockBreak", 2);
|
|
||||||
getConfig().addDefault("settings.levels.Level-5.Cost-xp", 40);
|
getConfig().options().copyDefaults(true);
|
||||||
getConfig().addDefault("settings.levels.Level-5.Cost-eco", 15000);
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfig().options().copyDefaults(true);
|
private void loadDataFile() {
|
||||||
saveConfig();
|
dataFile.getConfig().options().copyDefaults(true);
|
||||||
}
|
dataFile.saveConfig();
|
||||||
|
}
|
||||||
private void loadDataFile() {
|
|
||||||
dataFile.getConfig().options().copyDefaults(true);
|
public void reload() {
|
||||||
dataFile.saveConfig();
|
locale.reloadMessages();
|
||||||
}
|
hooks.hooksFile.createNewFile("Loading hooks File", "EpicSpawners Spawners File");
|
||||||
|
hooks = new HookHandler();
|
||||||
public void reload() {
|
hooks.hook();
|
||||||
locale.reloadMessages();
|
references = new References();
|
||||||
hooks.hooksFile.createNewFile("Loading hooks File", "EpicSpawners Spawners File");
|
reloadConfig();
|
||||||
hooks = new HookHandler();
|
saveConfig();
|
||||||
hooks.hook();
|
loadLevelManager();
|
||||||
references = new References();
|
}
|
||||||
reloadConfig();
|
|
||||||
saveConfig();
|
|
||||||
loadLevelManager();
|
@Override
|
||||||
}
|
public Level getLevelFromItem(ItemStack item) {
|
||||||
|
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||||
public Locale getLocale() {
|
String arr[] = item.getItemMeta().getDisplayName().replace("§", "").split(":");
|
||||||
return locale;
|
return getLevelManager().getLevel(Integer.parseInt(arr[0]));
|
||||||
}
|
} else {
|
||||||
|
return getLevelManager().getLowestLevel();
|
||||||
public TeleportHandler getTeleportHandler() {
|
}
|
||||||
return teleportHandler;
|
}
|
||||||
}
|
|
||||||
|
public Locale getLocale() {
|
||||||
public LevelManager getLevelManager() {
|
return locale;
|
||||||
return levelManager;
|
}
|
||||||
}
|
|
||||||
|
public TeleportHandler getTeleportHandler() {
|
||||||
public HopperManager getHopperManager() {
|
return teleportHandler;
|
||||||
return hopperManager;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
public static EpicHoppers getInstance() {
|
public LevelManager getLevelManager() {
|
||||||
return (EpicHoppers) Bukkit.getServer().getPluginManager().getPlugin("EpicHoppers");
|
return levelManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EpicHoppersAPI getApi() {
|
@Override
|
||||||
return api;
|
public HopperManager getHopperManager() {
|
||||||
}
|
return hopperManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerDataManager getPlayerDataManager() {
|
||||||
|
return playerDataManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EpicHoppersPlugin getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
@ -1,365 +1,365 @@
|
|||||||
package com.songoda.epichoppers;
|
package com.songoda.epichoppers;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assists in the creation of multiple localizations and languages,
|
* Assists in the creation of multiple localizations and languages,
|
||||||
* as well as the generation of default .lang files
|
* as well as the generation of default .lang files
|
||||||
*
|
*
|
||||||
* @author Parker Hawke - 2008Choco
|
* @author Parker Hawke - 2008Choco
|
||||||
*/
|
*/
|
||||||
public class Locale {
|
public class Locale {
|
||||||
|
|
||||||
private static JavaPlugin plugin;
|
private static JavaPlugin plugin;
|
||||||
private static final List<Locale> LOCALES = Lists.newArrayList();
|
private static final List<Locale> LOCALES = Lists.newArrayList();
|
||||||
|
|
||||||
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.\\w+)*)\\s*=\\s*\"(.*)\"");
|
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.\\w+)*)\\s*=\\s*\"(.*)\"");
|
||||||
private static final String FILE_EXTENSION = ".lang";
|
private static final String FILE_EXTENSION = ".lang";
|
||||||
private static File localeFolder;
|
private static File localeFolder;
|
||||||
|
|
||||||
private static String defaultLocale;
|
private static String defaultLocale;
|
||||||
|
|
||||||
private final Map<String, String> nodes = new HashMap<>();
|
private final Map<String, String> nodes = new HashMap<>();
|
||||||
|
|
||||||
private final File file;
|
private final File file;
|
||||||
private final String name, region;
|
private final String name, region;
|
||||||
|
|
||||||
private Locale(String name, String region) {
|
private Locale(String name, String region) {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
throw new IllegalStateException("Cannot generate locales without first initializing the class (Locale#init(JavaPlugin))");
|
throw new IllegalStateException("Cannot generate locales without first initializing the class (Locale#init(JavaPlugin))");
|
||||||
|
|
||||||
this.name = name.toLowerCase();
|
this.name = name.toLowerCase();
|
||||||
this.region = region.toUpperCase();
|
this.region = region.toUpperCase();
|
||||||
|
|
||||||
String fileName = name + "_" + region + FILE_EXTENSION;
|
String fileName = name + "_" + region + FILE_EXTENSION;
|
||||||
this.file = new File(localeFolder, fileName);
|
this.file = new File(localeFolder, fileName);
|
||||||
|
|
||||||
if (this.reloadMessages()) return;
|
if (this.reloadMessages()) return;
|
||||||
|
|
||||||
plugin.getLogger().info("Loaded locale " + fileName);
|
plugin.getLogger().info("Loaded locale " + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the language that this locale is based on.
|
* Get the name of the language that this locale is based on.
|
||||||
* (i.e. "en" for English, or "fr" for French)
|
* (i.e. "en" for English, or "fr" for French)
|
||||||
*
|
*
|
||||||
* @return the name of the language
|
* @return the name of the language
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the region that this locale is from.
|
* Get the name of the region that this locale is from.
|
||||||
* (i.e. "US" for United States or "CA" for Canada)
|
* (i.e. "US" for United States or "CA" for Canada)
|
||||||
*
|
*
|
||||||
* @return the name of the region
|
* @return the name of the region
|
||||||
*/
|
*/
|
||||||
public String getRegion() {
|
public String getRegion() {
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the entire locale tag (i.e. "en_US")
|
* Return the entire locale tag (i.e. "en_US")
|
||||||
*
|
*
|
||||||
* @return the language tag
|
* @return the language tag
|
||||||
*/
|
*/
|
||||||
public String getLanguageTag() {
|
public String getLanguageTag() {
|
||||||
return name + "_" + region;
|
return name + "_" + region;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the file that represents this locale
|
* Get the file that represents this locale
|
||||||
*
|
*
|
||||||
* @return the locale file (.lang)
|
* @return the locale file (.lang)
|
||||||
*/
|
*/
|
||||||
public File getFile() {
|
public File getFile() {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a message set for a specific node
|
* Get a message set for a specific node
|
||||||
*
|
*
|
||||||
* @param node the node to get
|
* @param node the node to get
|
||||||
* @return the message for the specified node
|
* @return the message for the specified node
|
||||||
*/
|
*/
|
||||||
public String getMessage(String node) {
|
public String getMessage(String node) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', this.getMessageOrDefault(node, node));
|
return ChatColor.translateAlternateColorCodes('&', this.getMessageOrDefault(node, node));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a message set for a specific node and replace its params with a supplied arguments.
|
* Get a message set for a specific node and replace its params with a supplied arguments.
|
||||||
*
|
*
|
||||||
* @param node the node to get
|
* @param node the node to get
|
||||||
* @param args the replacement arguments
|
* @param args the replacement arguments
|
||||||
* @return the message for the specified node
|
* @return the message for the specified node
|
||||||
*/
|
*/
|
||||||
public String getMessage(String node, Object... args) {
|
public String getMessage(String node, Object... args) {
|
||||||
String message = getMessage(node);
|
String message = getMessage(node);
|
||||||
for (Object arg : args) {
|
for (Object arg : args) {
|
||||||
message = message.replaceFirst("%.*?%", arg.toString());
|
message = message.replaceFirst("%.*?%", arg.toString());
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a message set for a specific node
|
* Get a message set for a specific node
|
||||||
*
|
*
|
||||||
* @param node the node to get
|
* @param node the node to get
|
||||||
* @param defaultValue the default value given that a value for the node was not found
|
* @param defaultValue the default value given that a value for the node was not found
|
||||||
*
|
*
|
||||||
* @return the message for the specified node. Default if none found
|
* @return the message for the specified node. Default if none found
|
||||||
*/
|
*/
|
||||||
public String getMessageOrDefault(String node, String defaultValue) {
|
public String getMessageOrDefault(String node, String defaultValue) {
|
||||||
return this.nodes.getOrDefault(node, defaultValue);
|
return this.nodes.getOrDefault(node, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the key-value map of nodes to messages
|
* Get the key-value map of nodes to messages
|
||||||
*
|
*
|
||||||
* @return node-message map
|
* @return node-message map
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getMessageNodeMap() {
|
public Map<String, String> getMessageNodeMap() {
|
||||||
return ImmutableMap.copyOf(nodes);
|
return ImmutableMap.copyOf(nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the previous message cache and load new messages directly from file
|
* Clear the previous message cache and load new messages directly from file
|
||||||
*
|
*
|
||||||
* @return reload messages from file
|
* @return reload messages from file
|
||||||
*/
|
*/
|
||||||
public boolean reloadMessages() {
|
public boolean reloadMessages() {
|
||||||
if (!this.file.exists()) {
|
if (!this.file.exists()) {
|
||||||
plugin.getLogger().warning("Could not find file for locale " + this.name);
|
plugin.getLogger().warning("Could not find file for locale " + this.name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nodes.clear(); // Clear previous data (if any)
|
this.nodes.clear(); // Clear previous data (if any)
|
||||||
|
|
||||||
try(BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
try(BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||||
String line;
|
String line;
|
||||||
for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) {
|
for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) {
|
||||||
if (line.isEmpty() || line.startsWith("#") /* Comment */) continue;
|
if (line.isEmpty() || line.startsWith("#") /* Comment */) continue;
|
||||||
|
|
||||||
Matcher matcher = NODE_PATTERN.matcher(line);
|
Matcher matcher = NODE_PATTERN.matcher(line);
|
||||||
if (!matcher.find()) {
|
if (!matcher.find()) {
|
||||||
System.err.println("Invalid locale syntax at (line=" + lineNumber + ")");
|
System.err.println("Invalid locale syntax at (line=" + lineNumber + ")");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes.put(matcher.group(1), matcher.group(2));
|
nodes.put(matcher.group(1), matcher.group(2));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the locale class to generate information and search for localizations.
|
* Initialize the locale class to generate information and search for localizations.
|
||||||
* This must be called before any other methods in the Locale class can be invoked.
|
* This must be called before any other methods in the Locale class can be invoked.
|
||||||
* Note that this will also call {@link #searchForLocales()}, so there is no need to
|
* Note that this will also call {@link #searchForLocales()}, so there is no need to
|
||||||
* invoke it for yourself after the initialization
|
* invoke it for yourself after the initialization
|
||||||
*
|
*
|
||||||
* @param plugin the plugin instance
|
* @param plugin the plugin instance
|
||||||
*/
|
*/
|
||||||
public static void init(JavaPlugin plugin) {
|
public static void init(JavaPlugin plugin) {
|
||||||
Locale.plugin = plugin;
|
Locale.plugin = plugin;
|
||||||
|
|
||||||
if (localeFolder == null) {
|
if (localeFolder == null) {
|
||||||
localeFolder = new File(plugin.getDataFolder(), "locales/");
|
localeFolder = new File(plugin.getDataFolder(), "locales/");
|
||||||
}
|
}
|
||||||
|
|
||||||
localeFolder.mkdirs();
|
localeFolder.mkdirs();
|
||||||
Locale.searchForLocales();
|
Locale.searchForLocales();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all .lang file locales under the "locales" folder
|
* Find all .lang file locales under the "locales" folder
|
||||||
*/
|
*/
|
||||||
public static void searchForLocales() {
|
public static void searchForLocales() {
|
||||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||||
|
|
||||||
for (File file : localeFolder.listFiles()) {
|
for (File file : localeFolder.listFiles()) {
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
if (!name.endsWith(".lang")) continue;
|
if (!name.endsWith(".lang")) continue;
|
||||||
|
|
||||||
String fileName = name.substring(0, name.lastIndexOf('.'));
|
String fileName = name.substring(0, name.lastIndexOf('.'));
|
||||||
String[] localeValues = fileName.split("_");
|
String[] localeValues = fileName.split("_");
|
||||||
|
|
||||||
if (localeValues.length != 2) continue;
|
if (localeValues.length != 2) continue;
|
||||||
if (localeExists(localeValues[0] + "_" + localeValues[1])) continue;
|
if (localeExists(localeValues[0] + "_" + localeValues[1])) continue;
|
||||||
|
|
||||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||||
plugin.getLogger().info("Found and loaded locale \"" + fileName + "\"");
|
plugin.getLogger().info("Found and loaded locale \"" + fileName + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a locale by its entire proper name (i.e. "en_US")
|
* Get a locale by its entire proper name (i.e. "en_US")
|
||||||
*
|
*
|
||||||
* @param name the full name of the locale
|
* @param name the full name of the locale
|
||||||
* @return locale of the specified name
|
* @return locale of the specified name
|
||||||
*/
|
*/
|
||||||
public static Locale getLocale(String name) {
|
public static Locale getLocale(String name) {
|
||||||
for (Locale locale : LOCALES)
|
for (Locale locale : LOCALES)
|
||||||
if (locale.getLanguageTag().equalsIgnoreCase(name)) return locale;
|
if (locale.getLanguageTag().equalsIgnoreCase(name)) return locale;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a locale from the cache by its name (i.e. "en" from "en_US")
|
* Get a locale from the cache by its name (i.e. "en" from "en_US")
|
||||||
*
|
*
|
||||||
* @param name the name of the language
|
* @param name the name of the language
|
||||||
* @return locale of the specified language. Null if not cached
|
* @return locale of the specified language. Null if not cached
|
||||||
*/
|
*/
|
||||||
public static Locale getLocaleByName(String name) {
|
public static Locale getLocaleByName(String name) {
|
||||||
for (Locale locale : LOCALES)
|
for (Locale locale : LOCALES)
|
||||||
if (locale.getName().equalsIgnoreCase(name)) return locale;
|
if (locale.getName().equalsIgnoreCase(name)) return locale;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a locale from the cache by its region (i.e. "US" from "en_US")
|
* Get a locale from the cache by its region (i.e. "US" from "en_US")
|
||||||
*
|
*
|
||||||
* @param region the name of the region
|
* @param region the name of the region
|
||||||
* @return locale of the specified region. Null if not cached
|
* @return locale of the specified region. Null if not cached
|
||||||
*/
|
*/
|
||||||
public static Locale getLocaleByRegion(String region) {
|
public static Locale getLocaleByRegion(String region) {
|
||||||
for (Locale locale : LOCALES)
|
for (Locale locale : LOCALES)
|
||||||
if (locale.getRegion().equalsIgnoreCase(region)) return locale;
|
if (locale.getRegion().equalsIgnoreCase(region)) return locale;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether a locale exists and is registered or not
|
* Check whether a locale exists and is registered or not
|
||||||
*
|
*
|
||||||
* @param name the whole language tag (i.e. "en_US")
|
* @param name the whole language tag (i.e. "en_US")
|
||||||
* @return true if it exists
|
* @return true if it exists
|
||||||
*/
|
*/
|
||||||
public static boolean localeExists(String name) {
|
public static boolean localeExists(String name) {
|
||||||
for (Locale locale : LOCALES)
|
for (Locale locale : LOCALES)
|
||||||
if (locale.getLanguageTag().equals(name)) return true;
|
if (locale.getLanguageTag().equals(name)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an immutable list of all currently loaded locales
|
* Get an immutable list of all currently loaded locales
|
||||||
*
|
*
|
||||||
* @return list of all locales
|
* @return list of all locales
|
||||||
*/
|
*/
|
||||||
public static List<Locale> getLocales() {
|
public static List<Locale> getLocales() {
|
||||||
return ImmutableList.copyOf(LOCALES);
|
return ImmutableList.copyOf(LOCALES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a default locale file from the project source directory, to the locale folder
|
* Save a default locale file from the project source directory, to the locale folder
|
||||||
*
|
*
|
||||||
* @param path the path to the file to save
|
* @param path the path to the file to save
|
||||||
* @param fileName the name of the file to save
|
* @param fileName the name of the file to save
|
||||||
*
|
*
|
||||||
* @return true if the operation was successful, false otherwise
|
* @return true if the operation was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean saveDefaultLocale(String path, String fileName) {
|
public static boolean saveDefaultLocale(String path, String fileName) {
|
||||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||||
|
|
||||||
if (!fileName.endsWith(FILE_EXTENSION))
|
if (!fileName.endsWith(FILE_EXTENSION))
|
||||||
fileName = (fileName.lastIndexOf(".") == -1 ? fileName : fileName.substring(0, fileName.lastIndexOf('.'))) + FILE_EXTENSION;
|
fileName = (fileName.lastIndexOf(".") == -1 ? fileName : fileName.substring(0, fileName.lastIndexOf('.'))) + FILE_EXTENSION;
|
||||||
|
|
||||||
File destinationFile = new File(localeFolder, fileName);
|
File destinationFile = new File(localeFolder, fileName);
|
||||||
if (destinationFile.exists()) {
|
if (destinationFile.exists()) {
|
||||||
return compareFiles(plugin.getResource(fileName), destinationFile);
|
return compareFiles(plugin.getResource(fileName), destinationFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (OutputStream outputStream = new FileOutputStream(destinationFile)) {
|
try (OutputStream outputStream = new FileOutputStream(destinationFile)) {
|
||||||
IOUtils.copy(plugin.getResource(fileName), outputStream);
|
IOUtils.copy(plugin.getResource(fileName), outputStream);
|
||||||
|
|
||||||
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||||
String[] localeValues = fileName.split("_");
|
String[] localeValues = fileName.split("_");
|
||||||
|
|
||||||
if (localeValues.length != 2) return false;
|
if (localeValues.length != 2) return false;
|
||||||
|
|
||||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||||
if (defaultLocale == null) defaultLocale = fileName;
|
if (defaultLocale == null) defaultLocale = fileName;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a default locale file from the project source directory, to the locale folder
|
* Save a default locale file from the project source directory, to the locale folder
|
||||||
*
|
*
|
||||||
* @param fileName the name of the file to save
|
* @param fileName the name of the file to save
|
||||||
* @return true if the operation was successful, false otherwise
|
* @return true if the operation was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean saveDefaultLocale(String fileName) {
|
public static boolean saveDefaultLocale(String fileName) {
|
||||||
return saveDefaultLocale("", fileName);
|
return saveDefaultLocale("", fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all current locale data
|
* Clear all current locale data
|
||||||
*/
|
*/
|
||||||
public static void clearLocaleData() {
|
public static void clearLocaleData() {
|
||||||
for (Locale locale : LOCALES)
|
for (Locale locale : LOCALES)
|
||||||
locale.nodes.clear();
|
locale.nodes.clear();
|
||||||
LOCALES.clear();
|
LOCALES.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write new changes to existing files, if any at all
|
// Write new changes to existing files, if any at all
|
||||||
private static boolean compareFiles(InputStream defaultFile, File existingFile) {
|
private static boolean compareFiles(InputStream defaultFile, File existingFile) {
|
||||||
// Look for default
|
// Look for default
|
||||||
if (defaultFile == null) {
|
if (defaultFile == null) {
|
||||||
defaultFile = plugin.getResource(defaultLocale != null ? defaultLocale : "en_US");
|
defaultFile = plugin.getResource(defaultLocale != null ? defaultLocale : "en_US");
|
||||||
if (defaultFile == null) return false; // No default at all
|
if (defaultFile == null) return false; // No default at all
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
List<String> defaultLines, existingLines;
|
List<String> defaultLines, existingLines;
|
||||||
try (BufferedReader defaultReader = new BufferedReader(new InputStreamReader(defaultFile));
|
try (BufferedReader defaultReader = new BufferedReader(new InputStreamReader(defaultFile));
|
||||||
BufferedReader existingReader = new BufferedReader(new FileReader(existingFile));
|
BufferedReader existingReader = new BufferedReader(new FileReader(existingFile));
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(existingFile, true))) {
|
BufferedWriter writer = new BufferedWriter(new FileWriter(existingFile, true))) {
|
||||||
defaultLines = defaultReader.lines().collect(Collectors.toList());
|
defaultLines = defaultReader.lines().collect(Collectors.toList());
|
||||||
existingLines = existingReader.lines().map(s -> s.split("\\s*=")[0]).collect(Collectors.toList());
|
existingLines = existingReader.lines().map(s -> s.split("\\s*=")[0]).collect(Collectors.toList());
|
||||||
|
|
||||||
for (String defaultValue : defaultLines) {
|
for (String defaultValue : defaultLines) {
|
||||||
if (defaultValue.isEmpty() || defaultValue.startsWith("#")) continue;
|
if (defaultValue.isEmpty() || defaultValue.startsWith("#")) continue;
|
||||||
|
|
||||||
String key = defaultValue.split("\\s*=")[0];
|
String key = defaultValue.split("\\s*=")[0];
|
||||||
|
|
||||||
if (!existingLines.contains(key)) {
|
if (!existingLines.contains(key)) {
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
writer.newLine(); writer.newLine();
|
writer.newLine(); writer.newLine();
|
||||||
writer.write("# New messages for " + plugin.getName() + " v" + plugin.getDescription().getVersion());
|
writer.write("# New messages for " + plugin.getName() + " v" + plugin.getDescription().getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
writer.write(defaultValue);
|
writer.write(defaultValue);
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
package com.songoda.epichoppers;
|
package com.songoda.epichoppers;
|
||||||
|
|
||||||
public class References {
|
public class References {
|
||||||
|
|
||||||
private String prefix;
|
private String prefix;
|
||||||
|
|
||||||
public References() {
|
public References() {
|
||||||
prefix = EpicHoppers.getInstance().getLocale().getMessage("general.nametag.prefix") + " ";
|
prefix = EpicHoppersPlugin.getInstance().getLocale().getMessage("general.nametag.prefix") + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix() {
|
public String getPrefix() {
|
||||||
return this.prefix;
|
return this.prefix;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,171 +1,165 @@
|
|||||||
package com.songoda.epichoppers.Events;
|
package com.songoda.epichoppers.events;
|
||||||
|
|
||||||
import com.songoda.arconix.plugin.Arconix;
|
import com.songoda.arconix.plugin.Arconix;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Hopper.Filter;
|
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||||
import com.songoda.epichoppers.Hopper.Hopper;
|
import com.songoda.epichoppers.hopper.EFilter;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.hopper.EHopper;
|
||||||
import com.songoda.epichoppers.Utils.Methods;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Bukkit;
|
import com.songoda.epichoppers.utils.Methods;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
/**
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
* Created by songoda on 3/14/2017.
|
||||||
|
*/
|
||||||
import java.util.Collection;
|
public class BlockListeners implements Listener {
|
||||||
|
|
||||||
/**
|
private EpicHoppersPlugin instance;
|
||||||
* Created by songoda on 3/14/2017.
|
|
||||||
*/
|
public BlockListeners(EpicHoppersPlugin instance) {
|
||||||
public class BlockListeners implements Listener {
|
this.instance = instance;
|
||||||
|
}
|
||||||
private EpicHoppers instance;
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public BlockListeners(EpicHoppers instance) {
|
public void onBlockPlace(BlockPlaceEvent e) {
|
||||||
this.instance = instance;
|
try {
|
||||||
}
|
if (e.getBlock().getType().equals(Material.ENDER_CHEST)) {
|
||||||
|
instance.dataFile.getConfig().set("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(e.getBlock()), e.getPlayer().getUniqueId().toString());
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
return;
|
||||||
public void onBlockPlace(BlockPlaceEvent e) {
|
}
|
||||||
try {
|
|
||||||
if (e.getBlock().getType().equals(Material.ENDER_CHEST)) {
|
if (e.getBlock().getType() != Material.HOPPER) return;
|
||||||
instance.dataFile.getConfig().set("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(e.getBlock()), e.getPlayer().getUniqueId().toString());
|
|
||||||
return;
|
int amt = count(e.getBlock().getChunk());
|
||||||
}
|
if (amt >= instance.getConfig().getInt("Main.Max Hoppers Per Chunk") && instance.getConfig().getInt("Main.Max Hoppers Per Chunk") != -1) {
|
||||||
|
e.getPlayer().sendMessage(instance.getLocale().getMessage("event.hopper.toomany"));
|
||||||
if (e.getBlock().getType() != Material.HOPPER) return;
|
e.setCancelled(true);
|
||||||
|
return;
|
||||||
int amt = count(e.getBlock().getChunk());
|
}
|
||||||
if (amt >= instance.getConfig().getInt("Main.Max Hoppers Per Chunk") && instance.getConfig().getInt("Main.Max Hoppers Per Chunk") != -1) {
|
|
||||||
e.getPlayer().sendMessage(instance.getLocale().getMessage("event.hopper.toomany"));
|
if (!e.getItemInHand().getItemMeta().hasDisplayName()) return;
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
ItemStack item = e.getItemInHand().clone();
|
||||||
}
|
|
||||||
|
e.getBlock().setType(Material.AIR);
|
||||||
if (!e.getItemInHand().getItemMeta().hasDisplayName()) return;
|
e.getBlock().getLocation().getBlock().setType(Material.HOPPER);
|
||||||
|
|
||||||
ItemStack item = e.getItemInHand().clone();
|
instance.getHopperManager().addHopper(e.getBlock().getLocation(), new EHopper(e.getBlock(), instance.getLevelFromItem(item), e.getPlayer().getUniqueId(), null, new EFilter(), false));
|
||||||
|
|
||||||
e.getBlock().setType(Material.AIR);
|
} catch (Exception ee) {
|
||||||
e.getBlock().getLocation().getBlock().setType(Material.HOPPER);
|
Debugger.runReport(ee);
|
||||||
|
}
|
||||||
instance.getHopperManager().addHopper(e.getBlock().getLocation(), new Hopper(e.getBlock(), instance.getLevelManager().getLevel(instance.getApi().getILevel(item)), e.getPlayer().getUniqueId(), null, new Filter(), false));
|
}
|
||||||
|
|
||||||
} catch (Exception ee) {
|
public int count(Chunk c) {
|
||||||
Debugger.runReport(ee);
|
try {
|
||||||
}
|
int count = 0;
|
||||||
}
|
for (int x = 0; x < 16; x++) {
|
||||||
|
for (int z = 0; z < 16; z++) {
|
||||||
public int count(Chunk c) {
|
for (int y = 0; y < c.getWorld().getMaxHeight(); y++) {
|
||||||
try {
|
if (c.getBlock(x, y, z).getType() == Material.HOPPER) count++;
|
||||||
int count = 0;
|
}
|
||||||
for (int x = 0; x < 16; x++) {
|
}
|
||||||
for (int z = 0; z < 16; z++) {
|
}
|
||||||
for (int y = 0; y < c.getWorld().getMaxHeight(); y++) {
|
return count;
|
||||||
if (c.getBlock(x, y, z).getType() == Material.HOPPER) count++;
|
} catch (Exception e) {
|
||||||
}
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
}
|
return 9999;
|
||||||
return count;
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
Debugger.runReport(e);
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
}
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
return 9999;
|
try {
|
||||||
}
|
if (event.getBlock().getType().equals(Material.ENDER_CHEST)) {
|
||||||
|
instance.dataFile.getConfig().set("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(event.getBlock()), null);
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
}
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
|
||||||
try {
|
Block block = event.getBlock();
|
||||||
if (event.getBlock().getType().equals(Material.ENDER_CHEST)) {
|
Player player = event.getPlayer();
|
||||||
instance.dataFile.getConfig().set("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(event.getBlock()), null);
|
|
||||||
}
|
if (player.getInventory().getItemInMainHand() == null) return;
|
||||||
|
|
||||||
Block block = event.getBlock();
|
handleSyncTouch(event);
|
||||||
|
|
||||||
if (event.getPlayer().getItemInHand() == null) return;
|
if (event.getBlock().getType() != Material.HOPPER) return;
|
||||||
|
|
||||||
handleSyncTouch(event);
|
Hopper hopper = instance.getHopperManager().getHopper(block);
|
||||||
|
|
||||||
if (event.getBlock().getType() != Material.HOPPER) return;
|
int level = hopper.getLevel().getLevel();
|
||||||
|
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(block);
|
if (level != 0) {
|
||||||
|
event.setCancelled(true);
|
||||||
int level = hopper.getLevel().getLevel();
|
ItemStack item = new ItemStack(Material.HOPPER, 1);
|
||||||
|
ItemMeta itemmeta = item.getItemMeta();
|
||||||
if (level != 0) {
|
itemmeta.setDisplayName(Arconix.pl().getApi().format().formatText(Methods.formatName(level, true)));
|
||||||
event.setCancelled(true);
|
item.setItemMeta(itemmeta);
|
||||||
ItemStack item = new ItemStack(Material.HOPPER, 1);
|
|
||||||
ItemMeta itemmeta = item.getItemMeta();
|
event.getBlock().setType(Material.AIR);
|
||||||
itemmeta.setDisplayName(Arconix.pl().getApi().format().formatText(Methods.formatName(level, true)));
|
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
|
||||||
item.setItemMeta(itemmeta);
|
}
|
||||||
|
|
||||||
event.getBlock().setType(Material.AIR);
|
for (ItemStack i : hopper.getFilter().getWhiteList()) {
|
||||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
|
if (i != null)
|
||||||
}
|
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
||||||
|
}
|
||||||
for (ItemStack i : hopper.getFilter().getWhiteList()) {
|
|
||||||
if (i != null)
|
for (ItemStack i : hopper.getFilter().getBlackList()) {
|
||||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
if (i != null)
|
||||||
}
|
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
||||||
|
}
|
||||||
for (ItemStack i : hopper.getFilter().getBlackList()) {
|
for (ItemStack i : hopper.getFilter().getVoidList()) {
|
||||||
if (i != null)
|
if (i != null)
|
||||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
||||||
}
|
}
|
||||||
for (ItemStack i : hopper.getFilter().getVoidList()) {
|
instance.getHopperManager().removeHopper(block.getLocation());
|
||||||
if (i != null)
|
|
||||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
instance.getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||||
}
|
|
||||||
instance.getHopperManager().removeHopper(block.getLocation());
|
|
||||||
|
} catch (Exception ee) {
|
||||||
instance.sync.remove(event.getPlayer());
|
Debugger.runReport(ee);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception ee) {
|
|
||||||
Debugger.runReport(ee);
|
private void handleSyncTouch(BlockBreakEvent e) {
|
||||||
}
|
if (!Methods.isSync(e.getPlayer())) return;
|
||||||
}
|
|
||||||
|
ItemStack tool = e.getPlayer().getInventory().getItemInMainHand();
|
||||||
private void handleSyncTouch(BlockBreakEvent e) {
|
ItemMeta meta = tool.getItemMeta();
|
||||||
if (!Methods.isSync(e.getPlayer())) return;
|
if (tool.getItemMeta().getLore().size() != 2) return;
|
||||||
|
|
||||||
ItemStack tool = e.getPlayer().getItemInHand();
|
Location location = Arconix.pl().getApi().serialize().unserializeLocation(meta.getLore().get(1).replaceAll("§", ""));
|
||||||
ItemMeta meta = tool.getItemMeta();
|
|
||||||
if (tool.getItemMeta().getLore().size() != 2) return;
|
if (location.getBlock().getType() != Material.CHEST) return;
|
||||||
|
|
||||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(meta.getLore().get(1).replaceAll("§", ""));
|
if (e.getBlock().getType() == Material.SHULKER_BOX
|
||||||
|
|| e.getBlock().getType() == Material.SPAWNER
|
||||||
if (location.getBlock().getType() != Material.CHEST) return;
|
|| e.getBlock().getType() == Material.HOPPER
|
||||||
|
|| e.getBlock().getType() == Material.DISPENSER) {
|
||||||
if (e.getBlock().getType() == Material.SPAWNER || e.getBlock().getType() == Material.HOPPER || e.getBlock().getType() == Material.DISPENSER) return;
|
return;
|
||||||
|
}
|
||||||
try {
|
|
||||||
if (e.getBlock().getType().name().contains("SHULKER") && e.getBlock().getType() != Material.SHULKER_SHELL) return;
|
InventoryHolder ih = (InventoryHolder) location.getBlock().getState();
|
||||||
} catch (Exception ee) {
|
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())
|
||||||
InventoryHolder ih = (InventoryHolder) location.getBlock().getState();
|
ih.getInventory().addItem(is);
|
||||||
if (e.getPlayer().getItemInHand().getItemMeta().hasEnchant(Enchantment.SILK_TOUCH)) {
|
}
|
||||||
ih.getInventory().addItem(new ItemStack(e.getBlock().getType(),1, e.getBlock().getData()));
|
e.setDropItems(false);
|
||||||
} else {
|
}
|
||||||
for (ItemStack is : e.getBlock().getDrops())
|
|
||||||
ih.getInventory().addItem(is);
|
|
||||||
}
|
|
||||||
e.setDropItems(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,107 +1,108 @@
|
|||||||
package com.songoda.epichoppers.Events;
|
package com.songoda.epichoppers.events;
|
||||||
|
|
||||||
import com.songoda.arconix.plugin.Arconix;
|
import com.songoda.arconix.plugin.Arconix;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||||
import com.songoda.epichoppers.Utils.Methods;
|
import com.songoda.epichoppers.hopper.EHopper;
|
||||||
import org.bukkit.Location;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Material;
|
import com.songoda.epichoppers.utils.Methods;
|
||||||
import org.bukkit.block.Hopper;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
/**
|
|
||||||
* Created by songoda on 4/18/2017.
|
/**
|
||||||
*/
|
* Created by songoda on 4/18/2017.
|
||||||
public class HopperListeners implements Listener {
|
*/
|
||||||
|
public class HopperListeners implements Listener {
|
||||||
private EpicHoppers instance;
|
|
||||||
|
private EpicHoppersPlugin instance;
|
||||||
public HopperListeners(EpicHoppers instance) {
|
|
||||||
this.instance = instance;
|
public HopperListeners(EpicHoppersPlugin instance) {
|
||||||
}
|
this.instance = instance;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onHop(InventoryMoveItemEvent e) {
|
@EventHandler(ignoreCancelled = true)
|
||||||
try {
|
public void onHop(InventoryMoveItemEvent e) {
|
||||||
Inventory source = e.getSource();
|
try {
|
||||||
|
Inventory source = e.getSource();
|
||||||
|
|
||||||
if (!instance.getHopperManager().isHopper(e.getSource().getLocation())) return;
|
|
||||||
|
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);
|
if (source.getHolder() instanceof Hopper && hopper.getSyncedBlock() != null) {
|
||||||
}
|
e.setCancelled(true);
|
||||||
} catch (Exception ee) {
|
}
|
||||||
Debugger.runReport(ee);
|
} catch (Exception ee) {
|
||||||
}
|
Debugger.runReport(ee);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private Map<UUID, Player> ents = new HashMap<>();
|
|
||||||
|
private Map<UUID, Player> ents = new HashMap<>();
|
||||||
@EventHandler
|
|
||||||
public void onDed(EntityDamageByEntityEvent e) {
|
@EventHandler
|
||||||
try {
|
public void onDed(EntityDamageByEntityEvent e) {
|
||||||
if (e.getDamager() instanceof Player) {
|
try {
|
||||||
Player p = (Player) e.getDamager();
|
if (e.getDamager() instanceof Player) {
|
||||||
if (Methods.isSync(p)) {
|
Player p = (Player) e.getDamager();
|
||||||
double d = ((LivingEntity) e.getEntity()).getHealth() - e.getDamage();
|
if (Methods.isSync(p)) {
|
||||||
if (d < 1) {
|
double d = ((LivingEntity) e.getEntity()).getHealth() - e.getDamage();
|
||||||
ents.put(e.getEntity().getUniqueId(), p);
|
if (d < 1) {
|
||||||
}
|
ents.put(e.getEntity().getUniqueId(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ee) {
|
}
|
||||||
Debugger.runReport(ee);
|
} catch (Exception ee) {
|
||||||
}
|
Debugger.runReport(ee);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@EventHandler
|
|
||||||
public void onDrop(EntityDeathEvent e) {
|
@EventHandler
|
||||||
try {
|
public void onDrop(EntityDeathEvent e) {
|
||||||
if (ents.containsKey(e.getEntity().getUniqueId())) {
|
try {
|
||||||
Player p = ents.get(e.getEntity().getUniqueId());
|
if (ents.containsKey(e.getEntity().getUniqueId())) {
|
||||||
|
Player p = ents.get(e.getEntity().getUniqueId());
|
||||||
ItemStack item = p.getItemInHand();
|
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemStack item = p.getItemInHand();
|
||||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(meta.getLore().get(1).replaceAll("§", ""));
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (location.getBlock().getType() == Material.CHEST) {
|
Location location = Arconix.pl().getApi().serialize().unserializeLocation(meta.getLore().get(1).replaceAll("§", ""));
|
||||||
InventoryHolder ih = (InventoryHolder) location.getBlock().getState();
|
if (location.getBlock().getType() == Material.CHEST) {
|
||||||
for (ItemStack is : e.getDrops()) {
|
InventoryHolder ih = (InventoryHolder) location.getBlock().getState();
|
||||||
ih.getInventory().addItem(is);
|
for (ItemStack is : e.getDrops()) {
|
||||||
}
|
ih.getInventory().addItem(is);
|
||||||
e.getDrops().clear();
|
}
|
||||||
}
|
e.getDrops().clear();
|
||||||
}
|
}
|
||||||
} catch (Exception ee) {
|
}
|
||||||
Debugger.runReport(ee);
|
} catch (Exception ee) {
|
||||||
}
|
Debugger.runReport(ee);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private int getItemCount(Inventory inventory, ItemStack item) {
|
|
||||||
int amount = 0;
|
private int getItemCount(Inventory inventory, ItemStack item) {
|
||||||
|
int amount = 0;
|
||||||
for (ItemStack inventoryItem : inventory) {
|
|
||||||
if (!item.isSimilar(inventoryItem)) continue;
|
for (ItemStack inventoryItem : inventory) {
|
||||||
amount += inventoryItem.getAmount();
|
if (!item.isSimilar(inventoryItem)) continue;
|
||||||
}
|
amount += inventoryItem.getAmount();
|
||||||
|
}
|
||||||
return amount;
|
|
||||||
}
|
return amount;
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,100 +1,96 @@
|
|||||||
package com.songoda.epichoppers.Events;
|
package com.songoda.epichoppers.events;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Hopper.Hopper;
|
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.hopper.EHopper;
|
||||||
import com.songoda.epichoppers.Utils.Methods;
|
import com.songoda.epichoppers.player.PlayerData;
|
||||||
import org.bukkit.Material;
|
import com.songoda.epichoppers.player.SyncType;
|
||||||
import org.bukkit.entity.Player;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.event.EventHandler;
|
import com.songoda.epichoppers.utils.Methods;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
/**
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
* Created by songoda on 3/14/2017.
|
import org.bukkit.inventory.ItemStack;
|
||||||
*/
|
|
||||||
public class InteractListeners implements Listener {
|
/**
|
||||||
|
* Created by songoda on 3/14/2017.
|
||||||
private EpicHoppers instance;
|
*/
|
||||||
|
public class InteractListeners implements Listener {
|
||||||
public InteractListeners(EpicHoppers instance) {
|
|
||||||
this.instance = instance;
|
private EpicHoppersPlugin instance;
|
||||||
}
|
|
||||||
|
public InteractListeners(EpicHoppersPlugin instance) {
|
||||||
@EventHandler
|
this.instance = instance;
|
||||||
public void onBlockInteract(PlayerInteractEvent e) {
|
}
|
||||||
try {
|
|
||||||
Player player = e.getPlayer();
|
@EventHandler
|
||||||
if (e.getAction() != Action.LEFT_CLICK_BLOCK
|
public void onBlockInteract(PlayerInteractEvent e) {
|
||||||
|| e.getClickedBlock() == null
|
try {
|
||||||
|| player.isSneaking()
|
Player player = e.getPlayer();
|
||||||
|| !player.hasPermission("EpicHoppers.overview")
|
if (e.getAction() != Action.LEFT_CLICK_BLOCK
|
||||||
|| !instance.hooks.canBuild(player, e.getClickedBlock().getLocation())
|
|| e.getClickedBlock() == null
|
||||||
|| !(e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST))) {
|
|| player.isSneaking()
|
||||||
return;
|
|| !player.hasPermission("EpicHoppers.overview")
|
||||||
}
|
|| !instance.hooks.canBuild(player, e.getClickedBlock().getLocation())
|
||||||
|
|| !(e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST))) {
|
||||||
if (e.getClickedBlock().getType() == Material.CHEST && Methods.isSync(player)) {
|
return;
|
||||||
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
|
}
|
||||||
if (item.getItemMeta().getLore().size() == 2) {
|
|
||||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.desyncchest", item.getType().toString()));
|
if (e.getClickedBlock().getType() == Material.CHEST && Methods.isSync(player)) {
|
||||||
instance.enchant.createSyncTouch(item, null);
|
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
|
||||||
} else {
|
if (item.getItemMeta().getLore().size() == 2) {
|
||||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncchest", item.getType().toString()));
|
player.sendMessage(instance.getLocale().getMessage("event.hopper.desyncchest", item.getType().toString()));
|
||||||
instance.enchant.createSyncTouch(item, e.getClickedBlock());
|
instance.enchantmentHandler.createSyncTouch(item, null);
|
||||||
}
|
} else {
|
||||||
e.setCancelled(true);
|
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncchest", item.getType().toString()));
|
||||||
return;
|
instance.enchantmentHandler.createSyncTouch(item, e.getClickedBlock());
|
||||||
}
|
}
|
||||||
|
e.setCancelled(true);
|
||||||
|
return;
|
||||||
if (!instance.sync.containsKey(player) && !instance.bsync.containsKey(player)) {
|
}
|
||||||
if (e.getClickedBlock().getType() == Material.HOPPER) {
|
|
||||||
instance.lastBlock.put(player, e.getClickedBlock());
|
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(e.getClickedBlock());
|
|
||||||
if (instance.getConfig().getBoolean("Main.Allow Hopper Upgrading")) {
|
if (playerData.getSyncType() == null) {
|
||||||
if (!player.getInventory().getItemInMainHand().getType().name().contains("PICKAXE")) {
|
if (e.getClickedBlock().getType() == Material.HOPPER) {
|
||||||
hopper.overview(player);
|
Hopper hopper = instance.getHopperManager().getHopper(e.getClickedBlock());
|
||||||
e.setCancelled(true);
|
playerData.setLastHopper(hopper);
|
||||||
}
|
if (instance.getConfig().getBoolean("Main.Allow hopper Upgrading")
|
||||||
} else { //ToDO: What is this?
|
&& !player.getInventory().getItemInMainHand().getType().name().contains("PICKAXE")) {
|
||||||
if (player.hasPermission("EpicHoppers.Admin")) {
|
((EHopper)hopper).overview(player);
|
||||||
instance.sync.put(player, instance.lastBlock.get(player));
|
e.setCancelled(true);
|
||||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncnext"));
|
return;
|
||||||
hopper.timeout(player);
|
}
|
||||||
player.closeInventory();
|
|
||||||
}
|
//ToDO: What is this?
|
||||||
e.setCancelled(true);
|
if (player.hasPermission("EpicHoppers.Admin")) {
|
||||||
}
|
playerData.setLastHopper(hopper);
|
||||||
}
|
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||||
return;
|
((EHopper)hopper).timeout(player);
|
||||||
}
|
player.closeInventory();
|
||||||
|
}
|
||||||
if (e.getClickedBlock().getType() == Material.BREWING_STAND) return;
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
if (e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && instance.getConfig().getBoolean("Main.Support Enderchests")) {
|
return;
|
||||||
if (instance.sync.containsKey(player) && instance.sync.get(player).equals(e.getClickedBlock()) || instance.bsync.containsKey(player) && instance.bsync.get(player).equals(e.getClickedBlock())) {
|
}
|
||||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncself"));
|
|
||||||
} else {
|
if (e.getClickedBlock().getType() == Material.BREWING_STAND) return;
|
||||||
if (instance.sync.containsKey(player)) {
|
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(instance.sync.get(player));
|
if (e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && instance.getConfig().getBoolean("Main.Support Enderchests")) {
|
||||||
hopper.sync(e.getClickedBlock(), false, player);
|
if (playerData.getSyncType() != null && e.getClickedBlock().getLocation().equals(playerData.getLastHopper().getLocation())) {
|
||||||
} else if (instance.bsync.containsKey(player)) {
|
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncself"));
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(instance.bsync.get(player));
|
} else if (playerData.getSyncType() != null) {
|
||||||
hopper.sync(e.getClickedBlock(), true, player);
|
playerData.getLastHopper().sync(e.getClickedBlock(), playerData.getSyncType() == SyncType.FILTERED, player);
|
||||||
}
|
}
|
||||||
}
|
e.setCancelled(true);
|
||||||
e.setCancelled(true);
|
playerData.setSyncType(null);
|
||||||
instance.sync.remove(player);
|
}
|
||||||
instance.bsync.remove(player);
|
} catch (Exception ee) {
|
||||||
}
|
Debugger.runReport(ee);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception ee) {
|
}
|
||||||
Debugger.runReport(ee);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,212 +1,220 @@
|
|||||||
package com.songoda.epichoppers.Events;
|
package com.songoda.epichoppers.events;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Hopper.Hopper;
|
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.hopper.EHopper;
|
||||||
import com.songoda.epichoppers.Utils.Methods;
|
import com.songoda.epichoppers.player.MenuType;
|
||||||
import org.bukkit.Bukkit;
|
import com.songoda.epichoppers.player.PlayerData;
|
||||||
import org.bukkit.Material;
|
import com.songoda.epichoppers.player.SyncType;
|
||||||
import org.bukkit.entity.Player;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.inventory.*;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.event.inventory.*;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
/**
|
import org.bukkit.inventory.Inventory;
|
||||||
* Created by songoda on 3/14/2017.
|
import org.bukkit.inventory.ItemStack;
|
||||||
*/
|
|
||||||
public class InventoryListeners implements Listener {
|
/**
|
||||||
|
* Created by songoda on 3/14/2017.
|
||||||
private EpicHoppers instance;
|
*/
|
||||||
|
public class InventoryListeners implements Listener {
|
||||||
public InventoryListeners(EpicHoppers instance) {
|
|
||||||
this.instance = instance;
|
private EpicHoppersPlugin instance;
|
||||||
}
|
|
||||||
|
public InventoryListeners(EpicHoppersPlugin instance) {
|
||||||
@EventHandler
|
this.instance = instance;
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
}
|
||||||
try {
|
|
||||||
|
@EventHandler
|
||||||
Inventory inv = e.getInventory();
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
Player player = (Player) e.getWhoClicked();
|
try {
|
||||||
if (inv == null || e.getCurrentItem() == null) return;
|
|
||||||
|
Inventory inv = event.getInventory();
|
||||||
if (e.getCursor() != null && e.getCurrentItem() != null) {
|
Player player = (Player) event.getWhoClicked();
|
||||||
ItemStack c = e.getCursor();
|
if (inv == null || event.getCurrentItem() == null) return;
|
||||||
ItemStack item = e.getCurrentItem();
|
|
||||||
if (c.hasItemMeta()
|
|
||||||
&& c.getItemMeta().hasLore()
|
if (event.getRawSlot() > event.getView().getTopInventory().getSize() - 1) return;
|
||||||
&& c.getType() == Material.ENCHANTED_BOOK
|
|
||||||
&& (item.getType().name().toUpperCase().contains("AXE") || item.getType().name().toUpperCase().contains("SPADE") || item.getType().name().toUpperCase().contains("SWORD"))
|
if (event.getCursor() != null && event.getCurrentItem() != null) {
|
||||||
&& c.getItemMeta().getLore().equals(instance.enchant.getbook().getItemMeta().getLore())) {
|
ItemStack c = event.getCursor();
|
||||||
instance.enchant.createSyncTouch(item, null);
|
ItemStack item = event.getCurrentItem();
|
||||||
e.setCancelled(true);
|
if (c.hasItemMeta()
|
||||||
player.setItemOnCursor(new ItemStack(Material.AIR));
|
&& c.getItemMeta().hasLore()
|
||||||
player.updateInventory();
|
&& 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.enchantmentHandler.getbook().getItemMeta().getLore())) {
|
||||||
}
|
instance.enchantmentHandler.createSyncTouch(item, null);
|
||||||
}
|
event.setCancelled(true);
|
||||||
if (!e.getCurrentItem().hasItemMeta()) return;
|
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||||
|
player.updateInventory();
|
||||||
if (doFilter(e)) return;
|
|
||||||
|
|
||||||
if (e.getSlot() != 64537
|
}
|
||||||
&& e.getInventory().getType() == InventoryType.ANVIL
|
}
|
||||||
&& e.getAction() != InventoryAction.NOTHING
|
if (!event.getCurrentItem().hasItemMeta()) return;
|
||||||
&& e.getCurrentItem().getType() != Material.AIR) {
|
|
||||||
ItemStack item = e.getCurrentItem();
|
if (doFilter(event)) return;
|
||||||
if (item.getType() == Material.HOPPER) {
|
|
||||||
e.setCancelled(true);
|
if (event.getSlot() != 64537
|
||||||
}
|
&& event.getInventory().getType() == InventoryType.ANVIL
|
||||||
}
|
&& event.getAction() != InventoryAction.NOTHING
|
||||||
|
&& event.getCurrentItem().getType() != Material.AIR) {
|
||||||
if (!instance.inShow.containsKey(player.getUniqueId()) || instance.inFilter.containsKey(player.getUniqueId())) {
|
ItemStack item = event.getCurrentItem();
|
||||||
return;
|
if (item.getType() == Material.HOPPER) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
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);
|
||||||
&& (instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || player.hasPermission("EpicHoppers.Teleport"))) {
|
|
||||||
if (e.isLeftClick()) {
|
if (playerData.getInMenu() != MenuType.OVERVIEW) return;
|
||||||
if (hopper.getSyncedBlock() != null) {
|
|
||||||
instance.getTeleportHandler().tpPlayer(player, hopper);
|
event.setCancelled(true);
|
||||||
}
|
Hopper hopper = playerData.getLastHopper();
|
||||||
} else {
|
if (event.getCurrentItem().getItemMeta().hasDisplayName()
|
||||||
if (!hopper.isWalkOnTeleport()) {
|
&& event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.perltitle"))
|
||||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.walkteleenabled"));
|
&& (instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || player.hasPermission("EpicHoppers.Teleport"))) {
|
||||||
hopper.setWalkOnTeleport(true);
|
if (event.isLeftClick()) {
|
||||||
} else {
|
if (hopper.getSyncedBlock() != null) {
|
||||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.walkteledisabled"));
|
instance.getTeleportHandler().tpPlayer(player, hopper);
|
||||||
hopper.setWalkOnTeleport(false);
|
}
|
||||||
}
|
} else {
|
||||||
}
|
if (!hopper.isWalkOnTeleport()) {
|
||||||
player.closeInventory();
|
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.walkteleenabled"));
|
||||||
|
hopper.setWalkOnTeleport(true);
|
||||||
|
} else {
|
||||||
} else if (e.getCurrentItem().getItemMeta().hasDisplayName() && e.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.filtertitle")) && player.hasPermission("EpicHoppers.Filter")) {
|
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.walkteledisabled"));
|
||||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
hopper.setWalkOnTeleport(false);
|
||||||
hopper.filter(player);
|
}
|
||||||
}
|
}
|
||||||
} else if (e.getSlot() == 11 && player.hasPermission("EpicHoppers.Upgrade.XP")) {
|
player.closeInventory();
|
||||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
|
||||||
hopper.upgrade("XP", player);
|
|
||||||
player.closeInventory();
|
} 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")) {
|
||||||
} else if (e.getSlot() == 15 && player.hasPermission("EpicHoppers.Upgrade.ECO")) {
|
((EHopper)hopper).filter(player);
|
||||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
}
|
||||||
hopper.upgrade("ECO", player);
|
} else if (event.getSlot() == 11 && player.hasPermission("EpicHoppers.Upgrade.XP")) {
|
||||||
player.closeInventory();
|
if (!event.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||||
}
|
((EHopper)hopper).upgrade("XP", player);
|
||||||
} else if (e.getSlot() == 22) {
|
player.closeInventory();
|
||||||
if (e.isRightClick()) {
|
}
|
||||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.desync"));
|
} else if (event.getSlot() == 15 && player.hasPermission("EpicHoppers.Upgrade.ECO")) {
|
||||||
hopper.setSyncedBlock(null);
|
if (!event.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||||
} else {
|
((EHopper)hopper).upgrade("ECO", player);
|
||||||
boolean can = true;
|
player.closeInventory();
|
||||||
if (hopper.getLastPlayer() != null) {
|
}
|
||||||
if (!hopper.getLastPlayer().equals(player.getUniqueId())) {
|
} else if (event.getSlot() == 22) {
|
||||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncdidnotplace"));
|
if (event.isRightClick()) {
|
||||||
can = false;
|
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.desync"));
|
||||||
}
|
hopper.setSyncedBlock(null);
|
||||||
}
|
} else {
|
||||||
if (can) {
|
boolean can = true;
|
||||||
instance.sync.put(player, instance.lastBlock.get(player));
|
if (hopper.getLastPlayer() != null) {
|
||||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
if (!hopper.getLastPlayer().equals(player.getUniqueId())) {
|
||||||
hopper.timeout(player);
|
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncdidnotplace"));
|
||||||
}
|
can = false;
|
||||||
}
|
}
|
||||||
player.closeInventory();
|
}
|
||||||
}
|
if (can) {
|
||||||
} catch (Exception ee) {
|
playerData.setSyncType(SyncType.REGULAR);
|
||||||
Debugger.runReport(ee);
|
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||||
}
|
((EHopper)hopper).timeout(player);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private boolean doFilter(InventoryClickEvent e) {
|
player.closeInventory();
|
||||||
Player player = (Player) e.getWhoClicked();
|
}
|
||||||
if (!instance.inFilter.containsKey(player.getUniqueId())
|
} catch (Exception ee) {
|
||||||
|| e.getInventory() == null
|
Debugger.runReport(ee);
|
||||||
|| !e.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
}
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
if (e.getClick().equals(ClickType.SHIFT_LEFT)) {
|
private boolean doFilter(InventoryClickEvent e) {
|
||||||
e.setCancelled(true);
|
Player player = (Player) e.getWhoClicked();
|
||||||
return true;
|
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||||
}
|
if (playerData.getInMenu() != MenuType.FILTER
|
||||||
|
|| e.getInventory() == null
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(instance.lastBlock.get(player));
|
|| !e.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
||||||
hopper.compile(player);
|
return false;
|
||||||
if (e.getSlot() == 40) {
|
}
|
||||||
instance.bsync.put(player, instance.lastBlock.get(player));
|
if (e.getClick().equals(ClickType.SHIFT_LEFT)) {
|
||||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
e.setCancelled(true);
|
||||||
hopper.timeout(player);
|
return true;
|
||||||
player.closeInventory();
|
}
|
||||||
return true;
|
|
||||||
}
|
Hopper hopper = playerData.getLastHopper();
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||||
int[] a = {0, 1, 9, 10, 18, 19, 27, 28, 36, 37, 45, 46, 7, 8, 16, 17, 25, 26, 34, 35, 43, 44, 52, 53};
|
((EHopper)hopper).compile(player);
|
||||||
e.setCancelled(true);
|
}, 1);
|
||||||
for (int aa : a) {
|
if (e.getSlot() == 40) {
|
||||||
if (aa != e.getSlot()) continue;
|
playerData.setSyncType(SyncType.FILTERED);
|
||||||
String name = "";
|
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||||
if (e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName())
|
((EHopper)hopper).timeout(player);
|
||||||
name = e.getCurrentItem().getItemMeta().getDisplayName();
|
player.closeInventory();
|
||||||
if (!name.equals(instance.getLocale().getMessage("interface.filter.whitelist")) &&
|
return true;
|
||||||
!name.equals(instance.getLocale().getMessage("interface.filter.blacklist")) &&
|
}
|
||||||
!name.equals(instance.getLocale().getMessage("interface.filter.void"))) {
|
|
||||||
e.setCancelled(false);
|
int[] a = {0, 1, 9, 10, 18, 19, 27, 28, 36, 37, 45, 46, 7, 8, 16, 17, 25, 26, 34, 35, 43, 44, 52, 53};
|
||||||
return true;
|
e.setCancelled(true);
|
||||||
}
|
for (int aa : a) {
|
||||||
|
if (aa != e.getSlot()) continue;
|
||||||
if (e.getCursor().getType().equals(Material.AIR)) return true;
|
String name = "";
|
||||||
if (e.getCursor().getAmount() != 1) {
|
if (e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName())
|
||||||
e.setCancelled(true);
|
name = e.getCurrentItem().getItemMeta().getDisplayName();
|
||||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.onlyone"));
|
if (!name.equals(instance.getLocale().getMessage("interface.filter.whitelist")) &&
|
||||||
return true;
|
!name.equals(instance.getLocale().getMessage("interface.filter.blacklist")) &&
|
||||||
}
|
!name.equals(instance.getLocale().getMessage("interface.filter.void"))) {
|
||||||
|
e.setCancelled(false);
|
||||||
e.setCancelled(false);
|
return true;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.setItemOnCursor(new ItemStack(Material.AIR)), 1L);
|
}
|
||||||
return true;
|
|
||||||
}
|
if (e.getCursor().getType().equals(Material.AIR)) return true;
|
||||||
return true;
|
if (e.getCursor().getAmount() != 1) {
|
||||||
}
|
e.setCancelled(true);
|
||||||
|
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.onlyone"));
|
||||||
@EventHandler
|
return true;
|
||||||
public void onDrop(PlayerDropItemEvent e) {
|
}
|
||||||
|
|
||||||
ItemStack item = e.getItemDrop().getItemStack();
|
e.setCancelled(false);
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.setItemOnCursor(new ItemStack(Material.AIR)), 1L);
|
||||||
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
|
return true;
|
||||||
return;
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
String name = item.getItemMeta().getDisplayName();
|
|
||||||
|
@EventHandler
|
||||||
if (!name.equals(instance.getLocale().getMessage("interface.filter.whitelist")) &&
|
public void onDrop(PlayerDropItemEvent e) {
|
||||||
!name.equals(instance.getLocale().getMessage("interface.filter.blacklist")) &&
|
|
||||||
!name.equals(instance.getLocale().getMessage("interface.filter.void"))) {
|
ItemStack item = e.getItemDrop().getItemStack();
|
||||||
return;
|
|
||||||
}
|
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
|
||||||
e.getItemDrop().remove();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
String name = item.getItemMeta().getDisplayName();
|
||||||
public void onClose(InventoryCloseEvent event) {
|
|
||||||
try {
|
if (!name.equals(instance.getLocale().getMessage("interface.filter.whitelist")) &&
|
||||||
final Player player = (Player) event.getPlayer();
|
!name.equals(instance.getLocale().getMessage("interface.filter.blacklist")) &&
|
||||||
instance.inShow.remove(player.getUniqueId());
|
!name.equals(instance.getLocale().getMessage("interface.filter.void"))) {
|
||||||
if (instance.inFilter.containsKey(player.getUniqueId())) {
|
return;
|
||||||
|
}
|
||||||
instance.getHopperManager().getHopper(instance.lastBlock.get(player)).compile(player);
|
e.getItemDrop().remove();
|
||||||
instance.inFilter.remove(player.getUniqueId());
|
}
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
@EventHandler
|
||||||
Debugger.runReport(e);
|
public void onClose(InventoryCloseEvent event) {
|
||||||
}
|
try {
|
||||||
}
|
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,45 +1,45 @@
|
|||||||
package com.songoda.epichoppers.Events;
|
package com.songoda.epichoppers.events;
|
||||||
|
|
||||||
import com.songoda.arconix.plugin.Arconix;
|
import com.songoda.arconix.plugin.Arconix;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/14/2017.
|
* Created by songoda on 3/14/2017.
|
||||||
*/
|
*/
|
||||||
public class LoginListeners implements Listener {
|
public class LoginListeners implements Listener {
|
||||||
|
|
||||||
private EpicHoppers instance;
|
private EpicHoppersPlugin instance;
|
||||||
|
|
||||||
public LoginListeners(EpicHoppers instance) {
|
public LoginListeners(EpicHoppersPlugin instance) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
try {
|
try {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
if (p.isOp() && instance.getConfig().getBoolean("Main.Display Helpful Tips For Operators")) {
|
if (p.isOp() && instance.getConfig().getBoolean("Main.Display Helpful Tips For Operators")) {
|
||||||
if (instance.getServer().getPluginManager().getPlugin("Factions") != null && instance.hooks.FactionsHook == null) {
|
if (instance.getServer().getPluginManager().getPlugin("Factions") != null && instance.hooks.FactionsHook == null) {
|
||||||
p.sendMessage("");
|
p.sendMessage("");
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&7Here's the deal,"));
|
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&7Here's the deal,"));
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Because you're not using the official versions of &6Factions"));
|
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Because you're not using the official versions of &6Factions"));
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7I cannot give you full support out of the box."));
|
p.sendMessage(Arconix.pl().getApi().format().formatText("&7I cannot give you full support out of the box."));
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Things will work without it but if you wan't a flawless"));
|
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Things will work without it but if you wan't a flawless"));
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7experience you need to download"));
|
p.sendMessage(Arconix.pl().getApi().format().formatText("&7experience you need to download"));
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7&6https://www.spigotmc.org/resources/54337/&7."));
|
p.sendMessage(Arconix.pl().getApi().format().formatText("&7&6https://www.spigotmc.org/resources/54337/&7."));
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7If you don't care and don't want to see this message again"));
|
p.sendMessage(Arconix.pl().getApi().format().formatText("&7If you don't care and don't want to see this message again"));
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7turn &6Helpful-Tips &7off in the config."));
|
p.sendMessage(Arconix.pl().getApi().format().formatText("&7turn &6Helpful-Tips &7off in the config."));
|
||||||
p.sendMessage("");
|
p.sendMessage("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
Debugger.runReport(ee);
|
Debugger.runReport(ee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,70 +1,70 @@
|
|||||||
package com.songoda.epichoppers.Handlers;
|
package com.songoda.epichoppers.handlers;
|
||||||
|
|
||||||
import com.songoda.arconix.plugin.Arconix;
|
import com.songoda.arconix.plugin.Arconix;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/14/2017.
|
* Created by songoda on 3/14/2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommandHandler implements CommandExecutor {
|
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;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
try {
|
try {
|
||||||
if (args.length == 0 || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
|
if (args.length == 0 || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&7" + plugin.getDescription().getVersion() + " Created by &5&l&oBrianna"));
|
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&7" + plugin.getDescription().getVersion() + " Created by &5&l&oBrianna"));
|
||||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH help &7Displays this page."));
|
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH help &7Displays this page."));
|
||||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH book [player] &7Gives Sync Touch book to you or a player."));
|
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH book [player] &7Gives Sync Touch book to you or a player."));
|
||||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH settings &7Edit the EpicHoppers Settings."));
|
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH settings &7Edit the EpicHoppers Settings."));
|
||||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH reload &7Reloads Configuration and Language files."));
|
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH reload &7Reloads Configuration and Language files."));
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
} else if (args[0].equalsIgnoreCase("book")) {
|
} else if (args[0].equalsIgnoreCase("book")) {
|
||||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||||
} else {
|
} else {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (sender instanceof Player)
|
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) {
|
} 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!"));
|
sender.sendMessage(plugin.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cThat username does not exist, or the user is not online!"));
|
||||||
} else {
|
} 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")) {
|
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||||
} else {
|
} else {
|
||||||
plugin.reload();
|
plugin.reload();
|
||||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&8Configuration and Language files reloaded."));
|
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&8Configuration and Language files reloaded."));
|
||||||
}
|
}
|
||||||
} else if (sender instanceof Player) {
|
} else if (sender instanceof Player) {
|
||||||
if (args[0].equalsIgnoreCase("settings")) {
|
if (args[0].equalsIgnoreCase("settings")) {
|
||||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||||
} else {
|
} else {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
plugin.sm.openSettingsManager(p);
|
plugin.settingsManager.openSettingsManager(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,83 +1,83 @@
|
|||||||
package com.songoda.epichoppers.Handlers;
|
package com.songoda.epichoppers.handlers;
|
||||||
|
|
||||||
import com.songoda.arconix.plugin.Arconix;
|
import com.songoda.arconix.plugin.Arconix;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/22/2017.
|
* Created by songoda on 3/22/2017.
|
||||||
*/
|
*/
|
||||||
public class EnchantmentHandler {
|
public class EnchantmentHandler {
|
||||||
|
|
||||||
private EpicHoppers instance;
|
private EpicHoppersPlugin instance;
|
||||||
|
|
||||||
public EnchantmentHandler(EpicHoppers instance) {
|
public EnchantmentHandler(EpicHoppersPlugin instance) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public EnchantmentHandler() {
|
public EnchantmentHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack createSyncTouch(ItemStack item, Block b) {
|
public ItemStack createSyncTouch(ItemStack item, Block b) {
|
||||||
try {
|
try {
|
||||||
ItemMeta itemmeta = item.getItemMeta();
|
ItemMeta itemmeta = item.getItemMeta();
|
||||||
ArrayList<String> lore = new ArrayList<String>();
|
ArrayList<String> lore = new ArrayList<String>();
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
lore.add(Arconix.pl().getApi().format().formatText("&aSync Touch"));
|
lore.add(Arconix.pl().getApi().format().formatText("&aSync Touch"));
|
||||||
lore.add(Arconix.pl().getApi().format().convertToInvisibleString(Arconix.pl().getApi().serialize().serializeLocation(b)));
|
lore.add(Arconix.pl().getApi().format().convertToInvisibleString(Arconix.pl().getApi().serialize().serializeLocation(b)));
|
||||||
} else {
|
} else {
|
||||||
lore.add(Arconix.pl().getApi().format().formatText("&7Sync Touch"));
|
lore.add(Arconix.pl().getApi().format().formatText("&7Sync Touch"));
|
||||||
}
|
}
|
||||||
itemmeta.setLore(lore);
|
itemmeta.setLore(lore);
|
||||||
item.setItemMeta(itemmeta);
|
item.setItemMeta(itemmeta);
|
||||||
return item;
|
return item;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveSyncTouchBook(Player p) {
|
public void giveSyncTouchBook(Player p) {
|
||||||
try {
|
try {
|
||||||
boolean isEmpty = false;
|
boolean isEmpty = false;
|
||||||
for (ItemStack item : p.getInventory().getContents()) {
|
for (ItemStack item : p.getInventory().getContents()) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
isEmpty = true;
|
isEmpty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isEmpty) {
|
if (!isEmpty) {
|
||||||
p.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.inventory.noroom"));
|
p.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.inventory.noroom"));
|
||||||
} else {
|
} else {
|
||||||
ItemStack book = getbook();
|
ItemStack book = getbook();
|
||||||
p.getInventory().addItem(book);
|
p.getInventory().addItem(book);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getbook() {
|
public ItemStack getbook() {
|
||||||
try {
|
try {
|
||||||
ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
|
ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
|
||||||
ItemMeta meta = book.getItemMeta();
|
ItemMeta meta = book.getItemMeta();
|
||||||
meta.setDisplayName(Arconix.pl().getApi().format().formatText("&eEnchanted Book"));
|
meta.setDisplayName(Arconix.pl().getApi().format().formatText("&eEnchanted Book"));
|
||||||
|
|
||||||
ArrayList<String> lore = new ArrayList<>();
|
ArrayList<String> lore = new ArrayList<>();
|
||||||
lore.add(Arconix.pl().getApi().format().formatText("&7Sync Touch"));
|
lore.add(Arconix.pl().getApi().format().formatText("&7Sync Touch"));
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
book.setItemMeta(meta);
|
book.setItemMeta(meta);
|
||||||
return book;
|
return book;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,114 +1,114 @@
|
|||||||
package com.songoda.epichoppers.Handlers;
|
package com.songoda.epichoppers.handlers;
|
||||||
|
|
||||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Hooks.*;
|
import com.songoda.epichoppers.hooks.*;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class HookHandler {
|
public class HookHandler {
|
||||||
|
|
||||||
public Hook FactionsHook = null, RedProtectHook = null, ASkyBlockHook = null, USkyBlockHook = null,
|
public Hook FactionsHook = null, RedProtectHook = null, ASkyBlockHook = null, USkyBlockHook = null,
|
||||||
WorldGuardHook = null, GriefPreventionHook = null, PlotSquaredHook = null, KingdomsHook = null,
|
WorldGuardHook = null, GriefPreventionHook = null, PlotSquaredHook = null, KingdomsHook = null,
|
||||||
TownyHook = null;
|
TownyHook = null;
|
||||||
|
|
||||||
public ConfigWrapper hooksFile = new ConfigWrapper(EpicHoppers.getInstance(), "", "hooks.yml");
|
public ConfigWrapper hooksFile = new ConfigWrapper(EpicHoppersPlugin.getInstance(), "", "hooks.yml");
|
||||||
|
|
||||||
public HookHandler() {
|
public HookHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hook() {
|
public void hook() {
|
||||||
try {
|
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 FactionsHook();
|
||||||
new RedProtectHook();
|
new RedProtectHook();
|
||||||
new GriefPreventionHook();
|
new GriefPreventionHook();
|
||||||
new ASkyBlockHook();
|
new ASkyBlockHook();
|
||||||
new USkyBlockHook();
|
new USkyBlockHook();
|
||||||
new WorldGuardHook();
|
new WorldGuardHook();
|
||||||
new PlotSquaredHook();
|
new PlotSquaredHook();
|
||||||
new KingdomsHook();
|
new KingdomsHook();
|
||||||
new TownyHook();
|
new TownyHook();
|
||||||
|
|
||||||
hooksFile.getConfig().options().copyDefaults(true);
|
hooksFile.getConfig().options().copyDefaults(true);
|
||||||
hooksFile.saveConfig();
|
hooksFile.saveConfig();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInFaction(String name, Location l) {
|
public boolean isInFaction(String name, Location l) {
|
||||||
if (FactionsHook != null) {
|
if (FactionsHook != null) {
|
||||||
return FactionsHook.isInClaim(name, l);
|
return FactionsHook.isInClaim(name, l);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionId(String name) {
|
public String getFactionId(String name) {
|
||||||
if (FactionsHook != null) {
|
if (FactionsHook != null) {
|
||||||
return FactionsHook.getClaimId(name);
|
return FactionsHook.getClaimId(name);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInTown(String name, Location l) {
|
public boolean isInTown(String name, Location l) {
|
||||||
if (TownyHook != null) {
|
if (TownyHook != null) {
|
||||||
return TownyHook.isInClaim(name, l);
|
return TownyHook.isInClaim(name, l);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTownId(String name) {
|
public String getTownId(String name) {
|
||||||
if (TownyHook != null) {
|
if (TownyHook != null) {
|
||||||
return TownyHook.getClaimId(name);
|
return TownyHook.getClaimId(name);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInIsland(String name, Location l) {
|
public boolean isInIsland(String name, Location l) {
|
||||||
if (USkyBlockHook != null)
|
if (USkyBlockHook != null)
|
||||||
return USkyBlockHook.isInClaim(name, l);
|
return USkyBlockHook.isInClaim(name, l);
|
||||||
else if (ASkyBlockHook != null)
|
else if (ASkyBlockHook != null)
|
||||||
return ASkyBlockHook.isInClaim(name, l);
|
return ASkyBlockHook.isInClaim(name, l);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIslandId(String name) {
|
public String getIslandId(String name) {
|
||||||
try {
|
try {
|
||||||
return Bukkit.getOfflinePlayer(name).getUniqueId().toString();
|
return Bukkit.getOfflinePlayer(name).getUniqueId().toString();
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBuild(Player p, Location l) {
|
public boolean canBuild(Player p, Location l) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
if (WorldGuardHook != null)
|
if (WorldGuardHook != null)
|
||||||
result = WorldGuardHook.canBuild(p, l);
|
result = WorldGuardHook.canBuild(p, l);
|
||||||
if (RedProtectHook != null && result)
|
if (RedProtectHook != null && result)
|
||||||
result = RedProtectHook.canBuild(p, l);
|
result = RedProtectHook.canBuild(p, l);
|
||||||
if (FactionsHook != null && result)
|
if (FactionsHook != null && result)
|
||||||
result = FactionsHook.canBuild(p, l);
|
result = FactionsHook.canBuild(p, l);
|
||||||
if (ASkyBlockHook != null && result)
|
if (ASkyBlockHook != null && result)
|
||||||
result = ASkyBlockHook.canBuild(p, l);
|
result = ASkyBlockHook.canBuild(p, l);
|
||||||
if (USkyBlockHook != null && result)
|
if (USkyBlockHook != null && result)
|
||||||
result = USkyBlockHook.canBuild(p, l);
|
result = USkyBlockHook.canBuild(p, l);
|
||||||
if (GriefPreventionHook != null && result)
|
if (GriefPreventionHook != null && result)
|
||||||
result = GriefPreventionHook.canBuild(p, l);
|
result = GriefPreventionHook.canBuild(p, l);
|
||||||
if (PlotSquaredHook != null && result)
|
if (PlotSquaredHook != null && result)
|
||||||
result = PlotSquaredHook.canBuild(p, l);
|
result = PlotSquaredHook.canBuild(p, l);
|
||||||
if (KingdomsHook != null && result)
|
if (KingdomsHook != null && result)
|
||||||
result = KingdomsHook.canBuild(p, l);
|
result = KingdomsHook.canBuild(p, l);
|
||||||
if (TownyHook != null && result)
|
if (TownyHook != null && result)
|
||||||
result = TownyHook.canBuild(p, l);
|
result = TownyHook.canBuild(p, l);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,344 +1,344 @@
|
|||||||
package com.songoda.epichoppers.Handlers;
|
package com.songoda.epichoppers.handlers;
|
||||||
|
|
||||||
import com.songoda.arconix.plugin.Arconix;
|
import com.songoda.arconix.plugin.Arconix;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.hopper.EHopper;
|
||||||
import com.songoda.epichoppers.Utils.Methods;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Hopper;
|
import org.bukkit.block.Hopper;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.inventory.FurnaceInventory;
|
import org.bukkit.inventory.FurnaceInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/14/2017.
|
* Created by songoda on 3/14/2017.
|
||||||
*/
|
*/
|
||||||
public class HopHandler {
|
public class HopHandler {
|
||||||
|
|
||||||
private EpicHoppers instance;
|
private EpicHoppersPlugin instance;
|
||||||
|
|
||||||
public HopHandler(EpicHoppers instance) {
|
public HopHandler(EpicHoppersPlugin instance) {
|
||||||
try {
|
try {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||||
hopperCleaner();
|
hopperCleaner();
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::hopperRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Hops"));
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::hopperRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Hops"));
|
||||||
}, 40L);
|
}, 40L);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hopperCleaner() {
|
private void hopperCleaner() {
|
||||||
try {
|
try {
|
||||||
if (instance.dataFile.getConfig().contains("data.sync")) {
|
if (instance.dataFile.getConfig().contains("data.sync")) {
|
||||||
ConfigurationSection cs = instance.dataFile.getConfig().getConfigurationSection("data.sync");
|
ConfigurationSection cs = instance.dataFile.getConfig().getConfigurationSection("data.sync");
|
||||||
for (String key : cs.getKeys(false)) {
|
for (String key : cs.getKeys(false)) {
|
||||||
if (Arconix.pl().getApi().serialize().unserializeLocation(key).getWorld() != null) {
|
if (Arconix.pl().getApi().serialize().unserializeLocation(key).getWorld() != null) {
|
||||||
Block b = Arconix.pl().getApi().serialize().unserializeLocation(key).getBlock();
|
Block b = Arconix.pl().getApi().serialize().unserializeLocation(key).getBlock();
|
||||||
if (b == null || !(b.getState() instanceof Hopper)) {
|
if (b == null || !(b.getState() instanceof Hopper)) {
|
||||||
instance.dataFile.getConfig().getConfigurationSection("data.sync").set(key, null);
|
instance.dataFile.getConfig().getConfigurationSection("data.sync").set(key, null);
|
||||||
instance.getLogger().info("EpicHoppers Removing non-hopper entry: " + key);
|
instance.getLogger().info("EpicHoppers Removing non-hopper entry: " + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Block, Integer> blockTick = new HashMap<>();
|
public Map<Block, Integer> blockTick = new HashMap<>();
|
||||||
|
|
||||||
private void hopperRunner() {
|
private void hopperRunner() {
|
||||||
try {
|
try {
|
||||||
Set<Entity> metaItems = new HashSet<>();
|
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();
|
Location location = hopper.getLocation();
|
||||||
|
|
||||||
int x = location.getBlockX() >> 4;
|
int x = location.getBlockX() >> 4;
|
||||||
int z = location.getBlockZ() >> 4;
|
int z = location.getBlockZ() >> 4;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!location.getWorld().isChunkLoaded(x, z)) {
|
if (!location.getWorld().isChunkLoaded(x, z)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
|
|
||||||
|
|
||||||
if (block == null || !(block.getState() instanceof Hopper)) {
|
if (block == null || !(block.getState() instanceof Hopper)) {
|
||||||
instance.getHopperManager().removeHopper(location);
|
instance.getHopperManager().removeHopper(location);
|
||||||
instance.getLogger().info("EpicHoppers Removing non-hopper entry: " + location.toString());
|
instance.getLogger().info("EpicHoppers Removing non-hopper entry: " + location.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
org.bukkit.block.Hopper hopperBlock = (org.bukkit.block.Hopper) (block != null ? block.getState() : null);
|
org.bukkit.block.Hopper hopperBlock = (org.bukkit.block.Hopper) (block != null ? block.getState() : null);
|
||||||
|
|
||||||
if (hopper.getLevel().getBlockBreak() != 0) {
|
if (hopper.getLevel().getBlockBreak() != 0) {
|
||||||
int amt = hopper.getLevel().getBlockBreak();
|
int amt = hopper.getLevel().getBlockBreak();
|
||||||
if (!blockTick.containsKey(block)) {
|
if (!blockTick.containsKey(block)) {
|
||||||
blockTick.put(block, 1);
|
blockTick.put(block, 1);
|
||||||
} else {
|
} else {
|
||||||
int tick = blockTick.get(block);
|
int tick = blockTick.get(block);
|
||||||
int put = tick + 1;
|
int put = tick + 1;
|
||||||
blockTick.put(block, put);
|
blockTick.put(block, put);
|
||||||
if (tick >= amt) {
|
if (tick >= amt) {
|
||||||
Block above = block.getRelative(0, 1, 0);
|
Block above = block.getRelative(0, 1, 0);
|
||||||
if (above.getType() != Material.AIR && !instance.getConfig().getStringList("Main.BlockBreak Blacklisted Blocks").contains(above.getType().name())) {
|
if (above.getType() != Material.AIR && !instance.getConfig().getStringList("Main.BlockBreak Blacklisted Blocks").contains(above.getType().name())) {
|
||||||
above.getWorld().playSound(above.getLocation(), Sound.BLOCK_STONE_BREAK, 1F, 1F);
|
above.getWorld().playSound(above.getLocation(), Sound.BLOCK_STONE_BREAK, 1F, 1F);
|
||||||
Location locationAbove = above.getLocation();
|
Location locationAbove = above.getLocation();
|
||||||
locationAbove.add(.5, .5, .5);
|
locationAbove.add(.5, .5, .5);
|
||||||
|
|
||||||
float ox = (float) (0 + (Math.random() * .5));
|
float ox = (float) (0 + (Math.random() * .5));
|
||||||
float oy = (float) (0 + (Math.random() * .5));
|
float oy = (float) (0 + (Math.random() * .5));
|
||||||
float oz = (float) (0 + (Math.random() * .5));
|
float oz = (float) (0 + (Math.random() * .5));
|
||||||
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(locationAbove, ox, oy, oz, 0, instance.getConfig().getString("Main.BlockBreak Particle Type"), 15);
|
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(locationAbove, ox, oy, oz, 0, instance.getConfig().getString("Main.BlockBreak Particle Type"), 15);
|
||||||
|
|
||||||
above.breakNaturally();
|
above.breakNaturally();
|
||||||
}
|
}
|
||||||
blockTick.remove(block);
|
blockTick.remove(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hopper.getLevel().getSuction() != 0) {
|
if (hopper.getLevel().getSuction() != 0) {
|
||||||
int suck = hopper.getLevel().getSuction();
|
int suck = hopper.getLevel().getSuction();
|
||||||
double radius = suck + .5;
|
double radius = suck + .5;
|
||||||
|
|
||||||
Collection<Entity> nearbyEntite = block.getLocation().getWorld().getNearbyEntities(block.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius);
|
Collection<Entity> nearbyEntite = block.getLocation().getWorld().getNearbyEntities(block.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius);
|
||||||
|
|
||||||
for (Entity e : nearbyEntite) {
|
for (Entity e : nearbyEntite) {
|
||||||
if (!(e instanceof Item) || e.getTicksLived() < 10 || e.getLocation().getBlock().getType() == Material.HOPPER) {
|
if (!(e instanceof Item) || e.getTicksLived() < 10 || e.getLocation().getBlock().getType() == Material.HOPPER) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ItemStack hopItem = ((Item) e).getItemStack().clone();
|
ItemStack hopItem = ((Item) e).getItemStack().clone();
|
||||||
if (hopItem.getType().name().contains("SHULKER_BOX"))
|
if (hopItem.getType().name().contains("SHULKER_BOX"))
|
||||||
continue;
|
continue;
|
||||||
if (hopItem.hasItemMeta() && hopItem.getItemMeta().hasDisplayName() &&
|
if (hopItem.hasItemMeta() && hopItem.getItemMeta().hasDisplayName() &&
|
||||||
StringUtils.substring(hopItem.getItemMeta().getDisplayName(), 0, 3).equals("***")) {
|
StringUtils.substring(hopItem.getItemMeta().getDisplayName(), 0, 3).equals("***")) {
|
||||||
continue; //Compatibility with Shop instance: https://www.spigotmc.org/resources/shop-a-simple-intuitive-shop-instance.9628/
|
continue; //Compatibility with Shop instance: https://www.spigotmc.org/resources/shop-a-simple-intuitive-shop-instance.9628/
|
||||||
}
|
}
|
||||||
if (e.hasMetadata("grabbed"))
|
if (e.hasMetadata("grabbed"))
|
||||||
continue;
|
continue;
|
||||||
ItemStack item = ((Item) e).getItemStack();
|
ItemStack item = ((Item) e).getItemStack();
|
||||||
if (!canHop(hopperBlock.getInventory(), item, 1)) {
|
if (!canHop(hopperBlock.getInventory(), item, 1)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
((Item) e).setPickupDelay(999);
|
((Item) e).setPickupDelay(999);
|
||||||
e.setMetadata("grabbed", new FixedMetadataValue(instance, ""));
|
e.setMetadata("grabbed", new FixedMetadataValue(instance, ""));
|
||||||
metaItems.add(e);
|
metaItems.add(e);
|
||||||
if (!e.isOnGround())
|
if (!e.isOnGround())
|
||||||
continue;
|
continue;
|
||||||
float xx = (float) (0 + (Math.random() * .3));
|
float xx = (float) (0 + (Math.random() * .3));
|
||||||
float yy = (float) (0 + (Math.random() * .3));
|
float yy = (float) (0 + (Math.random() * .3));
|
||||||
float zz = (float) (0 + (Math.random() * .3));
|
float zz = (float) (0 + (Math.random() * .3));
|
||||||
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(e.getLocation(), xx, yy, zz, 0, "FLAME", 5);
|
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(e.getLocation(), xx, yy, zz, 0, "FLAME", 5);
|
||||||
e.remove();
|
e.remove();
|
||||||
hopperBlock.getInventory().addItem(hopItem);
|
hopperBlock.getInventory().addItem(hopItem);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hopper.getSyncedBlock() == null) continue;
|
if (hopper.getSyncedBlock() == null) continue;
|
||||||
Location dest = hopper.getSyncedBlock().getLocation();
|
Location dest = hopper.getSyncedBlock().getLocation();
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
hopper.setSyncedBlock(null);
|
hopper.setSyncedBlock(null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int destx = location.getBlockX() >> 4;
|
int destx = location.getBlockX() >> 4;
|
||||||
int destz = location.getBlockZ() >> 4;
|
int destz = location.getBlockZ() >> 4;
|
||||||
if (!dest.getWorld().isChunkLoaded(destx, destz)) {
|
if (!dest.getWorld().isChunkLoaded(destx, destz)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Block b2 = dest.getBlock();
|
Block b2 = dest.getBlock();
|
||||||
if (!b2.getType().equals(Material.HOPPER) && !b2.getType().equals(Material.CHEST) && !b2.getType().equals(Material.TRAPPED_CHEST) && !(b2.getType().equals(Material.ENDER_CHEST))) {
|
if (!b2.getType().equals(Material.HOPPER) && !b2.getType().equals(Material.CHEST) && !b2.getType().equals(Material.TRAPPED_CHEST) && !(b2.getType().equals(Material.ENDER_CHEST))) {
|
||||||
hopper.setSyncedBlock(null);
|
hopper.setSyncedBlock(null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int amt = hopper.getLevel().getAmount();
|
int amt = hopper.getLevel().getAmount();
|
||||||
|
|
||||||
ItemStack[] is = hopperBlock.getInventory().getContents();
|
ItemStack[] is = hopperBlock.getInventory().getContents();
|
||||||
|
|
||||||
List<ItemStack> whiteList = hopper.getFilter().getWhiteList();
|
List<ItemStack> whiteList = hopper.getFilter().getWhiteList();
|
||||||
|
|
||||||
List<ItemStack> blackList = hopper.getFilter().getBlackList();
|
List<ItemStack> blackList = hopper.getFilter().getBlackList();
|
||||||
|
|
||||||
int num = 0;
|
int num = 0;
|
||||||
while (num != 5) {
|
while (num != 5) {
|
||||||
ItemStack it = null;
|
ItemStack it = null;
|
||||||
if (is[num] != null) {
|
if (is[num] != null) {
|
||||||
it = is[num].clone();
|
it = is[num].clone();
|
||||||
it.setAmount(1);
|
it.setAmount(1);
|
||||||
}
|
}
|
||||||
if (is[num] != null
|
if (is[num] != null
|
||||||
&& !whiteList.isEmpty()
|
&& !whiteList.isEmpty()
|
||||||
&& !whiteList.contains(it)) {
|
&& !whiteList.contains(it)) {
|
||||||
doBlacklist(hopperBlock, hopper, is[num].clone(), is, amt, num);
|
doBlacklist(hopperBlock, hopper, is[num].clone(), is, amt, num);
|
||||||
} else if (is[num] != null && !blackList.contains(it)) {
|
} else if (is[num] != null && !blackList.contains(it)) {
|
||||||
int numm = addItem(hopperBlock, hopper, b2, is[num], is, amt, num);
|
int numm = addItem(hopperBlock, hopper, b2, is[num], is, amt, num);
|
||||||
if (numm != 10)
|
if (numm != 10)
|
||||||
num = numm;
|
num = numm;
|
||||||
} else if (is[num] != null && blackList.contains(it)) {
|
} else if (is[num] != null && blackList.contains(it)) {
|
||||||
doBlacklist(hopperBlock, hopper, is[num].clone(), is, amt, num);
|
doBlacklist(hopperBlock, hopper, is[num].clone(), is, amt, num);
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
try {
|
||||||
Location loc = hopperBlock.getLocation();
|
Location loc = hopperBlock.getLocation();
|
||||||
Block b = loc.getBlock();
|
Block b = loc.getBlock();
|
||||||
if (hopper.getFilter().getEndPoint() != null
|
if (hopper.getFilter().getEndPoint() != null
|
||||||
&& b != null && b.getState() instanceof Hopper) {
|
&& b != null && b.getState() instanceof Hopper) {
|
||||||
Location dest = hopper.getFilter().getEndPoint().getLocation();
|
Location dest = hopper.getFilter().getEndPoint().getLocation();
|
||||||
int destx = loc.getBlockX() >> 4;
|
int destx = loc.getBlockX() >> 4;
|
||||||
int destz = loc.getBlockZ() >> 4;
|
int destz = loc.getBlockZ() >> 4;
|
||||||
if (!dest.getWorld().isChunkLoaded(destx, destz)) {
|
if (!dest.getWorld().isChunkLoaded(destx, destz)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Block b2 = dest.getBlock();
|
Block b2 = dest.getBlock();
|
||||||
|
|
||||||
addItem(hopperBlock, hopper, b2, item, isS, amt, place);
|
addItem(hopperBlock, hopper, b2, item, isS, amt, place);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
try {
|
||||||
ItemStack it = null;
|
ItemStack it = null;
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
it = is.clone();
|
it = is.clone();
|
||||||
it.setAmount(1);
|
it.setAmount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Material> ovoid = new ArrayList<>();
|
List<Material> ovoid = new ArrayList<>();
|
||||||
|
|
||||||
for (ItemStack iss : hopper.getFilter().getVoidList()) {
|
for (ItemStack iss : hopper.getFilter().getVoidList()) {
|
||||||
ovoid.add(iss.getType());
|
ovoid.add(iss.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is.getType() == Material.AIR) {
|
if (is.getType() == Material.AIR) {
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
ItemStack item = is;
|
ItemStack item = is;
|
||||||
ItemStack newItem = is.clone();
|
ItemStack newItem = is.clone();
|
||||||
|
|
||||||
if ((item.getAmount() - amt) <= 0) {
|
if ((item.getAmount() - amt) <= 0) {
|
||||||
amt = item.getAmount();
|
amt = item.getAmount();
|
||||||
}
|
}
|
||||||
if ((item.getAmount() - amt) >= 1) {
|
if ((item.getAmount() - amt) >= 1) {
|
||||||
newItem.setAmount(newItem.getAmount() - amt);
|
newItem.setAmount(newItem.getAmount() - amt);
|
||||||
is = newItem.clone();
|
is = newItem.clone();
|
||||||
} else {
|
} else {
|
||||||
is = null;
|
is = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
newItem.setAmount(amt);
|
newItem.setAmount(amt);
|
||||||
InventoryHolder ih = null;
|
InventoryHolder ih = null;
|
||||||
if (!b2.getType().equals(Material.ENDER_CHEST)) {
|
if (!b2.getType().equals(Material.ENDER_CHEST)) {
|
||||||
ih = (InventoryHolder) b2.getState();
|
ih = (InventoryHolder) b2.getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b2.getType().equals(Material.ENDER_CHEST)) {
|
if (b2.getType().equals(Material.ENDER_CHEST)) {
|
||||||
try {
|
try {
|
||||||
OfflinePlayer op = Bukkit.getOfflinePlayer(UUID.fromString(instance.dataFile.getConfig().getString("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(b2))));
|
OfflinePlayer op = Bukkit.getOfflinePlayer(UUID.fromString(instance.dataFile.getConfig().getString("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(b2))));
|
||||||
if (op.isOnline() && canHop(op.getPlayer().getEnderChest(), newItem, amt)) {
|
if (op.isOnline() && canHop(op.getPlayer().getEnderChest(), newItem, amt)) {
|
||||||
if (!ovoid.contains(it.getType())) {
|
if (!ovoid.contains(it.getType())) {
|
||||||
op.getPlayer().getEnderChest().addItem(newItem);
|
op.getPlayer().getEnderChest().addItem(newItem);
|
||||||
}
|
}
|
||||||
isS[place] = is;
|
isS[place] = is;
|
||||||
hopperBlock.getInventory().setContents(isS);
|
hopperBlock.getInventory().setContents(isS);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!canHop(ih.getInventory(), newItem, amt) || b2.getType() == Material.BREWING_STAND) {
|
if (!canHop(ih.getInventory(), newItem, amt) || b2.getType() == Material.BREWING_STAND) {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
if (b2.getType() == Material.FURNACE) {
|
if (b2.getType() == Material.FURNACE) {
|
||||||
FurnaceInventory fi = (FurnaceInventory) ih.getInventory();
|
FurnaceInventory fi = (FurnaceInventory) ih.getInventory();
|
||||||
int amtt = 0;
|
int amtt = 0;
|
||||||
boolean dont = false;
|
boolean dont = false;
|
||||||
if (fi.getSmelting() != null) {
|
if (fi.getSmelting() != null) {
|
||||||
amtt = fi.getSmelting().getAmount();
|
amtt = fi.getSmelting().getAmount();
|
||||||
if (fi.getSmelting().getType() != newItem.getType()) {
|
if (fi.getSmelting().getType() != newItem.getType()) {
|
||||||
dont = true;
|
dont = true;
|
||||||
} else {
|
} else {
|
||||||
if (fi.getSmelting().getAmount() == fi.getSmelting().getMaxStackSize()) {
|
if (fi.getSmelting().getAmount() == fi.getSmelting().getMaxStackSize()) {
|
||||||
dont = true;
|
dont = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!dont) {
|
if (!dont) {
|
||||||
if (amtt + newItem.getAmount() <= 64) {
|
if (amtt + newItem.getAmount() <= 64) {
|
||||||
if (!ovoid.contains(it.getType())) {
|
if (!ovoid.contains(it.getType())) {
|
||||||
ih.getInventory().addItem(newItem);
|
ih.getInventory().addItem(newItem);
|
||||||
}
|
}
|
||||||
isS[place] = is;
|
isS[place] = is;
|
||||||
hopperBlock.getInventory().setContents(isS);
|
hopperBlock.getInventory().setContents(isS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!ovoid.contains(it.getType())) {
|
if (!ovoid.contains(it.getType())) {
|
||||||
ih.getInventory().addItem(newItem);
|
ih.getInventory().addItem(newItem);
|
||||||
}
|
}
|
||||||
isS[place] = is;
|
isS[place] = is;
|
||||||
hopperBlock.getInventory().setContents(isS);
|
hopperBlock.getInventory().setContents(isS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 4;
|
return 4;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canHop(Inventory i, ItemStack item, int hop) {
|
public boolean canHop(Inventory i, ItemStack item, int hop) {
|
||||||
try {
|
try {
|
||||||
if (i.firstEmpty() != -1) {
|
if (i.firstEmpty() != -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean can = false;
|
boolean can = false;
|
||||||
for (ItemStack it : i.getContents()) {
|
for (ItemStack it : i.getContents()) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
can = true;
|
can = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (it.isSimilar(item)) {
|
if (it.isSimilar(item)) {
|
||||||
if ((it.getAmount() + hop) <= it.getMaxStackSize()) {
|
if ((it.getAmount() + hop) <= it.getMaxStackSize()) {
|
||||||
can = true;
|
can = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return can;
|
return can;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,109 +1,113 @@
|
|||||||
package com.songoda.epichoppers.Handlers;
|
package com.songoda.epichoppers.handlers;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Hopper.Hopper;
|
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.hopper.EHopper;
|
||||||
import com.songoda.epichoppers.Utils.Methods;
|
import com.songoda.epichoppers.player.PlayerData;
|
||||||
import org.bukkit.Bukkit;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Location;
|
import com.songoda.epichoppers.utils.Methods;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import java.util.Date;
|
import org.bukkit.entity.Player;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
public class TeleportHandler {
|
import java.util.Map;
|
||||||
|
|
||||||
//Teleport from - teleport 2
|
public class TeleportHandler {
|
||||||
private final Map<Location, Location> teleportFrom = new HashMap<>();
|
|
||||||
|
//Teleport from - teleport 2
|
||||||
private EpicHoppers instance;
|
private final Map<Location, Location> teleportFrom = new HashMap<>();
|
||||||
|
|
||||||
public TeleportHandler(EpicHoppers instance) {
|
private EpicHoppersPlugin instance;
|
||||||
try {
|
|
||||||
this.instance = instance;
|
public TeleportHandler(EpicHoppersPlugin instance) {
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::teleportRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Teleport"));
|
try {
|
||||||
} catch (Exception e) {
|
this.instance = instance;
|
||||||
Debugger.runReport(e);
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::teleportRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Teleport"));
|
||||||
}
|
} catch (Exception e) {
|
||||||
}
|
Debugger.runReport(e);
|
||||||
|
}
|
||||||
private void teleportRunner() {
|
}
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
if (!instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || !player.hasPermission("EpicHoppers.Teleport")) {
|
private void teleportRunner() {
|
||||||
continue;
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
}
|
if (!instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || !player.hasPermission("EpicHoppers.Teleport")) {
|
||||||
|
continue;
|
||||||
Location location = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation();
|
}
|
||||||
|
|
||||||
if (!instance.getHopperManager().isHopper(location)) {
|
Location location = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation();
|
||||||
continue;
|
|
||||||
}
|
if (!instance.getHopperManager().isHopper(location)) {
|
||||||
|
continue;
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(location);
|
}
|
||||||
|
|
||||||
if (!hopper.isWalkOnTeleport()) continue;
|
Hopper hopper = instance.getHopperManager().getHopper(location);
|
||||||
|
|
||||||
if (instance.lastTp.containsKey(player)) {
|
if (!hopper.isWalkOnTeleport()) continue;
|
||||||
long duration = (new Date()).getTime() - instance.lastTp.get(player).getTime();
|
|
||||||
if (duration <= 5 * 1000) {
|
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||||
continue;
|
|
||||||
}
|
if (playerData.getLastTeleport() != null) {
|
||||||
}
|
long duration = (new Date()).getTime() - playerData.getLastTeleport().getTime();
|
||||||
|
if (duration <= 5 * 1000) {
|
||||||
tpPlayer(player, hopper);
|
continue;
|
||||||
instance.lastTp.put(player, new Date());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
tpPlayer(player, hopper);
|
||||||
public void tpPlayer(Player player, Hopper hopper) {
|
playerData.setLastTeleport(new Date());
|
||||||
try {
|
}
|
||||||
EpicHoppers instance = EpicHoppers.getInstance();
|
}
|
||||||
Block next = hopper.getLocation().getBlock();
|
|
||||||
int num = 1;
|
public void tpPlayer(Player player, Hopper hopper) {
|
||||||
while (instance.getHopperManager().isHopper(next.getLocation()) && instance.getHopperManager().getHopper(next.getLocation()).getSyncedBlock() != null && num != 15) {
|
try {
|
||||||
Hopper nextHopper = instance.getHopperManager().getHopper(next);
|
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||||
if (nextHopper.getSyncedBlock() != null) {
|
Block next = hopper.getLocation().getBlock();
|
||||||
next = nextHopper.getSyncedBlock();
|
int num = 1;
|
||||||
}
|
while (instance.getHopperManager().isHopper(next.getLocation()) && instance.getHopperManager().getHopper(next.getLocation()).getSyncedBlock() != null && num != 15) {
|
||||||
if (!next.getType().equals(Material.HOPPER)) {
|
Hopper nextHopper = instance.getHopperManager().getHopper(next);
|
||||||
instance.getHopperManager().removeHopper(nextHopper.getLocation());
|
if (nextHopper.getSyncedBlock() != null) {
|
||||||
break;
|
next = nextHopper.getSyncedBlock();
|
||||||
}
|
}
|
||||||
|
if (!next.getType().equals(Material.HOPPER)) {
|
||||||
Location location = next.getLocation();
|
instance.getHopperManager().removeHopper(nextHopper.getLocation());
|
||||||
location.setX(location.getX() + 0.5);
|
break;
|
||||||
location.setZ(location.getZ() + 0.5);
|
}
|
||||||
location.setY(location.getY() + 1);
|
|
||||||
location.setPitch(player.getLocation().getPitch());
|
Location location = next.getLocation();
|
||||||
location.setDirection(player.getLocation().getDirection());
|
location.setX(location.getX() + 0.5);
|
||||||
player.teleport(location);
|
location.setZ(location.getZ() + 0.5);
|
||||||
next = player.getLocation().subtract(0, 0.5, 0).getBlock();
|
location.setY(location.getY() + 1);
|
||||||
|
location.setPitch(player.getLocation().getPitch());
|
||||||
num++;
|
location.setDirection(player.getLocation().getDirection());
|
||||||
}
|
player.teleport(location);
|
||||||
if (num == 1 && teleportFrom.containsKey(hopper.getLocation())) {
|
next = player.getLocation().subtract(0, 0.5, 0).getBlock();
|
||||||
Location location = teleportFrom.get(hopper.getLocation());
|
|
||||||
location.setX(location.getX() + 0.5);
|
num++;
|
||||||
location.setZ(location.getZ() + 0.5);
|
}
|
||||||
location.setY(location.getY() + 1);
|
if (num == 1 && teleportFrom.containsKey(hopper.getLocation())) {
|
||||||
location.setPitch(player.getLocation().getPitch());
|
Location location = teleportFrom.get(hopper.getLocation());
|
||||||
location.setDirection(player.getLocation().getDirection());
|
location.setX(location.getX() + 0.5);
|
||||||
player.teleport(location);
|
location.setZ(location.getZ() + 0.5);
|
||||||
next = player.getLocation().subtract(0, 0.5, 0).getBlock();
|
location.setY(location.getY() + 1);
|
||||||
num ++;
|
location.setPitch(player.getLocation().getPitch());
|
||||||
|
location.setDirection(player.getLocation().getDirection());
|
||||||
}
|
player.teleport(location);
|
||||||
if (num != 1) {
|
next = player.getLocation().subtract(0, 0.5, 0).getBlock();
|
||||||
teleportFrom.put(next.getLocation(), hopper.getLocation());
|
num ++;
|
||||||
Methods.doParticles(player, hopper.getLocation());
|
|
||||||
Methods.doParticles(player, next.getLocation());
|
}
|
||||||
}
|
if (num != 1) {
|
||||||
} catch (Exception e) {
|
teleportFrom.put(next.getLocation(), hopper.getLocation());
|
||||||
Debugger.runReport(e);
|
Methods.doParticles(player, hopper.getLocation());
|
||||||
}
|
Methods.doParticles(player, next.getLocation());
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
Debugger.runReport(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,64 +1,64 @@
|
|||||||
package com.songoda.epichoppers.Hooks;
|
package com.songoda.epichoppers.hooks;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class ASkyBlockHook extends Hook {
|
public class ASkyBlockHook extends Hook {
|
||||||
|
|
||||||
private ASkyBlockAPI as;
|
private ASkyBlockAPI as;
|
||||||
|
|
||||||
public ASkyBlockHook() {
|
public ASkyBlockHook() {
|
||||||
super("ASkyblock");
|
super("ASkyblock");
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
as = ASkyBlockAPI.getInstance();
|
as = ASkyBlockAPI.getInstance();
|
||||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||||
plugin.hooks.ASkyBlockHook = this;
|
plugin.hooks.ASkyBlockHook = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild(Player p, Location location) {
|
public boolean canBuild(Player p, Location location) {
|
||||||
try {
|
try {
|
||||||
if (hasBypass(p) || as.getIslandAt(location) == null) return true;
|
if (hasBypass(p) || as.getIslandAt(location) == null) return true;
|
||||||
|
|
||||||
UUID owner = as.getOwner(location);
|
UUID owner = as.getOwner(location);
|
||||||
List<UUID> list = as.getTeamMembers(owner);
|
List<UUID> list = as.getTeamMembers(owner);
|
||||||
Set<Location> list2 = as.getCoopIslands(p);
|
Set<Location> list2 = as.getCoopIslands(p);
|
||||||
|
|
||||||
if (owner == null) return true;
|
if (owner == null) return true;
|
||||||
|
|
||||||
for (UUID uuid : list) {
|
for (UUID uuid : list) {
|
||||||
if (uuid.equals(p.getUniqueId())) {
|
if (uuid.equals(p.getUniqueId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Location loc : list2) {
|
for (Location loc : list2) {
|
||||||
if (as.getIslandAt(location).getOwner().equals(as.getIslandAt(loc).getOwner())) {
|
if (as.getIslandAt(location).getOwner().equals(as.getIslandAt(loc).getOwner())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return owner.equals(p.getUniqueId());
|
return owner.equals(p.getUniqueId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInClaim(String uuid, Location location) {
|
public boolean isInClaim(String uuid, Location location) {
|
||||||
return as.getOwner(location).toString().equals(uuid);
|
return as.getOwner(location).toString().equals(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,56 +1,56 @@
|
|||||||
package com.songoda.epichoppers.Hooks;
|
package com.songoda.epichoppers.hooks;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import me.markeh.factionsframework.entities.FPlayer;
|
import me.markeh.factionsframework.entities.FPlayer;
|
||||||
import me.markeh.factionsframework.entities.FPlayers;
|
import me.markeh.factionsframework.entities.FPlayers;
|
||||||
import me.markeh.factionsframework.entities.Faction;
|
import me.markeh.factionsframework.entities.Faction;
|
||||||
import me.markeh.factionsframework.entities.Factions;
|
import me.markeh.factionsframework.entities.Factions;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class FactionsHook extends Hook {
|
public class FactionsHook extends Hook {
|
||||||
|
|
||||||
public FactionsHook() {
|
public FactionsHook() {
|
||||||
super("Factions");
|
super("Factions");
|
||||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||||
if (isEnabled())
|
if (isEnabled())
|
||||||
plugin.hooks.GriefPreventionHook = this;
|
plugin.hooks.GriefPreventionHook = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild(Player p, Location location) {
|
public boolean canBuild(Player p, Location location) {
|
||||||
try {
|
try {
|
||||||
FPlayer fp = FPlayers.getBySender(p);
|
FPlayer fp = FPlayers.getBySender(p);
|
||||||
|
|
||||||
Faction faction = Factions.getFactionAt(location);
|
Faction faction = Factions.getFactionAt(location);
|
||||||
|
|
||||||
return (fp.getFaction().equals(faction) || faction.isNone());
|
return (fp.getFaction().equals(faction) || faction.isNone());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInClaim(String id, Location location) {
|
public boolean isInClaim(String id, Location location) {
|
||||||
Faction faction = Factions.getFactionAt(location);
|
Faction faction = Factions.getFactionAt(location);
|
||||||
|
|
||||||
return faction.getId().equals(id);
|
return faction.getId().equals(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getClaimId(String name) {
|
public String getClaimId(String name) {
|
||||||
try {
|
try {
|
||||||
Faction faction = Factions.getByName(name, "");
|
Faction faction = Factions.getByName(name, "");
|
||||||
|
|
||||||
return faction.getId();
|
return faction.getId();
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,37 +1,37 @@
|
|||||||
package com.songoda.epichoppers.Hooks;
|
package com.songoda.epichoppers.hooks;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import me.ryanhamshire.GriefPrevention.Claim;
|
import me.ryanhamshire.GriefPrevention.Claim;
|
||||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class GriefPreventionHook extends Hook {
|
public class GriefPreventionHook extends Hook {
|
||||||
|
|
||||||
public GriefPreventionHook() {
|
public GriefPreventionHook() {
|
||||||
super("GriefPrevention");
|
super("GriefPrevention");
|
||||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||||
if (isEnabled())
|
if (isEnabled())
|
||||||
plugin.hooks.GriefPreventionHook = this;
|
plugin.hooks.GriefPreventionHook = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild(Player p, Location location) {
|
public boolean canBuild(Player p, Location location) {
|
||||||
try {
|
try {
|
||||||
if (hasBypass(p))
|
if (hasBypass(p))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null);
|
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null);
|
||||||
return claim != null && claim.allowBuild(p, Material.STONE) == null;
|
return claim != null && claim.allowBuild(p, Material.STONE) == null;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,38 +1,38 @@
|
|||||||
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public abstract class Hook {
|
public abstract class Hook {
|
||||||
|
|
||||||
final String pluginName;
|
final String pluginName;
|
||||||
|
|
||||||
protected Hook(String pluginName) {
|
protected Hook(String pluginName) {
|
||||||
this.pluginName = pluginName;
|
this.pluginName = pluginName;
|
||||||
if (isEnabled())
|
if (isEnabled())
|
||||||
EpicHoppers.getInstance().hooks.hooksFile.getConfig().addDefault("hooks." + pluginName, true);
|
EpicHoppersPlugin.getInstance().hooks.hooksFile.getConfig().addDefault("hooks." + pluginName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isEnabled() {
|
protected boolean isEnabled() {
|
||||||
return (Bukkit.getPluginManager().isPluginEnabled(pluginName)
|
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) {
|
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);
|
public abstract boolean canBuild(Player p, Location location);
|
||||||
|
|
||||||
public boolean isInClaim(String id, Location location) {
|
public boolean isInClaim(String id, Location location) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClaimId(String name) {
|
public String getClaimId(String name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,43 +1,43 @@
|
|||||||
package com.songoda.epichoppers.Hooks;
|
package com.songoda.epichoppers.hooks;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.kingdoms.constants.land.Land;
|
import org.kingdoms.constants.land.Land;
|
||||||
import org.kingdoms.constants.land.SimpleChunkLocation;
|
import org.kingdoms.constants.land.SimpleChunkLocation;
|
||||||
import org.kingdoms.constants.player.OfflineKingdomPlayer;
|
import org.kingdoms.constants.player.OfflineKingdomPlayer;
|
||||||
import org.kingdoms.manager.game.GameManagement;
|
import org.kingdoms.manager.game.GameManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class KingdomsHook extends Hook {
|
public class KingdomsHook extends Hook {
|
||||||
|
|
||||||
public KingdomsHook() {
|
public KingdomsHook() {
|
||||||
super("Kingdoms");
|
super("Kingdoms");
|
||||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||||
if (isEnabled())
|
if (isEnabled())
|
||||||
plugin.hooks.KingdomsHook = this;
|
plugin.hooks.KingdomsHook = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild(Player p, Location location) {
|
public boolean canBuild(Player p, Location location) {
|
||||||
try {
|
try {
|
||||||
if (hasBypass(p)) return true;
|
if (hasBypass(p)) return true;
|
||||||
|
|
||||||
OfflineKingdomPlayer pl = GameManagement.getPlayerManager().getOfflineKingdomPlayer(p);
|
OfflineKingdomPlayer pl = GameManagement.getPlayerManager().getOfflineKingdomPlayer(p);
|
||||||
if (pl.getKingdomPlayer().getKingdom() == null) return true;
|
if (pl.getKingdomPlayer().getKingdom() == null) return true;
|
||||||
|
|
||||||
SimpleChunkLocation chunkLocation = new SimpleChunkLocation(location.getWorld().getName(), location.getChunk().getX(), location.getChunk().getZ());
|
SimpleChunkLocation chunkLocation = new SimpleChunkLocation(location.getWorld().getName(), location.getChunk().getX(), location.getChunk().getZ());
|
||||||
Land land = GameManagement.getLandManager().getOrLoadLand(chunkLocation);
|
Land land = GameManagement.getLandManager().getOrLoadLand(chunkLocation);
|
||||||
String owner = land.getOwner();
|
String owner = land.getOwner();
|
||||||
|
|
||||||
return pl.getKingdomPlayer().getKingdom().getKingdomName().equals(owner) || owner == null;
|
return pl.getKingdomPlayer().getKingdom().getKingdomName().equals(owner) || owner == null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,37 +1,37 @@
|
|||||||
package com.songoda.epichoppers.Hooks;
|
package com.songoda.epichoppers.hooks;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.api.PlotAPI;
|
import com.intellectualcrafters.plot.api.PlotAPI;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class PlotSquaredHook extends Hook {
|
public class PlotSquaredHook extends Hook {
|
||||||
|
|
||||||
private PlotAPI plotAPI;
|
private PlotAPI plotAPI;
|
||||||
|
|
||||||
public PlotSquaredHook() {
|
public PlotSquaredHook() {
|
||||||
super("PlotSquared");
|
super("PlotSquared");
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||||
plugin.hooks.PlotSquaredHook = this;
|
plugin.hooks.PlotSquaredHook = this;
|
||||||
this.plotAPI = new PlotAPI();
|
this.plotAPI = new PlotAPI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild(Player p, Location location) {
|
public boolean canBuild(Player p, Location location) {
|
||||||
try {
|
try {
|
||||||
return hasBypass(p)
|
return hasBypass(p)
|
||||||
|| (plotAPI.getPlot(location) != null
|
|| (plotAPI.getPlot(location) != null
|
||||||
&& plotAPI.isInPlot(p)
|
&& plotAPI.isInPlot(p)
|
||||||
&& plotAPI.getPlot(p) == plotAPI.getPlot(location));
|
&& plotAPI.getPlot(p) == plotAPI.getPlot(location));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,33 +1,33 @@
|
|||||||
package com.songoda.epichoppers.Hooks;
|
package com.songoda.epichoppers.hooks;
|
||||||
|
|
||||||
import br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI;
|
import br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI;
|
||||||
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
|
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class RedProtectHook extends Hook {
|
public class RedProtectHook extends Hook {
|
||||||
|
|
||||||
public RedProtectHook() {
|
public RedProtectHook() {
|
||||||
super("RedProtect");
|
super("RedProtect");
|
||||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||||
if (isEnabled())
|
if (isEnabled())
|
||||||
plugin.hooks.RedProtectHook = this;
|
plugin.hooks.RedProtectHook = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild(Player p, Location location) {
|
public boolean canBuild(Player p, Location location) {
|
||||||
try {
|
try {
|
||||||
RedProtectAPI rpAPI = RedProtect.get().getAPI();
|
RedProtectAPI rpAPI = RedProtect.get().getAPI();
|
||||||
return hasBypass(p) || (rpAPI.getRegion(location) != null && rpAPI.getRegion(location).canBuild(p));
|
return hasBypass(p) || (rpAPI.getRegion(location) != null && rpAPI.getRegion(location).canBuild(p));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,56 +1,56 @@
|
|||||||
package com.songoda.epichoppers.Hooks;
|
package com.songoda.epichoppers.hooks;
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class TownyHook extends Hook {
|
public class TownyHook extends Hook {
|
||||||
|
|
||||||
public TownyHook() {
|
public TownyHook() {
|
||||||
super("Towny");
|
super("Towny");
|
||||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||||
if (isEnabled())
|
if (isEnabled())
|
||||||
plugin.hooks.TownyHook = this;
|
plugin.hooks.TownyHook = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild(Player p, Location location) {
|
public boolean canBuild(Player p, Location location) {
|
||||||
try {
|
try {
|
||||||
if (hasBypass(p) || TownyUniverse.isWilderness(location.getBlock())) return true;
|
if (hasBypass(p) || TownyUniverse.isWilderness(location.getBlock())) return true;
|
||||||
if (!TownyUniverse.getTownBlock(location).hasTown()) return true;
|
if (!TownyUniverse.getTownBlock(location).hasTown()) return true;
|
||||||
|
|
||||||
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
||||||
return r.hasTown() && TownyUniverse.getTownName(location).equals(r.getTown().getName());
|
return r.hasTown() && TownyUniverse.getTownName(location).equals(r.getTown().getName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInClaim(String id, Location location) {
|
public boolean isInClaim(String id, Location location) {
|
||||||
try {
|
try {
|
||||||
return !TownyUniverse.isWilderness(location.getBlock())
|
return !TownyUniverse.isWilderness(location.getBlock())
|
||||||
&& TownyUniverse.getTownBlock(location).getTown().getUID() == Integer.parseInt(id);
|
&& TownyUniverse.getTownBlock(location).getTown().getUID() == Integer.parseInt(id);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getClaimId(String name) {
|
public String getClaimId(String name) {
|
||||||
try {
|
try {
|
||||||
return TownyUniverse.getDataSource().getTown(name).getUID().toString();
|
return TownyUniverse.getDataSource().getTown(name).getUID().toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,49 +1,49 @@
|
|||||||
package com.songoda.epichoppers.Hooks;
|
package com.songoda.epichoppers.hooks;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
|
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class USkyBlockHook extends Hook {
|
public class USkyBlockHook extends Hook {
|
||||||
|
|
||||||
private uSkyBlockAPI usb;
|
private uSkyBlockAPI usb;
|
||||||
|
|
||||||
public USkyBlockHook() {
|
public USkyBlockHook() {
|
||||||
super("USkyBlock");
|
super("USkyBlock");
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||||
plugin.hooks.USkyBlockHook = this;
|
plugin.hooks.USkyBlockHook = this;
|
||||||
this.usb = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin(pluginName);
|
this.usb = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin(pluginName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild(Player p, Location location) {
|
public boolean canBuild(Player p, Location location) {
|
||||||
try {
|
try {
|
||||||
if (hasBypass(p)) return true;
|
if (hasBypass(p)) return true;
|
||||||
|
|
||||||
for (Player pl : usb.getIslandInfo(location).getOnlineMembers()) {
|
for (Player pl : usb.getIslandInfo(location).getOnlineMembers()) {
|
||||||
if (pl.equals(p)) {
|
if (pl.equals(p)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return usb.getIslandInfo(location).isLeader(p);
|
return usb.getIslandInfo(location).isLeader(p);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInClaim(String uuid, Location location) {
|
public boolean isInClaim(String uuid, Location location) {
|
||||||
return usb.getIslandInfo(location).getLeader().equals(uuid);
|
return usb.getIslandInfo(location).getLeader().equals(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,31 +1,31 @@
|
|||||||
package com.songoda.epichoppers.Hooks;
|
package com.songoda.epichoppers.hooks;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Utils.Debugger;
|
import com.songoda.epichoppers.utils.Debugger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by songoda on 3/17/2017.
|
* Created by songoda on 3/17/2017.
|
||||||
*/
|
*/
|
||||||
public class WorldGuardHook extends Hook {
|
public class WorldGuardHook extends Hook {
|
||||||
|
|
||||||
private EpicHoppers plugin = EpicHoppers.getInstance();
|
private EpicHoppersPlugin plugin = EpicHoppersPlugin.getInstance();
|
||||||
|
|
||||||
public WorldGuardHook() {
|
public WorldGuardHook() {
|
||||||
super("WorldGuard");
|
super("WorldGuard");
|
||||||
if (isEnabled())
|
if (isEnabled())
|
||||||
plugin.hooks.WorldGuardHook = this;
|
plugin.hooks.WorldGuardHook = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBuild(Player p, Location location) {
|
public boolean canBuild(Player p, Location location) {
|
||||||
try {
|
try {
|
||||||
return p.hasPermission(plugin.getDescription().getName() + ".bypass") || WorldGuardPlugin.inst().canBuild(p, location);
|
return p.hasPermission(plugin.getDescription().getName() + ".bypass") || WorldGuardPlugin.inst().canBuild(p, location);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,51 +1,60 @@
|
|||||||
package com.songoda.epichoppers.Hopper;
|
package com.songoda.epichoppers.hopper;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import com.songoda.epichoppers.api.hopper.Filter;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
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<>();
|
private List<ItemStack> whiteList = new ArrayList<>();
|
||||||
private List<ItemStack> voidList = new ArrayList<>();
|
private List<ItemStack> blackList = new ArrayList<>();
|
||||||
|
private List<ItemStack> voidList = new ArrayList<>();
|
||||||
private Block endPoint;
|
|
||||||
|
private Block endPoint;
|
||||||
public List<ItemStack> getWhiteList() {
|
|
||||||
if (whiteList == null) return new ArrayList<>();
|
@Override
|
||||||
return whiteList;
|
public List<ItemStack> getWhiteList() {
|
||||||
}
|
if (whiteList == null) return new ArrayList<>();
|
||||||
|
return whiteList;
|
||||||
public void setWhiteList(List<ItemStack> whiteList) {
|
}
|
||||||
this.whiteList = whiteList;
|
|
||||||
}
|
@Override
|
||||||
|
public void setWhiteList(List<ItemStack> whiteList) {
|
||||||
public List<ItemStack> getBlackList() {
|
this.whiteList = whiteList;
|
||||||
if (blackList == null) return new ArrayList<>();
|
}
|
||||||
return blackList;
|
|
||||||
}
|
@Override
|
||||||
|
public List<ItemStack> getBlackList() {
|
||||||
public void setBlackList(List<ItemStack> blackList) {
|
if (blackList == null) return new ArrayList<>();
|
||||||
this.blackList = blackList;
|
return blackList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ItemStack> getVoidList() {
|
@Override
|
||||||
if (voidList == null) return new ArrayList<>();
|
public void setBlackList(List<ItemStack> blackList) {
|
||||||
return voidList;
|
this.blackList = blackList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVoidList(List<ItemStack> voidList) {
|
@Override
|
||||||
this.voidList = voidList;
|
public List<ItemStack> getVoidList() {
|
||||||
}
|
if (voidList == null) return new ArrayList<>();
|
||||||
|
return voidList;
|
||||||
public Block getEndPoint() {
|
}
|
||||||
return endPoint;
|
|
||||||
}
|
@Override
|
||||||
|
public void setVoidList(List<ItemStack> voidList) {
|
||||||
public void setEndPoint(Block endPoint) {
|
this.voidList = voidList;
|
||||||
this.endPoint = endPoint;
|
}
|
||||||
}
|
|
||||||
}
|
@Override
|
||||||
|
public Block getEndPoint() {
|
||||||
|
return endPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEndPoint(Block endPoint) {
|
||||||
|
this.endPoint = endPoint;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,49 +1,58 @@
|
|||||||
package com.songoda.epichoppers.Hopper;
|
package com.songoda.epichoppers.hopper;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import org.bukkit.Location;
|
import com.songoda.epichoppers.api.hopper.Filter;
|
||||||
import org.bukkit.block.Block;
|
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||||
|
import com.songoda.epichoppers.api.hopper.HopperManager;
|
||||||
import java.util.Collections;
|
import org.bukkit.Location;
|
||||||
import java.util.HashMap;
|
import org.bukkit.block.Block;
|
||||||
import java.util.Map;
|
|
||||||
|
import java.util.Collections;
|
||||||
public class HopperManager {
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
private final Map<Location, Hopper> registeredHoppers = new HashMap<>();
|
|
||||||
|
public class EHopperManager implements HopperManager {
|
||||||
public void addHopper(Location location, Hopper hopper) {
|
|
||||||
registeredHoppers.put(roundLocation(location), hopper);
|
private final Map<Location, Hopper> registeredHoppers = new HashMap<>();
|
||||||
}
|
|
||||||
|
@Override
|
||||||
public Hopper removeHopper(Location location) {
|
public void addHopper(Location location, Hopper hopper) {
|
||||||
return registeredHoppers.remove(location);
|
registeredHoppers.put(roundLocation(location), hopper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hopper getHopper(Location location) {
|
@Override
|
||||||
if (!registeredHoppers.containsKey(roundLocation(location))) {
|
public Hopper removeHopper(Location location) {
|
||||||
addHopper(location, new Hopper(location, EpicHoppers.getInstance().getLevelManager().getLowestLevel(), null, null, new Filter(), false));
|
return registeredHoppers.remove(location);
|
||||||
}
|
}
|
||||||
return registeredHoppers.get(roundLocation(location));
|
|
||||||
}
|
@Override
|
||||||
|
public Hopper getHopper(Location location) {
|
||||||
public Hopper getHopper(Block block) {
|
if (!registeredHoppers.containsKey(roundLocation(location))) {
|
||||||
return getHopper(block.getLocation());
|
addHopper(location, new EHopper(location, EpicHoppersPlugin.getInstance().getLevelManager().getLowestLevel(), null, null, new EFilter(), false));
|
||||||
}
|
}
|
||||||
|
return registeredHoppers.get(roundLocation(location));
|
||||||
public boolean isHopper(Location location) {
|
}
|
||||||
return registeredHoppers.containsKey(roundLocation(location));
|
|
||||||
}
|
@Override
|
||||||
|
public Hopper getHopper(Block block) {
|
||||||
public Map<Location, Hopper> getHoppers() {
|
return getHopper(block.getLocation());
|
||||||
return Collections.unmodifiableMap(registeredHoppers);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
private Location roundLocation(Location location) {
|
public boolean isHopper(Location location) {
|
||||||
location = location.clone();
|
return registeredHoppers.containsKey(roundLocation(location));
|
||||||
location.setX(location.getBlockX());
|
}
|
||||||
location.setY(location.getBlockY());
|
|
||||||
location.setZ(location.getBlockZ());
|
@Override
|
||||||
return location;
|
public Map<Location, Hopper> getHoppers() {
|
||||||
}
|
return Collections.unmodifiableMap(registeredHoppers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Location roundLocation(Location location) {
|
||||||
|
location = location.clone();
|
||||||
|
location.setX(location.getBlockX());
|
||||||
|
location.setY(location.getBlockY());
|
||||||
|
location.setZ(location.getBlockZ());
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
}
|
@ -1,63 +1,72 @@
|
|||||||
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;
|
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 int level, costExperience, costEconomy, range, amount, blockBreak, suction;
|
||||||
private List<String> description = new ArrayList<>();
|
|
||||||
|
private List<String> description = new ArrayList<>();
|
||||||
public Level(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
|
||||||
this.level = level;
|
public ELevel(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||||
this.costExperience = costExperience;
|
this.level = level;
|
||||||
this.costEconomy = costEconomy;
|
this.costExperience = costExperience;
|
||||||
this.range = range;
|
this.costEconomy = costEconomy;
|
||||||
this.amount = amount;
|
this.range = range;
|
||||||
this.blockBreak = blockBreak;
|
this.amount = amount;
|
||||||
this.suction = suction;
|
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));
|
description.add(instance.getLocale().getMessage("interface.hopper.range", range));
|
||||||
if (suction != 0) description.add(instance.getLocale().getMessage("interface.hopper.suction", suction));
|
description.add(instance.getLocale().getMessage("interface.hopper.amount", amount));
|
||||||
if (blockBreak != 0) description.add(instance.getLocale().getMessage("interface.hopper.blockbreak", blockBreak));
|
if (suction != 0) description.add(instance.getLocale().getMessage("interface.hopper.suction", suction));
|
||||||
}
|
if (blockBreak != 0) description.add(instance.getLocale().getMessage("interface.hopper.blockbreak", blockBreak));
|
||||||
|
}
|
||||||
public List<String> getDescription() {
|
|
||||||
return new ArrayList<>(description);
|
@Override
|
||||||
}
|
public List<String> getDescription() {
|
||||||
|
return new ArrayList<>(description);
|
||||||
public int getLevel() {
|
}
|
||||||
return level;
|
|
||||||
}
|
@Override
|
||||||
|
public int getLevel() {
|
||||||
public int getRange() {
|
return level;
|
||||||
return range;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
public int getAmount() {
|
public int getRange() {
|
||||||
return amount;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBlockBreak() {
|
@Override
|
||||||
return blockBreak;
|
public int getAmount() {
|
||||||
}
|
return amount;
|
||||||
|
}
|
||||||
public int getSuction() {
|
|
||||||
return suction;
|
@Override
|
||||||
}
|
public int getBlockBreak() {
|
||||||
|
return blockBreak;
|
||||||
public int getCostExperience() {
|
}
|
||||||
return costExperience;
|
|
||||||
}
|
@Override
|
||||||
|
public int getSuction() {
|
||||||
public int getCostEconomy() {
|
return suction;
|
||||||
return costEconomy;
|
}
|
||||||
}
|
|
||||||
}
|
@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,31 +1,31 @@
|
|||||||
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.
|
* Created by songoda on 3/21/2017.
|
||||||
*/
|
*/
|
||||||
public class Debugger {
|
public class Debugger {
|
||||||
|
|
||||||
|
|
||||||
public static void runReport(Exception e) {
|
public static void runReport(Exception e) {
|
||||||
if (isDebug()) {
|
if (isDebug()) {
|
||||||
System.out.println("==============================================================");
|
System.out.println("==============================================================");
|
||||||
System.out.println("The following is an error encountered in EpicHoppers.");
|
System.out.println("The following is an error encountered in EpicHoppers.");
|
||||||
System.out.println("--------------------------------------------------------------");
|
System.out.println("--------------------------------------------------------------");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("==============================================================");
|
System.out.println("==============================================================");
|
||||||
}
|
}
|
||||||
sendReport(e);
|
sendReport(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendReport(Exception e) {
|
public static void sendReport(Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDebug() {
|
public static boolean isDebug() {
|
||||||
EpicHoppers instance = EpicHoppers.getInstance();
|
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||||
return instance.getConfig().getBoolean("System.Debugger Enabled");
|
return instance.getConfig().getBoolean("System.Debugger Enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,92 +1,83 @@
|
|||||||
package com.songoda.epichoppers.Utils;
|
package com.songoda.epichoppers.utils;
|
||||||
|
|
||||||
import com.songoda.arconix.plugin.Arconix;
|
import com.songoda.arconix.plugin.Arconix;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.Hopper.Hopper;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.World;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Entity;
|
/**
|
||||||
import org.bukkit.entity.Player;
|
* Created by songoda on 2/24/2017.
|
||||||
import org.bukkit.inventory.ItemStack;
|
*/
|
||||||
|
public class Methods {
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
public static boolean isSync(Player p) {
|
||||||
import java.util.Collections;
|
try {
|
||||||
import java.util.List;
|
if (p.getItemInHand().hasItemMeta()
|
||||||
|
&& p.getItemInHand().getType() != Material.AIR
|
||||||
/**
|
&& p.getItemInHand().getItemMeta().hasLore()) {
|
||||||
* Created by songoda on 2/24/2017.
|
for (String str : p.getItemInHand().getItemMeta().getLore()) {
|
||||||
*/
|
if (str.equals(Arconix.pl().getApi().format().formatText("&7Sync Touch")) || str.equals(Arconix.pl().getApi().format().formatText("&aSync Touch"))) {
|
||||||
public class Methods {
|
return true;
|
||||||
|
}
|
||||||
public static boolean isSync(Player p) {
|
}
|
||||||
try {
|
}
|
||||||
if (p.getItemInHand().hasItemMeta()
|
} catch (Exception e) {
|
||||||
&& p.getItemInHand().getType() != Material.AIR
|
Debugger.runReport(e);
|
||||||
&& p.getItemInHand().getItemMeta().hasLore()) {
|
}
|
||||||
for (String str : p.getItemInHand().getItemMeta().getLore()) {
|
return false;
|
||||||
if (str.equals(Arconix.pl().getApi().format().formatText("&7Sync Touch")) || str.equals(Arconix.pl().getApi().format().formatText("&aSync Touch"))) {
|
}
|
||||||
return true;
|
|
||||||
}
|
public static ItemStack getGlass() {
|
||||||
}
|
try {
|
||||||
}
|
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||||
} catch (Exception e) {
|
return Arconix.pl().getApi().getGUI().getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
|
||||||
Debugger.runReport(e);
|
} catch (Exception e) {
|
||||||
}
|
Debugger.runReport(e);
|
||||||
return false;
|
}
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
public static ItemStack getGlass() {
|
|
||||||
try {
|
public static ItemStack getBackgroundGlass(boolean type) {
|
||||||
EpicHoppers instance = EpicHoppers.getInstance();
|
try {
|
||||||
return Arconix.pl().getApi().getGUI().getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
|
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||||
} catch (Exception e) {
|
if (type)
|
||||||
Debugger.runReport(e);
|
return Arconix.pl().getApi().getGUI().getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
|
||||||
}
|
else
|
||||||
return null;
|
return Arconix.pl().getApi().getGUI().getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 3"));
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
Debugger.runReport(e);
|
||||||
public static ItemStack getBackgroundGlass(boolean type) {
|
}
|
||||||
try {
|
return null;
|
||||||
EpicHoppers instance = EpicHoppers.getInstance();
|
}
|
||||||
if (type)
|
|
||||||
return Arconix.pl().getApi().getGUI().getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
|
public static String formatName(int level, boolean full) {
|
||||||
else
|
try {
|
||||||
return Arconix.pl().getApi().getGUI().getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 3"));
|
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||||
} catch (Exception e) {
|
String name = instance.getLocale().getMessage("general.nametag.nameformat", level);
|
||||||
Debugger.runReport(e);
|
|
||||||
}
|
String info = "";
|
||||||
return null;
|
if (full) {
|
||||||
}
|
info += Arconix.pl().getApi().format().convertToInvisibleString(level + ":");
|
||||||
|
}
|
||||||
public static String formatName(int level, boolean full) {
|
|
||||||
try {
|
return info + Arconix.pl().getApi().format().formatText(name);
|
||||||
EpicHoppers instance = EpicHoppers.getInstance();
|
} catch (Exception e) {
|
||||||
String name = instance.getLocale().getMessage("general.nametag.nameformat", level);
|
Debugger.runReport(e);
|
||||||
|
}
|
||||||
String info = "";
|
return null;
|
||||||
if (full) {
|
}
|
||||||
info += Arconix.pl().getApi().format().convertToInvisibleString(level + ":");
|
|
||||||
}
|
public static void doParticles(Player p, Location location) {
|
||||||
|
try {
|
||||||
return info + Arconix.pl().getApi().format().formatText(name);
|
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||||
} catch (Exception e) {
|
location.setX(location.getX() + .5);
|
||||||
Debugger.runReport(e);
|
location.setY(location.getY() + .5);
|
||||||
}
|
location.setZ(location.getZ() + .5);
|
||||||
return null;
|
p.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), location, 200, .5, .5, .5);
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
Debugger.runReport(e);
|
||||||
public static void doParticles(Player p, Location location) {
|
}
|
||||||
try {
|
}
|
||||||
EpicHoppers instance = EpicHoppers.getInstance();
|
}
|
||||||
location.setX(location.getX() + .5);
|
|
||||||
location.setY(location.getY() + .5);
|
|
||||||
location.setZ(location.getZ() + .5);
|
|
||||||
p.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), location, 200, .5, .5, .5);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Debugger.runReport(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,239 +1,238 @@
|
|||||||
package com.songoda.epichoppers.Utils;
|
package com.songoda.epichoppers.utils;
|
||||||
|
|
||||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||||
import com.songoda.arconix.plugin.Arconix;
|
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
import java.util.*;
|
||||||
import java.util.*;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
/**
|
||||||
/**
|
* Created by songo on 6/4/2017.
|
||||||
* Created by songo on 6/4/2017.
|
*/
|
||||||
*/
|
public class SettingsManager implements Listener {
|
||||||
public class SettingsManager implements Listener {
|
|
||||||
|
private String pluginName = "EpicHoppers";
|
||||||
private String pluginName = "EpicHoppers";
|
|
||||||
|
private static final Pattern SETTINGS_PATTERN = Pattern.compile("(.{1,28}(?:\\s|$))|(.{0,28})", Pattern.DOTALL);
|
||||||
private static final Pattern SETTINGS_PATTERN = Pattern.compile("(.{1,28}(?:\\s|$))|(.{0,28})", Pattern.DOTALL);
|
|
||||||
|
private static ConfigWrapper defs;
|
||||||
private static ConfigWrapper defs;
|
|
||||||
|
private Map<Player, String> cat = new HashMap<>();
|
||||||
private Map<Player, String> cat = new HashMap<>();
|
|
||||||
|
private final EpicHoppersPlugin instance;
|
||||||
private final EpicHoppers instance;
|
|
||||||
|
public SettingsManager(EpicHoppersPlugin plugin) {
|
||||||
public SettingsManager(EpicHoppers plugin) {
|
this.instance = plugin;
|
||||||
this.instance = plugin;
|
|
||||||
|
plugin.saveResource("SettingDefinitions.yml", true);
|
||||||
plugin.saveResource("SettingDefinitions.yml", true);
|
defs = new ConfigWrapper(plugin, "", "SettingDefinitions.yml");
|
||||||
defs = new ConfigWrapper(plugin, "", "SettingDefinitions.yml");
|
defs.createNewFile("Loading data file", pluginName + " SettingDefinitions file");
|
||||||
defs.createNewFile("Loading data file", pluginName + " SettingDefinitions file");
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
}
|
||||||
}
|
|
||||||
|
private Map<Player, String> current = new HashMap<>();
|
||||||
private Map<Player, String> current = new HashMap<>();
|
|
||||||
|
@EventHandler
|
||||||
@EventHandler
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
ItemStack clickedItem = event.getCurrentItem();
|
||||||
ItemStack clickedItem = event.getCurrentItem();
|
|
||||||
|
if (event.getInventory() != event.getWhoClicked().getOpenInventory().getTopInventory()
|
||||||
if (event.getInventory() != event.getWhoClicked().getOpenInventory().getTopInventory()
|
|| clickedItem == null || !clickedItem.hasItemMeta()
|
||||||
|| clickedItem == null || !clickedItem.hasItemMeta()
|
|| !clickedItem.getItemMeta().hasDisplayName()) {
|
||||||
|| !clickedItem.getItemMeta().hasDisplayName()) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
if (event.getInventory().getTitle().equals(pluginName + " Settings Manager")) {
|
||||||
if (event.getInventory().getTitle().equals(pluginName + " Settings Manager")) {
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
if (clickedItem.getType().name().contains("STAINED_GLASS")) return;
|
||||||
if (clickedItem.getType().name().contains("STAINED_GLASS")) return;
|
|
||||||
|
String type = ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName());
|
||||||
String type = ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName());
|
this.cat.put((Player) event.getWhoClicked(), type);
|
||||||
this.cat.put((Player) event.getWhoClicked(), type);
|
this.openEditor((Player) event.getWhoClicked());
|
||||||
this.openEditor((Player) event.getWhoClicked());
|
} else if (event.getInventory().getTitle().equals(pluginName + " Settings Editor")) {
|
||||||
} else if (event.getInventory().getTitle().equals(pluginName + " Settings Editor")) {
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
if (clickedItem.getType().name().contains("STAINED_GLASS")) return;
|
||||||
if (clickedItem.getType().name().contains("STAINED_GLASS")) return;
|
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
Player player = (Player) event.getWhoClicked();
|
|
||||||
|
String key = cat.get(player) + "." + ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName());
|
||||||
String key = cat.get(player) + "." + ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName());
|
|
||||||
|
if (instance.getConfig().get(key).getClass().getName().equals("java.lang.Boolean")) {
|
||||||
if (instance.getConfig().get(key).getClass().getName().equals("java.lang.Boolean")) {
|
this.instance.getConfig().set(key, !instance.getConfig().getBoolean(key));
|
||||||
this.instance.getConfig().set(key, !instance.getConfig().getBoolean(key));
|
this.finishEditing(player);
|
||||||
this.finishEditing(player);
|
} else {
|
||||||
} else {
|
this.editObject(player, key);
|
||||||
this.editObject(player, key);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@EventHandler
|
||||||
@EventHandler
|
public void onChat(AsyncPlayerChatEvent event) {
|
||||||
public void onChat(AsyncPlayerChatEvent event) {
|
Player player = event.getPlayer();
|
||||||
Player player = event.getPlayer();
|
if (!current.containsKey(player)) return;
|
||||||
if (!current.containsKey(player)) return;
|
|
||||||
|
String value = current.get(player);
|
||||||
String value = current.get(player);
|
FileConfiguration config = instance.getConfig();
|
||||||
FileConfiguration config = instance.getConfig();
|
if (config.isInt(value)) {
|
||||||
if (config.isInt(value)) {
|
config.set(value, Integer.parseInt(event.getMessage()));
|
||||||
config.set(value, Integer.parseInt(event.getMessage()));
|
} else if (config.isDouble(value)) {
|
||||||
} else if (config.isDouble(value)) {
|
config.set(value, Double.parseDouble(event.getMessage()));
|
||||||
config.set(value, Double.parseDouble(event.getMessage()));
|
} else if (config.isString(value)) {
|
||||||
} else if (config.isString(value)) {
|
config.set(value, event.getMessage());
|
||||||
config.set(value, event.getMessage());
|
}
|
||||||
}
|
|
||||||
|
this.finishEditing(player);
|
||||||
this.finishEditing(player);
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
}
|
||||||
}
|
|
||||||
|
public void finishEditing(Player player) {
|
||||||
public void finishEditing(Player player) {
|
this.current.remove(player);
|
||||||
this.current.remove(player);
|
this.instance.saveConfig();
|
||||||
this.instance.saveConfig();
|
this.openEditor(player);
|
||||||
this.openEditor(player);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public void editObject(Player player, String current) {
|
||||||
public void editObject(Player player, String current) {
|
this.current.put(player, ChatColor.stripColor(current));
|
||||||
this.current.put(player, ChatColor.stripColor(current));
|
|
||||||
|
player.closeInventory();
|
||||||
player.closeInventory();
|
player.sendMessage("");
|
||||||
player.sendMessage("");
|
player.sendMessage(TextComponent.formatText("&7Please enter a value for &6" + current + "&7."));
|
||||||
player.sendMessage(TextComponent.formatText("&7Please enter a value for &6" + current + "&7."));
|
if (instance.getConfig().isInt(current) || instance.getConfig().isDouble(current)) {
|
||||||
if (instance.getConfig().isInt(current) || instance.getConfig().isDouble(current)) {
|
player.sendMessage(TextComponent.formatText("&cUse only numbers."));
|
||||||
player.sendMessage(TextComponent.formatText("&cUse only numbers."));
|
}
|
||||||
}
|
player.sendMessage("");
|
||||||
player.sendMessage("");
|
}
|
||||||
}
|
|
||||||
|
public void openSettingsManager(Player player) {
|
||||||
public void openSettingsManager(Player player) {
|
Inventory inventory = Bukkit.createInventory(null, 27, pluginName + " Settings Manager");
|
||||||
Inventory inventory = Bukkit.createInventory(null, 27, pluginName + " Settings Manager");
|
ItemStack glass = Methods.getGlass();
|
||||||
ItemStack glass = Methods.getGlass();
|
for (int i = 0; i < inventory.getSize(); i++) {
|
||||||
for (int i = 0; i < inventory.getSize(); i++) {
|
inventory.setItem(i, glass);
|
||||||
inventory.setItem(i, glass);
|
}
|
||||||
}
|
|
||||||
|
int slot = 10;
|
||||||
int slot = 10;
|
for (String key : instance.getConfig().getDefaultSection().getKeys(false)) {
|
||||||
for (String key : instance.getConfig().getDefaultSection().getKeys(false)) {
|
ItemStack item = new ItemStack(Material.WHITE_WOOL, 1, (byte) (slot - 9)); //ToDo: Make this function as it was meant to.
|
||||||
ItemStack item = new ItemStack(Material.WHITE_WOOL, 1, (byte) (slot - 9)); //ToDo: Make this function as it was meant to.
|
ItemMeta meta = item.getItemMeta();
|
||||||
ItemMeta meta = item.getItemMeta();
|
meta.setLore(Collections.singletonList(TextComponent.formatText("&6Click To Edit This Category.")));
|
||||||
meta.setLore(Collections.singletonList(TextComponent.formatText("&6Click To Edit This Category.")));
|
meta.setDisplayName(TextComponent.formatText("&f&l" + key));
|
||||||
meta.setDisplayName(TextComponent.formatText("&f&l" + key));
|
item.setItemMeta(meta);
|
||||||
item.setItemMeta(meta);
|
inventory.setItem(slot, item);
|
||||||
inventory.setItem(slot, item);
|
slot++;
|
||||||
slot++;
|
}
|
||||||
}
|
|
||||||
|
player.openInventory(inventory);
|
||||||
player.openInventory(inventory);
|
}
|
||||||
}
|
|
||||||
|
public void openEditor(Player player) {
|
||||||
public void openEditor(Player player) {
|
Inventory inventory = Bukkit.createInventory(null, 54, pluginName + " Settings Editor");
|
||||||
Inventory inventory = Bukkit.createInventory(null, 54, pluginName + " Settings Editor");
|
FileConfiguration config = instance.getConfig();
|
||||||
FileConfiguration config = instance.getConfig();
|
|
||||||
|
int slot = 0;
|
||||||
int slot = 0;
|
for (String key : config.getConfigurationSection(cat.get(player)).getKeys(true)) {
|
||||||
for (String key : config.getConfigurationSection(cat.get(player)).getKeys(true)) {
|
String fKey = cat.get(player) + "." + key;
|
||||||
String fKey = cat.get(player) + "." + key;
|
ItemStack item = new ItemStack(Material.DIAMOND_HELMET);
|
||||||
ItemStack item = new ItemStack(Material.DIAMOND_HELMET);
|
ItemMeta meta = item.getItemMeta();
|
||||||
ItemMeta meta = item.getItemMeta();
|
meta.setDisplayName(TextComponent.formatText("&6" + key));
|
||||||
meta.setDisplayName(TextComponent.formatText("&6" + key));
|
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
List<String> lore = new ArrayList<>();
|
if (config.isBoolean(fKey)) {
|
||||||
if (config.isBoolean(fKey)) {
|
item.setType(Material.LEVER);
|
||||||
item.setType(Material.LEVER);
|
lore.add(TextComponent.formatText(config.getBoolean(fKey) ? "&atrue" : "&cfalse"));
|
||||||
lore.add(TextComponent.formatText(config.getBoolean(fKey) ? "&atrue" : "&cfalse"));
|
} else if (config.isString(fKey)) {
|
||||||
} else if (config.isString(fKey)) {
|
item.setType(Material.PAPER);
|
||||||
item.setType(Material.PAPER);
|
lore.add(TextComponent.formatText("&9" + config.getString(fKey)));
|
||||||
lore.add(TextComponent.formatText("&9" + config.getString(fKey)));
|
} else if (config.isInt(fKey)) {
|
||||||
} else if (config.isInt(fKey)) {
|
item.setType(Material.CLOCK);
|
||||||
item.setType(Material.CLOCK);
|
lore.add(TextComponent.formatText("&5" + config.getInt(fKey)));
|
||||||
lore.add(TextComponent.formatText("&5" + config.getInt(fKey)));
|
}
|
||||||
}
|
|
||||||
|
if (defs.getConfig().contains(fKey)) {
|
||||||
if (defs.getConfig().contains(fKey)) {
|
String text = defs.getConfig().getString(key);
|
||||||
String text = defs.getConfig().getString(key);
|
|
||||||
|
Matcher m = SETTINGS_PATTERN.matcher(text);
|
||||||
Matcher m = SETTINGS_PATTERN.matcher(text);
|
while (m.find()) {
|
||||||
while (m.find()) {
|
if (m.end() != text.length() || m.group().length() != 0)
|
||||||
if (m.end() != text.length() || m.group().length() != 0)
|
lore.add(TextComponent.formatText("&7" + m.group()));
|
||||||
lore.add(TextComponent.formatText("&7" + m.group()));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
meta.setLore(lore);
|
||||||
meta.setLore(lore);
|
item.setItemMeta(meta);
|
||||||
item.setItemMeta(meta);
|
|
||||||
|
inventory.setItem(slot, item);
|
||||||
inventory.setItem(slot, item);
|
slot++;
|
||||||
slot++;
|
}
|
||||||
}
|
|
||||||
|
player.openInventory(inventory);
|
||||||
player.openInventory(inventory);
|
}
|
||||||
}
|
|
||||||
|
public void updateSettings() {
|
||||||
public void updateSettings() {
|
FileConfiguration config = instance.getConfig();
|
||||||
FileConfiguration config = instance.getConfig();
|
|
||||||
|
for (Setting setting : Setting.values()) {
|
||||||
for (Setting setting : Setting.values()) {
|
if (config.contains("settings." + setting.oldSetting)) {
|
||||||
if (config.contains("settings." + setting.oldSetting)) {
|
config.addDefault(setting.setting, instance.getConfig().get("settings." + setting.oldSetting));
|
||||||
config.addDefault(setting.setting, instance.getConfig().get("settings." + setting.oldSetting));
|
config.set("settings." + setting.oldSetting, null);
|
||||||
config.set("settings." + setting.oldSetting, null);
|
} else if (setting.setting.equals("Main.Upgrade Particle Type")) {
|
||||||
} else if (setting.setting.equals("Main.Upgrade Particle Type")) {
|
config.addDefault(setting.setting, setting.option);
|
||||||
config.addDefault(setting.setting, setting.option);
|
} else {
|
||||||
} else {
|
config.addDefault(setting.setting, setting.option);
|
||||||
config.addDefault(setting.setting, setting.option);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
config.set("settings", null);
|
||||||
config.set("settings", null);
|
}
|
||||||
}
|
public enum Setting {
|
||||||
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),
|
||||||
o2("Upgrade-with-eco", "Main.Upgrade With Economy", true),
|
o3("Upgrade-with-xp", "Main.Upgrade With XP", true),
|
||||||
o3("Upgrade-with-xp", "Main.Upgrade With XP", true),
|
o4("Teleport-hoppers", "Main.Allow Players To Teleport Through Hoppers", 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),
|
||||||
o6("EnderChest-support", "Main.Support Enderchests", true),
|
o7("Upgrade-particle-type", "Main.Upgrade Particle Type", "SPELL_WITCH"),
|
||||||
o7("Upgrade-particle-type", "Main.Upgrade Particle Type", "SPELL_WITCH"),
|
o8("Hop-Tick", "Main.Amount of Ticks Between Hops", 8L),
|
||||||
o8("Hop-Tick", "Main.Amount of Ticks Between Hops", 8L),
|
o9("Tele-Tick", "Main.Amount of Ticks Between Teleport", 10L),
|
||||||
o9("Tele-Tick", "Main.Amount of Ticks Between Teleport", 10L),
|
o10("Sync-Timeout", "Main.Timeout When Syncing Hoppers", 300L),
|
||||||
o10("Sync-Timeout", "Main.Timeout When Syncing Hoppers", 300L),
|
o11("hopper-Limit", "Main.Max Hoppers Per Chunk", -1),
|
||||||
o11("hopper-Limit", "Main.Max Hoppers Per Chunk", -1),
|
o12("Helpful-Tips", "Main.Display Helpful Tips For Operators", true),
|
||||||
o12("Helpful-Tips", "Main.Display Helpful Tips For Operators", true),
|
o13("Sounds", "Main.Sounds Enabled", true),
|
||||||
o13("Sounds", "Main.Sounds Enabled", true),
|
o14("BlockBreak-Particle-Type", "Main.BlockBreak Particle Type", "LAVA"),
|
||||||
o14("BlockBreak-Particle-Type", "Main.BlockBreak Particle Type", "LAVA"),
|
o15("BlockBreak-Blacklist", "Main.BlockBreak Blacklisted Blocks", Arrays.asList("BEDROCK")),
|
||||||
o15("BlockBreak-Blacklist", "Main.BlockBreak Blacklisted Blocks", Arrays.asList("BEDROCK")),
|
|
||||||
|
o16("Rainbow-Glass", "Interfaces.Replace Glass Type 1 With Rainbow Glass", false),
|
||||||
o16("Rainbow-Glass", "Interfaces.Replace Glass Type 1 With Rainbow Glass", false),
|
o17("ECO-Icon", "Interfaces.Economy Icon", "SUNFLOWER"),
|
||||||
o17("ECO-Icon", "Interfaces.Economy Icon", "SUNFLOWER"),
|
o18("XP-Icon", "Interfaces.XP Icon", "EXPERIENCE_BOTTLE"),
|
||||||
o18("XP-Icon", "Interfaces.XP Icon", "EXPERIENCE_BOTTLE"),
|
o19("Glass-Type-1", "Interfaces.Glass Type 1", 7),
|
||||||
o19("Glass-Type-1", "Interfaces.Glass Type 1", 7),
|
o20("Glass-Type-2", "Interfaces.Glass Type 2", 11),
|
||||||
o20("Glass-Type-2", "Interfaces.Glass Type 2", 11),
|
o21("Glass-Type-3", "Interfaces.Glass Type 3", 3),
|
||||||
o21("Glass-Type-3", "Interfaces.Glass Type 3", 3),
|
|
||||||
|
o22("Debug-Mode", "System.Debugger Enabled", false);
|
||||||
o22("Debug-Mode", "System.Debugger Enabled", false);
|
|
||||||
|
private String setting;
|
||||||
private String setting;
|
private String oldSetting;
|
||||||
private String oldSetting;
|
private Object option;
|
||||||
private Object option;
|
|
||||||
|
Setting(String oldSetting, String setting, Object option) {
|
||||||
Setting(String oldSetting, String setting, Object option) {
|
this.oldSetting = oldSetting;
|
||||||
this.oldSetting = oldSetting;
|
this.setting = setting;
|
||||||
this.setting = setting;
|
this.option = option;
|
||||||
this.option = option;
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
ECO-Icon: 'This is the default icon that will be used for the Economy upgrade button.'
|
ECO-Icon: 'This is the default icon that will be used for the Economy upgrade button.'
|
||||||
XP-Icon: 'This is the default icon that will be used for the Experience upgrade button.'
|
XP-Icon: 'This is the default icon that will be used for the Experience upgrade button.'
|
||||||
Upgrading-enabled: 'Setting this to true will allow users to access the upgrade window.'
|
Upgrading-enabled: 'Setting this to true will allow users to access the upgrade window.'
|
||||||
Upgrade-with-eco: 'Setting this to true will allow users to use Economy to upgrade their hoppers.'
|
Upgrade-with-eco: 'Setting this to true will allow users to use Economy to upgrade their hoppers.'
|
||||||
Upgrade-with-xp: 'Setting this to true will allow users to use Experience to upgrade their hoppers.'
|
Upgrade-with-xp: 'Setting this to true will allow users to use Experience to upgrade their hoppers.'
|
||||||
On-upgrade-particles: 'Setting this to true will cause particles to emit when a hopper is upgraded.'
|
On-upgrade-particles: 'Setting this to true will cause particles to emit when a hopper is upgraded.'
|
||||||
Teleport-hoppers: 'These are the default levels, the amount of levels can be expanded if you want, just add another level to the bottom of the list while keeping numeric order. Allows you to enable or disable teleporting with hoppers'
|
Teleport-hoppers: 'These are the default levels, the amount of levels can be expanded if you want, just add another level to the bottom of the list while keeping numeric order. Allows you to enable or disable teleporting with hoppers'
|
||||||
Hop-Tick: 'This is the tick speed for synced hoppers.'
|
Hop-Tick: 'This is the tick speed for synced hoppers.'
|
||||||
Sync-Timeout: 'This is the timeout that if reached will cancel a sync.'
|
Sync-Timeout: 'This is the timeout that if reached will cancel a sync.'
|
||||||
Glass-Type: 'This is the id of the glass used for the background in the guis.'
|
Glass-Type: 'This is the id of the glass used for the background in the guis.'
|
||||||
Rainbow-Glass: 'If this is enabled the glass background will be randomized colors. '
|
Rainbow-Glass: 'If this is enabled the glass background will be randomized colors. '
|
||||||
Limit-Hoppers-Per-Chunk: 'If enabled this will limit the amount hoppers per chunk'
|
Limit-Hoppers-Per-Chunk: 'If enabled this will limit the amount hoppers per chunk'
|
||||||
Hopper-Limit: 'This is the amount of allowed hoppers per chunk.'
|
Hopper-Limit: 'This is the amount of allowed hoppers per chunk.'
|
||||||
Upgrade-particle-type: 'This is the type of particle an upgrade will emit.'
|
Upgrade-particle-type: 'This is the type of particle an upgrade will emit.'
|
@ -1,53 +1,53 @@
|
|||||||
#General Messages
|
#General Messages
|
||||||
|
|
||||||
general.nametag.prefix = "&7[&6EpicHoppers&7]"
|
general.nametag.prefix = "&7[&6EpicHoppers&7]"
|
||||||
general.nametag.next = "&9Next"
|
general.nametag.next = "&9Next"
|
||||||
general.nametag.back = "&9Back"
|
general.nametag.back = "&9Back"
|
||||||
general.nametag.nameformat = "&eLevel %level% &fHopper"
|
general.nametag.nameformat = "&eLevel %level% &fHopper"
|
||||||
|
|
||||||
#Interface Messages
|
#Interface Messages
|
||||||
|
|
||||||
interface.hopper.upgradewithxp = "&aUpgrade with XP"
|
interface.hopper.upgradewithxp = "&aUpgrade with XP"
|
||||||
interface.hopper.upgradewithxplore = "&7Cost: &a%cost% Levels"
|
interface.hopper.upgradewithxplore = "&7Cost: &a%cost% Levels"
|
||||||
interface.hopper.upgradewitheconomy = "&aUpgrade with ECO"
|
interface.hopper.upgradewitheconomy = "&aUpgrade with ECO"
|
||||||
interface.hopper.upgradewitheconomylore = "&7Cost: &a$%cost%"
|
interface.hopper.upgradewitheconomylore = "&7Cost: &a$%cost%"
|
||||||
interface.hopper.currentlevel = "&6Hopper Level &7%level%"
|
interface.hopper.currentlevel = "&6Hopper Level &7%level%"
|
||||||
interface.hopper.nextlevel = "&6Next Level &7%level%"
|
interface.hopper.nextlevel = "&6Next Level &7%level%"
|
||||||
interface.hopper.range = "&7Range: &6%range%"
|
interface.hopper.range = "&7Range: &6%range%"
|
||||||
interface.hopper.amount = "&7Amount: &6%amount%"
|
interface.hopper.amount = "&7Amount: &6%amount%"
|
||||||
interface.hopper.suction = "&7Suction: &6%suction%"
|
interface.hopper.suction = "&7Suction: &6%suction%"
|
||||||
interface.hopper.blockbreak = "&7Block Break: &6Every %ticks% ticks"
|
interface.hopper.blockbreak = "&7Block Break: &6Every %ticks% ticks"
|
||||||
interface.hopper.alreadymaxed = "&7This hopper is already maxed out!"
|
interface.hopper.alreadymaxed = "&7This hopper is already maxed out!"
|
||||||
interface.hopper.synclore = "|&7Left-Click then click a another|&7hopper or chest to sync!||&7Right-Click to desync."
|
interface.hopper.synclore = "|&7Left-Click then click a another|&7hopper or chest to sync!||&7Right-Click to desync."
|
||||||
interface.hopper.perltitle = "&6Click to Teleport"
|
interface.hopper.perltitle = "&6Click to Teleport"
|
||||||
interface.hopper.perllore = "|&7Left-Click to teleport to|&7the end of the chain.||&7Right-Click to toggle walk|&7on teleport."
|
interface.hopper.perllore = "|&7Left-Click to teleport to|&7the end of the chain.||&7Right-Click to toggle walk|&7on teleport."
|
||||||
interface.hopper.filtertitle = "&cClick to Filter"
|
interface.hopper.filtertitle = "&cClick to Filter"
|
||||||
interface.hopper.filterlore = "|&7This allows you to choose|&7which items go where."
|
interface.hopper.filterlore = "|&7This allows you to choose|&7which items go where."
|
||||||
interface.hopper.synchopper = "&6Click to Sync This hopper"
|
interface.hopper.synchopper = "&6Click to Sync This hopper"
|
||||||
interface.hopper.rejectsync = "&6Click to Sync Rejected Items"
|
interface.hopper.rejectsync = "&6Click to Sync Rejected Items"
|
||||||
interface.filter.infotitle = "&aFilter Guide"
|
interface.filter.infotitle = "&aFilter Guide"
|
||||||
interface.filter.infolore = "&7Items placed in the top left|&7space will be whitelisted.||&7Items placed in the right|&7will be void.||&7Items placed in the bottom left|&7will be blacklisted.||&cUsing the whitelist will disable|&cboth the blacklist and the void."
|
interface.filter.infolore = "&7Items placed in the top left|&7space will be whitelisted.||&7Items placed in the right|&7will be void.||&7Items placed in the bottom left|&7will be blacklisted.||&cUsing the whitelist will disable|&cboth the blacklist and the void."
|
||||||
interface.filter.whitelist = "&f&lWhite List"
|
interface.filter.whitelist = "&f&lWhite List"
|
||||||
interface.filter.blacklist = "&8&lBlack List"
|
interface.filter.blacklist = "&8&lBlack List"
|
||||||
interface.filter.void = "&c&lVoid"
|
interface.filter.void = "&c&lVoid"
|
||||||
|
|
||||||
#Event Messages
|
#Event Messages
|
||||||
|
|
||||||
event.general.nopermission = "&cYou do not have permission to do that."
|
event.general.nopermission = "&cYou do not have permission to do that."
|
||||||
event.upgrade.cannotafford = "&cYou cannot afford this upgrade."
|
event.upgrade.cannotafford = "&cYou cannot afford this upgrade."
|
||||||
event.upgrade.success = "&7You successfully upgraded this hopper to &6level %level%&7!"
|
event.upgrade.success = "&7You successfully upgraded this hopper to &6level %level%&7!"
|
||||||
event.upgrade.maxed = "&7You maxed out this hopper at &6level %level%&7."
|
event.upgrade.maxed = "&7You maxed out this hopper at &6level %level%&7."
|
||||||
event.inventory.noroom = "&7You do not have space in your inventory for this."
|
event.inventory.noroom = "&7You do not have space in your inventory for this."
|
||||||
event.hopper.syncsuccess = "&aSynchronization Successful."
|
event.hopper.syncsuccess = "&aSynchronization Successful."
|
||||||
event.hopper.desync = "&7You have desynchronized this hopper."
|
event.hopper.desync = "&7You have desynchronized this hopper."
|
||||||
event.hopper.syncnext = "&7Click another hopper or container to sync."
|
event.hopper.syncnext = "&7Click another hopper or container to sync."
|
||||||
event.hopper.syncself = "&cYou can't sync a hopper to itself."
|
event.hopper.syncself = "&cYou can't sync a hopper to itself."
|
||||||
event.hopper.synctimeout = "&cSyncing timed out."
|
event.hopper.synctimeout = "&cSyncing timed out."
|
||||||
event.hopper.syncoutofrange = "&cThis block is out of your hoppers range."
|
event.hopper.syncoutofrange = "&cThis block is out of your hoppers range."
|
||||||
event.hopper.syncdidnotplace = "&cSorry! You need to have placed this hopper to sync things to it."
|
event.hopper.syncdidnotplace = "&cSorry! You need to have placed this hopper to sync things to it."
|
||||||
event.hopper.toomany = "&cYou can only place %amount% hoppers per chunk..."
|
event.hopper.toomany = "&cYou can only place %amount% hoppers per chunk..."
|
||||||
event.hopper.walkteleenabled = "Walk on teleporting has been enabled for this hopper."
|
event.hopper.walkteleenabled = "Walk on teleporting has been enabled for this hopper."
|
||||||
event.hopper.walkteledisabled = "Walk on teleporting has been disabled for this hopper."
|
event.hopper.walkteledisabled = "Walk on teleporting has been disabled for this hopper."
|
||||||
event.hopper.onlyone = "&cYou may only place a single item at a time."
|
event.hopper.onlyone = "&cYou may only place a single item at a time."
|
||||||
event.hopper.syncchest = "&7You have synchronized your &9%name% &7with this chest."
|
event.hopper.syncchest = "&7You have synchronized your &9%name% &7with this chest."
|
||||||
event.hopper.desyncchest = "&7You have desynchronized your &9%name% &7with this chest."
|
event.hopper.desyncchest = "&7You have desynchronized your &9%name% &7with this chest."
|
@ -1,14 +1,14 @@
|
|||||||
name: EpicHoppers
|
name: EpicHoppers
|
||||||
description: EpicHoppers
|
description: EpicHoppers
|
||||||
main: com.songoda.epichoppers.EpicHoppers
|
main: com.songoda.epichoppers.EpicHoppersPlugin
|
||||||
depend: [Arconix]
|
depend: [Arconix]
|
||||||
softdepend: [Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault]
|
softdepend: [Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault]
|
||||||
version: 2.4
|
version: 3
|
||||||
author: Songoda
|
author: Songoda
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
commands:
|
commands:
|
||||||
epichoppers:
|
epichoppers:
|
||||||
description: View information on this plugin.
|
description: View information on this plugin.
|
||||||
default: true
|
default: true
|
||||||
aliases: [sc, eh, synccraft]
|
aliases: [eh, synccraft]
|
||||||
usage: /eh
|
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