Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Fix Vault integration + remove DummyFAWE
Dieser Commit ist enthalten in:
Ursprung
4243e8e86b
Commit
9431f7c189
@ -53,7 +53,6 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(FaweBukkit.class);
|
private static final Logger log = LoggerFactory.getLogger(FaweBukkit.class);
|
||||||
|
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
private VaultUtil vault;
|
|
||||||
private ItemUtil itemUtil;
|
private ItemUtil itemUtil;
|
||||||
|
|
||||||
private boolean listeningImages;
|
private boolean listeningImages;
|
||||||
@ -61,10 +60,6 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
private CFIPacketListener packetListener;
|
private CFIPacketListener packetListener;
|
||||||
private final boolean chunksStretched;
|
private final boolean chunksStretched;
|
||||||
|
|
||||||
public VaultUtil getVault() {
|
|
||||||
return this.vault;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FaweBukkit(Plugin plugin) {
|
public FaweBukkit(Plugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
try {
|
try {
|
||||||
@ -87,9 +82,6 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
chunksStretched =
|
chunksStretched =
|
||||||
Integer.parseInt(Bukkit.getBukkitVersion().split("-")[0].split("\\.")[1]) >= 16;
|
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
|
//PlotSquared support is limited to Spigot/Paper as of 02/20/2020
|
||||||
TaskManager.IMP.later(this::setupPlotSquared, 0);
|
TaskManager.IMP.later(this::setupPlotSquared, 0);
|
||||||
|
|
||||||
@ -177,13 +169,6 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupVault() {
|
|
||||||
try {
|
|
||||||
this.vault = new VaultUtil();
|
|
||||||
} catch (final Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String getDebugInfo() {
|
@Override public String getDebugInfo() {
|
||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n");
|
msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n");
|
||||||
|
@ -28,7 +28,7 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
|||||||
|
|
||||||
public class VaultResolver implements PermissionsResolver {
|
public class VaultResolver implements PermissionsResolver {
|
||||||
|
|
||||||
private static Permission perms = null;
|
public static Permission perms = null;
|
||||||
|
|
||||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||||
if (server.getPluginManager().getPlugin("Vault") == null) {
|
if (server.getPluginManager().getPlugin("Vault") == null) {
|
||||||
|
@ -26,6 +26,7 @@ import com.boydti.fawe.config.Settings;
|
|||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
|
import com.sk89q.wepif.VaultResolver;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
@ -240,13 +241,15 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
* Permissions are used to managing WorldEdit region restrictions
|
* Permissions are used to managing WorldEdit region restrictions
|
||||||
* - The `/wea` command will give/remove the required bypass permission
|
* - The `/wea` command will give/remove the required bypass permission
|
||||||
*/
|
*/
|
||||||
if (Fawe.<FaweBukkit>imp().getVault() == null || Fawe.<FaweBukkit> imp().getVault().permission == null) {
|
if(VaultResolver.perms != null){
|
||||||
player.addAttachment(plugin).setPermission(permission, value);
|
if(value){
|
||||||
} else if (value) {
|
if(!VaultResolver.perms.playerAdd(player, permission)){
|
||||||
if (!Fawe.<FaweBukkit> imp().getVault().permission.playerAdd(player, permission)) {
|
|
||||||
player.addAttachment(plugin).setPermission(permission, value);
|
player.addAttachment(plugin).setPermission(permission, value);
|
||||||
}
|
}
|
||||||
} else if (!Fawe.<FaweBukkit>imp().getVault().permission.playerRemove(player, permission)) {
|
}else if(!VaultResolver.perms.playerRemove(player, permission)){
|
||||||
|
player.addAttachment(plugin).setPermission(permission, value);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
player.addAttachment(plugin).setPermission(permission, value);
|
player.addAttachment(plugin).setPermission(permission, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,70 +125,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
|||||||
private BukkitServerInterface server;
|
private BukkitServerInterface server;
|
||||||
private BukkitConfiguration config;
|
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
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
if (INSTANCE != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
rename();
|
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
FaweBukkit imp = new FaweBukkit(this);
|
|
||||||
|
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
getDataFolder().mkdirs();
|
getDataFolder().mkdirs();
|
||||||
@ -203,8 +142,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
|||||||
if (Files.exists(delChunks)) {
|
if (Files.exists(delChunks)) {
|
||||||
ChunkDeleter.runFromFile(delChunks, true);
|
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
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
if (INSTANCE != null) {
|
|
||||||
return;
|
FaweBukkit imp = new FaweBukkit(this);
|
||||||
}
|
|
||||||
onLoad();
|
|
||||||
|
|
||||||
PermissionsResolverManager.initialize(this); // Setup permission resolver
|
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) {
|
private void fail(Runnable run, String message) {
|
||||||
try {
|
try {
|
||||||
run.run();
|
run.run();
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
name: WorldEdit
|
name: FastAsyncWorldEdit
|
||||||
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
|
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
|
||||||
version: "${internalVersion}"
|
version: "${internalVersion}"
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
softdepend: [Vault]
|
softdepend: [Vault]
|
||||||
|
provides: [WorldEdit]
|
||||||
website: https://intellectualsites.github.io/download/fawe.html
|
website: https://intellectualsites.github.io/download/fawe.html
|
||||||
description: Blazingly fast world manipulation for builders, large networks and developers.
|
description: Blazingly fast world manipulation for builders, large networks and developers.
|
||||||
authors: [Empire92, MattBDev, IronApollo, dordsor21, NotMyFault]
|
authors: [Empire92, MattBDev, IronApollo, dordsor21, NotMyFault]
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren