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.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
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.RegionContainer;
|
||||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
import com.willfp.eco.util.integrations.antigrief.AntigriefWrapper;
|
import com.willfp.eco.util.integrations.antigrief.AntigriefWrapper;
|
||||||
@@ -25,7 +24,7 @@ public class AntigriefWorldGuard implements AntigriefWrapper {
|
|||||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
RegionQuery query = container.createQuery();
|
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 WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -40,7 +39,7 @@ public class AntigriefWorldGuard implements AntigriefWrapper {
|
|||||||
World world = location.getWorld();
|
World world = location.getWorld();
|
||||||
Validate.notNull(world, "World cannot be null!");
|
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 WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(world));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -53,7 +52,7 @@ public class AntigriefWorldGuard implements AntigriefWrapper {
|
|||||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
RegionQuery query = container.createQuery();
|
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 WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -67,11 +66,11 @@ public class AntigriefWorldGuard implements AntigriefWrapper {
|
|||||||
RegionQuery query = container.createQuery();
|
RegionQuery query = container.createQuery();
|
||||||
|
|
||||||
if (victim instanceof Player) {
|
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()));
|
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld()));
|
||||||
}
|
}
|
||||||
} else {
|
} 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()));
|
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
|||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
private final File configFile;
|
private final File configFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full name of the config file (eg config.yml).
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The subdirectory path.
|
* The subdirectory path.
|
||||||
*/
|
*/
|
||||||
@@ -48,6 +54,7 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
|||||||
@NotNull final String subDirectoryPath,
|
@NotNull final String subDirectoryPath,
|
||||||
@NotNull final Class<?> source) {
|
@NotNull final Class<?> source) {
|
||||||
super(configName, plugin);
|
super(configName, plugin);
|
||||||
|
this.name = configName + ".yml";
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.subDirectoryPath = subDirectoryPath;
|
this.subDirectoryPath = subDirectoryPath;
|
||||||
|
|
||||||
@@ -56,11 +63,11 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
|||||||
directory.mkdirs();
|
directory.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!new File(directory, this.getName()).exists()) {
|
if (!new File(directory, this.name).exists()) {
|
||||||
createFile();
|
createFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.configFile = new File(directory, this.getName());
|
this.configFile = new File(directory, this.name);
|
||||||
init(YamlConfiguration.loadConfiguration(configFile));
|
init(YamlConfiguration.loadConfiguration(configFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,9 +107,9 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
|||||||
String resourcePath;
|
String resourcePath;
|
||||||
|
|
||||||
if (subDirectoryPath.isEmpty()) {
|
if (subDirectoryPath.isEmpty()) {
|
||||||
resourcePath = this.getName();
|
resourcePath = name;
|
||||||
} else {
|
} else {
|
||||||
resourcePath = subDirectoryPath + this.getName();
|
resourcePath = subDirectoryPath + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "/" + resourcePath;
|
return "/" + resourcePath;
|
||||||
@@ -117,7 +124,7 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig {
|
|||||||
InputStream newIn = source.getResourceAsStream(getResourcePath());
|
InputStream newIn = source.getResourceAsStream(getResourcePath());
|
||||||
|
|
||||||
if (newIn == null) {
|
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));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8));
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ public abstract class AbstractUndefinedConfig extends PluginDependent {
|
|||||||
@Getter(AccessLevel.PUBLIC)
|
@Getter(AccessLevel.PUBLIC)
|
||||||
protected YamlConfiguration config = null;
|
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.
|
* Cached values for faster reading.
|
||||||
*/
|
*/
|
||||||
@@ -43,7 +37,6 @@ public abstract class AbstractUndefinedConfig extends PluginDependent {
|
|||||||
protected AbstractUndefinedConfig(@NotNull final String configName,
|
protected AbstractUndefinedConfig(@NotNull final String configName,
|
||||||
@NotNull final AbstractEcoPlugin plugin) {
|
@NotNull final AbstractEcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.name = configName + ".yml";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(@NotNull final YamlConfiguration config) {
|
protected void init(@NotNull final YamlConfiguration config) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class Display {
|
public class Display {
|
||||||
/**
|
/**
|
||||||
* The prefix for lore lines.
|
* The prefix for lore lines.
|
||||||
@@ -40,6 +41,8 @@ public class Display {
|
|||||||
public void registerDisplayModule(@NotNull final DisplayModule module) {
|
public void registerDisplayModule(@NotNull final DisplayModule module) {
|
||||||
List<DisplayModule> modules = MODULES.get(module.getPriority());
|
List<DisplayModule> modules = MODULES.get(module.getPriority());
|
||||||
|
|
||||||
|
modules.removeIf(module1 -> module1.getPluginName().equalsIgnoreCase(module.getPluginName()));
|
||||||
|
|
||||||
modules.add(module);
|
modules.add(module);
|
||||||
|
|
||||||
MODULES.put(module.getPriority(), modules);
|
MODULES.put(module.getPriority(), modules);
|
||||||
@@ -57,6 +60,15 @@ public class Display {
|
|||||||
return itemStack;
|
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);
|
revert(itemStack);
|
||||||
|
|
||||||
if (!itemStack.hasItemMeta()) {
|
if (!itemStack.hasItemMeta()) {
|
||||||
@@ -72,7 +84,12 @@ public class Display {
|
|||||||
for (DisplayPriority priority : DisplayPriority.values()) {
|
for (DisplayPriority priority : DisplayPriority.values()) {
|
||||||
List<DisplayModule> modules = MODULES.get(priority);
|
List<DisplayModule> modules = MODULES.get(priority);
|
||||||
for (DisplayModule module : modules) {
|
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.
|
* Display an item.
|
||||||
*
|
*
|
||||||
* @param itemStack The 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.
|
* Revert an item.
|
||||||
*
|
*
|
||||||
* @param itemStack The 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
|
plugin-name = eco
|
||||||
Reference in New Issue
Block a user