Refactor code to make it more readable

This commit is contained in:
GeorgH93 2018-06-07 22:10:43 +02:00
parent 09cd1a0fb2
commit f3ea7f3fee
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 7 additions and 11 deletions

View File

@ -38,6 +38,7 @@ public ItemsCollector(Minepacks plugin)
{
this.plugin = plugin;
this.radius = plugin.getConfiguration().getFullInvRadius();
runTaskTimer(plugin, plugin.getConfiguration().getFullInvCheckInterval(), plugin.getConfiguration().getFullInvCheckInterval());
}
@Override

View File

@ -30,11 +30,11 @@
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class EventListener extends MinepacksListener
public class BackpackEventListener extends MinepacksListener
{
private final Message messageOwnBackpackClose, messageOtherBackpackClose;
public EventListener(Minepacks plugin)
public BackpackEventListener(Minepacks plugin)
{
super(plugin);
messageOwnBackpackClose = plugin.getLanguage().getMessage("Ingame.OwnBackpackClose");
@ -82,10 +82,9 @@ public void onClick(InventoryClickEvent event)
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLeaveEvent(PlayerQuitEvent event)
{
plugin.cooldowns.remove(event.getPlayer().getUniqueId());
Backpack backpack = plugin.getDatabase().getBackpack(event.getPlayer());
if(backpack != null) backpack.save();
}

View File

@ -33,7 +33,7 @@
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.DisableShulkerboxes;
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Database;
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.DropOnDeath;
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.EventListener;
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.BackpackEventListener;
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.ItemFilter;
import at.pcgamingfreaks.PluginLib.Bukkit.PluginLib;
import at.pcgamingfreaks.StringUtils;
@ -169,16 +169,12 @@ private void load()
//region register events
PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(new EventListener(this), this);
pluginManager.registerEvents(new BackpackEventListener(this), this);
if(config.getDropOnDeath()) pluginManager.registerEvents(new DropOnDeath(this), this);
if(config.isItemFilterEnabled()) pluginManager.registerEvents(new ItemFilter(this), this);
if(MCVersion.isNewerOrEqualThan(MCVersion.MC_1_11) && config.isShulkerboxesDisable()) pluginManager.registerEvents(new DisableShulkerboxes(this), this);
//endregion
if(config.getFullInvCollect())
{
collector = new ItemsCollector(this);
collector.runTaskTimer(this, config.getFullInvCheckInterval(), config.getFullInvCheckInterval());
}
if(config.getFullInvCollect()) collector = new ItemsCollector(this);
worldBlacklist = config.getWorldBlacklist();
if(worldBlacklist.size() == 0)
{