Really fixed block-break flags

This commit is contained in:
isokissa3 2017-01-26 01:12:03 +02:00
parent 190ece604b
commit ee37c705c2
3 changed files with 26 additions and 29 deletions

View file

@ -22,7 +22,7 @@ public class MaterialFlag extends Flag<Material>
@Override
public Material parseInput(FlagContext context) throws InvalidFlagFormat
{
return Material.getMaterial(context.getUserInput().trim());
return Material.getMaterial(context.getUserInput().trim().toUpperCase());
}
@Override

View file

@ -49,41 +49,39 @@ public class BlockListener implements Listener
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onBlockPlaceEvent(PlaceBlockEvent event)
{
if (event.getResult() == Result.DEFAULT)
{
Object cause = event.getCause().getRootCause();
if (cause instanceof Player)
{
Player player = (Player)cause;
Result originalResult = event.getResult();
Object cause = event.getCause().getRootCause();
if (!WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().hasBypass(player, player.getWorld()))
if (cause instanceof Player)
{
Player player = (Player)cause;
if (!WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().hasBypass(player, player.getWorld()))
{
for(Block block : event.getBlocks())
{
for(Block block : event.getBlocks())
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
Set<Material> state = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.allowBlockPlace);
if (state != null && state.contains(block.getType()))
{
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
Set<Material> state = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.allowBlockPlace);
if (state != null && state.contains(block.getType()))
event.setResult(Result.ALLOW);
}
else
{
Set<Material> state2 = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.denyBlockPlace);
if (state2 != null && state2.contains(block.getType()))
{
event.setResult(Result.ALLOW);
event.setResult(Result.DENY);
return;
}
else
{
Set<Material> state2 = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.denyBlockPlace);
if (state2 != null && state2.contains(block.getType()))
{
event.setResult(Result.DENY);
return;
}
else
{
event.setResult(Result.DEFAULT);
return;
}
event.setResult(originalResult);
return;
}
}
}
}
}
}
}
}

View file

@ -30,7 +30,6 @@ import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
import com.sk89q.worldedit.Location;
import com.sk89q.worldedit.bukkit.BukkitUtil;