Started storing the config values inside variables for easier access,

also it stops the config from being loaded every time it needs to check
a variable.
This commit is contained in:
sekwah41 2013-10-08 22:46:12 +01:00
parent 4ec8e600d3
commit 78ba57b841
1 changed files with 7 additions and 2 deletions

View File

@ -16,8 +16,14 @@ public class Listeners implements Listener {
private final AdvancedPortalsPlugin plugin;
// The needed config values will be stored so they are easier to access later
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("§eP...
private boolean UseOnlyServerAxe = false;
public Listeners(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
this.UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@ -36,12 +42,11 @@ public class Listeners implements Listener {
Player player = event.getPlayer();
Location blockloc = event.getClickedBlock().getLocation();
if(player.hasPermission("AdvancedPortals.create")){
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
// UseOnlyServerMadeAxe being set to true makes is so only the axe generated by the server can be used so other iron axes can be used normally,
// by default its false but it is a nice feature in case the user wants to use the axe normally too, such as a admin playing survival or it being used
// as a weapon.
if((!config.getConfig().getBoolean("UseOnlyServerMadeAxe") || event.getItem().getItemMeta().getDisplayName().equals("§ePortal Region Selector")) && event.getPlayer().getItemInHand().getTypeId() == Material.IRON_AXE.getId()) {
if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("§ePortal Region Selector")) && event.getPlayer().getItemInHand().getTypeId() == Material.IRON_AXE.getId()) {
// This checks if the action was a left or right click and if it was directly effecting a block.
if(event.getAction() == Action.LEFT_CLICK_BLOCK) {