Pull Request Fixes / Changes, config changes
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
package com.willfp.eco.core.drops;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.events.DropQueuePushEvent;
|
||||
import com.willfp.eco.core.integrations.antigrief.AntigriefManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -21,11 +18,6 @@ import java.util.Collection;
|
||||
* @see com.willfp.eco.util.TelekinesisUtils
|
||||
*/
|
||||
public class DropQueue {
|
||||
|
||||
private Location location;
|
||||
private boolean forceTelekinesis = false;
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* The internally used {@link DropQueue}.
|
||||
*/
|
||||
@@ -36,7 +28,6 @@ public class DropQueue {
|
||||
*/
|
||||
public DropQueue(@NotNull final Player player) {
|
||||
handle = Eco.getHandler().getDropQueueFactory().create(player);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +71,6 @@ public class DropQueue {
|
||||
*/
|
||||
public DropQueue setLocation(@NotNull final Location location) {
|
||||
handle.setLocation(location);
|
||||
this.location = location;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -91,7 +81,6 @@ public class DropQueue {
|
||||
*/
|
||||
public DropQueue forceTelekinesis() {
|
||||
handle.forceTelekinesis();
|
||||
this.forceTelekinesis = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -99,11 +88,6 @@ public class DropQueue {
|
||||
* Push the queue.
|
||||
*/
|
||||
public void push() {
|
||||
if (!AntigriefManager.canPickupItem(this.player, this.location)) return;
|
||||
DropQueuePushEvent event = new DropQueuePushEvent(this.player, this.handle, this, this.forceTelekinesis);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
handle.push();
|
||||
}
|
||||
handle.push();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,40 @@
|
||||
package com.willfp.eco.core.events;
|
||||
|
||||
import com.willfp.eco.core.drops.DropQueue;
|
||||
import com.willfp.eco.core.drops.InternalDropQueue;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class DropQueuePushEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
/**
|
||||
* Queue handle.
|
||||
*/
|
||||
private final InternalDropQueue handle;
|
||||
|
||||
/**
|
||||
* Queue itself.
|
||||
*/
|
||||
private final DropQueue queue;
|
||||
|
||||
/**
|
||||
* Cancel state.
|
||||
*/
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* Force telekinesis state
|
||||
* If telekinetic.
|
||||
*/
|
||||
private final boolean forceTelekinesis;
|
||||
private final boolean isTelekinetic;
|
||||
|
||||
/**
|
||||
* The items.
|
||||
*/
|
||||
private final Collection<? extends ItemStack> items;
|
||||
|
||||
/**
|
||||
* The xp.
|
||||
*/
|
||||
private final int xp;
|
||||
|
||||
/**
|
||||
* The location.
|
||||
*/
|
||||
private final Location location;
|
||||
|
||||
/**
|
||||
* Bukkit parity.
|
||||
@@ -36,15 +42,24 @@ public class DropQueuePushEvent extends PlayerEvent implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
/**
|
||||
* Create a new ArmorEquipEvent.
|
||||
* Create a new DropQueuePushEvent.
|
||||
*
|
||||
* @param player The player.
|
||||
* @param player The player.
|
||||
* @param items The items.
|
||||
* @param location The location.
|
||||
* @param xp The xp.
|
||||
* @param isTelekinetic If the event is telekinetic.
|
||||
*/
|
||||
public DropQueuePushEvent(@NotNull final Player player, @NotNull final InternalDropQueue handle, @NotNull final DropQueue queue, final boolean forceTelekinesis) {
|
||||
public DropQueuePushEvent(@NotNull final Player player,
|
||||
@NotNull final Collection<? extends ItemStack> items,
|
||||
@NotNull final Location location,
|
||||
final int xp,
|
||||
final boolean isTelekinetic) {
|
||||
super(player);
|
||||
this.handle = handle;
|
||||
this.queue = queue;
|
||||
this.forceTelekinesis = forceTelekinesis;
|
||||
this.items = items;
|
||||
this.location = location;
|
||||
this.xp = xp;
|
||||
this.isTelekinetic = isTelekinetic;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,29 +95,38 @@ public class DropQueuePushEvent extends PlayerEvent implements Cancellable {
|
||||
/**
|
||||
* Set cancel state.
|
||||
*
|
||||
* @param b The state.
|
||||
* @param cancelled If cancelled.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean b) {
|
||||
this.cancelled = b;
|
||||
public void setCancelled(final boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get queue handle.
|
||||
* Get the items to be dropped.
|
||||
*
|
||||
* @return The handle.
|
||||
* @return The items.
|
||||
*/
|
||||
public InternalDropQueue getHandle() {
|
||||
return handle;
|
||||
public Collection<? extends ItemStack> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get queue.
|
||||
* Get the xp to be dropped.
|
||||
*
|
||||
* @return The queue.
|
||||
* @return The xp.
|
||||
*/
|
||||
public DropQueue getQueue() {
|
||||
return queue;
|
||||
public int getXp() {
|
||||
return xp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the location.
|
||||
*
|
||||
* @return The location.
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,8 +134,7 @@ public class DropQueuePushEvent extends PlayerEvent implements Cancellable {
|
||||
*
|
||||
* @return The force telekinesis state.
|
||||
*/
|
||||
public boolean isForceTelekinesis() {
|
||||
return this.forceTelekinesis;
|
||||
public boolean isTelekinetic() {
|
||||
return this.isTelekinetic;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.willfp.eco.core.integrations.antigrief;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -57,7 +56,7 @@ public final class AntigriefManager {
|
||||
* @return If player can break block.
|
||||
*/
|
||||
public static boolean canBreakBlock(@NotNull final Player player,
|
||||
@NotNull final Block block) {
|
||||
@NotNull final Block block) {
|
||||
return REGISTERED.stream().allMatch(antigriefWrapper -> antigriefWrapper.canBreakBlock(player, block));
|
||||
}
|
||||
|
||||
@@ -69,7 +68,7 @@ public final class AntigriefManager {
|
||||
* @return If player can create explosion.
|
||||
*/
|
||||
public static boolean canCreateExplosion(@NotNull final Player player,
|
||||
@NotNull final Location location) {
|
||||
@NotNull final Location location) {
|
||||
return REGISTERED.stream().allMatch(antigriefWrapper -> antigriefWrapper.canCreateExplosion(player, location));
|
||||
}
|
||||
|
||||
@@ -81,7 +80,7 @@ public final class AntigriefManager {
|
||||
* @return If player can place block.
|
||||
*/
|
||||
public static boolean canPlaceBlock(@NotNull final Player player,
|
||||
@NotNull final Block block) {
|
||||
@NotNull final Block block) {
|
||||
return REGISTERED.stream().allMatch(antigriefWrapper -> antigriefWrapper.canPlaceBlock(player, block));
|
||||
}
|
||||
|
||||
@@ -93,7 +92,7 @@ public final class AntigriefManager {
|
||||
* @return If player can injure.
|
||||
*/
|
||||
public static boolean canInjure(@NotNull final Player player,
|
||||
@NotNull final LivingEntity victim) {
|
||||
@NotNull final LivingEntity victim) {
|
||||
return REGISTERED.stream().allMatch(antigriefWrapper -> antigriefWrapper.canInjure(player, victim));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface AntigriefWrapper extends Integration {
|
||||
* @param block The block.
|
||||
* @return If player can break block.
|
||||
*/
|
||||
boolean canBreakBlock(Player player, Block block);
|
||||
boolean canBreakBlock(@NotNull Player player, @NotNull Block block);
|
||||
|
||||
/**
|
||||
* Can player create explosion at location.
|
||||
@@ -27,7 +27,7 @@ public interface AntigriefWrapper extends Integration {
|
||||
* @param location The location.
|
||||
* @return If player can create explosion.
|
||||
*/
|
||||
boolean canCreateExplosion(Player player, Location location);
|
||||
boolean canCreateExplosion(@NotNull Player player, @NotNull Location location);
|
||||
|
||||
/**
|
||||
* Can player place block.
|
||||
@@ -36,7 +36,7 @@ public interface AntigriefWrapper extends Integration {
|
||||
* @param block The block.
|
||||
* @return If player can place block.
|
||||
*/
|
||||
boolean canPlaceBlock(Player player, Block block);
|
||||
boolean canPlaceBlock(@NotNull Player player, @NotNull Block block);
|
||||
|
||||
/**
|
||||
* Can player injure living entity.
|
||||
@@ -45,7 +45,7 @@ public interface AntigriefWrapper extends Integration {
|
||||
* @param victim The victim.
|
||||
* @return If player can injure.
|
||||
*/
|
||||
boolean canInjure(Player player, LivingEntity victim);
|
||||
boolean canInjure(@NotNull Player player, @NotNull LivingEntity victim);
|
||||
|
||||
/**
|
||||
* Can player pick up item.
|
||||
@@ -54,6 +54,6 @@ public interface AntigriefWrapper extends Integration {
|
||||
* @param location The location.
|
||||
* @return If player can pick up item.
|
||||
*/
|
||||
boolean canPickupItem(@NotNull final Player player, @NotNull final Location location);
|
||||
boolean canPickupItem(@NotNull Player player, @NotNull Location location);
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public final class Items {
|
||||
* @param item The item.
|
||||
*/
|
||||
public static void registerCustomItem(@NotNull final NamespacedKey key,
|
||||
@NotNull final TestableItem item) {
|
||||
@NotNull final TestableItem item) {
|
||||
REGISTRY.put(key, item);
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ public final class Items {
|
||||
* @param key The lookup string.
|
||||
* @return The testable item, or an {@link EmptyTestableItem}.
|
||||
*/
|
||||
@NotNull
|
||||
public static TestableItem lookup(@NotNull final String key) {
|
||||
if (key.contains("?")) {
|
||||
String[] options = key.split("\\?");
|
||||
@@ -236,16 +237,32 @@ public final class Items {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TestableItem from ItemStack
|
||||
* Get a Testable Item from an ItemStack.
|
||||
* <p>
|
||||
* Will search for registered items first. If there are no matches in the registry,
|
||||
* then it will return a {@link MaterialTestableItem} matching the item type.
|
||||
* <p>
|
||||
* Does not account for modifiers (arg parser data).
|
||||
*
|
||||
* @param item The item
|
||||
* @return TestableItem
|
||||
* @param item The ItemStack.
|
||||
* @return The found Testable Item.
|
||||
*/
|
||||
@NotNull
|
||||
public static TestableItem getItem(@Nullable final ItemStack item) {
|
||||
if (item == null || item.getType().isAir()) return new EmptyTestableItem();
|
||||
if (isCustomItem(item)) return getCustomItem(item);
|
||||
for (TestableItem value : REGISTRY.values()) {
|
||||
if (value.matches(item)) return value;
|
||||
if (item == null || item.getType().isAir()) {
|
||||
return new EmptyTestableItem();
|
||||
}
|
||||
|
||||
CustomItem customItem = getCustomItem(item);
|
||||
|
||||
if (customItem != null) {
|
||||
return customItem;
|
||||
}
|
||||
|
||||
for (TestableItem known : REGISTRY.values()) {
|
||||
if (known.matches(item)) {
|
||||
return known;
|
||||
}
|
||||
}
|
||||
return new MaterialTestableItem(item.getType());
|
||||
}
|
||||
@@ -299,6 +316,7 @@ public final class Items {
|
||||
* @param item The item.
|
||||
* @return The CustomItem.
|
||||
*/
|
||||
@NotNull
|
||||
public static CustomItem getOrWrap(@NotNull final TestableItem item) {
|
||||
if (item instanceof CustomItem) {
|
||||
return (CustomItem) item;
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.willfp.eco.core.items.args;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class LeatherArmorColorArgParser implements LookupArgParser {
|
||||
@Override
|
||||
public @Nullable Predicate<ItemStack> parseArguments(@NotNull String[] args, @NotNull ItemMeta meta) {
|
||||
|
||||
if (!(meta instanceof LeatherArmorMeta)) return pred -> false;
|
||||
|
||||
for (String arg : args) {
|
||||
String[] argSplit = arg.split(":");
|
||||
if (!argSplit[0].equalsIgnoreCase("color")) {
|
||||
continue;
|
||||
}
|
||||
if (argSplit.length < 2) {
|
||||
continue;
|
||||
}
|
||||
String asString = argSplit[1];
|
||||
|
||||
LeatherArmorMeta lMeta = (LeatherArmorMeta) meta;
|
||||
|
||||
lMeta.setColor(fromString(asString));
|
||||
|
||||
return pred -> true;
|
||||
}
|
||||
|
||||
return pred -> false;
|
||||
|
||||
}
|
||||
|
||||
private Color fromString(String color) {
|
||||
|
||||
if (color.contains(",")) {
|
||||
|
||||
String[] split = color.split(",");
|
||||
|
||||
int red = 0;
|
||||
int green = 0;
|
||||
int blue = 0;
|
||||
|
||||
if (split.length > 0) {
|
||||
red = Integer.parseInt(split[0]);
|
||||
}
|
||||
if (split.length > 1) {
|
||||
green = Integer.parseInt(split[1]);
|
||||
}
|
||||
if (split.length > 2) {
|
||||
blue = Integer.parseInt(split[2]);
|
||||
}
|
||||
|
||||
return Color.fromRGB(red, green, blue);
|
||||
|
||||
} else if (color.startsWith("#")) {
|
||||
|
||||
java.awt.Color from = java.awt.Color.decode(color);
|
||||
|
||||
return Color.fromRGB(from.getRed(), from.getGreen(), from.getBlue());
|
||||
|
||||
} else {
|
||||
return fromString("#"+color);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -4,10 +4,8 @@ import com.willfp.eco.core.PluginLike
|
||||
import com.willfp.eco.core.config.interfaces.LoadableConfig
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.FileOutputStream
|
||||
import java.io.FileReader
|
||||
import java.io.IOException
|
||||
import java.io.OutputStream
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardOpenOption
|
||||
|
||||
@@ -30,19 +28,11 @@ open class EcoLoadableJSONConfig(
|
||||
}
|
||||
}
|
||||
|
||||
override fun createFile() {
|
||||
val inputStream = source.getResourceAsStream(resourcePath)!!
|
||||
final override fun createFile() {
|
||||
val inputFile = File(source.getResource(resourcePath)!!.path)
|
||||
val outFile = File(this.plugin.dataFolder, resourcePath)
|
||||
val lastIndex = resourcePath.lastIndexOf('/')
|
||||
val outDir = File(this.plugin.dataFolder, resourcePath.substring(0, lastIndex.coerceAtLeast(0)))
|
||||
if (!outDir.exists()) {
|
||||
outDir.mkdirs()
|
||||
}
|
||||
if (!outFile.exists()) {
|
||||
val out: OutputStream = FileOutputStream(outFile)
|
||||
inputStream.copyTo(out, 1024)
|
||||
out.close()
|
||||
inputStream.close()
|
||||
inputFile.copyTo(outFile, true, 1024)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@ import com.willfp.eco.core.config.interfaces.WrappedYamlConfiguration
|
||||
import org.bukkit.configuration.InvalidConfigurationException
|
||||
import org.bukkit.configuration.file.YamlConfiguration
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.OutputStream
|
||||
|
||||
open class EcoLoadableYamlConfig(
|
||||
configName: String,
|
||||
@@ -31,20 +29,11 @@ open class EcoLoadableYamlConfig(
|
||||
}
|
||||
|
||||
final override fun createFile() {
|
||||
val inputStream = source.getResourceAsStream(resourcePath)!!
|
||||
val inputFile = File(source.getResource(resourcePath)!!.path)
|
||||
val outFile = File(this.plugin.dataFolder, resourcePath)
|
||||
val lastIndex = resourcePath.lastIndexOf('/')
|
||||
val outDir = File(this.plugin.dataFolder, resourcePath.substring(0, lastIndex.coerceAtLeast(0)))
|
||||
if (!outDir.exists()) {
|
||||
outDir.mkdirs()
|
||||
}
|
||||
if (!outFile.exists()) {
|
||||
val out: OutputStream = FileOutputStream(outFile)
|
||||
inputStream.copyTo(out, 1024)
|
||||
out.close()
|
||||
inputStream.close()
|
||||
inputFile.copyTo(outFile, true, 1024)
|
||||
}
|
||||
plugin.configHandler.addConfig(this)
|
||||
}
|
||||
|
||||
override fun getResourcePath(): String {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.willfp.eco.internal.drops.impl
|
||||
|
||||
import com.willfp.eco.core.drops.InternalDropQueue
|
||||
import com.willfp.eco.core.events.DropQueuePushEvent
|
||||
import com.willfp.eco.core.integrations.antigrief.AntigriefManager
|
||||
import com.willfp.eco.util.TelekinesisUtils
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Location
|
||||
@@ -15,7 +17,7 @@ import org.bukkit.util.Vector
|
||||
open class EcoDropQueue(val player: Player) : InternalDropQueue {
|
||||
val items = mutableListOf<ItemStack>()
|
||||
var xp: Int = 0
|
||||
var loc: Location
|
||||
var location: Location
|
||||
var hasTelekinesis = false
|
||||
|
||||
override fun addItem(item: ItemStack): InternalDropQueue {
|
||||
@@ -34,7 +36,7 @@ open class EcoDropQueue(val player: Player) : InternalDropQueue {
|
||||
}
|
||||
|
||||
override fun setLocation(location: Location): InternalDropQueue {
|
||||
loc = location
|
||||
this.location = location
|
||||
return this
|
||||
}
|
||||
|
||||
@@ -47,8 +49,20 @@ open class EcoDropQueue(val player: Player) : InternalDropQueue {
|
||||
if (!hasTelekinesis) {
|
||||
hasTelekinesis = TelekinesisUtils.testPlayer(player)
|
||||
}
|
||||
val world = loc.world!!
|
||||
loc = loc.add(0.5, 0.5, 0.5)
|
||||
|
||||
if (hasTelekinesis && !AntigriefManager.canPickupItem(player, location)) {
|
||||
hasTelekinesis = false
|
||||
}
|
||||
|
||||
val event = DropQueuePushEvent(player, items, location, xp, hasTelekinesis)
|
||||
Bukkit.getServer().pluginManager.callEvent(event)
|
||||
|
||||
if (event.isCancelled) {
|
||||
return
|
||||
}
|
||||
|
||||
val world = location.world!!
|
||||
location = location.add(0.5, 0.5, 0.5)
|
||||
items.removeIf { itemStack: ItemStack -> itemStack.type == Material.AIR }
|
||||
if (items.isEmpty()) {
|
||||
return
|
||||
@@ -56,7 +70,7 @@ open class EcoDropQueue(val player: Player) : InternalDropQueue {
|
||||
if (hasTelekinesis) {
|
||||
val leftover = player.inventory.addItem(*items.toTypedArray())
|
||||
for (drop in leftover.values) {
|
||||
world.dropItem(loc, drop!!).velocity = Vector()
|
||||
world.dropItem(location, drop!!).velocity = Vector()
|
||||
}
|
||||
if (xp > 0) {
|
||||
val event = PlayerExpChangeEvent(player, xp)
|
||||
@@ -68,16 +82,16 @@ open class EcoDropQueue(val player: Player) : InternalDropQueue {
|
||||
}
|
||||
} else {
|
||||
for (drop in items) {
|
||||
world.dropItem(loc, drop).velocity = Vector()
|
||||
world.dropItem(location, drop).velocity = Vector()
|
||||
}
|
||||
if (xp > 0) {
|
||||
val orb = world.spawnEntity(loc, EntityType.EXPERIENCE_ORB) as ExperienceOrb
|
||||
val orb = world.spawnEntity(location, EntityType.EXPERIENCE_ORB) as ExperienceOrb
|
||||
orb.experience = xp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
loc = player.location
|
||||
location = player.location
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,10 @@ class EcoFastCollatedDropQueue(player: Player) : EcoDropQueue(player) {
|
||||
val fetched = COLLATED_MAP[player]
|
||||
|
||||
if (fetched == null) {
|
||||
COLLATED_MAP[player] = CollatedDrops(items, loc, xp, hasTelekinesis)
|
||||
COLLATED_MAP[player] = CollatedDrops(items, location, xp, hasTelekinesis)
|
||||
} else {
|
||||
fetched.addDrops(items)
|
||||
fetched.location = loc
|
||||
fetched.location = location
|
||||
fetched.addXp(xp)
|
||||
if (this.hasTelekinesis) {
|
||||
fetched.forceTelekinesis()
|
||||
|
||||
@@ -69,6 +69,7 @@ import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsItemsA
|
||||
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsOraxen
|
||||
import com.willfp.eco.internal.spigot.integrations.economy.EconomyVault
|
||||
import com.willfp.eco.internal.spigot.integrations.hologram.HologramCMI
|
||||
import com.willfp.eco.internal.spigot.integrations.hologram.HologramDecentHolograms
|
||||
import com.willfp.eco.internal.spigot.integrations.hologram.HologramHolographicDisplays
|
||||
import com.willfp.eco.internal.spigot.integrations.mcmmo.McmmoIntegrationImpl
|
||||
import com.willfp.eco.internal.spigot.integrations.multiverseinventories.MultiverseInventoriesIntegration
|
||||
@@ -218,6 +219,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
// Hologram
|
||||
IntegrationLoader("HolographicDisplays") { HologramManager.register(HologramHolographicDisplays(this)) },
|
||||
IntegrationLoader("CMI") { HologramManager.register(HologramCMI()) },
|
||||
IntegrationLoader("DecentHolograms") { HologramManager.register(HologramDecentHolograms()) },
|
||||
//IntegrationLoader("GHolo") { HologramManager.register(HologramGHolo()) },
|
||||
|
||||
// AFK
|
||||
|
||||
@@ -57,6 +57,11 @@ class AntigriefBentoBox : AntigriefWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
val island = BentoBox.getInstance().islandsManager.getIslandAt(location).orElse(null) ?: return true
|
||||
return island.isAllowed(User.getInstance(player), Flags.ITEM_PICKUP)
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "BentoBox"
|
||||
}
|
||||
|
||||
@@ -55,6 +55,10 @@ class AntigriefCombatLogXV10 : AntigriefWrapper {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "CombatLogX"
|
||||
}
|
||||
|
||||
@@ -58,6 +58,10 @@ class AntigriefCombatLogXV11 : AntigriefWrapper {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "CombatLogX"
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer
|
||||
import com.willfp.eco.core.integrations.antigrief.AntigriefWrapper
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.block.Block
|
||||
import org.bukkit.entity.*
|
||||
import org.bukkit.entity.LivingEntity
|
||||
import org.bukkit.entity.Monster
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
||||
override fun getPluginName(): String {
|
||||
@@ -78,7 +80,8 @@ class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
||||
|
||||
val island: Island? = SuperiorSkyblockAPI.getSuperiorSkyblock().grid.getIslandAt(victim.location)
|
||||
|
||||
if (victim is Player) return SuperiorSkyblockAPI.getPlayer(player).canHit(SuperiorSkyblockAPI.getPlayer(victim)).equals(HitActionResult.SUCCESS)
|
||||
if (victim is Player) return SuperiorSkyblockAPI.getPlayer(player).canHit(SuperiorSkyblockAPI.getPlayer(victim))
|
||||
.equals(HitActionResult.SUCCESS)
|
||||
|
||||
val islandPermission = when (victim) {
|
||||
is Monster -> IslandPrivilege.getByName("MONSTER_DAMAGE")
|
||||
|
||||
@@ -102,7 +102,14 @@ class AntigriefWorldGuard : AntigriefWrapper {
|
||||
val localPlayer: LocalPlayer = WorldGuardPlugin.inst().wrapPlayer(player)
|
||||
val container: RegionContainer = WorldGuard.getInstance().platform.regionContainer
|
||||
val query: RegionQuery = container.createQuery()
|
||||
return query.testState(BukkitAdapter.adapt(location), localPlayer, Flags.ITEM_PICKUP)
|
||||
val world = location.world
|
||||
Validate.notNull(world, "World cannot be null!")
|
||||
return if (!query.testBuild(BukkitAdapter.adapt(location), localPlayer, Flags.ITEM_PICKUP)) {
|
||||
WorldGuard.getInstance().platform.sessionManager.hasBypass(
|
||||
localPlayer,
|
||||
BukkitAdapter.adapt(world)
|
||||
)
|
||||
} else true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
|
||||
@@ -3,26 +3,24 @@ package com.willfp.eco.internal.spigot.integrations.hologram
|
||||
import com.willfp.eco.core.integrations.hologram.Hologram
|
||||
import com.willfp.eco.core.integrations.hologram.HologramWrapper
|
||||
import eu.decentsoftware.holograms.api.DHAPI
|
||||
import me.gholo.api.GHoloAPI
|
||||
import org.bukkit.Location
|
||||
import java.util.UUID
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
class HologramDecentHolograms : HologramWrapper {
|
||||
|
||||
override fun createHologram(location: Location, contents: MutableList<String>): Hologram {
|
||||
val id = UUID.randomUUID().toString()
|
||||
|
||||
val holo = DHAPI.createHologram(id, location, contents)
|
||||
DHAPI.createHologram(id, location, contents)
|
||||
|
||||
return HologramImplGHolo(id)
|
||||
return HologramImplDecentHolograms(id)
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "GHolo"
|
||||
return "DecentHolograms"
|
||||
}
|
||||
|
||||
class HologramImplGHolo(
|
||||
class HologramImplDecentHolograms(
|
||||
private val id: String,
|
||||
) : Hologram {
|
||||
override fun remove() {
|
||||
|
||||
@@ -38,6 +38,7 @@ softdepend:
|
||||
- IridiumSkyblock
|
||||
- SuperiorSkyblock2
|
||||
- CrashClaim
|
||||
- DecentHolograms
|
||||
libraries:
|
||||
- 'org.reflections:reflections:0.9.12'
|
||||
- 'org.apache.maven:maven-artifact:3.0.3'
|
||||
|
||||
Reference in New Issue
Block a user