Archived
0

Add a few components of dicore3

This commit is contained in:
Dico200
2018-07-22 03:25:13 +02:00
parent 519f3f6b5c
commit dbcc90ac8a
12 changed files with 2514 additions and 1 deletions

View File

@@ -8,7 +8,8 @@ import java.util.*
class Parcel(val world: ParcelWorld,
val pos: Vec2i,
val data: ParcelData = ParcelData()) {
var data: ParcelData = ParcelData()) {
}

View File

@@ -0,0 +1,39 @@
package io.dico.parcels2.util
import org.bukkit.entity.Player
val Player.hasBanBypass get() = hasPermission("plots.admin.bypass.ban")
val Player.hasBuildAnywhere get() = hasPermission("plots.admin.bypass.build")
val Player.hasGamemodeBypass get() = hasPermission("plots.admin.bypass.gamemode")
val Player.hasAdminManage get() = hasPermission("plots.admin.manage")
val Player.hasPlotHomeOthers get() = hasPermission("plots.command.home.others")
val Player.hasRandomSpecific get() = hasPermission("plots.command.random.specific")
val Player.plotLimit: Int
get() {
for (info in effectivePermissions) {
val perm = info.permission
if (perm.startsWith("plots.limit.")) {
val limitString = perm.substring("plots.limit.".length)
if (limitString == "*") {
return Int.MAX_VALUE
}
return limitString.toIntOrNull() ?: DEFAULT_LIMIT.also {
Main.instance.logger.severe("$name has permission '$perm'. The suffix can not be parsed to an integer (or *).")
}
}
}
return DEFAULT_LIMIT
}
val DEFAULT_LIMIT = 1
internal val prefix = Formatting.translateChars('&', "&4[&c${Main.instance.name}&4] &a")
fun Player.sendPlotMessage(except: Boolean = false, nopermit: Boolean = false, message: String) {
if (except) {
sendMessage(prefix + Formatting.YELLOW + Formatting.translateChars('&', message))
} else if (nopermit) {
sendMessage(prefix + Formatting.RED + Formatting.translateChars('&', message))
} else {
sendMessage(prefix + Formatting.translateChars('&', message))
}
}