Archived
0

Perform some fixes

This commit is contained in:
Dico Karssiens
2019-01-06 12:02:34 +00:00
parent 5ef2584fdb
commit a475226ffc
10 changed files with 1063 additions and 1052 deletions

View File

@@ -238,14 +238,14 @@ public class RootCommandAddress extends ModifiableCommandAddress implements ICom
try {
ICommandAddress target = getCommandTarget(context, buffer);
List<String> out;
if (target.hasCommand()) {
List<String> out = Collections.emptyList();
/*if (target.hasCommand()) {
context.setCommand(target.getCommand());
target.getCommand().initializeAndFilterContext(context);
out = target.getCommand().tabComplete(sender, context, location);
} else {
out = Collections.emptyList();
}
}*/
int cursor = buffer.getCursor();
String input;

View File

@@ -113,6 +113,7 @@ class CommandsGeneral(plugin: ParcelsPlugin, parent: SpecialCommandAddress) : Ab
return "Enjoy your new parcel!"
}
/*
@Cmd("unclaim")
@Desc("Unclaims this parcel")
@RequireParcelPrivilege(Privilege.OWNER)
@@ -120,7 +121,7 @@ class CommandsGeneral(plugin: ParcelsPlugin, parent: SpecialCommandAddress) : Ab
checkConnected("be unclaimed")
parcel.dispose()
return "Your parcel has been disposed"
}
}*/
@Cmd("clear")
@RequireParcelPrivilege(Privilege.OWNER)

View File

@@ -106,7 +106,8 @@ sealed class ParcelTarget(val world: ParcelWorld, val parsedKind: Int, val isDef
parcelProvider.getWorld(player.world)
?: invalidInput(parameter, "You cannot omit the world if you're not in a parcel world")
} 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

View File

@@ -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 }
}

View File

@@ -69,7 +69,7 @@ class ParcelWorldImpl(
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()
}

View File

@@ -10,6 +10,7 @@ import io.dico.parcels2.storage.Storage
import io.dico.parcels2.util.ext.*
import io.dico.parcels2.util.math.*
import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.Material.*
import org.bukkit.World
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.
*/
@Suppress("NON_EXHAUSTIVE_WHEN")
@field:ListenerMarker(priority = NORMAL)
@field:ListenerMarker(priority = NORMAL, ignoreCancelled = false)
val onPlayerInteractEvent = RegistratorListener<PlayerInteractEvent> l@{ event ->
val user = event.player
val world = parcelProvider.getWorld(user.world) ?: return@l
@@ -223,6 +224,7 @@ class ParcelListeners(
when (event.action) {
Action.RIGHT_CLICK_BLOCK -> run {
if (event.isCancelled) return@l
val type = clickedBlock.type
val interactableClass = Interactables[type]
@@ -259,12 +261,18 @@ class ParcelListeners(
}
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")
event.isCancelled = true; return@l
}
}
}
}
// private val blockPlaceInteractItems = EnumSet.of(LAVA_BUCKET, WATER_BUCKET, BUCKET, FLINT_AND_STEEL)
@@ -437,13 +445,15 @@ class ParcelListeners(
@field:ListenerMarker(priority = NORMAL)
val onEntitySpawnEvent = RegistratorListener<EntitySpawnEvent> l@{ event ->
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
} else if (world.getParcelAt(event.entity).let { it != null && it.hasBlockVisitors }) {
event.isCancelled = true
}
}
/*
* Prevents minecarts/boats from moving outside a plot
*/
@@ -471,7 +481,7 @@ class ParcelListeners(
@field:ListenerMarker(priority = NORMAL)
val onEntityDamageByEntityEvent = RegistratorListener<EntityDamageByEntityEvent> l@{ event ->
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
}
@@ -538,6 +548,14 @@ class ParcelListeners(
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
*/

View File

@@ -1,13 +1,13 @@
package io.dico.parcels2.listener
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.bukkit.WorldEditPlugin
import com.sk89q.worldedit.event.extent.EditSessionEvent
import com.sk89q.worldedit.extent.AbstractDelegateExtent
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.Subscribe
import com.sk89q.worldedit.world.biome.BaseBiome
@@ -57,14 +57,13 @@ class WorldEditListener(val parcels: ParcelsPlugin, val worldEdit: WorldEdit) {
return false
}
override fun setBlock(location: Vector, block: BlockStateHolder<*>): Boolean {
return canBuild(location.blockX, location.blockZ) && super.setBlock(location, block)
}
override fun setBiome(coord: Vector2D, biome: BaseBiome): Boolean {
override fun setBiome(coord: BlockVector2, biome: BaseBiome): Boolean {
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 {

View File

@@ -1,3 +1,5 @@
@file:Suppress("RedundantLambdaArrow")
package io.dico.parcels2.util
import org.bukkit.plugin.Plugin
@@ -8,11 +10,10 @@ interface PluginAware {
}
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 {
return plugin.server.scheduler.runTaskTimer(plugin, { task() }, delay.toLong(), interval.toLong())
return plugin.server.scheduler.runTaskTimer(plugin, { -> task() }, delay.toLong(), interval.toLong())
}

View File

@@ -1,9 +0,0 @@
package io.dico.parcels2.util
fun doParallel() {
val array = IntArray(1000)
IntRange(0, 1000).chunked()
}

20
todo.md
View File

@@ -88,16 +88,16 @@ After testing on Redstoner
-
~~Clear (and swap) entities on /p clear etc~~
Fix command lag
Chorus fruit can grow outside plots
Vines can grow outside plots
Ghasts, bats, phantoms and magma cubes can be spawned with eggs
ParcelTarget doesn't report a world that wasn't found correctly
Jumping on turtle eggs is considered as interacting with pressure plates
~~Fix command lag~~
Chorus fruit can grow outside plots -- not detectable?
~~Vines can grow outside plots~~
~~Ghasts, bats, phantoms and magma cubes can be spawned with eggs~~
ParcelTarget doesn't report a world that wasn't found correctly -- ??
~~Jumping on turtle eggs is considered as interacting with pressure plates~~
Setbiome internal error when progress reporting is attached
Unclaim doesn't clear the plot. It probably should.
Players can shoot boats and minecarts.
You can use disabled items by rightclicking air.
Tab complete isn't working correctly.
~~Unclaim doesn't clear the plot. It probably should.~~ removed
Players can shoot boats and minecarts. -- ??
~~You can use disabled items by rightclicking air.~~
Tab complete isn't working correctly. -- disabled much of it now
~~Bed use in nether and end might not have to be blocked.~~