Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d3efb5e83 | ||
|
|
8a5d1a604a | ||
|
|
ef67c6d6ae | ||
|
|
5b2654db15 | ||
|
|
eccd793317 | ||
|
|
1bc44755a0 | ||
|
|
ec606d9ebe | ||
|
|
c5556f15ab | ||
|
|
399cce21f5 | ||
|
|
b25feffdfa |
@@ -1,5 +1,7 @@
|
||||
package com.willfp.eco.core.command;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A notification exception is thrown when {@link org.bukkit.command.CommandSender}s don't
|
||||
* specify valid arguments in commands.
|
||||
@@ -18,7 +20,7 @@ public class NotificationException extends Exception {
|
||||
*
|
||||
* @param key The lang key of the notification.
|
||||
*/
|
||||
public NotificationException(String key) {
|
||||
public NotificationException(@NotNull final String key) {
|
||||
super(key);
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@@ -71,10 +71,6 @@ public final class Prices {
|
||||
ctx
|
||||
);
|
||||
|
||||
if (function.apply(context) <= 0) {
|
||||
return new PriceFree();
|
||||
}
|
||||
|
||||
// Default to economy
|
||||
if (priceName == null) {
|
||||
return new PriceEconomy(context, function);
|
||||
|
||||
@@ -31,7 +31,7 @@ dependencies {
|
||||
compileOnly('com.github.TownyAdvanced:Towny:0.97.2.6') {
|
||||
exclude group: 'com.zaxxer', module: 'HikariCP'
|
||||
}
|
||||
compileOnly 'com.github.angeschossen:LandsAPI:6.26.7'
|
||||
compileOnly 'com.github.angeschossen:LandsAPI:6.26.18'
|
||||
compileOnly 'com.github.angeschossen:PluginFrameworkAPI:1.0.0'
|
||||
compileOnly 'fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT'
|
||||
compileOnly 'com.github.jiangdashao:matrix-api-repo:317d4635fd'
|
||||
@@ -48,7 +48,7 @@ dependencies {
|
||||
compileOnly 'com.github.WhipDevelopment:CrashClaim:f9cd7d92eb'
|
||||
compileOnly 'com.wolfyscript.wolfyutilities:wolfyutilities:3.16.0.0'
|
||||
compileOnly 'com.github.decentsoftware-eu:decentholograms:2.1.2'
|
||||
compileOnly 'com.github.Gypopo:EconomyShopGUI-API:1.1.0'
|
||||
compileOnly 'com.github.Gypopo:EconomyShopGUI-API:1.4.6'
|
||||
compileOnly 'com.github.N0RSKA:ScytherAPI:55a'
|
||||
compileOnly 'com.ticxo.modelengine:api:R3.0.1'
|
||||
compileOnly 'me.TechsCode:UltraEconomyAPI:1.0.0'
|
||||
|
||||
@@ -316,6 +316,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
||||
IntegrationLoader("zShop") { ShopManager.register(ShopZShop()) },
|
||||
IntegrationLoader("DeluxeSellwands") { ShopManager.register(ShopDeluxeSellwands()) },
|
||||
IntegrationLoader("EconomyShopGUI") { ShopManager.register(ShopEconomyShopGUI()) },
|
||||
IntegrationLoader("EconomyShopGUI-Premium") { ShopManager.register(ShopEconomyShopGUI()) },
|
||||
|
||||
// Hologram
|
||||
IntegrationLoader("HolographicDisplays") { HologramManager.register(HologramHolographicDisplays(this)) },
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.willfp.eco.internal.spigot.integrations.antigrief
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.integrations.antigrief.AntigriefIntegration
|
||||
import me.angeschossen.lands.api.LandsIntegration
|
||||
import me.angeschossen.lands.api.flags.Flags
|
||||
import me.angeschossen.lands.api.flags.enums.FlagTarget
|
||||
import me.angeschossen.lands.api.flags.enums.RoleFlagCategory
|
||||
import me.angeschossen.lands.api.flags.type.RoleFlag
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.block.Block
|
||||
import org.bukkit.entity.Animals
|
||||
import org.bukkit.entity.LivingEntity
|
||||
@@ -18,7 +21,10 @@ class AntigriefLands(private val plugin: EcoPlugin) : AntigriefIntegration {
|
||||
block: Block
|
||||
): Boolean {
|
||||
val area = landsIntegration.getArea(block.location) ?: return true
|
||||
return area.hasFlag(player, Flags.BLOCK_BREAK, false)
|
||||
return area.hasRoleFlag(player, RoleFlag.of(landsIntegration,
|
||||
FlagTarget.PLAYER,
|
||||
RoleFlagCategory.ACTION,
|
||||
"BLOCK_BREAK"), block.type, false)
|
||||
}
|
||||
|
||||
override fun canCreateExplosion(
|
||||
@@ -26,7 +32,13 @@ class AntigriefLands(private val plugin: EcoPlugin) : AntigriefIntegration {
|
||||
location: Location
|
||||
): Boolean {
|
||||
val area = landsIntegration.getArea(location) ?: return true
|
||||
return area.hasFlag(player, Flags.ATTACK_PLAYER, false) && area.hasFlag(player, Flags.ATTACK_ANIMAL, false)
|
||||
return area.hasRoleFlag(player, RoleFlag.of(landsIntegration,
|
||||
FlagTarget.PLAYER,
|
||||
RoleFlagCategory.ACTION,
|
||||
"ATTACK_PLAYER"), Material.AIR, false) && area.hasRoleFlag(player, RoleFlag.of(landsIntegration,
|
||||
FlagTarget.PLAYER,
|
||||
RoleFlagCategory.ACTION,
|
||||
"ATTACK_ANIMAL"), Material.AIR, false)
|
||||
}
|
||||
|
||||
override fun canPlaceBlock(
|
||||
@@ -34,7 +46,10 @@ class AntigriefLands(private val plugin: EcoPlugin) : AntigriefIntegration {
|
||||
block: Block
|
||||
): Boolean {
|
||||
val area = landsIntegration.getArea(block.location) ?: return true
|
||||
return area.hasFlag(player, Flags.BLOCK_PLACE, false)
|
||||
return area.hasRoleFlag(player, RoleFlag.of(landsIntegration,
|
||||
FlagTarget.PLAYER,
|
||||
RoleFlagCategory.ACTION,
|
||||
"BLOCK_PLACE"), Material.AIR, false)
|
||||
}
|
||||
|
||||
override fun canInjure(
|
||||
@@ -45,16 +60,28 @@ class AntigriefLands(private val plugin: EcoPlugin) : AntigriefIntegration {
|
||||
val area = landsIntegration.getArea(victim.location) ?: return true
|
||||
|
||||
return when(victim) {
|
||||
is Player -> area.hasFlag(player, Flags.ATTACK_PLAYER, false)
|
||||
is Monster -> area.hasFlag(player, Flags.ATTACK_MONSTER, false)
|
||||
is Animals -> area.hasFlag(player, Flags.ATTACK_MONSTER, false)
|
||||
is Player -> area.hasRoleFlag(player, RoleFlag.of(landsIntegration,
|
||||
FlagTarget.PLAYER,
|
||||
RoleFlagCategory.ACTION,
|
||||
"ATTACK_PLAYER"), Material.AIR, false)
|
||||
is Monster -> area.hasRoleFlag(player, RoleFlag.of(landsIntegration,
|
||||
FlagTarget.PLAYER,
|
||||
RoleFlagCategory.ACTION,
|
||||
"ATTACK_MONSTER"), Material.AIR, false)
|
||||
is Animals -> area.hasRoleFlag(player, RoleFlag.of(landsIntegration,
|
||||
FlagTarget.PLAYER,
|
||||
RoleFlagCategory.ACTION,
|
||||
"ATTACK_ANIMAL"), Material.AIR, false)
|
||||
else -> area.isTrusted(player.uniqueId)
|
||||
}
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
val area = landsIntegration.getArea(location) ?: return true
|
||||
return area.hasFlag(player, Flags.ITEM_PICKUP, false)
|
||||
return area.hasRoleFlag(player, RoleFlag.of(landsIntegration,
|
||||
FlagTarget.PLAYER,
|
||||
RoleFlagCategory.ACTION,
|
||||
"ITEM_PICKUP"), Material.AIR, false)
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.willfp.eco.core.integrations.shop.ShopIntegration
|
||||
import com.willfp.eco.core.integrations.shop.ShopSellEvent
|
||||
import com.willfp.eco.core.price.Price
|
||||
import com.willfp.eco.core.price.impl.PriceEconomy
|
||||
import com.willfp.eco.core.price.impl.PriceFree
|
||||
import me.gypopo.economyshopgui.api.EconomyShopGUIHook
|
||||
import me.gypopo.economyshopgui.api.events.PreTransactionEvent
|
||||
import me.gypopo.economyshopgui.util.Transaction
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
@@ -18,27 +20,63 @@ class ShopEconomyShopGUI : ShopIntegration {
|
||||
}
|
||||
|
||||
override fun getUnitValue(itemStack: ItemStack, player: Player): Price {
|
||||
val shopItem = EconomyShopGUIHook.getShopItem(itemStack) ?: return PriceFree()
|
||||
|
||||
return PriceEconomy(
|
||||
EconomyShopGUIHook.getItemSellPrice(player, itemStack.clone().apply {
|
||||
EconomyShopGUIHook.getItemSellPrice(shopItem, itemStack.clone().apply {
|
||||
amount = 1
|
||||
})
|
||||
}, player)
|
||||
)
|
||||
}
|
||||
|
||||
override fun isSellable(itemStack: ItemStack, player: Player): Boolean {
|
||||
return EconomyShopGUIHook.getItemSellPrice(player, itemStack) > 0
|
||||
val shopItem = EconomyShopGUIHook.getShopItem(itemStack) ?: return false
|
||||
return EconomyShopGUIHook.getItemSellPrice(shopItem, itemStack, player) > 0
|
||||
}
|
||||
|
||||
object EconomyShopGUISellEventListeners : Listener {
|
||||
private val sellTypes = listOf(
|
||||
Transaction.Type.SELL_GUI_SCREEN,
|
||||
Transaction.Type.SELL_SCREEN,
|
||||
Transaction.Type.SELL_ALL_SCREEN,
|
||||
Transaction.Type.SELL_ALL_COMMAND,
|
||||
Transaction.Type.QUICK_SELL,
|
||||
Transaction.Type.AUTO_SELL_CHEST,
|
||||
)
|
||||
|
||||
private val sellAllTypes = listOf(
|
||||
Transaction.Type.SELL_GUI_SCREEN,
|
||||
Transaction.Type.SELL_ALL_COMMAND,
|
||||
)
|
||||
|
||||
@EventHandler
|
||||
fun shopEventToEcoEvent(event: PreTransactionEvent) {
|
||||
if (event.transactionType !in sellTypes) {
|
||||
return
|
||||
}
|
||||
|
||||
if (event.isCancelled) {
|
||||
return
|
||||
}
|
||||
|
||||
val ecoEvent = ShopSellEvent(event.player, PriceEconomy(event.price), event.itemStack)
|
||||
val prices = if (event.transactionType in sellAllTypes) {
|
||||
event.items!!
|
||||
} else {
|
||||
mapOf(event.shopItem to event.amount)
|
||||
}
|
||||
|
||||
var total = 0.0
|
||||
|
||||
for ((shopItem, amount) in prices) {
|
||||
val price = EconomyShopGUIHook.getItemSellPrice(shopItem, shopItem.itemToGive
|
||||
.apply { this.amount = amount }, event.player)
|
||||
val ecoEvent = ShopSellEvent(event.player, PriceEconomy(price), shopItem.itemToGive
|
||||
.apply { this.amount = amount })
|
||||
Bukkit.getPluginManager().callEvent(ecoEvent)
|
||||
event.price = ecoEvent.value.getValue(event.player) * ecoEvent.multiplier
|
||||
total += ecoEvent.value.getValue(event.player) * ecoEvent.multiplier
|
||||
}
|
||||
|
||||
event.price = total
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.49.1
|
||||
version = 6.49.2
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
Reference in New Issue
Block a user