mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-30 13:27:37 +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;
|
||||
|
||||
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.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
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)
|
||||
{
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
|
@ -36,22 +36,17 @@ public class Trailer extends FreedomService
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (trailPlayers.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!trailPlayers.contains(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.pl.getData(event.getPlayer()).hasItem(ShopItem.RAINBOW_TRAIL))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPlayer().getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()))
|
||||
/* Doesn't continue any further if...
|
||||
* - The trail list is empty
|
||||
* - 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.isEmpty()
|
||||
|| !trailPlayers.contains(event.getPlayer().getUniqueId())
|
||||
|| !plugin.pl.getData(event.getPlayer()).hasItem(ShopItem.RAINBOW_TRAIL)
|
||||
|| plugin.wr.doRestrict(event.getPlayer())
|
||||
|| !plugin.wgb.canEditCurrentWorld(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user