Updated references for listener

This commit is contained in:
Sekwah 2018-06-06 15:02:28 +01:00 committed by Sekwah
parent a3625af88f
commit 2f9a9622db
3 changed files with 20 additions and 9 deletions

View File

@ -434,7 +434,6 @@ jar {
from configurations.includeLibs.collect { it.isDirectory() ? it : zipTree(it) }
}
// Set SPIGOT_LOC to the location of your server and SPIGOT_JAR as the name of the jar file in the server you want to run
// DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
task runJar() << {

View File

@ -1,5 +1,7 @@
package com.sekwah.advancedportals.spigot;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.util.DataStorage;
import com.sekwah.advancedportals.coreconnector.ConnectorDataCollector;
@ -10,11 +12,17 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
private AdvancedPortalsCore portalsCore;
/**
* Readd this when the injector is actually needed.
*/
//private Injector injector;
public void onEnable() {
// TODO actually get the minecraft version
this.portalsCore = new AdvancedPortalsCore(new DataStorage(this.getDataFolder()),
new SpigotInfoLogger(this), new CommandRegister(this), new ConnectorDataCollector(), new int[]{1,12,2});
this.getServer().getPluginManager().registerEvents(new Listeners(this), this);
//injector = Guice.createInjector(new RepositoryModule(this.portalsCore));
this.getServer().getPluginManager().registerEvents(new Listeners(), this);
}
public void onDisable() {

View File

@ -1,5 +1,7 @@
package com.sekwah.advancedportals.spigot;
import com.google.inject.name.Named;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.CoreListeners;
import com.sekwah.advancedportals.core.data.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
@ -11,22 +13,24 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import javax.inject.Inject;
public class Listeners implements Listener {
private final AdvancedPortalsPlugin plugin;
private final CoreListeners coreListeners;
public Listeners(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
this.coreListeners = plugin.getPortalsCore().getCoreListeners();
}
private CoreListeners coreListeners = AdvancedPortalsCore.getCoreListeners();
@EventHandler
public void onJoinEvent(PlayerJoinEvent event) {
coreListeners.playerJoin(new PlayerContainer(event.getPlayer()));
}
@EventHandler
public void onJoinEvent(PlayerQuitEvent event) {
coreListeners.playerLeave(new PlayerContainer(event.getPlayer()));
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event) {
if (!event.isCancelled()) {