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;
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ class CommandsGeneral(plugin: ParcelsPlugin, parent: SpecialCommandAddress) : Ab
|
|||||||
return "Enjoy your new parcel!"
|
return "Enjoy your new parcel!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Cmd("unclaim")
|
@Cmd("unclaim")
|
||||||
@Desc("Unclaims this parcel")
|
@Desc("Unclaims this parcel")
|
||||||
@RequireParcelPrivilege(Privilege.OWNER)
|
@RequireParcelPrivilege(Privilege.OWNER)
|
||||||
@@ -120,7 +121,7 @@ class CommandsGeneral(plugin: ParcelsPlugin, parent: SpecialCommandAddress) : Ab
|
|||||||
checkConnected("be unclaimed")
|
checkConnected("be unclaimed")
|
||||||
parcel.dispose()
|
parcel.dispose()
|
||||||
return "Your parcel has been disposed"
|
return "Your parcel has been disposed"
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Cmd("clear")
|
@Cmd("clear")
|
||||||
@RequireParcelPrivilege(Privilege.OWNER)
|
@RequireParcelPrivilege(Privilege.OWNER)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class DefaultParcelContainer(val world: ParcelWorld) : ParcelContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun nextEmptyParcel(): Parcel? {
|
override suspend fun nextEmptyParcel(): Parcel? {
|
||||||
return walkInCircle().find { it.owner == null }
|
return walkInCircle().find { it.owner == null }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class ParcelWorldImpl(
|
|||||||
|
|
||||||
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()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import io.dico.parcels2.storage.Storage
|
|||||||
import io.dico.parcels2.util.ext.*
|
import io.dico.parcels2.util.ext.*
|
||||||
import io.dico.parcels2.util.math.*
|
import io.dico.parcels2.util.math.*
|
||||||
import org.bukkit.Location
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Material
|
||||||
import org.bukkit.Material.*
|
import org.bukkit.Material.*
|
||||||
import org.bukkit.World
|
import org.bukkit.World
|
||||||
import org.bukkit.block.Biome
|
import org.bukkit.block.Biome
|
||||||
@@ -209,7 +210,7 @@ class ParcelListeners(
|
|||||||
* Prevents player from using beds in HELL or SKY biomes if explosions are disabled.
|
* Prevents player from using beds in HELL or SKY biomes if explosions are disabled.
|
||||||
*/
|
*/
|
||||||
@Suppress("NON_EXHAUSTIVE_WHEN")
|
@Suppress("NON_EXHAUSTIVE_WHEN")
|
||||||
@field:ListenerMarker(priority = NORMAL)
|
@field:ListenerMarker(priority = NORMAL, ignoreCancelled = false)
|
||||||
val onPlayerInteractEvent = RegistratorListener<PlayerInteractEvent> l@{ event ->
|
val onPlayerInteractEvent = RegistratorListener<PlayerInteractEvent> l@{ event ->
|
||||||
val user = event.player
|
val user = event.player
|
||||||
val world = parcelProvider.getWorld(user.world) ?: return@l
|
val world = parcelProvider.getWorld(user.world) ?: return@l
|
||||||
@@ -223,6 +224,7 @@ class ParcelListeners(
|
|||||||
|
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
Action.RIGHT_CLICK_BLOCK -> run {
|
Action.RIGHT_CLICK_BLOCK -> run {
|
||||||
|
if (event.isCancelled) return@l
|
||||||
val type = clickedBlock.type
|
val type = clickedBlock.type
|
||||||
|
|
||||||
val interactableClass = Interactables[type]
|
val interactableClass = Interactables[type]
|
||||||
@@ -259,12 +261,18 @@ class ParcelListeners(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Action.RIGHT_CLICK_AIR -> onPlayerRightClick(event, world, parcel)
|
Action.RIGHT_CLICK_AIR -> onPlayerRightClick(event, world, parcel)
|
||||||
Action.PHYSICAL -> if (!canBuildOnArea(user, parcel) && !(parcel != null && parcel.interactableConfig("pressure_plates"))) {
|
Action.PHYSICAL -> if (!event.isCancelled && !canBuildOnArea(user, parcel)) {
|
||||||
|
if (clickedBlock.type == Material.TURTLE_EGG) {
|
||||||
|
event.isCancelled = true; return@l
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(parcel != null && parcel.interactableConfig("pressure_plates"))) {
|
||||||
user.sendParcelMessage(nopermit = true, message = "You cannot use inputs in this parcel")
|
user.sendParcelMessage(nopermit = true, message = "You cannot use inputs in this parcel")
|
||||||
event.isCancelled = true; return@l
|
event.isCancelled = true; return@l
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// private val blockPlaceInteractItems = EnumSet.of(LAVA_BUCKET, WATER_BUCKET, BUCKET, FLINT_AND_STEEL)
|
// private val blockPlaceInteractItems = EnumSet.of(LAVA_BUCKET, WATER_BUCKET, BUCKET, FLINT_AND_STEEL)
|
||||||
|
|
||||||
@@ -437,13 +445,15 @@ class ParcelListeners(
|
|||||||
@field:ListenerMarker(priority = NORMAL)
|
@field:ListenerMarker(priority = NORMAL)
|
||||||
val onEntitySpawnEvent = RegistratorListener<EntitySpawnEvent> l@{ event ->
|
val onEntitySpawnEvent = RegistratorListener<EntitySpawnEvent> l@{ event ->
|
||||||
val world = parcelProvider.getWorld(event.entity.world) ?: return@l
|
val world = parcelProvider.getWorld(event.entity.world) ?: return@l
|
||||||
if (event.entity is Creature && world.options.blockMobSpawning) {
|
if (event.entity is Mob && world.options.blockMobSpawning) {
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
} else if (world.getParcelAt(event.entity).let { it != null && it.hasBlockVisitors }) {
|
} else if (world.getParcelAt(event.entity).let { it != null && it.hasBlockVisitors }) {
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prevents minecarts/boats from moving outside a plot
|
* Prevents minecarts/boats from moving outside a plot
|
||||||
*/
|
*/
|
||||||
@@ -471,7 +481,7 @@ class ParcelListeners(
|
|||||||
@field:ListenerMarker(priority = NORMAL)
|
@field:ListenerMarker(priority = NORMAL)
|
||||||
val onEntityDamageByEntityEvent = RegistratorListener<EntityDamageByEntityEvent> l@{ event ->
|
val onEntityDamageByEntityEvent = RegistratorListener<EntityDamageByEntityEvent> l@{ event ->
|
||||||
val world = parcelProvider.getWorld(event.entity.world) ?: return@l
|
val world = parcelProvider.getWorld(event.entity.world) ?: return@l
|
||||||
if (world.options.disableExplosions && event.damager is ExplosiveMinecart || event.damager is Creeper) {
|
if (world.options.disableExplosions && (event.damager is ExplosiveMinecart || event.damager is Creeper)) {
|
||||||
event.isCancelled = true; return@l
|
event.isCancelled = true; return@l
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,6 +548,14 @@ class ParcelListeners(
|
|||||||
event.blocks.removeIf { world.getParcelAt(it.block) !== area }
|
event.blocks.removeIf { world.getParcelAt(it.block) !== area }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@field:ListenerMarker(priority = NORMAL)
|
||||||
|
val onBlockGrowEvent = RegistratorListener<BlockGrowEvent> l@{ event ->
|
||||||
|
val (world, area) = getWorldAndArea(event.block) ?: return@l
|
||||||
|
if (area == null) {
|
||||||
|
event.isCancelled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prevents dispensers/droppers from dispensing out of parcels
|
* Prevents dispensers/droppers from dispensing out of parcels
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
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.Vector2D
|
|
||||||
import com.sk89q.worldedit.WorldEdit
|
import com.sk89q.worldedit.WorldEdit
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent
|
import com.sk89q.worldedit.event.extent.EditSessionEvent
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent
|
||||||
import com.sk89q.worldedit.extent.Extent
|
import com.sk89q.worldedit.extent.Extent
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2
|
||||||
|
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
|
||||||
@@ -57,14 +57,13 @@ class WorldEditListener(val parcels: ParcelsPlugin, val worldEdit: WorldEdit) {
|
|||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setBiome(coord: Vector2D, biome: BaseBiome): Boolean {
|
|
||||||
return canBuild(coord.blockX, coord.blockZ) && super.setBiome(coord, biome)
|
return canBuild(coord.blockX, coord.blockZ) && super.setBiome(coord, biome)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun <T : BlockStateHolder<T>> setBlock(location: BlockVector3, block: T): Boolean {
|
||||||
|
return canBuild(location.blockX, location.blockZ) && super.setBlock(location, block)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -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