Remove old Plugin compat.

This commit is contained in:
MattBDev 2019-10-07 12:26:29 -04:00
parent a8511d4a63
commit 78872719f3
8 changed files with 29 additions and 214 deletions

View File

@ -1,7 +1,7 @@
object Versions {
const val TEXT = "3.0.1"
const val TEXT_EXTRAS = "3.0.2"
const val PISTON = "0.4.4-SNAPSHOT"
const val PISTON = "0.5.2"
const val AUTO_VALUE = "1.6.5"
const val JUNIT = "5.5.0"
const val MOCKITO = "3.0.0"

View File

@ -16,9 +16,10 @@ repositories {
maven { url = uri("http://ci.frostcast.net/plugin/repository/everything") }
maven { url = uri("http://dl.bintray.com/tastybento/maven-repo") }
maven { url = uri("http://ci.emc.gs/nexus/content/groups/aikar/") }
maven { url = uri("https://libraries.minecraft.net") }
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://repo.destroystokyo.com/repository/maven-public//") }
maven { url = uri("http://repo.dmulloy2.net/content/groups/public/") }
maven { url = uri("http://ci.ender.zone/plugin/repository/everything/") }
}
configurations.all {
@ -49,10 +50,8 @@ dependencies {
}
"implementation"("com.massivecraft:factions:2.8.0") { isTransitive = false }
"implementation"("com.drtshock:factions:1.6.9.5") { isTransitive = false }
"implementation"("com.factionsone:FactionsOne:1.2.2") { isTransitive = false }
"implementation"("me.ryanhamshire:GriefPrevention:11.5.2") { isTransitive = false }
"implementation"("com.github.TechFortress:GriefPrevention:16.12.0") { isTransitive = false }
"implementation"("com.massivecraft:mcore:7.0.1") { isTransitive = false }
"implementation"("net.sacredlabyrinth.Phaed:PreciousStones:10.0.4-SNAPSHOT") { isTransitive = false }
"implementation"("net.jzx7:regios:5.9.9") { isTransitive = false }
"implementation"("com.bekvon.bukkit.residence:Residence:4.5._13.1") { isTransitive = false }
"implementation"("com.palmergames.bukkit:towny:0.84.0.9") { isTransitive = false }

View File

@ -11,11 +11,9 @@ import com.boydti.fawe.bukkit.listener.ChunkListener_9;
import com.boydti.fawe.bukkit.listener.RenderListener;
import com.boydti.fawe.bukkit.regions.ASkyBlockHook;
import com.boydti.fawe.bukkit.regions.FactionsFeature;
import com.boydti.fawe.bukkit.regions.FactionsOneFeature;
import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature;
import com.boydti.fawe.bukkit.regions.FreeBuildRegion;
import com.boydti.fawe.bukkit.regions.GriefPreventionFeature;
import com.boydti.fawe.bukkit.regions.PreciousStonesFeature;
import com.boydti.fawe.bukkit.regions.ResidenceFeature;
import com.boydti.fawe.bukkit.regions.TownyFeature;
import com.boydti.fawe.bukkit.regions.Worldguard;
@ -86,7 +84,11 @@ public class FaweBukkit implements IFawe, Listener {
if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) {
new RenderListener(plugin);
}
WEManager.IMP.managers.add(new PlotSquaredFeature());
try {
WEManager.IMP.managers.add(new PlotSquaredFeature());
} catch (Exception ignored) {
//Not everyone uses or needs PlotSquared.
}
} catch (final Throwable e) {
e.printStackTrace();
Bukkit.getServer().shutdown();
@ -291,37 +293,28 @@ public class FaweBukkit implements IFawe, Listener {
try {
managers.add(new Worldguard(worldguardPlugin));
managers.add(new WorldguardFlag(worldguardPlugin));
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
Fawe.debug("Attempting to use plugin 'WorldGuard'");
} catch (Throwable ignored) {
}
}
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
if (townyPlugin != null && townyPlugin.isEnabled()) {
try {
managers.add(new TownyFeature(townyPlugin));
Fawe.debug("Plugin 'Towny' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
Fawe.debug("Attempting to use plugin 'Towny'");
} catch (Throwable ignored) {
}
}
final Plugin factionsPlugin = Bukkit.getServer().getPluginManager().getPlugin("Factions");
if (factionsPlugin != null && factionsPlugin.isEnabled()) {
try {
managers.add(new FactionsFeature(factionsPlugin));
Fawe.debug("Plugin 'Factions' found. Using it now.");
Fawe.debug("Attempting to use plugin 'Factions'");
} catch (Throwable e) {
try {
managers.add(new FactionsUUIDFeature(factionsPlugin, this));
Fawe.debug("Plugin 'FactionsUUID' found. Using it now.");
} catch (Throwable e2) {
try {
managers.add(new FactionsOneFeature(factionsPlugin));
Fawe.debug("Plugin 'FactionsUUID' found. Using it now.");
} catch (Throwable e3) {
e.printStackTrace();
}
Fawe.debug("Attempting to use plugin 'FactionsUUID'");
} catch (Throwable ignored) {
}
}
}
@ -329,36 +322,24 @@ public class FaweBukkit implements IFawe, Listener {
if (residencePlugin != null && residencePlugin.isEnabled()) {
try {
managers.add(new ResidenceFeature(residencePlugin, this));
Fawe.debug("Plugin 'Residence' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
Fawe.debug("Attempting to use plugin 'Residence'");
} catch (Throwable ignored) {
}
}
final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
if (griefpreventionPlugin != null && griefpreventionPlugin.isEnabled()) {
try {
managers.add(new GriefPreventionFeature(griefpreventionPlugin));
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
Fawe.debug("Attempting to use plugin 'GriefPrevention'");
} catch (Throwable ignored) {
}
}
final Plugin preciousStonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
if (preciousStonesPlugin != null && preciousStonesPlugin.isEnabled()) {
try {
managers.add(new PreciousStonesFeature(preciousStonesPlugin));
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
}
final Plugin aSkyBlock = Bukkit.getServer().getPluginManager().getPlugin("ASkyBlock");
if (aSkyBlock != null && aSkyBlock.isEnabled()) {
try {
managers.add(new ASkyBlockHook(aSkyBlock));
Fawe.debug("Plugin 'ASkyBlock' found. Using it now.");
Fawe.debug("Attempting to use plugin 'ASkyBlock' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
@ -366,9 +347,8 @@ public class FaweBukkit implements IFawe, Listener {
if (Settings.IMP.EXPERIMENTAL.FREEBUILD) {
try {
managers.add(new FreeBuildRegion());
Fawe.debug("Plugin '<internal.freebuild>' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
Fawe.debug("Attempting to use plugin '<internal.freebuild>'");
} catch (Throwable ignored) {
}
}

View File

@ -1,111 +0,0 @@
package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.util.Permission;
import com.massivecraft.factions.FLocation;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import java.lang.reflect.Method;
import java.util.List;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
public class FactionsOneFeature extends BukkitMaskManager implements Listener {
private final Method methodGetFactionAt;
public FactionsOneFeature(final Plugin factionsPlugin) throws Throwable {
super(factionsPlugin.getName());
Class clazzBoard = Class.forName("com.massivecraft.factions.Board");
this.methodGetFactionAt = clazzBoard.getDeclaredMethod("getFactionAt", FLocation.class);
}
@Override
public FaweMask getMask(final com.sk89q.worldedit.entity.Player p, MaskType type) {
final Player player = BukkitAdapter.adapt(p);
final Chunk chunk = player.getLocation().getChunk();
final boolean perm = Permission.hasPermission(p, "fawe.factions.wilderness");
final World world = player.getWorld();
RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ());
int count = 32;
if (this.isAdded(locs, world, player, perm, type)) {
boolean hasPerm = true;
while (hasPerm && count > 0) {
count--;
hasPerm = false;
RegionWrapper chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ);
if (this.isAdded(chunkSelection, world, player, perm, type)) {
locs = new RegionWrapper(locs.minX, locs.maxX + 1, locs.minZ, locs.maxZ);
hasPerm = true;
}
chunkSelection = new RegionWrapper(locs.minX - 1, locs.minX - 1, locs.minZ, locs.maxZ);
if (this.isAdded(chunkSelection, world, player, perm, type)) {
locs = new RegionWrapper(locs.minX - 1, locs.maxX, locs.minZ, locs.maxZ);
hasPerm = true;
}
chunkSelection = new RegionWrapper(locs.minX, locs.maxX, locs.maxZ + 1, locs.maxZ + 1);
if (this.isAdded(chunkSelection, world, player, perm, type)) {
locs = new RegionWrapper(locs.minX, locs.maxX, locs.minZ, locs.maxZ + 1);
hasPerm = true;
}
chunkSelection = new RegionWrapper(locs.minX, locs.maxX, locs.minZ - 1, locs.minZ - 1);
if (this.isAdded(chunkSelection, world, player, perm, type)) {
locs = new RegionWrapper(locs.minX, locs.maxX, locs.minZ - 1, locs.maxZ);
hasPerm = true;
}
}
final BlockVector3 pos1 = BlockVector3.at(locs.minX << 4, 1, locs.minZ << 4);
final BlockVector3 pos2 = BlockVector3.at(15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
return new FaweMask(pos1, pos2);
}
return null;
}
public boolean isAdded(final RegionWrapper locs, final World world, final Player player, final boolean perm, MaskType type) {
try {
for (int x = locs.minX; x <= locs.maxX; x++) {
for (int z = locs.minZ; z <= locs.maxZ; z++) {
final Object fac = methodGetFactionAt.invoke(null, new FLocation(world.getName(), x, z));
if (fac == null) {
return false;
}
if (type == MaskType.OWNER) {
Object leader = fac.getClass().getDeclaredMethod("getFPlayerLeader").invoke(fac);
return player.getName().equals(leader.getClass().getDeclaredMethod("getName").invoke(leader));
}
Method methodGetOnlinePlayers = fac.getClass().getDeclaredMethod("getOnlinePlayers");
List<Player> players = (List<Player>) methodGetOnlinePlayers.invoke(fac);
if (!players.contains(player)) {
return false;
}
Method isNone = fac.getClass().getDeclaredMethod("isNone");
if ((boolean) isNone.invoke(fac)) {
return false;
}
}
}
return true;
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
}

View File

@ -4,6 +4,7 @@ import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.boydti.fawe.bukkit.wrapper.AsyncWorld;
import com.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
@ -35,7 +36,7 @@ public class FreeBuildRegion extends BukkitMaskManager {
}
@Override
public FaweMask getMask(com.sk89q.worldedit.entity.Player player, MaskType type) {
public FaweMask getMask(Player player, MaskType type) {
if (type != MaskType.MEMBER) return null;
ArrayList<RegisteredListener> currRegList = new ArrayList<>();
for (RegisteredListener listener : this.listeners) {
@ -58,7 +59,7 @@ public class FreeBuildRegion extends BukkitMaskManager {
return new FaweMask(pos1, pos2) {
@Override
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
public boolean isValid(Player player, MaskType type) {
return bukkitWorld == BukkitAdapter.adapt(player.getWorld()) && type == MaskType.MEMBER;
}

View File

@ -1,50 +0,0 @@
package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.List;
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
import net.sacredlabyrinth.Phaed.PreciousStones.field.Field;
import net.sacredlabyrinth.Phaed.PreciousStones.field.FieldFlag;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
public class PreciousStonesFeature extends BukkitMaskManager implements Listener {
public PreciousStonesFeature(Plugin preciousstonesPlugin) {
super(preciousstonesPlugin.getName());
}
public boolean isAllowed(Player player, Field field, MaskType type, boolean allowMember) {
return field != null && (field.isOwner(player.getName()) || type == MaskType.MEMBER && allowMember && field.getAllAllowed().contains(player.getName()));
}
@Override
public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) {
final Player player = BukkitAdapter.adapt(fp);
final Location location = player.getLocation();
final List<Field> fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, location);
if (fields.isEmpty()) {
return null;
}
String name = player.getName();
boolean member = fp.hasPermission("fawe.preciousstones.member");
for (Field myField : fields) {
if (isAllowed(player, myField, type, member)) {
BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz());
BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz());
return new FaweMask(pos1, pos2) {
@Override
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
return isAllowed(BukkitAdapter.adapt(player), myField, type, fp.hasPermission("fawe.preciousstones.member"));
}
};
}
}
return null;
}
}

View File

@ -1,9 +1,6 @@
applyLibrariesConfiguration()
dependencies {
"shade"("FAWE-Piston:core/build/libs/core-${Versions.PISTON}:lastSuccessfulBuild@jar")
"shade"("FAWE-Piston:core-ap/annotations/build/libs/annotations-${Versions.PISTON}:lastSuccessfulBuild@jar")
"shade"("FAWE-Piston:core-ap/processor/build/libs/processor-${Versions.PISTON}:lastSuccessfulBuild@jar")
"shade"("org.enginehub.piston.core-ap:annotations:${Versions.PISTON}")
"shade"("org.enginehub.piston.core-ap:processor:${Versions.PISTON}")
}

View File

@ -11,8 +11,7 @@ dependencies {
"shade"("com.github.luben:zstd-jni:1.4.3-1")
"shade"("com.thoughtworks.paranamer:paranamer:2.6")
"shade"("com.sk89q.lib:jlibnoise:1.0.0")
"shade"("FAWE-Piston:core/build/libs/core-${Versions.PISTON}:lastSuccessfulBuild@jar")
"shade"("FAWE-Piston:core-ap/runtime/build/libs/runtime-${Versions.PISTON}:lastSuccessfulBuild@jar")
"shade"("FAWE-Piston:default-impl/build/libs/default-impl-${Versions.PISTON}:lastSuccessfulBuild@jar")
"shade"("org.enginehub.piston:core:${Versions.PISTON}")
"shade"("org.enginehub.piston.core-ap:runtime:${Versions.PISTON}")
"shade"("org.enginehub.piston:default-impl:${Versions.PISTON}")
}