mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 19:35:00 -04:00
improve CancelableEvents
This commit is contained in:
parent
8907adb032
commit
694e5a9489
@ -16,8 +16,9 @@ package de.bixilon.minosoft.gui.rendering.modding.events
|
|||||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||||
import de.bixilon.minosoft.gui.rendering.Rendering
|
import de.bixilon.minosoft.gui.rendering.Rendering
|
||||||
import de.bixilon.minosoft.gui.rendering.system.window.BaseWindow
|
import de.bixilon.minosoft.gui.rendering.system.window.BaseWindow
|
||||||
|
import de.bixilon.minosoft.modding.event.events.CancelableEvent
|
||||||
|
|
||||||
class WindowCloseEvent(
|
class WindowCloseEvent(
|
||||||
renderWindow: RenderWindow = Rendering.currentContext!!,
|
renderWindow: RenderWindow = Rendering.currentContext!!,
|
||||||
val window: BaseWindow,
|
val window: BaseWindow,
|
||||||
) : RenderEvent(renderWindow)
|
) : RenderEvent(renderWindow), CancelableEvent
|
||||||
|
@ -32,7 +32,7 @@ class EventInvokerMethod(
|
|||||||
if (!method.parameters[0].type.isAssignableFrom(event.javaClass)) {
|
if (!method.parameters[0].type.isAssignableFrom(event.javaClass)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.isIgnoreCancelled && event is CancelableEvent && event.isCancelled) {
|
if (!this.isIgnoreCancelled && event is CancelableEvent && event.cancelled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
method(listener, event)
|
method(listener, event)
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.modding.event.events;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.play.BlockBreakAnimationS2CP;
|
|
||||||
import glm_.vec3.Vec3i;
|
|
||||||
|
|
||||||
public class BlockBreakAnimationEvent extends CancelableEvent {
|
|
||||||
private final int entityId;
|
|
||||||
private final Vec3i position;
|
|
||||||
private final int stage;
|
|
||||||
|
|
||||||
public BlockBreakAnimationEvent(PlayConnection connection, int entityId, Vec3i position, int stage) {
|
|
||||||
super(connection);
|
|
||||||
this.entityId = entityId;
|
|
||||||
this.position = position;
|
|
||||||
this.stage = stage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockBreakAnimationEvent(PlayConnection connection, BlockBreakAnimationS2CP pkg) {
|
|
||||||
super(connection);
|
|
||||||
this.entityId = pkg.getAnimationId();
|
|
||||||
this.position = pkg.getBlockPosition();
|
|
||||||
this.stage = pkg.getStage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEntityId() {
|
|
||||||
return this.entityId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vec3i getPosition() {
|
|
||||||
return this.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStage() {
|
|
||||||
return this.stage;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.modding.event.events
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.play.BlockBreakAnimationS2CP
|
||||||
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
|
class BlockBreakAnimationEvent(
|
||||||
|
connection: PlayConnection,
|
||||||
|
initiator: EventInitiators,
|
||||||
|
val animationId: Int,
|
||||||
|
val blockPosition: Vec3i,
|
||||||
|
val stage: Int,
|
||||||
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
|
constructor(connection: PlayConnection, packet: BlockBreakAnimationS2CP) : this(connection, EventInitiators.SERVER, packet.animationId, packet.blockPosition, packet.stage)
|
||||||
|
}
|
@ -12,12 +12,20 @@
|
|||||||
*/
|
*/
|
||||||
package de.bixilon.minosoft.modding.event.events
|
package de.bixilon.minosoft.modding.event.events
|
||||||
|
|
||||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
import de.bixilon.minosoft.util.KUtil.synchronizedSetOf
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
|
||||||
|
|
||||||
abstract class CancelableEvent @JvmOverloads constructor(
|
interface CancelableEvent {
|
||||||
connection: PlayConnection,
|
var cancelled: Boolean
|
||||||
initiator: EventInitiators = EventInitiators.DEFAULT,
|
get() = CANCELLED_EVENTS.contains(this)
|
||||||
) : PlayConnectionEvent(connection, initiator) {
|
set(value) {
|
||||||
var isCancelled = false
|
if (value) {
|
||||||
|
CANCELLED_EVENTS -= this
|
||||||
|
} else {
|
||||||
|
CANCELLED_EVENTS += this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
val CANCELLED_EVENTS: MutableSet<CancelableEvent> = synchronizedSetOf()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class ChatMessageReceiveEvent(
|
|||||||
val message: ChatComponent,
|
val message: ChatComponent,
|
||||||
val position: ChatTextPositions,
|
val position: ChatTextPositions,
|
||||||
val sender: UUID?,
|
val sender: UUID?,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: ChatMessageS2CP) : this(connection, EventInitiators.SERVER, packet.message, packet.position, packet.sender)
|
constructor(connection: PlayConnection, packet: ChatMessageS2CP) : this(connection, EventInitiators.SERVER, packet.message, packet.position, packet.sender)
|
||||||
|
@ -15,4 +15,4 @@ package de.bixilon.minosoft.modding.event.events
|
|||||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
|
||||||
class ChatMessageSendEvent(connection: PlayConnection, val message: String) : CancelableEvent(connection, EventInitiators.CLIENT)
|
class ChatMessageSendEvent(connection: PlayConnection, val message: String) : PlayConnectionEvent(connection, EventInitiators.CLIENT), CancelableEvent
|
||||||
|
@ -25,7 +25,7 @@ class CollectItemAnimationEvent(
|
|||||||
val collectedEntity: Entity,
|
val collectedEntity: Entity,
|
||||||
val collector: LivingEntity,
|
val collector: LivingEntity,
|
||||||
val count: Int,
|
val count: Int,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: ItemCollectAnimationS2CP) : this(connection, EventInitiators.SERVER, connection.world.entities[packet.itemEntityId]!!.unsafeCast<Entity>(), connection.world.entities[packet.collectorEntityId]!!.unsafeCast<LivingEntity>(), packet.count)
|
constructor(connection: PlayConnection, packet: ItemCollectAnimationS2CP) : this(connection, EventInitiators.SERVER, connection.world.entities[packet.itemEntityId]!!.unsafeCast<Entity>(), connection.world.entities[packet.collectorEntityId]!!.unsafeCast<LivingEntity>(), packet.count)
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class ContainerCloseEvent(
|
|||||||
connection: PlayConnection,
|
connection: PlayConnection,
|
||||||
initiator: EventInitiators,
|
initiator: EventInitiators,
|
||||||
val containerId: Int,
|
val containerId: Int,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: ContainerCloseS2CP) : this(connection, EventInitiators.SERVER, packet.containerId)
|
constructor(connection: PlayConnection, packet: ContainerCloseS2CP) : this(connection, EventInitiators.SERVER, packet.containerId)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class ExperienceChangeEvent(
|
|||||||
val bar: Float,
|
val bar: Float,
|
||||||
val level: Int,
|
val level: Int,
|
||||||
val total: Int,
|
val total: Int,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: ExperienceSetS2CP) : this(connection, EventInitiators.SERVER, packet.bar, packet.level, packet.total)
|
constructor(connection: PlayConnection, packet: ExperienceSetS2CP) : this(connection, EventInitiators.SERVER, packet.bar, packet.level, packet.total)
|
||||||
}
|
}
|
||||||
|
@ -1,110 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.modding.event.events;
|
|
||||||
|
|
||||||
import com.google.common.collect.HashBiMap;
|
|
||||||
import de.bixilon.minosoft.data.Difficulties;
|
|
||||||
import de.bixilon.minosoft.data.abilities.Gamemodes;
|
|
||||||
import de.bixilon.minosoft.data.registries.Dimension;
|
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation;
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.play.JoinGameS2CP;
|
|
||||||
|
|
||||||
public class JoinGameEvent extends CancelableEvent {
|
|
||||||
private final int entityId;
|
|
||||||
private final boolean hardcore;
|
|
||||||
private final Gamemodes gamemode;
|
|
||||||
private final Dimension dimension;
|
|
||||||
private final Difficulties difficulty;
|
|
||||||
private final int viewDistance;
|
|
||||||
private final int maxPlayers;
|
|
||||||
private final boolean reducedDebugScreen;
|
|
||||||
private final boolean enableRespawnScreen;
|
|
||||||
private final long hashedSeed;
|
|
||||||
private final HashBiMap<ResourceLocation, Dimension> dimensions;
|
|
||||||
|
|
||||||
public JoinGameEvent(PlayConnection connection, int entityId, boolean hardcore, Gamemodes gamemode, Dimension dimension, Difficulties difficulty, int viewDistance, int maxPlayers, boolean reducedDebugScreen, boolean enableRespawnScreen, long hashedSeed, HashBiMap<ResourceLocation, Dimension> dimensions) {
|
|
||||||
super(connection);
|
|
||||||
this.entityId = entityId;
|
|
||||||
this.hardcore = hardcore;
|
|
||||||
this.gamemode = gamemode;
|
|
||||||
this.dimension = dimension;
|
|
||||||
this.difficulty = difficulty;
|
|
||||||
this.viewDistance = viewDistance;
|
|
||||||
this.maxPlayers = maxPlayers;
|
|
||||||
this.reducedDebugScreen = reducedDebugScreen;
|
|
||||||
this.enableRespawnScreen = enableRespawnScreen;
|
|
||||||
this.hashedSeed = hashedSeed;
|
|
||||||
this.dimensions = dimensions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JoinGameEvent(PlayConnection connection, JoinGameS2CP pkg) {
|
|
||||||
super(connection);
|
|
||||||
this.entityId = pkg.getEntityId();
|
|
||||||
this.hardcore = pkg.isHardcore();
|
|
||||||
this.gamemode = pkg.getGamemode();
|
|
||||||
this.dimension = pkg.getDimension();
|
|
||||||
this.difficulty = pkg.getDifficulty();
|
|
||||||
this.viewDistance = pkg.getViewDistance();
|
|
||||||
this.maxPlayers = pkg.getMaxPlayers();
|
|
||||||
this.reducedDebugScreen = pkg.isReducedDebugScreen();
|
|
||||||
this.enableRespawnScreen = pkg.isEnableRespawnScreen();
|
|
||||||
this.hashedSeed = pkg.getHashedSeed();
|
|
||||||
this.dimensions = pkg.getDimensions();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEntityId() {
|
|
||||||
return this.entityId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isHardcore() {
|
|
||||||
return this.hardcore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Gamemodes getGamemode() {
|
|
||||||
return this.gamemode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dimension getDimension() {
|
|
||||||
return this.dimension;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Difficulties getDifficulty() {
|
|
||||||
return this.difficulty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getViewDistance() {
|
|
||||||
return this.viewDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxPlayers() {
|
|
||||||
return this.maxPlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReducedDebugScreen() {
|
|
||||||
return this.reducedDebugScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnableRespawnScreen() {
|
|
||||||
return this.enableRespawnScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getHashedSeed() {
|
|
||||||
return this.hashedSeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashBiMap<ResourceLocation, Dimension> getDimensions() {
|
|
||||||
return this.dimensions;
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,7 +21,7 @@ class OpenSignEditorEvent(
|
|||||||
connection: PlayConnection,
|
connection: PlayConnection,
|
||||||
initiator: EventInitiators,
|
initiator: EventInitiators,
|
||||||
val blockPosition: Vec3i,
|
val blockPosition: Vec3i,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: SignEditorOpenS2CP) : this(connection, EventInitiators.SERVER, packet.blockPosition)
|
constructor(connection: PlayConnection, packet: SignEditorOpenS2CP) : this(connection, EventInitiators.SERVER, packet.blockPosition)
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ class ParticleSpawnEvent(
|
|||||||
val speed: Float,
|
val speed: Float,
|
||||||
val count: Int,
|
val count: Int,
|
||||||
val data: ParticleData,
|
val data: ParticleData,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
val position: Vec3d = position
|
val position: Vec3d = position
|
||||||
get() = Vec3d(field)
|
get() = Vec3d(field)
|
||||||
val offset: Vec3 = offset
|
val offset: Vec3 = offset
|
||||||
|
@ -29,7 +29,7 @@ class PlaySoundEvent(
|
|||||||
val soundEvent: SoundEvent,
|
val soundEvent: SoundEvent,
|
||||||
val volume: Float,
|
val volume: Float,
|
||||||
val pitch: Float,
|
val pitch: Float,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
val position: Vec3 = position
|
val position: Vec3 = position
|
||||||
get() = Vec3(field)
|
get() = Vec3(field)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class PlayerListInfoChangeEvent(
|
|||||||
initiator: EventInitiators,
|
initiator: EventInitiators,
|
||||||
val header: ChatComponent,
|
val header: ChatComponent,
|
||||||
val footer: ChatComponent,
|
val footer: ChatComponent,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: TabListTextSetS2CP) : this(connection, EventInitiators.SERVER, packet.header, packet.footer)
|
constructor(connection: PlayConnection, packet: TabListTextSetS2CP) : this(connection, EventInitiators.SERVER, packet.header, packet.footer)
|
||||||
}
|
}
|
||||||
|
@ -10,30 +10,19 @@
|
|||||||
*
|
*
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
package de.bixilon.minosoft.modding.event.events
|
||||||
|
|
||||||
package de.bixilon.minosoft.modding.event.events;
|
import de.bixilon.minosoft.data.player.tab.TabListItemData
|
||||||
|
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.play.TabListDataS2CP
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.player.tab.TabListItemData;
|
class PlayerListItemChangeEvent(
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
connection: PlayConnection,
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.play.TabListDataS2CP;
|
initiator: EventInitiators,
|
||||||
|
val items: Map<UUID, TabListItemData>,
|
||||||
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
import java.util.Map;
|
constructor(connection: PlayConnection, packet: TabListDataS2CP) : this(connection, EventInitiators.SERVER, packet.items)
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class PlayerListItemChangeEvent extends CancelableEvent {
|
|
||||||
private final Map<UUID, TabListItemData> items;
|
|
||||||
|
|
||||||
public PlayerListItemChangeEvent(PlayConnection connection, Map<UUID, TabListItemData> items) {
|
|
||||||
super(connection);
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerListItemChangeEvent(PlayConnection connection, TabListDataS2CP pkg) {
|
|
||||||
super(connection);
|
|
||||||
this.items = pkg.getItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<UUID, TabListItemData> getItems() {
|
|
||||||
return this.items;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -20,10 +20,10 @@ import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
|||||||
|
|
||||||
class PluginMessageReceiveEvent(
|
class PluginMessageReceiveEvent(
|
||||||
connection: PlayConnection,
|
connection: PlayConnection,
|
||||||
initiators: EventInitiators,
|
initiator: EventInitiators,
|
||||||
val channel: ResourceLocation,
|
val channel: ResourceLocation,
|
||||||
data: PlayInByteBuffer,
|
data: PlayInByteBuffer,
|
||||||
) : CancelableEvent(connection, initiators) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
val data: PlayInByteBuffer = data
|
val data: PlayInByteBuffer = data
|
||||||
get() = PlayInByteBuffer(field)
|
get() = PlayInByteBuffer(field)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class ResourcePackRequestEvent(
|
|||||||
val url: String,
|
val url: String,
|
||||||
val hash: String,
|
val hash: String,
|
||||||
val promptText: ChatComponent?,
|
val promptText: ChatComponent?,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: ResourcepackRequestS2CP) : this(connection, EventInitiators.SERVER, packet.url, packet.hash, packet.promptText)
|
constructor(connection: PlayConnection, packet: ResourcepackRequestS2CP) : this(connection, EventInitiators.SERVER, packet.url, packet.hash, packet.promptText)
|
||||||
|
@ -21,7 +21,7 @@ class TimeChangeEvent(
|
|||||||
initiator: EventInitiators,
|
initiator: EventInitiators,
|
||||||
val age: Long,
|
val age: Long,
|
||||||
val time: Long,
|
val time: Long,
|
||||||
) : CancelableEvent(connection, initiator) {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: WorldTimeSetS2CP) : this(connection, EventInitiators.SERVER, packet.age, packet.time)
|
constructor(connection: PlayConnection, packet: WorldTimeSetS2CP) : this(connection, EventInitiators.SERVER, packet.age, packet.time)
|
||||||
|
@ -65,7 +65,9 @@ abstract class Connection : EventMaster {
|
|||||||
eventInvoker(event)
|
eventInvoker(event)
|
||||||
}
|
}
|
||||||
if (event is CancelableEvent) {
|
if (event is CancelableEvent) {
|
||||||
return event.isCancelled
|
val cancelled = event.cancelled
|
||||||
|
event.cancelled = false // Cleanup memory
|
||||||
|
return cancelled
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import de.bixilon.minosoft.data.registries.ResourceLocation
|
|||||||
import de.bixilon.minosoft.data.world.biome.accessor.BlockBiomeAccessor
|
import de.bixilon.minosoft.data.world.biome.accessor.BlockBiomeAccessor
|
||||||
import de.bixilon.minosoft.data.world.biome.accessor.NoiseBiomeAccessor
|
import de.bixilon.minosoft.data.world.biome.accessor.NoiseBiomeAccessor
|
||||||
import de.bixilon.minosoft.modding.channels.DefaultPluginChannels
|
import de.bixilon.minosoft.modding.channels.DefaultPluginChannels
|
||||||
import de.bixilon.minosoft.modding.event.events.JoinGameEvent
|
|
||||||
import de.bixilon.minosoft.protocol.ErrorHandler
|
import de.bixilon.minosoft.protocol.ErrorHandler
|
||||||
import de.bixilon.minosoft.protocol.network.connection.Connection
|
import de.bixilon.minosoft.protocol.network.connection.Connection
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
@ -140,9 +139,6 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
if (connection.fireEvent(JoinGameEvent(connection, this))) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val playerEntity = connection.player
|
val playerEntity = connection.player
|
||||||
playerEntity.tabListItem.gamemode = gamemode
|
playerEntity.tabListItem.gamemode = gamemode
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user