Perform some fixes
This commit is contained in:
@@ -238,14 +238,14 @@ public class RootCommandAddress extends ModifiableCommandAddress implements ICom
|
|||||||
try {
|
try {
|
||||||
ICommandAddress target = getCommandTarget(context, buffer);
|
ICommandAddress target = getCommandTarget(context, buffer);
|
||||||
|
|
||||||
List<String> out;
|
List<String> out = Collections.emptyList();
|
||||||
if (target.hasCommand()) {
|
/*if (target.hasCommand()) {
|
||||||
context.setCommand(target.getCommand());
|
context.setCommand(target.getCommand());
|
||||||
target.getCommand().initializeAndFilterContext(context);
|
target.getCommand().initializeAndFilterContext(context);
|
||||||
out = target.getCommand().tabComplete(sender, context, location);
|
out = target.getCommand().tabComplete(sender, context, location);
|
||||||
} else {
|
} else {
|
||||||
out = Collections.emptyList();
|
out = Collections.emptyList();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
int cursor = buffer.getCursor();
|
int cursor = buffer.getCursor();
|
||||||
String input;
|
String input;
|
||||||
|
|||||||
@@ -1,142 +1,143 @@
|
|||||||
package io.dico.parcels2.command
|
package io.dico.parcels2.command
|
||||||
|
|
||||||
import io.dico.dicore.command.ExecutionContext
|
import io.dico.dicore.command.ExecutionContext
|
||||||
import io.dico.dicore.command.Validate
|
import io.dico.dicore.command.Validate
|
||||||
import io.dico.dicore.command.annotation.Cmd
|
import io.dico.dicore.command.annotation.Cmd
|
||||||
import io.dico.dicore.command.annotation.Desc
|
import io.dico.dicore.command.annotation.Desc
|
||||||
import io.dico.dicore.command.annotation.Flag
|
import io.dico.dicore.command.annotation.Flag
|
||||||
import io.dico.dicore.command.annotation.RequireParameters
|
import io.dico.dicore.command.annotation.RequireParameters
|
||||||
import io.dico.parcels2.ParcelsPlugin
|
import io.dico.parcels2.ParcelsPlugin
|
||||||
import io.dico.parcels2.PlayerProfile
|
import io.dico.parcels2.PlayerProfile
|
||||||
import io.dico.parcels2.Privilege
|
import io.dico.parcels2.Privilege
|
||||||
import io.dico.parcels2.command.ParcelTarget.TargetKind
|
import io.dico.parcels2.command.ParcelTarget.TargetKind
|
||||||
import io.dico.parcels2.util.ext.hasParcelHomeOthers
|
import io.dico.parcels2.util.ext.hasParcelHomeOthers
|
||||||
import io.dico.parcels2.util.ext.hasPermAdminManage
|
import io.dico.parcels2.util.ext.hasPermAdminManage
|
||||||
import io.dico.parcels2.util.ext.uuid
|
import io.dico.parcels2.util.ext.uuid
|
||||||
import org.bukkit.block.Biome
|
import org.bukkit.block.Biome
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
class CommandsGeneral(plugin: ParcelsPlugin, parent: SpecialCommandAddress) : AbstractParcelCommands(plugin) {
|
class CommandsGeneral(plugin: ParcelsPlugin, parent: SpecialCommandAddress) : AbstractParcelCommands(plugin) {
|
||||||
|
|
||||||
@Cmd("auto")
|
@Cmd("auto")
|
||||||
@Desc(
|
@Desc(
|
||||||
"Finds the unclaimed parcel nearest to origin,",
|
"Finds the unclaimed parcel nearest to origin,",
|
||||||
"and gives it to you",
|
"and gives it to you",
|
||||||
shortVersion = "sets you up with a fresh, unclaimed parcel"
|
shortVersion = "sets you up with a fresh, unclaimed parcel"
|
||||||
)
|
)
|
||||||
suspend fun WorldScope.cmdAuto(player: Player): Any? {
|
suspend fun WorldScope.cmdAuto(player: Player): Any? {
|
||||||
checkConnected("be claimed")
|
checkConnected("be claimed")
|
||||||
checkParcelLimit(player, world)
|
checkParcelLimit(player, world)
|
||||||
|
|
||||||
val parcel = world.nextEmptyParcel()
|
val parcel = world.nextEmptyParcel()
|
||||||
?: err("This world is full, please ask an admin to upsize it")
|
?: err("This world is full, please ask an admin to upsize it")
|
||||||
parcel.owner = PlayerProfile(uuid = player.uuid)
|
parcel.owner = PlayerProfile(uuid = player.uuid)
|
||||||
player.teleport(parcel.homeLocation)
|
player.teleport(parcel.homeLocation)
|
||||||
return "Enjoy your new parcel!"
|
return "Enjoy your new parcel!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cmd("info", aliases = ["i"])
|
@Cmd("info", aliases = ["i"])
|
||||||
@Desc(
|
@Desc(
|
||||||
"Displays general information",
|
"Displays general information",
|
||||||
"about the parcel you're on",
|
"about the parcel you're on",
|
||||||
shortVersion = "displays information about this parcel"
|
shortVersion = "displays information about this parcel"
|
||||||
)
|
)
|
||||||
fun ParcelScope.cmdInfo(player: Player) = parcel.infoString
|
fun ParcelScope.cmdInfo(player: Player) = parcel.infoString
|
||||||
|
|
||||||
init {
|
init {
|
||||||
parent.addSpeciallyTreatedKeys("home", "h")
|
parent.addSpeciallyTreatedKeys("home", "h")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cmd("home", aliases = ["h"])
|
@Cmd("home", aliases = ["h"])
|
||||||
@Desc(
|
@Desc(
|
||||||
"Teleports you to your parcels,",
|
"Teleports you to your parcels,",
|
||||||
"unless another player was specified.",
|
"unless another player was specified.",
|
||||||
"You can specify an index number if you have",
|
"You can specify an index number if you have",
|
||||||
"more than one parcel",
|
"more than one parcel",
|
||||||
shortVersion = "teleports you to parcels"
|
shortVersion = "teleports you to parcels"
|
||||||
)
|
)
|
||||||
@RequireParameters(0)
|
@RequireParameters(0)
|
||||||
suspend fun cmdHome(
|
suspend fun cmdHome(
|
||||||
player: Player,
|
player: Player,
|
||||||
@TargetKind(TargetKind.OWNER_REAL) target: ParcelTarget
|
@TargetKind(TargetKind.OWNER_REAL) target: ParcelTarget
|
||||||
): Any? {
|
): Any? {
|
||||||
return cmdGoto(player, target)
|
return cmdGoto(player, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cmd("tp", aliases = ["teleport"])
|
@Cmd("tp", aliases = ["teleport"])
|
||||||
suspend fun cmdTp(
|
suspend fun cmdTp(
|
||||||
player: Player,
|
player: Player,
|
||||||
@TargetKind(TargetKind.ID) target: ParcelTarget
|
@TargetKind(TargetKind.ID) target: ParcelTarget
|
||||||
): Any? {
|
): Any? {
|
||||||
return cmdGoto(player, target)
|
return cmdGoto(player, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cmd("goto")
|
@Cmd("goto")
|
||||||
suspend fun cmdGoto(
|
suspend fun cmdGoto(
|
||||||
player: Player,
|
player: Player,
|
||||||
@TargetKind(TargetKind.ANY) target: ParcelTarget
|
@TargetKind(TargetKind.ANY) target: ParcelTarget
|
||||||
): Any? {
|
): Any? {
|
||||||
if (target is ParcelTarget.ByOwner) {
|
if (target is ParcelTarget.ByOwner) {
|
||||||
target.resolveOwner(plugin.storage)
|
target.resolveOwner(plugin.storage)
|
||||||
if (!target.owner.matches(player) && !player.hasParcelHomeOthers) {
|
if (!target.owner.matches(player) && !player.hasParcelHomeOthers) {
|
||||||
err("You do not have permission to teleport to other people's parcels")
|
err("You do not have permission to teleport to other people's parcels")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val match = target.getParcelSuspend(plugin.storage)
|
val match = target.getParcelSuspend(plugin.storage)
|
||||||
?: err("The specified parcel could not be matched")
|
?: err("The specified parcel could not be matched")
|
||||||
player.teleport(match.homeLocation)
|
player.teleport(match.homeLocation)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cmd("goto_fake")
|
@Cmd("goto_fake")
|
||||||
suspend fun cmdGotoFake(
|
suspend fun cmdGotoFake(
|
||||||
player: Player,
|
player: Player,
|
||||||
@TargetKind(TargetKind.OWNER_FAKE) target: ParcelTarget
|
@TargetKind(TargetKind.OWNER_FAKE) target: ParcelTarget
|
||||||
): Any? {
|
): Any? {
|
||||||
return cmdGoto(player, target)
|
return cmdGoto(player, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cmd("claim")
|
@Cmd("claim")
|
||||||
@Desc(
|
@Desc(
|
||||||
"If this parcel is unowned, makes you the owner",
|
"If this parcel is unowned, makes you the owner",
|
||||||
shortVersion = "claims this parcel"
|
shortVersion = "claims this parcel"
|
||||||
)
|
)
|
||||||
suspend fun ParcelScope.cmdClaim(player: Player): Any? {
|
suspend fun ParcelScope.cmdClaim(player: Player): Any? {
|
||||||
checkConnected("be claimed")
|
checkConnected("be claimed")
|
||||||
parcel.owner.takeIf { !player.hasPermAdminManage }?.let {
|
parcel.owner.takeIf { !player.hasPermAdminManage }?.let {
|
||||||
err(if (it.matches(player)) "You already own this parcel" else "This parcel is not available")
|
err(if (it.matches(player)) "You already own this parcel" else "This parcel is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
checkParcelLimit(player, world)
|
checkParcelLimit(player, world)
|
||||||
parcel.owner = PlayerProfile(player)
|
parcel.owner = PlayerProfile(player)
|
||||||
return "Enjoy your new parcel!"
|
return "Enjoy your new parcel!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cmd("unclaim")
|
/*
|
||||||
@Desc("Unclaims this parcel")
|
@Cmd("unclaim")
|
||||||
@RequireParcelPrivilege(Privilege.OWNER)
|
@Desc("Unclaims this parcel")
|
||||||
fun ParcelScope.cmdUnclaim(player: Player): Any? {
|
@RequireParcelPrivilege(Privilege.OWNER)
|
||||||
checkConnected("be unclaimed")
|
fun ParcelScope.cmdUnclaim(player: Player): Any? {
|
||||||
parcel.dispose()
|
checkConnected("be unclaimed")
|
||||||
return "Your parcel has been disposed"
|
parcel.dispose()
|
||||||
}
|
return "Your parcel has been disposed"
|
||||||
|
}*/
|
||||||
@Cmd("clear")
|
|
||||||
@RequireParcelPrivilege(Privilege.OWNER)
|
@Cmd("clear")
|
||||||
fun ParcelScope.cmdClear(context: ExecutionContext, @Flag sure: Boolean): Any? {
|
@RequireParcelPrivilege(Privilege.OWNER)
|
||||||
Validate.isTrue(!parcel.hasBlockVisitors, "A process is already running in this parcel")
|
fun ParcelScope.cmdClear(context: ExecutionContext, @Flag sure: Boolean): Any? {
|
||||||
if (!sure) return areYouSureMessage(context)
|
Validate.isTrue(!parcel.hasBlockVisitors, "A process is already running in this parcel")
|
||||||
world.blockManager.clearParcel(parcel.id)?.reportProgressUpdates(context, "Clear")
|
if (!sure) return areYouSureMessage(context)
|
||||||
return null
|
world.blockManager.clearParcel(parcel.id)?.reportProgressUpdates(context, "Clear")
|
||||||
}
|
return null
|
||||||
|
}
|
||||||
@Cmd("setbiome")
|
|
||||||
@RequireParcelPrivilege(Privilege.OWNER)
|
@Cmd("setbiome")
|
||||||
fun ParcelScope.cmdSetbiome(context: ExecutionContext, biome: Biome): Any? {
|
@RequireParcelPrivilege(Privilege.OWNER)
|
||||||
Validate.isTrue(!parcel.hasBlockVisitors, "A process is already running in this parcel")
|
fun ParcelScope.cmdSetbiome(context: ExecutionContext, biome: Biome): Any? {
|
||||||
world.blockManager.setBiome(parcel.id, biome)?.reportProgressUpdates(context, "Biome change")
|
Validate.isTrue(!parcel.hasBlockVisitors, "A process is already running in this parcel")
|
||||||
return null
|
world.blockManager.setBiome(parcel.id, biome)?.reportProgressUpdates(context, "Biome change")
|
||||||
}
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,8 @@ sealed class ParcelTarget(val world: ParcelWorld, val parsedKind: Int, val isDef
|
|||||||
parcelProvider.getWorld(player.world)
|
parcelProvider.getWorld(player.world)
|
||||||
?: invalidInput(parameter, "You cannot omit the world if you're not in a parcel world")
|
?: invalidInput(parameter, "You cannot omit the world if you're not in a parcel world")
|
||||||
} else {
|
} else {
|
||||||
parcelProvider.getWorld(worldString) ?: invalidInput(parameter, "$worldString is not a parcel world")
|
parcelProvider.getWorld(worldString)
|
||||||
|
?: invalidInput(parameter, "$worldString is not a parcel world")
|
||||||
}
|
}
|
||||||
|
|
||||||
val kind = parameter.paramInfo ?: DEFAULT_KIND
|
val kind = parameter.paramInfo ?: DEFAULT_KIND
|
||||||
|
|||||||
@@ -1,73 +1,73 @@
|
|||||||
package io.dico.parcels2.defaultimpl
|
package io.dico.parcels2.defaultimpl
|
||||||
|
|
||||||
import io.dico.parcels2.Parcel
|
import io.dico.parcels2.Parcel
|
||||||
import io.dico.parcels2.ParcelContainer
|
import io.dico.parcels2.ParcelContainer
|
||||||
import io.dico.parcels2.ParcelId
|
import io.dico.parcels2.ParcelId
|
||||||
import io.dico.parcels2.ParcelWorld
|
import io.dico.parcels2.ParcelWorld
|
||||||
|
|
||||||
class DefaultParcelContainer(val world: ParcelWorld) : ParcelContainer {
|
class DefaultParcelContainer(val world: ParcelWorld) : ParcelContainer {
|
||||||
private var parcels: Array<Array<Parcel>>
|
private var parcels: Array<Array<Parcel>>
|
||||||
|
|
||||||
init {
|
init {
|
||||||
parcels = initArray(world.options.axisLimit, world)
|
parcels = initArray(world.options.axisLimit, world)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resizeIfSizeChanged() {
|
fun resizeIfSizeChanged() {
|
||||||
if (parcels.size != world.options.axisLimit * 2 + 1) {
|
if (parcels.size != world.options.axisLimit * 2 + 1) {
|
||||||
resize(world.options.axisLimit)
|
resize(world.options.axisLimit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resize(axisLimit: Int) {
|
fun resize(axisLimit: Int) {
|
||||||
parcels = initArray(axisLimit, world, this)
|
parcels = initArray(axisLimit, world, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initArray(axisLimit: Int, world: ParcelWorld, cur: DefaultParcelContainer? = null): Array<Array<Parcel>> {
|
fun initArray(axisLimit: Int, world: ParcelWorld, cur: DefaultParcelContainer? = null): Array<Array<Parcel>> {
|
||||||
val arraySize = 2 * axisLimit + 1
|
val arraySize = 2 * axisLimit + 1
|
||||||
return Array(arraySize) {
|
return Array(arraySize) {
|
||||||
val x = it - axisLimit
|
val x = it - axisLimit
|
||||||
Array(arraySize) {
|
Array(arraySize) {
|
||||||
val z = it - axisLimit
|
val z = it - axisLimit
|
||||||
cur?.getParcelById(x, z) ?: ParcelImpl(world, x, z)
|
cur?.getParcelById(x, z) ?: ParcelImpl(world, x, z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getParcelById(x: Int, z: Int): Parcel? {
|
override fun getParcelById(x: Int, z: Int): Parcel? {
|
||||||
return parcels.getOrNull(x + world.options.axisLimit)?.getOrNull(z + world.options.axisLimit)
|
return parcels.getOrNull(x + world.options.axisLimit)?.getOrNull(z + world.options.axisLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getParcelById(id: ParcelId): Parcel? {
|
override fun getParcelById(id: ParcelId): Parcel? {
|
||||||
if (!world.id.equals(id.worldId)) throw IllegalArgumentException()
|
if (!world.id.equals(id.worldId)) throw IllegalArgumentException()
|
||||||
return when (id) {
|
return when (id) {
|
||||||
is Parcel -> id
|
is Parcel -> id
|
||||||
else -> getParcelById(id.x, id.z)
|
else -> getParcelById(id.x, id.z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun nextEmptyParcel(): Parcel? {
|
override suspend fun nextEmptyParcel(): Parcel? {
|
||||||
return walkInCircle().find { it.owner == null }
|
return walkInCircle().find { it.owner == null }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun walkInCircle(): Iterable<Parcel> = Iterable {
|
private fun walkInCircle(): Iterable<Parcel> = Iterable {
|
||||||
iterator {
|
iterator {
|
||||||
val center = world.options.axisLimit
|
val center = world.options.axisLimit
|
||||||
yield(parcels[center][center])
|
yield(parcels[center][center])
|
||||||
for (radius in 0..center) {
|
for (radius in 0..center) {
|
||||||
var x = center - radius;
|
var x = center - radius;
|
||||||
var z = center - radius
|
var z = center - radius
|
||||||
repeat(radius * 2) { yield(parcels[x++][z]) }
|
repeat(radius * 2) { yield(parcels[x++][z]) }
|
||||||
repeat(radius * 2) { yield(parcels[x][z++]) }
|
repeat(radius * 2) { yield(parcels[x][z++]) }
|
||||||
repeat(radius * 2) { yield(parcels[x--][z]) }
|
repeat(radius * 2) { yield(parcels[x--][z]) }
|
||||||
repeat(radius * 2) { yield(parcels[x][z--]) }
|
repeat(radius * 2) { yield(parcels[x][z--]) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAllParcels(): Iterator<Parcel> = iterator {
|
fun getAllParcels(): Iterator<Parcel> = iterator {
|
||||||
for (array in parcels) {
|
for (array in parcels) {
|
||||||
yieldAll(array.iterator())
|
yieldAll(array.iterator())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,75 +1,75 @@
|
|||||||
@file:Suppress("CanBePrimaryConstructorProperty", "UsePropertyAccessSyntax")
|
@file:Suppress("CanBePrimaryConstructorProperty", "UsePropertyAccessSyntax")
|
||||||
|
|
||||||
package io.dico.parcels2.defaultimpl
|
package io.dico.parcels2.defaultimpl
|
||||||
|
|
||||||
import io.dico.parcels2.*
|
import io.dico.parcels2.*
|
||||||
import io.dico.parcels2.options.RuntimeWorldOptions
|
import io.dico.parcels2.options.RuntimeWorldOptions
|
||||||
import io.dico.parcels2.storage.Storage
|
import io.dico.parcels2.storage.Storage
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import org.bukkit.GameRule
|
import org.bukkit.GameRule
|
||||||
import org.bukkit.World
|
import org.bukkit.World
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
class ParcelWorldImpl(
|
class ParcelWorldImpl(
|
||||||
val plugin: ParcelsPlugin,
|
val plugin: ParcelsPlugin,
|
||||||
override val world: World,
|
override val world: World,
|
||||||
override val generator: ParcelGenerator,
|
override val generator: ParcelGenerator,
|
||||||
override var options: RuntimeWorldOptions,
|
override var options: RuntimeWorldOptions,
|
||||||
containerFactory: ParcelContainerFactory
|
containerFactory: ParcelContainerFactory
|
||||||
) : ParcelWorld, ParcelWorldId, ParcelContainer, ParcelLocator {
|
) : ParcelWorld, ParcelWorldId, ParcelContainer, ParcelLocator {
|
||||||
override val id: ParcelWorldId get() = this
|
override val id: ParcelWorldId get() = this
|
||||||
override val uid: UUID? get() = world.uid
|
override val uid: UUID? get() = world.uid
|
||||||
|
|
||||||
override val storage get() = plugin.storage
|
override val storage get() = plugin.storage
|
||||||
override val globalPrivileges get() = plugin.globalPrivileges
|
override val globalPrivileges get() = plugin.globalPrivileges
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (generator.world != world) {
|
if (generator.world != world) {
|
||||||
throw IllegalArgumentException()
|
throw IllegalArgumentException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name: String = world.name!!
|
override val name: String = world.name!!
|
||||||
override val container: ParcelContainer = containerFactory(this)
|
override val container: ParcelContainer = containerFactory(this)
|
||||||
override val locator: ParcelLocator
|
override val locator: ParcelLocator
|
||||||
override val blockManager: ParcelBlockManager
|
override val blockManager: ParcelBlockManager
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val (locator, blockManager) = generator.makeParcelLocatorAndBlockManager(plugin.parcelProvider, container, plugin, plugin.jobDispatcher)
|
val (locator, blockManager) = generator.makeParcelLocatorAndBlockManager(plugin.parcelProvider, container, plugin, plugin.jobDispatcher)
|
||||||
this.locator = locator
|
this.locator = locator
|
||||||
this.blockManager = blockManager
|
this.blockManager = blockManager
|
||||||
enforceOptions()
|
enforceOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enforceOptions() {
|
fun enforceOptions() {
|
||||||
if (options.dayTime) {
|
if (options.dayTime) {
|
||||||
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false)
|
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false)
|
||||||
world.setTime(6000)
|
world.setTime(6000)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.noWeather) {
|
if (options.noWeather) {
|
||||||
world.setStorm(false)
|
world.setStorm(false)
|
||||||
world.setThundering(false)
|
world.setThundering(false)
|
||||||
world.weatherDuration = Int.MAX_VALUE
|
world.weatherDuration = Int.MAX_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
world.setGameRule(GameRule.DO_TILE_DROPS, options.doTileDrops)
|
world.setGameRule(GameRule.DO_TILE_DROPS, options.doTileDrops)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessed by ParcelProviderImpl
|
// Accessed by ParcelProviderImpl
|
||||||
override var creationTime: DateTime? = null
|
override var creationTime: DateTime? = null
|
||||||
|
|
||||||
|
|
||||||
override fun getParcelAt(x: Int, z: Int): Parcel? = locator.getParcelAt(x, z)
|
override fun getParcelAt(x: Int, z: Int): Parcel? = locator.getParcelAt(x, z)
|
||||||
|
|
||||||
override fun getParcelIdAt(x: Int, z: Int): ParcelId? = locator.getParcelIdAt(x, z)
|
override fun getParcelIdAt(x: Int, z: Int): ParcelId? = locator.getParcelIdAt(x, z)
|
||||||
|
|
||||||
override fun getParcelById(x: Int, z: Int): Parcel? = container.getParcelById(x, z)
|
override fun getParcelById(x: Int, z: Int): Parcel? = container.getParcelById(x, z)
|
||||||
|
|
||||||
override fun getParcelById(id: ParcelId): Parcel? = container.getParcelById(id)
|
override fun getParcelById(id: ParcelId): Parcel? = container.getParcelById(id)
|
||||||
|
|
||||||
override fun nextEmptyParcel(): Parcel? = container.nextEmptyParcel()
|
override suspend fun nextEmptyParcel(): Parcel? = container.nextEmptyParcel()
|
||||||
|
|
||||||
override fun toString() = parcelWorldIdToString()
|
override fun toString() = parcelWorldIdToString()
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,79 +1,78 @@
|
|||||||
package io.dico.parcels2.listener
|
package io.dico.parcels2.listener
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession.Stage.BEFORE_REORDER
|
import com.sk89q.worldedit.EditSession.Stage.BEFORE_REORDER
|
||||||
import com.sk89q.worldedit.Vector
|
import com.sk89q.worldedit.WorldEdit
|
||||||
import com.sk89q.worldedit.Vector2D
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin
|
||||||
import com.sk89q.worldedit.WorldEdit
|
import com.sk89q.worldedit.event.extent.EditSessionEvent
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent
|
import com.sk89q.worldedit.extent.Extent
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent
|
import com.sk89q.worldedit.math.BlockVector2
|
||||||
import com.sk89q.worldedit.extent.Extent
|
import com.sk89q.worldedit.math.BlockVector3
|
||||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority.VERY_EARLY
|
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority.VERY_EARLY
|
||||||
import com.sk89q.worldedit.util.eventbus.Subscribe
|
import com.sk89q.worldedit.util.eventbus.Subscribe
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome
|
import com.sk89q.worldedit.world.biome.BaseBiome
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder
|
import com.sk89q.worldedit.world.block.BlockStateHolder
|
||||||
import io.dico.parcels2.ParcelWorld
|
import io.dico.parcels2.ParcelWorld
|
||||||
import io.dico.parcels2.ParcelsPlugin
|
import io.dico.parcels2.ParcelsPlugin
|
||||||
import io.dico.parcels2.canBuildFast
|
import io.dico.parcels2.canBuildFast
|
||||||
import io.dico.parcels2.util.ext.hasPermBuildAnywhere
|
import io.dico.parcels2.util.ext.hasPermBuildAnywhere
|
||||||
import io.dico.parcels2.util.ext.sendParcelMessage
|
import io.dico.parcels2.util.ext.sendParcelMessage
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
|
|
||||||
class WorldEditListener(val parcels: ParcelsPlugin, val worldEdit: WorldEdit) {
|
class WorldEditListener(val parcels: ParcelsPlugin, val worldEdit: WorldEdit) {
|
||||||
|
|
||||||
@Subscribe(priority = VERY_EARLY)
|
@Subscribe(priority = VERY_EARLY)
|
||||||
fun onEditSession(event: EditSessionEvent) {
|
fun onEditSession(event: EditSessionEvent) {
|
||||||
val worldName = event.world?.name ?: return
|
val worldName = event.world?.name ?: return
|
||||||
val world = parcels.parcelProvider.getWorld(worldName) ?: return
|
val world = parcels.parcelProvider.getWorld(worldName) ?: return
|
||||||
if (event.stage == BEFORE_REORDER) return
|
if (event.stage == BEFORE_REORDER) return
|
||||||
|
|
||||||
val actor = event.actor
|
val actor = event.actor
|
||||||
if (actor == null || !actor.isPlayer) return
|
if (actor == null || !actor.isPlayer) return
|
||||||
|
|
||||||
val player = parcels.server.getPlayer(actor.uniqueId)
|
val player = parcels.server.getPlayer(actor.uniqueId)
|
||||||
if (player.hasPermBuildAnywhere) return
|
if (player.hasPermBuildAnywhere) return
|
||||||
|
|
||||||
event.extent = ParcelsExtent(event.extent, world, player)
|
event.extent = ParcelsExtent(event.extent, world, player)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ParcelsExtent(extent: Extent,
|
private class ParcelsExtent(extent: Extent,
|
||||||
val world: ParcelWorld,
|
val world: ParcelWorld,
|
||||||
val player: Player) : AbstractDelegateExtent(extent) {
|
val player: Player) : AbstractDelegateExtent(extent) {
|
||||||
private var messageSent = false
|
private var messageSent = false
|
||||||
|
|
||||||
private fun canBuild(x: Int, z: Int): Boolean {
|
private fun canBuild(x: Int, z: Int): Boolean {
|
||||||
world.getParcelAt(x, z)?.let { parcel ->
|
world.getParcelAt(x, z)?.let { parcel ->
|
||||||
if (parcel.canBuildFast(player)) {
|
if (parcel.canBuildFast(player)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!messageSent) {
|
if (!messageSent) {
|
||||||
messageSent = true
|
messageSent = true
|
||||||
player.sendParcelMessage(except = true, message = "You can't use WorldEdit there")
|
player.sendParcelMessage(except = true, message = "You can't use WorldEdit there")
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setBlock(location: Vector, block: BlockStateHolder<*>): Boolean {
|
override fun setBiome(coord: BlockVector2, biome: BaseBiome): Boolean {
|
||||||
return canBuild(location.blockX, location.blockZ) && super.setBlock(location, block)
|
return canBuild(coord.blockX, coord.blockZ) && super.setBiome(coord, biome)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setBiome(coord: Vector2D, biome: BaseBiome): Boolean {
|
override fun <T : BlockStateHolder<T>> setBlock(location: BlockVector3, block: T): Boolean {
|
||||||
return canBuild(coord.blockX, coord.blockZ) && super.setBiome(coord, biome)
|
return canBuild(location.blockX, location.blockZ) && super.setBlock(location, block)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
companion object {
|
||||||
companion object {
|
fun register(parcels: ParcelsPlugin, worldEditPlugin: Plugin) {
|
||||||
fun register(parcels: ParcelsPlugin, worldEditPlugin: Plugin) {
|
if (worldEditPlugin !is WorldEditPlugin) return
|
||||||
if (worldEditPlugin !is WorldEditPlugin) return
|
val worldEdit = worldEditPlugin.worldEdit
|
||||||
val worldEdit = worldEditPlugin.worldEdit
|
val listener = WorldEditListener(parcels, worldEdit)
|
||||||
val listener = WorldEditListener(parcels, worldEdit)
|
worldEdit.eventBus.register(listener)
|
||||||
worldEdit.eventBus.register(listener)
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@file:Suppress("RedundantLambdaArrow")
|
||||||
|
|
||||||
package io.dico.parcels2.util
|
package io.dico.parcels2.util
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
@@ -8,11 +10,10 @@ interface PluginAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline fun PluginAware.schedule(delay: Int = 0, crossinline task: () -> Unit): BukkitTask {
|
inline fun PluginAware.schedule(delay: Int = 0, crossinline task: () -> Unit): BukkitTask {
|
||||||
return plugin.server.scheduler.runTaskLater(plugin, { task() }, delay.toLong())
|
return plugin.server.scheduler.runTaskLater(plugin, { -> task() }, delay.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun PluginAware.scheduleRepeating(interval: Int, delay: Int = 0, crossinline task: () -> Unit): BukkitTask {
|
inline fun PluginAware.scheduleRepeating(interval: Int, delay: Int = 0, crossinline task: () -> Unit): BukkitTask {
|
||||||
return plugin.server.scheduler.runTaskTimer(plugin, { task() }, delay.toLong(), interval.toLong())
|
return plugin.server.scheduler.runTaskTimer(plugin, { -> task() }, delay.toLong(), interval.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package io.dico.parcels2.util
|
|
||||||
|
|
||||||
fun doParallel() {
|
|
||||||
|
|
||||||
val array = IntArray(1000)
|
|
||||||
IntRange(0, 1000).chunked()
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
20
todo.md
20
todo.md
@@ -88,16 +88,16 @@ After testing on Redstoner
|
|||||||
-
|
-
|
||||||
|
|
||||||
~~Clear (and swap) entities on /p clear etc~~
|
~~Clear (and swap) entities on /p clear etc~~
|
||||||
Fix command lag
|
~~Fix command lag~~
|
||||||
Chorus fruit can grow outside plots
|
Chorus fruit can grow outside plots -- not detectable?
|
||||||
Vines can grow outside plots
|
~~Vines can grow outside plots~~
|
||||||
Ghasts, bats, phantoms and magma cubes can be spawned with eggs
|
~~Ghasts, bats, phantoms and magma cubes can be spawned with eggs~~
|
||||||
ParcelTarget doesn't report a world that wasn't found correctly
|
ParcelTarget doesn't report a world that wasn't found correctly -- ??
|
||||||
Jumping on turtle eggs is considered as interacting with pressure plates
|
~~Jumping on turtle eggs is considered as interacting with pressure plates~~
|
||||||
Setbiome internal error when progress reporting is attached
|
Setbiome internal error when progress reporting is attached
|
||||||
Unclaim doesn't clear the plot. It probably should.
|
~~Unclaim doesn't clear the plot. It probably should.~~ removed
|
||||||
Players can shoot boats and minecarts.
|
Players can shoot boats and minecarts. -- ??
|
||||||
You can use disabled items by rightclicking air.
|
~~You can use disabled items by rightclicking air.~~
|
||||||
Tab complete isn't working correctly.
|
Tab complete isn't working correctly. -- disabled much of it now
|
||||||
~~Bed use in nether and end might not have to be blocked.~~
|
~~Bed use in nether and end might not have to be blocked.~~
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user