Convert components, add Towny-Factions #14
2 changed files with 42 additions and 0 deletions
|
@ -3,6 +3,7 @@ package buttondevteam.presents;
|
|||
import buttondevteam.lib.architecture.Component;
|
||||
import buttondevteam.presents.components.chunkarchive.ChunkArchiveComponent;
|
||||
import buttondevteam.presents.components.magic.MagicComponent;
|
||||
import buttondevteam.presents.components.portals.PortalLimitComponent;
|
||||
import buttondevteam.presents.components.research.ResearchComponent;
|
||||
import buttondevteam.presents.components.research.dictionary.DictionaryComponent;
|
||||
import buttondevteam.presents.components.spawn.SpawnComponent;
|
||||
|
@ -31,6 +32,7 @@ public class ButtonPresents extends JavaPlugin{
|
|||
getLogger().warning("ChunkArchive compatibility error, not registering it.");
|
||||
}
|
||||
Component.registerComponent(this, new TownyFactionsComponent());
|
||||
Component.registerComponent(this, new PortalLimitComponent());
|
||||
|
||||
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package buttondevteam.presents.components.portals;
|
||||
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
import buttondevteam.lib.architecture.ConfigData;
|
||||
import buttondevteam.presents.ButtonPresents;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityPortalEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PortalLimitComponent extends Component<ButtonPresents> implements Listener {
|
||||
@Override
|
||||
protected void enable() {
|
||||
registerListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disable() {
|
||||
|
||||
}
|
||||
|
||||
private ConfigData<List<String>> worlds() {
|
||||
return getConfig().getData("worlds", Lists.newArrayList("v1", "v2", "v3"));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPortalEnter(PlayerPortalEvent event) {
|
||||
if (worlds().get().contains(event.getFrom().getWorld().getName()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPortalEnter(EntityPortalEvent event) {
|
||||
if (worlds().get().contains(event.getFrom().getWorld().getName()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue