Kotlin cleanup
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
-->
|
-->
|
||||||
<property name="severity" value="error"/>
|
<property name="severity" value="error"/>
|
||||||
|
|
||||||
<property name="fileExtensions" value="java, properties, xml"/>
|
<property name="fileExtensions" value="java, properties, xml, kt"/>
|
||||||
|
|
||||||
<!-- Excludes all 'module-info.java' files -->
|
<!-- Excludes all 'module-info.java' files -->
|
||||||
<!-- See https://checkstyle.org/config_filefilters.html -->
|
<!-- See https://checkstyle.org/config_filefilters.html -->
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
<module name="FileLength"/>
|
<module name="FileLength"/>
|
||||||
<module name="LineLength">
|
<module name="LineLength">
|
||||||
<property name="fileExtensions" value="java"/>
|
<property name="fileExtensions" value="java"/>
|
||||||
|
<property name="fileExtensions" value="kt"/>
|
||||||
<property name="max" value="200"/>
|
<property name="max" value="200"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ import org.bukkit.entity.Player
|
|||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
import org.bukkit.inventory.meta.SkullMeta
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
|
|
||||||
abstract class EcoSpigotPlugin: EcoPlugin(
|
abstract class EcoSpigotPlugin : EcoPlugin(
|
||||||
87955,
|
87955,
|
||||||
10043,
|
10043,
|
||||||
"com.willfp.eco.proxy",
|
"com.willfp.eco.proxy",
|
||||||
"&a"
|
"&a"
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
Display.setFinalizeKey(namespacedKeyFactory.create("finalized"))
|
Display.setFinalizeKey(namespacedKeyFactory.create("finalized"))
|
||||||
@@ -57,41 +57,48 @@ abstract class EcoSpigotPlugin: EcoPlugin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun loadIntegrationLoaders(): List<IntegrationLoader> {
|
override fun loadIntegrationLoaders(): List<IntegrationLoader> {
|
||||||
return listOf( // AntiGrief
|
return listOf(
|
||||||
IntegrationLoader("WorldGuard") { AntigriefManager.register(AntigriefWorldGuard()) },
|
// AntiGrief
|
||||||
IntegrationLoader("GriefPrevention") { AntigriefManager.register(AntigriefGriefPrevention()) },
|
IntegrationLoader("WorldGuard") { AntigriefManager.register(AntigriefWorldGuard()) },
|
||||||
IntegrationLoader("FactionsUUID") { AntigriefManager.register(AntigriefFactionsUUID()) },
|
IntegrationLoader("GriefPrevention") { AntigriefManager.register(AntigriefGriefPrevention()) },
|
||||||
IntegrationLoader("Towny") { AntigriefManager.register(AntigriefTowny()) },
|
IntegrationLoader("FactionsUUID") { AntigriefManager.register(AntigriefFactionsUUID()) },
|
||||||
IntegrationLoader("Lands") { AntigriefManager.register(AntigriefLands(this)) },
|
IntegrationLoader("Towny") { AntigriefManager.register(AntigriefTowny()) },
|
||||||
IntegrationLoader("Kingdoms") { AntigriefManager.register(AntigriefKingdoms()) },
|
IntegrationLoader("Lands") { AntigriefManager.register(AntigriefLands(this)) },
|
||||||
IntegrationLoader("CombatLogX") {
|
IntegrationLoader("Kingdoms") { AntigriefManager.register(AntigriefKingdoms()) },
|
||||||
val pluginManager = Bukkit.getPluginManager()
|
IntegrationLoader("CombatLogX") {
|
||||||
val combatLogXPlugin = pluginManager.getPlugin("CombatLogX") ?: return@IntegrationLoader
|
val pluginManager = Bukkit.getPluginManager()
|
||||||
val pluginVersion = combatLogXPlugin.description.version
|
val combatLogXPlugin = pluginManager.getPlugin("CombatLogX") ?: return@IntegrationLoader
|
||||||
if (pluginVersion.startsWith("10")) {
|
val pluginVersion = combatLogXPlugin.description.version
|
||||||
AntigriefManager.register(AntigriefCombatLogXV10())
|
if (pluginVersion.startsWith("10")) {
|
||||||
}
|
AntigriefManager.register(AntigriefCombatLogXV10())
|
||||||
if (pluginVersion.startsWith("11")) {
|
}
|
||||||
AntigriefManager.register(AntigriefCombatLogXV11())
|
if (pluginVersion.startsWith("11")) {
|
||||||
}
|
AntigriefManager.register(AntigriefCombatLogXV11())
|
||||||
}, // Anticheat
|
}
|
||||||
IntegrationLoader("AAC5") { AnticheatManager.register(this, AnticheatAAC()) },
|
},
|
||||||
IntegrationLoader("Matrix") { AnticheatManager.register(this, AnticheatMatrix()) },
|
|
||||||
IntegrationLoader("NoCheatPlus") { AnticheatManager.register(this, AnticheatNCP()) },
|
// Anticheat
|
||||||
IntegrationLoader("Spartan") { AnticheatManager.register(this, AnticheatSpartan()) },
|
IntegrationLoader("AAC5") { AnticheatManager.register(this, AnticheatAAC()) },
|
||||||
IntegrationLoader("Vulcan") { AnticheatManager.register(this, AnticheatVulcan()) }, // Custom Items
|
IntegrationLoader("Matrix") { AnticheatManager.register(this, AnticheatMatrix()) },
|
||||||
IntegrationLoader("Oraxen") { CustomItemsManager.register(CustomItemsOraxen()) }, // Misc
|
IntegrationLoader("NoCheatPlus") { AnticheatManager.register(this, AnticheatNCP()) },
|
||||||
IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) }
|
IntegrationLoader("Spartan") { AnticheatManager.register(this, AnticheatSpartan()) },
|
||||||
|
IntegrationLoader("Vulcan") { AnticheatManager.register(this, AnticheatVulcan()) },
|
||||||
|
|
||||||
|
// Custom Items
|
||||||
|
IntegrationLoader("Oraxen") { CustomItemsManager.register(CustomItemsOraxen()) },
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadPacketAdapters(): List<AbstractPacketAdapter> {
|
override fun loadPacketAdapters(): List<AbstractPacketAdapter> {
|
||||||
val adapters = mutableListOf(
|
val adapters = mutableListOf(
|
||||||
PacketAutoRecipe(this),
|
PacketAutoRecipe(this),
|
||||||
PacketChat(this),
|
PacketChat(this),
|
||||||
PacketSetCreativeSlot(this),
|
PacketSetCreativeSlot(this),
|
||||||
PacketSetSlot(this),
|
PacketSetSlot(this),
|
||||||
PacketWindowItems(this)
|
PacketWindowItems(this)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!configYml.getBool("disable-display-on-villagers")) {
|
if (!configYml.getBool("disable-display-on-villagers")) {
|
||||||
@@ -103,15 +110,15 @@ abstract class EcoSpigotPlugin: EcoPlugin(
|
|||||||
|
|
||||||
override fun loadListeners(): List<Listener> {
|
override fun loadListeners(): List<Listener> {
|
||||||
return listOf(
|
return listOf(
|
||||||
NaturalExpGainListeners(),
|
NaturalExpGainListeners(),
|
||||||
ArmorListener(),
|
ArmorListener(),
|
||||||
DispenserArmorListener(),
|
DispenserArmorListener(),
|
||||||
EntityDeathByEntityListeners(this),
|
EntityDeathByEntityListeners(this),
|
||||||
ShapedRecipeListener(this),
|
ShapedRecipeListener(this),
|
||||||
PlayerJumpListeners(),
|
PlayerJumpListeners(),
|
||||||
GUIListener(this),
|
GUIListener(this),
|
||||||
ArrowDataListener(this),
|
ArrowDataListener(this),
|
||||||
ArmorChangeEventListeners(this)
|
ArmorChangeEventListeners(this)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,18 +13,18 @@ import java.util.concurrent.atomic.AtomicReference
|
|||||||
class EntityDeathByEntityListeners(
|
class EntityDeathByEntityListeners(
|
||||||
plugin: EcoPlugin
|
plugin: EcoPlugin
|
||||||
) : PluginDependent<EcoPlugin>(plugin), Listener {
|
) : PluginDependent<EcoPlugin>(plugin), Listener {
|
||||||
private val events = HashSet<EntityDeathByEntityBuilder>();
|
private val events = HashSet<EntityDeathByEntityBuilder>()
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
fun onEntityDamage(event: EntityDamageByEntityEvent) {
|
fun onEntityDamage(event: EntityDamageByEntityEvent) {
|
||||||
if ((event.entity !is LivingEntity)) {
|
if ((event.entity !is LivingEntity)) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val victim = event.entity as LivingEntity
|
val victim = event.entity as LivingEntity
|
||||||
|
|
||||||
if (victim.health > event.finalDamage) {
|
if (victim.health > event.finalDamage) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val builtEvent = EntityDeathByEntityBuilder()
|
val builtEvent = EntityDeathByEntityBuilder()
|
||||||
@@ -51,15 +51,15 @@ class EntityDeathByEntityListeners(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (atomicBuiltEvent.get() == null) {
|
if (atomicBuiltEvent.get() == null) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val builtEvent = atomicBuiltEvent.get();
|
val builtEvent = atomicBuiltEvent.get()
|
||||||
events.remove(builtEvent);
|
events.remove(builtEvent)
|
||||||
builtEvent.drops = drops
|
builtEvent.drops = drops
|
||||||
builtEvent.xp = xp
|
builtEvent.xp = xp
|
||||||
builtEvent.deathEvent = event
|
builtEvent.deathEvent = event
|
||||||
|
|
||||||
builtEvent.push();
|
builtEvent.push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.bukkit.Location
|
|||||||
import org.bukkit.event.player.PlayerExpChangeEvent
|
import org.bukkit.event.player.PlayerExpChangeEvent
|
||||||
|
|
||||||
internal class NaturalExpGainBuilder(var reason: BuildReason) {
|
internal class NaturalExpGainBuilder(var reason: BuildReason) {
|
||||||
var cancelled = false
|
private var cancelled = false
|
||||||
var event: PlayerExpChangeEvent? = null
|
var event: PlayerExpChangeEvent? = null
|
||||||
var location: Location? = null
|
var location: Location? = null
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class PlayerJumpListeners : Listener {
|
|||||||
jumpVelocity = FORMAT.format(jumpVelocity.toDouble()).replace(',', '.').toFloat()
|
jumpVelocity = FORMAT.format(jumpVelocity.toDouble()).replace(',', '.').toFloat()
|
||||||
if (event.player.location.block.type != Material.LADDER && PREVIOUS_PLAYERS_ON_GROUND.contains(player.uniqueId)
|
if (event.player.location.block.type != Material.LADDER && PREVIOUS_PLAYERS_ON_GROUND.contains(player.uniqueId)
|
||||||
&& !player.isOnGround
|
&& !player.isOnGround
|
||||||
&& java.lang.Float.compare(player.velocity.y.toFloat(), jumpVelocity) == 0
|
&& player.velocity.y.toFloat().compareTo(jumpVelocity) == 0
|
||||||
) {
|
) {
|
||||||
Bukkit.getPluginManager().callEvent(PlayerJumpEvent(event))
|
Bukkit.getPluginManager().callEvent(PlayerJumpEvent(event))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,10 @@ import me.konsolas.aac.api.AACExemption
|
|||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class AnticheatAAC : AnticheatWrapper, Listener {
|
class AnticheatAAC : AnticheatWrapper, Listener {
|
||||||
private val ecoExemption = AACExemption("eco")
|
private val ecoExemption = AACExemption("eco")
|
||||||
private val api = Objects.requireNonNull(
|
private val api = Bukkit.getServicesManager().load(AACAPI::class.java)!!
|
||||||
Bukkit.getServicesManager().load(
|
|
||||||
AACAPI::class.java
|
|
||||||
)
|
|
||||||
)!!
|
|
||||||
|
|
||||||
override fun getPluginName(): String {
|
override fun getPluginName(): String {
|
||||||
return "AAC"
|
return "AAC"
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ import org.bukkit.entity.LivingEntity
|
|||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
class AntigriefCombatLogXV10 : AntigriefWrapper {
|
class AntigriefCombatLogXV10 : AntigriefWrapper {
|
||||||
private val instance: ICombatLogX?
|
private val instance: ICombatLogX = Bukkit.getPluginManager().getPlugin("CombatLogX") as ICombatLogX
|
||||||
|
|
||||||
override fun canBreakBlock(
|
override fun canBreakBlock(
|
||||||
player: Player,
|
player: Player,
|
||||||
block: Block
|
block: Block
|
||||||
@@ -43,12 +44,12 @@ class AntigriefCombatLogXV10 : AntigriefWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only run checks if the NewbieHelper expansion is installed on the server.
|
// Only run checks if the NewbieHelper expansion is installed on the server.
|
||||||
val expansionManager = instance!!.expansionManager
|
val expansionManager = instance.expansionManager
|
||||||
val optionalExpansion = expansionManager.getExpansionByName<Expansion>("NewbieHelper")
|
val optionalExpansion = expansionManager.getExpansionByName<Expansion>("NewbieHelper")
|
||||||
if (optionalExpansion.isPresent) {
|
if (optionalExpansion.isPresent) {
|
||||||
val expansion = optionalExpansion.get()
|
val expansion = optionalExpansion.get()
|
||||||
val newbieHelper: NewbieHelper = expansion as NewbieHelper
|
val newbieHelper: NewbieHelper = expansion as NewbieHelper
|
||||||
val pvpListener: ListenerPVP = newbieHelper.getPVPListener()
|
val pvpListener: ListenerPVP = newbieHelper.pvpListener
|
||||||
return pvpListener.isPVPEnabled(player) && pvpListener.isPVPEnabled(victim)
|
return pvpListener.isPVPEnabled(player) && pvpListener.isPVPEnabled(victim)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@@ -58,7 +59,4 @@ class AntigriefCombatLogXV10 : AntigriefWrapper {
|
|||||||
return "CombatLogX"
|
return "CombatLogX"
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
|
||||||
instance = Bukkit.getPluginManager().getPlugin("CombatLogX") as ICombatLogX?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ import org.bukkit.entity.LivingEntity
|
|||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
class AntigriefCombatLogXV11 : AntigriefWrapper {
|
class AntigriefCombatLogXV11 : AntigriefWrapper {
|
||||||
private val instance: ICombatLogX?
|
private val instance: ICombatLogX = Bukkit.getPluginManager().getPlugin("CombatLogX") as ICombatLogX
|
||||||
override fun canBreakBlock(
|
override fun canBreakBlock(
|
||||||
player: Player,
|
player: Player,
|
||||||
block: Block
|
block: Block
|
||||||
@@ -43,16 +43,15 @@ class AntigriefCombatLogXV11 : AntigriefWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only run checks if the NewbieHelper expansion is installed on the server.
|
// Only run checks if the NewbieHelper expansion is installed on the server.
|
||||||
val expansionManager = instance!!.expansionManager
|
val expansionManager = instance.expansionManager
|
||||||
val optionalExpansion = expansionManager.getExpansion("NewbieHelper")
|
val optionalExpansion = expansionManager.getExpansion("NewbieHelper")
|
||||||
if (optionalExpansion.isPresent) {
|
if (optionalExpansion.isPresent) {
|
||||||
val expansion = optionalExpansion.get()
|
val expansion = optionalExpansion.get()
|
||||||
val newbieHelperExpansion: NewbieHelperExpansion = expansion as NewbieHelperExpansion
|
val newbieHelperExpansion: NewbieHelperExpansion = expansion as NewbieHelperExpansion
|
||||||
val protectionManager: ProtectionManager = newbieHelperExpansion.getProtectionManager()
|
val protectionManager: ProtectionManager = newbieHelperExpansion.protectionManager
|
||||||
val pvpManager: PVPManager = newbieHelperExpansion.getPVPManager()
|
val pvpManager: PVPManager = newbieHelperExpansion.pvpManager
|
||||||
val victimPlayer = victim
|
val victimProtected: Boolean = protectionManager.isProtected(victim)
|
||||||
val victimProtected: Boolean = protectionManager.isProtected(victimPlayer)
|
val victimDisabledPvP: Boolean = pvpManager.isDisabled(victim)
|
||||||
val victimDisabledPvP: Boolean = pvpManager.isDisabled(victimPlayer)
|
|
||||||
val playerDisabledPvp: Boolean = pvpManager.isDisabled(player)
|
val playerDisabledPvp: Boolean = pvpManager.isDisabled(player)
|
||||||
return !victimProtected && !victimDisabledPvP && !playerDisabledPvp
|
return !victimProtected && !victimDisabledPvP && !playerDisabledPvp
|
||||||
}
|
}
|
||||||
@@ -63,7 +62,4 @@ class AntigriefCombatLogXV11 : AntigriefWrapper {
|
|||||||
return "CombatLogX"
|
return "CombatLogX"
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
|
||||||
instance = Bukkit.getPluginManager().getPlugin("CombatLogX") as ICombatLogX?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ class AntigriefFactionsUUID : AntigriefWrapper {
|
|||||||
val flocation = FLocation(block.location)
|
val flocation = FLocation(block.location)
|
||||||
val faction: Faction = Board.getInstance().getFactionAt(flocation)
|
val faction: Faction = Board.getInstance().getFactionAt(flocation)
|
||||||
return if (!faction.hasAccess(fplayer, PermissibleAction.DESTROY)) {
|
return if (!faction.hasAccess(fplayer, PermissibleAction.DESTROY)) {
|
||||||
fplayer.isAdminBypassing()
|
fplayer.isAdminBypassing
|
||||||
} else true
|
} else true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ class AntigriefFactionsUUID : AntigriefWrapper {
|
|||||||
val flocation = FLocation(block.location)
|
val flocation = FLocation(block.location)
|
||||||
val faction: Faction = Board.getInstance().getFactionAt(flocation)
|
val faction: Faction = Board.getInstance().getFactionAt(flocation)
|
||||||
return if (!faction.hasAccess(fplayer, PermissibleAction.BUILD)) {
|
return if (!faction.hasAccess(fplayer, PermissibleAction.BUILD)) {
|
||||||
fplayer.isAdminBypassing()
|
fplayer.isAdminBypassing
|
||||||
} else true
|
} else true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,12 +50,12 @@ class AntigriefFactionsUUID : AntigriefWrapper {
|
|||||||
val flocation = FLocation(victim.location)
|
val flocation = FLocation(victim.location)
|
||||||
val faction: Faction = Board.getInstance().getFactionAt(flocation)
|
val faction: Faction = Board.getInstance().getFactionAt(flocation)
|
||||||
if (victim is Player) {
|
if (victim is Player) {
|
||||||
if (faction.isPeaceful()) {
|
if (faction.isPeaceful) {
|
||||||
return fplayer.isAdminBypassing()
|
return fplayer.isAdminBypassing
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (faction.hasAccess(fplayer, PermissibleAction.DESTROY)) {
|
if (faction.hasAccess(fplayer, PermissibleAction.DESTROY)) {
|
||||||
return fplayer.isAdminBypassing()
|
return fplayer.isAdminBypassing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class AntigriefGriefPrevention : AntigriefWrapper {
|
|||||||
player: Player,
|
player: Player,
|
||||||
block: Block
|
block: Block
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val claim: Claim = GriefPrevention.instance.dataStore.getClaimAt(block.location, false, null)
|
val claim: Claim? = GriefPrevention.instance.dataStore.getClaimAt(block.location, false, null)
|
||||||
return if (claim != null) {
|
return if (claim != null) {
|
||||||
claim.allowBreak(player, block.type) == null
|
claim.allowBreak(player, block.type) == null
|
||||||
} else true
|
} else true
|
||||||
@@ -23,17 +23,15 @@ class AntigriefGriefPrevention : AntigriefWrapper {
|
|||||||
player: Player,
|
player: Player,
|
||||||
location: Location
|
location: Location
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val claim: Claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null)
|
val claim: Claim? = GriefPrevention.instance.dataStore.getClaimAt(location, false, null)
|
||||||
return if (claim != null) {
|
return claim?.areExplosivesAllowed ?: true
|
||||||
claim.areExplosivesAllowed
|
|
||||||
} else true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun canPlaceBlock(
|
override fun canPlaceBlock(
|
||||||
player: Player,
|
player: Player,
|
||||||
block: Block
|
block: Block
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val claim: Claim = GriefPrevention.instance.dataStore.getClaimAt(block.location, false, null)
|
val claim: Claim? = GriefPrevention.instance.dataStore.getClaimAt(block.location, false, null)
|
||||||
return if (claim != null) {
|
return if (claim != null) {
|
||||||
claim.allowBuild(player, block.type) == null
|
claim.allowBuild(player, block.type) == null
|
||||||
} else true
|
} else true
|
||||||
@@ -43,11 +41,11 @@ class AntigriefGriefPrevention : AntigriefWrapper {
|
|||||||
player: Player,
|
player: Player,
|
||||||
victim: LivingEntity
|
victim: LivingEntity
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val claim: Claim = GriefPrevention.instance.dataStore.getClaimAt(victim.location, false, null)
|
val claim: Claim? = GriefPrevention.instance.dataStore.getClaimAt(victim.location, false, null)
|
||||||
return if (victim is Player) {
|
return if (victim is Player) {
|
||||||
claim == null
|
claim == null
|
||||||
} else {
|
} else {
|
||||||
if (claim != null && claim.ownerID != null) {
|
if (claim?.ownerID != null) {
|
||||||
claim.ownerID == player.uniqueId
|
claim.ownerID == player.uniqueId
|
||||||
} else true
|
} else true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ class AntigriefKingdoms : AntigriefWrapper {
|
|||||||
block: Block
|
block: Block
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val kp: KingdomPlayer = KingdomPlayer.getKingdomPlayer(player)
|
val kp: KingdomPlayer = KingdomPlayer.getKingdomPlayer(player)
|
||||||
if (kp.isAdmin()) {
|
if (kp.isAdmin) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
val kingdom: Kingdom = kp.getKingdom() ?: return false
|
val kingdom: Kingdom = kp.kingdom ?: return false
|
||||||
val land = Land.getLand(block) ?: return true
|
val land = Land.getLand(block) ?: return true
|
||||||
val permission: DefaultKingdomPermission =
|
val permission: DefaultKingdomPermission =
|
||||||
if (land.isNexusLand) DefaultKingdomPermission.NEXUS_BUILD else DefaultKingdomPermission.BUILD
|
if (land.isNexusLand) DefaultKingdomPermission.NEXUS_BUILD else DefaultKingdomPermission.BUILD
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class AntigriefTowny : AntigriefWrapper {
|
|||||||
player: Player,
|
player: Player,
|
||||||
block: Block
|
block: Block
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val world = TownyUniverse.getInstance().worldMap[block.location.world!!.name] ?: return true
|
TownyUniverse.getInstance().worldMap[block.location.world!!.name] ?: return true
|
||||||
return if (TownyAPI.getInstance().isWilderness(block)) {
|
return if (TownyAPI.getInstance().isWilderness(block)) {
|
||||||
true
|
true
|
||||||
} else PlayerCacheUtil.getCachePermission(
|
} else PlayerCacheUtil.getCachePermission(
|
||||||
@@ -39,7 +39,7 @@ class AntigriefTowny : AntigriefWrapper {
|
|||||||
player: Player,
|
player: Player,
|
||||||
location: Location
|
location: Location
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val world = TownyUniverse.getInstance().worldMap[location.world!!.name] ?: return true
|
TownyUniverse.getInstance().worldMap[location.world?.name] ?: return true
|
||||||
return if (TownyAPI.getInstance().isWilderness(location)) {
|
return if (TownyAPI.getInstance().isWilderness(location)) {
|
||||||
true
|
true
|
||||||
} else PlayerCacheUtil.getCachePermission(player, location, Material.TNT, TownyPermission.ActionType.ITEM_USE)
|
} else PlayerCacheUtil.getCachePermission(player, location, Material.TNT, TownyPermission.ActionType.ITEM_USE)
|
||||||
@@ -49,7 +49,7 @@ class AntigriefTowny : AntigriefWrapper {
|
|||||||
player: Player,
|
player: Player,
|
||||||
block: Block
|
block: Block
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val world = TownyUniverse.getInstance().worldMap[block.location.world!!.name] ?: return true
|
TownyUniverse.getInstance().worldMap[block.location.world?.name] ?: return true
|
||||||
return if (TownyAPI.getInstance().isWilderness(block)) {
|
return if (TownyAPI.getInstance().isWilderness(block)) {
|
||||||
true
|
true
|
||||||
} else PlayerCacheUtil.getCachePermission(player, block.location, block.type, TownyPermission.ActionType.BUILD)
|
} else PlayerCacheUtil.getCachePermission(player, block.location, block.type, TownyPermission.ActionType.BUILD)
|
||||||
@@ -59,7 +59,7 @@ class AntigriefTowny : AntigriefWrapper {
|
|||||||
player: Player,
|
player: Player,
|
||||||
victim: LivingEntity
|
victim: LivingEntity
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val world = TownyUniverse.getInstance().worldMap[victim.location.world!!.name] ?: return true
|
val world = TownyUniverse.getInstance().worldMap[victim.location.world?.name] ?: return true
|
||||||
if (TownyAPI.getInstance().isWilderness(victim.location)) {
|
if (TownyAPI.getInstance().isWilderness(victim.location)) {
|
||||||
return if (victim is Player) {
|
return if (victim is Player) {
|
||||||
world.isPVP
|
world.isPVP
|
||||||
@@ -69,14 +69,14 @@ class AntigriefTowny : AntigriefWrapper {
|
|||||||
}
|
}
|
||||||
if (victim is Player) {
|
if (victim is Player) {
|
||||||
try {
|
try {
|
||||||
val town: Town = WorldCoord.parseWorldCoord(victim.getLocation()).getTownBlock().getTown()
|
val town: Town = WorldCoord.parseWorldCoord(victim.getLocation()).townBlock.town
|
||||||
return town.isPVP()
|
return town.isPVP
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
// If exception, no town was found, thus return true.
|
// If exception, no town was found, thus return true.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
val town: Town = WorldCoord.parseWorldCoord(victim.location).getTownBlock().getTown()
|
val town: Town = WorldCoord.parseWorldCoord(victim.location).townBlock.town
|
||||||
return town.hasMobs()
|
return town.hasMobs()
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
// If exception, no town was found, thus return true.
|
// If exception, no town was found, thus return true.
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ class CustomItemsOraxen : CustomItemsWrapper {
|
|||||||
for (item in OraxenItems.getItems()) {
|
for (item in OraxenItems.getItems()) {
|
||||||
val stack = item.build()
|
val stack = item.build()
|
||||||
val id: String = OraxenItems.getIdByItem(item)
|
val id: String = OraxenItems.getIdByItem(item)
|
||||||
val key: NamespacedKey = NamespacedKeyUtils.create("oraxen", id.toLowerCase())
|
val key: NamespacedKey = NamespacedKeyUtils.create("oraxen", id.lowercase())
|
||||||
CustomItem(
|
CustomItem(
|
||||||
key, Predicate { test: ItemStack? ->
|
key, Predicate { test: ItemStack ->
|
||||||
val oraxenId: String = OraxenItems.getIdByItem(test) ?: return@Predicate false
|
val oraxenId: String = OraxenItems.getIdByItem(test) ?: return@Predicate false
|
||||||
oraxenId.equals(id, ignoreCase = true)
|
oraxenId.equals(id, ignoreCase = true)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user