Add getter for WG main class

This commit is contained in:
Gabriele C 2018-08-02 01:29:04 +02:00
parent 21f175b19c
commit 275f497dff
3 changed files with 17 additions and 4 deletions

View File

@ -3,11 +3,14 @@ package org.codemc.worldguardwrapper.implementation;
import lombok.NonNull; import lombok.NonNull;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Optional; import java.util.Optional;
public interface IWorldGuardImplementation { public interface IWorldGuardImplementation {
JavaPlugin getWorldGuardPlugin();
int getApiVersion(); int getApiVersion();
// String flag // String flag

View File

@ -13,6 +13,7 @@ import lombok.NonNull;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.codemc.worldguardwrapper.implementation.AbstractWorldGuardImplementation; import org.codemc.worldguardwrapper.implementation.AbstractWorldGuardImplementation;
import java.util.Optional; import java.util.Optional;
@ -47,6 +48,11 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player).orElse(null), stateFlags)); return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player).orElse(null), stateFlags));
} }
@Override
public JavaPlugin getWorldGuardPlugin() {
return WorldGuardPlugin.inst();
}
@Override @Override
public int getApiVersion() { public int getApiVersion() {
return 6; return 6;

View File

@ -17,22 +17,21 @@ import lombok.NonNull;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.codemc.worldguardwrapper.implementation.AbstractWorldGuardImplementation; import org.codemc.worldguardwrapper.implementation.AbstractWorldGuardImplementation;
import java.util.Optional; import java.util.Optional;
public class WorldGuardImplementation extends AbstractWorldGuardImplementation { public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
private final WorldGuard core;
private final FlagRegistry flagRegistry; private final FlagRegistry flagRegistry;
private final WorldGuardPlatform platform;
private final RegionContainer container; private final RegionContainer container;
private final WorldGuardPlugin plugin; private final WorldGuardPlugin plugin;
public WorldGuardImplementation() { public WorldGuardImplementation() {
core = WorldGuard.getInstance(); WorldGuard core = WorldGuard.getInstance();
flagRegistry = core.getFlagRegistry(); flagRegistry = core.getFlagRegistry();
platform = core.getPlatform(); WorldGuardPlatform platform = core.getPlatform();
container = platform.getRegionContainer(); container = platform.getRegionContainer();
plugin = WorldGuardPlugin.inst(); plugin = WorldGuardPlugin.inst();
} }
@ -57,6 +56,11 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player).orElse(null), stateFlags)); return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player).orElse(null), stateFlags));
} }
@Override
public JavaPlugin getWorldGuardPlugin() {
return WorldGuardPlugin.inst();
}
@Override @Override
public int getApiVersion() { public int getApiVersion() {
return 7; return 7;