Merge changes

This commit is contained in:
Telesphoreo 2021-09-29 17:03:45 -05:00
commit 624df45b5d
16 changed files with 147 additions and 105 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
*.iml
/*/target/
/*/dependency-reduced-pom.xml
.DS_Store

View file

@ -3,7 +3,7 @@
<parent>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.5-SNAPSHOT</version>
<version>4.1.6-SNAPSHOT</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>

View file

@ -3,7 +3,7 @@
<parent>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.5-SNAPSHOT</version>
<version>4.1.6-SNAPSHOT</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>

View file

@ -5,7 +5,7 @@
<parent>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.5-SNAPSHOT</version>
<version>4.1.6-SNAPSHOT</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>

View file

@ -8,6 +8,7 @@ import java.util.Set;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import net.goldtreeservers.worldguardextraflags.listeners.*;
import org.bstats.bukkit.Metrics;
import org.bukkit.World;
import org.bukkit.block.BlockState;
@ -23,13 +24,6 @@ import lombok.Getter;
import net.goldtreeservers.worldguardextraflags.essentials.EssentialsHelper;
import net.goldtreeservers.worldguardextraflags.fawe.FAWEHelper;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.listeners.BlockListener;
import net.goldtreeservers.worldguardextraflags.listeners.EntityListener;
import net.goldtreeservers.worldguardextraflags.listeners.EntityListenerOnePointNine;
import net.goldtreeservers.worldguardextraflags.listeners.EntityPotionEffectEventListener;
import net.goldtreeservers.worldguardextraflags.listeners.PlayerListener;
import net.goldtreeservers.worldguardextraflags.listeners.WorldEditListener;
import net.goldtreeservers.worldguardextraflags.listeners.WorldListener;
import net.goldtreeservers.worldguardextraflags.protocollib.ProtocolLibHelper;
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
@ -143,6 +137,11 @@ public class WorldGuardExtraFlagsPlugin extends AbstractWorldGuardExtraFlagsPlug
this.getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
this.getServer().getPluginManager().registerEvents(new BlockListener(this), this);
this.getServer().getPluginManager().registerEvents(new WorldListener(this), this);
if (this.worldGuardCommunicator.isLegacy())
{
this.getServer().getPluginManager().registerEvents(new BlockListenerWG(this), this);
}
try
{

View file

@ -59,86 +59,4 @@ public class BlockListener implements Listener
}
}
}
//TODO: Figure out something better for this
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onBlockPlaceEvent(PlaceBlockEvent event)
{
Result originalResult = event.getResult();
Object cause = event.getCause().getRootCause();
if (cause instanceof Player)
{
Player player = (Player)cause;
for(Block block : event.getBlocks())
{
Material type = block.getType();
if (type == Material.AIR) //Workaround for https://github.com/aromaa/WorldGuardExtraFlagsPlugin/issues/12
{
type = event.getEffectiveMaterial();
}
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
Set<Material> state = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.ALLOW_BLOCK_PLACE);
if (state != null && state.contains(type))
{
event.setResult(Result.ALLOW);
}
else
{
Set<Material> state2 = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.DENY_BLOCK_PLACE);
if (state2 != null && state2.contains(type))
{
event.setResult(Result.DENY);
return;
}
else
{
event.setResult(originalResult);
return;
}
}
}
}
}
//TODO: Figure out something better for this
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onBlockBreakEvent(BreakBlockEvent event)
{
Result originalResult = event.getResult();
Object cause = event.getCause().getRootCause();
if (cause instanceof Player)
{
Player player = (Player)cause;
for(Block block : event.getBlocks())
{
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
Set<Material> state = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.ALLOW_BLOCK_BREAK);
if (state != null && state.contains(block.getType()))
{
event.setResult(Result.ALLOW);
}
else
{
Set<Material> state2 = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.DENY_BLOCK_BREAK);
if (state2 != null && state2.contains(block.getType()))
{
event.setResult(Result.DENY);
return;
}
else
{
event.setResult(originalResult);
return;
}
}
}
}
}
}

View file

@ -0,0 +1,107 @@
package net.goldtreeservers.worldguardextraflags.listeners;
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.Set;
@RequiredArgsConstructor
public class BlockListenerWG implements Listener
{
@Getter private final WorldGuardExtraFlagsPlugin plugin;
//TODO: Figure out something better for this
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onBlockPlaceEvent(PlaceBlockEvent event)
{
Event.Result originalResult = event.getResult();
Object cause = event.getCause().getRootCause();
if (cause instanceof Player)
{
Player player = (Player)cause;
for(Block block : event.getBlocks())
{
Material type = block.getType();
if (type == Material.AIR) //Workaround for https://github.com/aromaa/WorldGuardExtraFlagsPlugin/issues/12
{
type = event.getEffectiveMaterial();
}
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
Set<Material> state = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.ALLOW_BLOCK_PLACE);
if (state != null && state.contains(type))
{
event.setResult(Event.Result.ALLOW);
}
else
{
Set<Material> state2 = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.DENY_BLOCK_PLACE);
if (state2 != null && state2.contains(type))
{
event.setResult(Event.Result.DENY);
return;
}
else
{
event.setResult(originalResult);
return;
}
}
}
}
}
//TODO: Figure out something better for this
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onBlockBreakEvent(BreakBlockEvent event)
{
Event.Result originalResult = event.getResult();
Object cause = event.getCause().getRootCause();
if (cause instanceof Player)
{
Player player = (Player)cause;
for(Block block : event.getBlocks())
{
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
Set<Material> state = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.ALLOW_BLOCK_BREAK);
if (state != null && state.contains(block.getType()))
{
event.setResult(Event.Result.ALLOW);
}
else
{
Set<Material> state2 = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.DENY_BLOCK_BREAK);
if (state2 != null && state2.contains(block.getType()))
{
event.setResult(Event.Result.DENY);
return;
}
else
{
event.setResult(originalResult);
return;
}
}
}
}
}
}

View file

@ -3,7 +3,7 @@
<parent>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.5-SNAPSHOT</version>
<version>4.1.6-SNAPSHOT</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
@ -70,9 +70,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.totalfreedom</groupId>
<groupId>com.github.AtlasMediaGroup</groupId>
<artifactId>TotalFreedomMod</artifactId>
<version>2020.11.5</version>
<version>development-0be2aa718f-1</version>
<scope>provided</scope>
</dependency>
</dependencies>

View file

@ -2,7 +2,6 @@ package net.goldtreeservers.worldguardextraflags.wg;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
public class TFMHandler
@ -25,7 +24,7 @@ public class TFMHandler
return null;
}
public static boolean isStaff(String name)
public static boolean isAdmin(String name)
{
return getTFM().al.getEntryByName(name) != null;
}

View file

@ -45,7 +45,7 @@ public class WorldGuardUtils
}
// Fuck your shitty permission system - packs
return TFMHandler.isStaff(player.getName());
return TFMHandler.isAdmin(player.getName());
}
public static State queryState(Player player, World world, Set<ProtectedRegion> regions, StateFlag flag)

View file

@ -54,14 +54,18 @@ public interface WorldGuardCommunicator
flagRegistry.register(Flags.MYTHICMOB_EGGS);
flagRegistry.register(Flags.FROSTWALKER);
flagRegistry.register(Flags.NETHER_PORTALS);
flagRegistry.register(Flags.ALLOW_BLOCK_PLACE);
flagRegistry.register(Flags.DENY_BLOCK_PLACE);
flagRegistry.register(Flags.ALLOW_BLOCK_BREAK);
flagRegistry.register(Flags.DENY_BLOCK_BREAK);
flagRegistry.register(Flags.GLIDE);
flagRegistry.register(Flags.CHUNK_UNLOAD);
flagRegistry.register(Flags.ITEM_DURABILITY);
flagRegistry.register(Flags.JOIN_LOCATION);
if (this.isLegacy())
{
flagRegistry.register(Flags.ALLOW_BLOCK_PLACE);
flagRegistry.register(Flags.DENY_BLOCK_PLACE);
flagRegistry.register(Flags.ALLOW_BLOCK_BREAK);
flagRegistry.register(Flags.DENY_BLOCK_BREAK);
}
}
default public void onEnable(Plugin plugin) throws Exception
@ -82,6 +86,8 @@ public interface WorldGuardCommunicator
sessionManager.registerHandler(PlaySoundsFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(GlideFlagHandler.FACTORY(plugin));
}
public boolean isLegacy();
public FlagRegistry getFlagRegistry();

View file

@ -3,7 +3,7 @@
<parent>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.5-SNAPSHOT</version>
<version>4.1.6-SNAPSHOT</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>

View file

@ -42,6 +42,12 @@ public class WorldGuardSixCommunicator implements WorldGuardCommunicator
WorldGuardCommunicator.super.onEnable(plugin);
}
@Override
public boolean isLegacy()
{
return true;
}
@Override
public FlagRegistry getFlagRegistry()
{

View file

@ -3,7 +3,7 @@
<parent>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.5-SNAPSHOT</version>
<version>4.1.6-SNAPSHOT</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>

View file

@ -57,6 +57,12 @@ public class WorldGuardSevenCommunicator implements WorldGuardCommunicator
WorldGuardCommunicator.super.onEnable(plugin);
}
@Override
public boolean isLegacy()
{
return false;
}
@Override
public FlagRegistry getFlagRegistry()
{

View file

@ -4,7 +4,7 @@
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<name>WorldGuardExtraFlags</name>
<version>4.1.5-SNAPSHOT</version>
<version>4.1.6-SNAPSHOT</version>
<packaging>pom</packaging>