mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-04 01:49:34 +01:00
Worldguard support
This commit is contained in:
parent
502fd92318
commit
1886d975fc
@ -71,7 +71,7 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private void checkVersion() {
|
||||
private boolean checkVersion() {
|
||||
int workingVersion = 13;
|
||||
int currentVersion = Integer.parseInt(Bukkit.getServer().getClass()
|
||||
.getPackage().getName().split("\\.")[3].split("_")[1]);
|
||||
@ -82,13 +82,15 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You installed the 1." + workingVersion + "+ only version of " + this.getDescription().getName() + " on a 1." + currentVersion + " server. Since you are on the wrong version we disabled the plugin for you. Please install correct version to continue using " + this.getDescription().getName() + ".");
|
||||
Bukkit.getConsoleSender().sendMessage("");
|
||||
}, 20L);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Check to make sure the Bukkit version is compatible.
|
||||
checkVersion();
|
||||
if (!checkVersion()) return;
|
||||
|
||||
INSTANCE = this;
|
||||
Arconix.pl().hook(this);
|
||||
|
@ -1,6 +1,11 @@
|
||||
package com.songoda.epicfarming.hooks;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import com.songoda.epicfarming.api.utils.ProtectionPluginHook;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -8,20 +13,22 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class HookWorldGuard implements ProtectionPluginHook {
|
||||
|
||||
private final WorldGuardPlugin worldGuard;
|
||||
private final WorldGuard worldGuard;
|
||||
|
||||
public HookWorldGuard() {
|
||||
this.worldGuard = WorldGuardPlugin.inst();
|
||||
this.worldGuard = WorldGuard.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaPlugin getPlugin() {
|
||||
return worldGuard;
|
||||
return WorldGuardPlugin.inst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player player, Location location) {
|
||||
return worldGuard.canBuild(player, location);
|
||||
RegionQuery q = worldGuard.getPlatform().getRegionContainer().createQuery();
|
||||
ApplicableRegionSet ars = q.getApplicableRegions(BukkitAdapter.adapt(player.getLocation()));
|
||||
return ars.testState(WorldGuardPlugin.inst().wrapPlayer(player), Flags.BUILD);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user