mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-10-31 21:47:10 +00:00
Redundancy fix and better protection system
This commit is contained in:
parent
ab00cb840f
commit
8356e831a5
@ -1,13 +1,20 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class WorldGuardBridge extends FreedomService
|
public class WorldGuardBridge extends FreedomService
|
||||||
@ -23,6 +30,16 @@ public class WorldGuardBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canEditCurrentWorld(Player player)
|
||||||
|
{
|
||||||
|
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||||
|
|
||||||
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
RegionQuery query = container.createQuery();
|
||||||
|
|
||||||
|
return query.testBuild(localPlayer.getLocation(), localPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
public RegionManager getRegionManager(World world)
|
public RegionManager getRegionManager(World world)
|
||||||
{
|
{
|
||||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
@ -36,22 +36,17 @@ public class Trailer extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
if (trailPlayers.isEmpty())
|
/* Doesn't continue any further if...
|
||||||
{
|
* - The trail list is empty
|
||||||
return;
|
* - The player doesn't have their trail enabled in the first place
|
||||||
}
|
* - The player doesn't have the trail item in the shop at all
|
||||||
|
* - The player doesn't have permission to modify blocks in their current world
|
||||||
if (!trailPlayers.contains(event.getPlayer().getUniqueId()))
|
*/
|
||||||
{
|
if (trailPlayers.isEmpty()
|
||||||
return;
|
|| !trailPlayers.contains(event.getPlayer().getUniqueId())
|
||||||
}
|
|| !plugin.pl.getData(event.getPlayer()).hasItem(ShopItem.RAINBOW_TRAIL)
|
||||||
|
|| plugin.wr.doRestrict(event.getPlayer())
|
||||||
if (!plugin.pl.getData(event.getPlayer()).hasItem(ShopItem.RAINBOW_TRAIL))
|
|| !plugin.wgb.canEditCurrentWorld(event.getPlayer()))
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getPlayer().getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user