3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-07 20:10:06 +01:00

Fix Vault integration + remove DummyFAWE

Dieser Commit ist enthalten in:
IronApollo 2020-09-14 21:18:06 -04:00
Ursprung 4243e8e86b
Commit 9431f7c189
5 geänderte Dateien mit 13 neuen und 127 gelöschten Zeilen

Datei anzeigen

@ -53,7 +53,6 @@ public class FaweBukkit implements IFawe, Listener {
private static final Logger log = LoggerFactory.getLogger(FaweBukkit.class);
private final Plugin plugin;
private VaultUtil vault;
private ItemUtil itemUtil;
private boolean listeningImages;
@ -61,10 +60,6 @@ public class FaweBukkit implements IFawe, Listener {
private CFIPacketListener packetListener;
private final boolean chunksStretched;
public VaultUtil getVault() {
return this.vault;
}
public FaweBukkit(Plugin plugin) {
this.plugin = plugin;
try {
@ -87,9 +82,6 @@ public class FaweBukkit implements IFawe, Listener {
chunksStretched =
Integer.parseInt(Bukkit.getBukkitVersion().split("-")[0].split("\\.")[1]) >= 16;
//Vault is Spigot/Paper only so this needs to be done in the Bukkit module
TaskManager.IMP.later(this::setupVault, 0);
//PlotSquared support is limited to Spigot/Paper as of 02/20/2020
TaskManager.IMP.later(this::setupPlotSquared, 0);
@ -177,13 +169,6 @@ public class FaweBukkit implements IFawe, Listener {
return tmp;
}
private void setupVault() {
try {
this.vault = new VaultUtil();
} catch (final Throwable ignored) {
}
}
@Override public String getDebugInfo() {
StringBuilder msg = new StringBuilder();
msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n");

Datei anzeigen

@ -28,7 +28,7 @@ import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultResolver implements PermissionsResolver {
private static Permission perms = null;
public static Permission perms = null;
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
if (server.getPluginManager().getPlugin("Vault") == null) {

Datei anzeigen

@ -26,6 +26,7 @@ import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.util.StringUtil;
import com.sk89q.wepif.VaultResolver;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
@ -240,13 +241,15 @@ public class BukkitPlayer extends AbstractPlayerActor {
* Permissions are used to managing WorldEdit region restrictions
* - The `/wea` command will give/remove the required bypass permission
*/
if (Fawe.<FaweBukkit>imp().getVault() == null || Fawe.<FaweBukkit> imp().getVault().permission == null) {
player.addAttachment(plugin).setPermission(permission, value);
} else if (value) {
if (!Fawe.<FaweBukkit> imp().getVault().permission.playerAdd(player, permission)) {
if(VaultResolver.perms != null){
if(value){
if(!VaultResolver.perms.playerAdd(player, permission)){
player.addAttachment(plugin).setPermission(permission, value);
}
}else if(!VaultResolver.perms.playerRemove(player, permission)){
player.addAttachment(plugin).setPermission(permission, value);
}
} else if (!Fawe.<FaweBukkit>imp().getVault().permission.playerRemove(player, permission)) {
}else{
player.addAttachment(plugin).setPermission(permission, value);
}
}

Datei anzeigen

@ -125,70 +125,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
private BukkitServerInterface server;
private BukkitConfiguration config;
private static Map<String, Plugin> lookupNames;
static {
// Disable AWE as otherwise both fail to load
PluginManager manager = Bukkit.getPluginManager();
try {
Field pluginsField = manager.getClass().getDeclaredField("plugins");
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
pluginsField.setAccessible(true);
lookupNamesField.setAccessible(true);
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
@Override
public boolean add(Plugin plugin) {
if (plugin.getName().startsWith("AsyncWorldEdit")) {
log.debug("Disabling `" + plugin.getName() + "` as it is incompatible");
} else {
return super.add(plugin);
}
return false;
}
});
lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap<String, Plugin>(lookupNames) {
@Override
public Plugin put(@NotNull String key, @NotNull Plugin plugin) {
if (plugin.getName().startsWith("AsyncWorldEdit")) {
return null;
}
return super.put(key, plugin);
}
});
} catch (Throwable ignored) {
}
}
public WorldEditPlugin() {
init();
}
public WorldEditPlugin(JavaPluginLoader loader, PluginDescriptionFile desc, File dataFolder, File jarFile) {
super(loader, desc, dataFolder, jarFile);
init();
}
private void init() {
if (lookupNames != null) {
lookupNames.putIfAbsent("FastAsyncWorldEdit".toLowerCase(Locale.ROOT), this);
lookupNames.putIfAbsent("WorldEdit".toLowerCase(Locale.ROOT), this);
lookupNames.putIfAbsent("FastAsyncWorldEdit", this);
lookupNames.putIfAbsent("WorldEdit", this);
rename();
}
setEnabled(true);
}
@Override
public void onLoad() {
if (INSTANCE != null) {
return;
}
rename();
INSTANCE = this;
FaweBukkit imp = new FaweBukkit(this);
//noinspection ResultOfMethodCallIgnored
getDataFolder().mkdirs();
@ -203,8 +142,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
if (Files.exists(delChunks)) {
ChunkDeleter.runFromFile(delChunks, true);
}
fail(() -> PermissionsResolverManager.initialize(INSTANCE), "Failed to initialize permissions resolver");
}
/**
@ -212,10 +149,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
*/
@Override
public void onEnable() {
if (INSTANCE != null) {
return;
}
onLoad();
FaweBukkit imp = new FaweBukkit(this);
PermissionsResolverManager.initialize(this); // Setup permission resolver
@ -335,44 +270,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
}
}
private void rename() {
File dir = new File(getDataFolder().getParentFile(), "FastAsyncWorldEdit");
try {
Field descriptionField = JavaPlugin.class.getDeclaredField("dataFolder");
descriptionField.setAccessible(true);
descriptionField.set(this, dir);
} catch (Throwable e) {
e.printStackTrace();
}
try {
File pluginsFolder = MainUtil.getJarFile().getParentFile();
for (File file : pluginsFolder.listFiles()) {
if (file.length() == 2052) {
return;
}
}
Plugin plugin = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit");
File dummy = MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "DummyFawe.jar");
if (dummy != null && dummy.exists() && plugin == this) {
try {
Bukkit.getPluginManager().loadPlugin(dummy);
} catch (Throwable e) {
if (Bukkit.getUpdateFolderFile().mkdirs()) {
MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, Bukkit.getUpdateFolder() + File.separator + "DummyFawe.jar");
} else {
getLogger().info("Please delete DummyFawe.jar and restart");
}
}
getLogger().info("Please restart the server if you have any plugins which depend on FAWE.");
} else if (dummy == null) {
MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "update" + File.separator + "DummyFawe.jar");
}
} catch (Throwable e) {
e.printStackTrace();
}
}
private void fail(Runnable run, String message) {
try {
run.run();

Datei anzeigen

@ -1,9 +1,10 @@
name: WorldEdit
name: FastAsyncWorldEdit
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
version: "${internalVersion}"
load: STARTUP
api-version: 1.13
softdepend: [Vault]
provides: [WorldEdit]
website: https://intellectualsites.github.io/download/fawe.html
description: Blazingly fast world manipulation for builders, large networks and developers.
authors: [Empire92, MattBDev, IronApollo, dordsor21, NotMyFault]