Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf29df7bce | ||
|
|
c259cb5a45 | ||
|
|
4148f55bb5 | ||
|
|
b63791c14b | ||
|
|
294dfabd54 | ||
|
|
d7f7cad863 | ||
|
|
afd8df5b48 | ||
|
|
b9d1f36604 | ||
|
|
403a7a7da8 | ||
|
|
f6fb5bcf66 | ||
|
|
194eb8b5f5 |
@@ -5,7 +5,6 @@ import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import com.willfp.eco.util.integrations.antigrief.AntigriefWrapper;
|
||||
@@ -25,7 +24,7 @@ public class AntigriefWorldGuard implements AntigriefWrapper {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
|
||||
if (query.queryState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BUILD) == StateFlag.State.DENY) {
|
||||
if (!query.testBuild(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BLOCK_BREAK)) {
|
||||
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld()));
|
||||
}
|
||||
return true;
|
||||
@@ -40,7 +39,7 @@ public class AntigriefWorldGuard implements AntigriefWrapper {
|
||||
World world = location.getWorld();
|
||||
Validate.notNull(world, "World cannot be null!");
|
||||
|
||||
if (query.queryState(BukkitAdapter.adapt(location), localPlayer, Flags.OTHER_EXPLOSION) == StateFlag.State.DENY) {
|
||||
if (!query.testBuild(BukkitAdapter.adapt(location), localPlayer, Flags.TNT)) {
|
||||
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(world));
|
||||
}
|
||||
return true;
|
||||
@@ -53,7 +52,7 @@ public class AntigriefWorldGuard implements AntigriefWrapper {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
|
||||
if (query.queryState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BLOCK_PLACE) == StateFlag.State.DENY) {
|
||||
if (!query.testBuild(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BLOCK_PLACE)) {
|
||||
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld()));
|
||||
}
|
||||
return true;
|
||||
@@ -67,11 +66,11 @@ public class AntigriefWorldGuard implements AntigriefWrapper {
|
||||
RegionQuery query = container.createQuery();
|
||||
|
||||
if (victim instanceof Player) {
|
||||
if (query.queryState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.PVP) == StateFlag.State.DENY) {
|
||||
if (!query.testBuild(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.PVP)) {
|
||||
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld()));
|
||||
}
|
||||
} else {
|
||||
if (query.queryState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.DAMAGE_ANIMALS) == StateFlag.State.DENY) {
|
||||
if (!query.testBuild(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.DAMAGE_ANIMALS)) {
|
||||
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final File configFile;
|
||||
|
||||
/**
|
||||
* The full name of the config file (eg config.yml).
|
||||
*/
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The subdirectory path.
|
||||
*/
|
||||
@@ -48,6 +54,7 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
||||
@NotNull final String subDirectoryPath,
|
||||
@NotNull final Class<?> source) {
|
||||
super(configName, plugin);
|
||||
this.name = configName + ".yml";
|
||||
this.source = source;
|
||||
this.subDirectoryPath = subDirectoryPath;
|
||||
|
||||
@@ -56,11 +63,11 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
||||
directory.mkdirs();
|
||||
}
|
||||
|
||||
if (!new File(directory, this.getName()).exists()) {
|
||||
if (!new File(directory, this.name).exists()) {
|
||||
createFile();
|
||||
}
|
||||
|
||||
this.configFile = new File(directory, this.getName());
|
||||
this.configFile = new File(directory, this.name);
|
||||
init(YamlConfiguration.loadConfiguration(configFile));
|
||||
}
|
||||
|
||||
@@ -100,9 +107,9 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
||||
String resourcePath;
|
||||
|
||||
if (subDirectoryPath.isEmpty()) {
|
||||
resourcePath = this.getName();
|
||||
resourcePath = name;
|
||||
} else {
|
||||
resourcePath = subDirectoryPath + this.getName();
|
||||
resourcePath = subDirectoryPath + name;
|
||||
}
|
||||
|
||||
return "/" + resourcePath;
|
||||
@@ -117,7 +124,7 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
||||
InputStream newIn = source.getResourceAsStream(getResourcePath());
|
||||
|
||||
if (newIn == null) {
|
||||
throw new NullPointerException(this.getName() + " is null?");
|
||||
throw new NullPointerException(name + " is null?");
|
||||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8));
|
||||
|
||||
@@ -23,12 +23,6 @@ public abstract class AbstractUndefinedConfig extends PluginDependent {
|
||||
@Getter(AccessLevel.PUBLIC)
|
||||
protected YamlConfiguration config = null;
|
||||
|
||||
/**
|
||||
* The full name of the config file (eg config.yml).
|
||||
*/
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Cached values for faster reading.
|
||||
*/
|
||||
@@ -43,7 +37,6 @@ public abstract class AbstractUndefinedConfig extends PluginDependent {
|
||||
protected AbstractUndefinedConfig(@NotNull final String configName,
|
||||
@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
this.name = configName + ".yml";
|
||||
}
|
||||
|
||||
protected void init(@NotNull final YamlConfiguration config) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@UtilityClass
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Display {
|
||||
/**
|
||||
* The prefix for lore lines.
|
||||
@@ -40,6 +41,8 @@ public class Display {
|
||||
public void registerDisplayModule(@NotNull final DisplayModule module) {
|
||||
List<DisplayModule> modules = MODULES.get(module.getPriority());
|
||||
|
||||
modules.removeIf(module1 -> module1.getPluginName().equalsIgnoreCase(module.getPluginName()));
|
||||
|
||||
modules.add(module);
|
||||
|
||||
MODULES.put(module.getPriority(), modules);
|
||||
@@ -57,6 +60,15 @@ public class Display {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
Map<String, Object[]> pluginVarArgs = new HashMap<>();
|
||||
|
||||
for (DisplayPriority priority : DisplayPriority.values()) {
|
||||
List<DisplayModule> modules = MODULES.get(priority);
|
||||
for (DisplayModule module : modules) {
|
||||
pluginVarArgs.put(module.getPluginName(), module.generateVarArgs(itemStack));
|
||||
}
|
||||
}
|
||||
|
||||
revert(itemStack);
|
||||
|
||||
if (!itemStack.hasItemMeta()) {
|
||||
@@ -72,7 +84,12 @@ public class Display {
|
||||
for (DisplayPriority priority : DisplayPriority.values()) {
|
||||
List<DisplayModule> modules = MODULES.get(priority);
|
||||
for (DisplayModule module : modules) {
|
||||
module.display(itemStack);
|
||||
Object[] varargs = pluginVarArgs.get(module.getPluginName());
|
||||
if (varargs.length == 0) {
|
||||
module.display(itemStack);
|
||||
} else {
|
||||
module.display(itemStack, varargs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,13 +29,51 @@ public abstract class DisplayModule extends PluginDependent {
|
||||
* Display an item.
|
||||
*
|
||||
* @param itemStack The item.
|
||||
* @param args Optional args for display.
|
||||
*/
|
||||
protected abstract void display(@NotNull ItemStack itemStack);
|
||||
protected void display(@NotNull final ItemStack itemStack,
|
||||
@NotNull final Object... args) {
|
||||
// Technically optional.
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an item.
|
||||
* <p>
|
||||
* This method exists for parity with older plugins that don't include the varargs.
|
||||
*
|
||||
* @param itemStack The item.
|
||||
* @deprecated Use {@link this#display(ItemStack, Object...)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
protected void display(@NotNull final ItemStack itemStack) {
|
||||
// Technically optional.
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert an item.
|
||||
*
|
||||
* @param itemStack The item.
|
||||
*/
|
||||
protected abstract void revert(@NotNull ItemStack itemStack);
|
||||
protected void revert(@NotNull final ItemStack itemStack) {
|
||||
// Technically optoinal.
|
||||
}
|
||||
|
||||
/**
|
||||
* Create varargs to pass back to itemstack after reverting, but before display.
|
||||
*
|
||||
* @param itemStack The itemStack.
|
||||
* @return The plugin-specific varargs.
|
||||
*/
|
||||
protected Object[] generateVarArgs(@NotNull final ItemStack itemStack) {
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of plugin.
|
||||
*
|
||||
* @return The plugin name.
|
||||
*/
|
||||
final String getPluginName() {
|
||||
return super.getPlugin().getPluginName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 4.1.0
|
||||
version = 4.2.0
|
||||
plugin-name = eco
|
||||
Reference in New Issue
Block a user