Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency com.palmergames.bukkit.towny:towny to v0.98.3.8 #115

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>io.github.rypofalem.armorstandeditor</groupId>
<artifactId>armorstandeditor</artifactId>
<packaging>jar</packaging>
<version>1.xx.x-37</version>
<version>1.19.2-37</version>
<name>armorstandeditor</name>
<url>http://maven.apache.org</url>

Expand Down Expand Up @@ -117,7 +117,7 @@
<dependency>
<groupId>com.palmergames.bukkit.towny</groupId>
<artifactId>towny</artifactId>
<version>0.98.3.4</version>
<version>0.98.3.8</version>
<scope>provided</scope>
</dependency>
<!--- UpdateChecker -->
Expand All @@ -141,6 +141,13 @@
<version>2.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Lands -->
<dependency>
<groupId>com.github.angeschossen</groupId>
<artifactId>LandsAPI</artifactId>
<version>6.12.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!--Java 8-->
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package io.github.rypofalem.armorstandeditor;

import com.google.common.collect.ImmutableList;
import io.github.rypofalem.armorstandeditor.menu.ASEHolder;
import io.github.rypofalem.armorstandeditor.protections.*;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
Expand Down Expand Up @@ -56,12 +57,10 @@ public class PlayerEditorManager implements Listener {
private TickCounter counter;
private ArrayList<ArmorStand> as = null;
private ArrayList<ItemFrame> itemF = null;
private TownyProtection townyProtection;
private PlotSquaredProtection plotSquaredProtection;
private WorldGuardProtection worldGuardProtection;
private GriefPreventionProtection griefPreventionProtection;
private SkyblockProtection skyblockProtection;
private GriefDefenderProtection griefDefenderProtection;
// Instantiate protections used to determine whether a player may edit an armor stand or item frame
private final List<Protection> protections = ImmutableList.of(
new GriefDefenderProtection(), new GriefPreventionProtection(), new LandsProtection(),
new PlotSquaredProtection(), new SkyblockProtection(), new TownyProtection(), new WorldGuardProtection());

PlayerEditorManager( ArmorStandEditorPlugin plugin) {
this.plugin = plugin;
Expand All @@ -72,14 +71,6 @@ public class PlayerEditorManager implements Listener {
fineMov = .03125; // 1/32
counter = new TickCounter();
Bukkit.getServer().getScheduler().runTaskTimer(plugin, counter, 0, 1);

//Implementation of Protection Support - PlotSquared, WorldGuard, Towny, GriefPrevention etc.
townyProtection = new TownyProtection();
plotSquaredProtection = new PlotSquaredProtection();
worldGuardProtection = new WorldGuardProtection();
griefPreventionProtection = new GriefPreventionProtection();
skyblockProtection = new SkyblockProtection();
griefDefenderProtection = new GriefDefenderProtection();
}

@EventHandler(priority = EventPriority.LOWEST)
Expand Down Expand Up @@ -290,37 +281,11 @@ private ArrayList<ItemFrame> getFrameTargets(Player player) {
}


boolean canEdit( Player player, ArmorStand as) {

boolean canEdit( Player player, Entity entity) {
//Get the Entity being checked for editing
Block block = as.getLocation().getBlock();

//Permission checks for Protection
boolean protectTActive = townyProtection.checkPermission(block, player);
boolean protectPSActive = plotSquaredProtection.checkPermission(block, player);
boolean protectWGActive = worldGuardProtection.checkPermission(block, player);
boolean protectGPActive = griefPreventionProtection.checkPermission(block, player);
boolean protectSkyActive = skyblockProtection.checkPermission(player);
boolean protectGDActive = griefDefenderProtection.checkPermission(block, player);

return protectTActive && protectPSActive && protectWGActive && protectGPActive && protectSkyActive && protectGDActive;

}

boolean canEdit( Player player, ItemFrame itemf) {

//Get the Entity being checked for editing
Block block = itemf.getLocation().getBlock();

//Permission checks for Protection
boolean protectTActive = townyProtection.checkPermission(block, player);
boolean protectPSActive = plotSquaredProtection.checkPermission(block, player);
boolean protectWGActive = worldGuardProtection.checkPermission(block, player);
boolean protectGPActive = griefPreventionProtection.checkPermission(block, player);
boolean protectSkyActive = skyblockProtection.checkPermission(player);
boolean protectGDActive = griefDefenderProtection.checkPermission(block, player);

return protectTActive && protectPSActive && protectWGActive && protectGPActive && protectSkyActive && protectGDActive;
Block block = entity.getLocation().getBlock();
// Check if all protections allow this edit, if one fails, don't allow edit
return protections.stream().allMatch(protection -> protection.checkPermission(block, player));
}

void applyLeftTool( Player player, ArmorStand as) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static com.griefdefender.api.claim.TrustTypes.BUILDER;


public class GriefDefenderProtection {
public class GriefDefenderProtection implements Protection {

private final boolean gdEnabled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.bukkit.entity.Player;


public class GriefPreventionProtection {
public class GriefPreventionProtection implements Protection {

private boolean gpEnabled;
private GriefPrevention griefPrevention = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.github.rypofalem.armorstandeditor.protections;

import io.github.rypofalem.armorstandeditor.ArmorStandEditorPlugin;
import me.angeschossen.lands.api.integration.LandsIntegration;
import me.angeschossen.lands.api.land.Area;
import me.angeschossen.lands.api.land.Land;
import me.angeschossen.lands.api.player.LandPlayer;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;

public class LandsProtection implements Protection {
private final boolean landsEnabled;
private LandsIntegration lands;

public LandsProtection() {
landsEnabled = Bukkit.getPluginManager().isPluginEnabled("Lands");

if (landsEnabled)
lands = new LandsIntegration(ArmorStandEditorPlugin.instance());
}

@Override
public boolean checkPermission(Block block, Player player) {
if (!landsEnabled || player.hasPermission("asedit.ignoreProtection.lands")) return true;

// Check if the player is trusted in the area or land, in case they're not in an area, they're in.
Land land = lands.getLand(block.getLocation());
Area area = land == null ? null : land.getArea(block.getLocation());
LandPlayer lPlayer = lands.getLandPlayer(player.getUniqueId());
return area == null ? land == null || land.isTrusted(lPlayer) : area.isTrusted(player.getUniqueId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;

public class PlotSquaredProtection {
public class PlotSquaredProtection implements Protection {

private final boolean psEnabled;
private BukkitPlatform psPlatform = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.rypofalem.armorstandeditor.protections;

import org.bukkit.block.Block;
import org.bukkit.entity.Player;

public interface Protection {
boolean checkPermission(Block block, Player player);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;

public class SkyblockProtection {
public class SkyblockProtection implements Protection {
private final boolean skyblockEnabled;

public SkyblockProtection(){
Expand All @@ -16,7 +17,7 @@ public SkyblockProtection(){
skyblockEnabled = Bukkit.getPluginManager().isPluginEnabled("SuperiorSkyblock2");
}

public boolean checkPermission(Player player) {
public boolean checkPermission(Block block, Player player) {
if (!skyblockEnabled) return true;
if (player.isOp()) return true;
if (player.hasPermission("asedit.ignoreProtection.skyblock")) return true; //Add Additional Permission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.bukkit.entity.Player;

//FIX for https://github.com/Wolfieheart/ArmorStandEditor-Issues/issues/15
public class TownyProtection {
public class TownyProtection implements Protection {
private final boolean tEnabled;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;

public class WorldGuardProtection {
public class WorldGuardProtection implements Protection {
private final boolean wgEnabled;
private RegionQuery regionQry;

Expand Down
13 changes: 9 additions & 4 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: ArmorStandEditor
main: io.github.rypofalem.armorstandeditor.ArmorStandEditorPlugin
version: 1.xx.x-37
version: 1.19.2-37
api-version: "1.13"
website: https://www.spigotmc.org/resources/94503/
author: Wolfstorm
authors: [Wolfstorm, Marfjeh, miknes123, rypofalem, sekwah41, Sikatsu1997, Cool_boy, sumdream, Amaury Carrade, nicuch, kotarobo, prettydude, Jumpy91, Niasio, Patbox, Puremin0rez, Prof-Bloodstone]
authors: [Wolfstorm, Marfjeh, miknes123, rypofalem, sekwah41, Sikatsu1997, Cool_boy, sumdream, Amaury Carrade, nicuch, kotarobo, prettydude, Jumpy91, Niasio, Patbox, Puremin0rez, Prof-Bloodstone, PlanetTeamSpeak]
description: Allows players to edit data of armorstands without any commands.
softdepend: [Towny, WorldGuard, GriefPrevention, PlotSquared]
softdepend: [Towny, WorldGuard, GriefPrevention, PlotSquared, Lands]

commands:
ase:
Expand Down Expand Up @@ -74,6 +74,9 @@ permissions:
asedit.ignoreProtection.griefDefender:
description: Allows user to ignore GriefDefender's Protection Limitations.
default: false
asedit.ignoreProtection.lands:
description: Allows user to ignore Lands' Protection Limitations.
default: false


asedit.ignoreProtection.*:
Expand All @@ -86,6 +89,7 @@ permissions:
asedit.ignoreProtection.worldGuard: true
asedit.ignoreProtection.skyblock: true
asedit.ignoreProtection.griefDefender: true
asedit.ignoreProtection.lands: true

asedit.permpack.dontIgnoreProtections:
default: true
Expand All @@ -96,6 +100,7 @@ permissions:
asedit.ignoreProtection.worldGuard: false
asedit.ignoreProtection.skyblock: false
asedit.ignoreProtection.griefDefender: false
asedit.ignoreProtection.lands: false

asedit.permpack.basic:
default: true
Expand All @@ -121,4 +126,4 @@ permissions:
asedit.disableSlots: true
asedit.rename: true
asedit.update: true
asedit.ignorePermissions.*: true
asedit.ignorePermissions.*: true