Code Patterns
Copy-paste examples for common plugin tasks. Commands, events, ECS, GUI, and more.
All
225
Command
60
Damage
2
Ecs
27
Entity
5
Gui
75
Interaction
2
Inventory
4
Moderation
3
Permission
2
Player
9
Plugin
4
Storage
2
Teleport
3
Ui
22
Util
5
← Back to Patterns
java
ecs
Place Block Listener
EntityEventSystem implementation
Example Code
package dev.myplugin.example;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.EntityEventSystem;
import com.hypixel.hytale.server.core.event.events.ecs.PlaceBlockEvent;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
import static ar.ncode.plugin.TroubleInTrorkTownPlugin.config;
public class ExampleClass extends EntityEventSystem<EntityStore, PlaceBlockEvent> {
public ExampleClass() {
super(PlaceBlockEvent.class);
}
@Override
public void handle(
int i, @NonNullDecl ArchetypeChunk<EntityStore> archetypeChunk,
@NonNullDecl Store<EntityStore> store, @NonNullDecl CommandBuffer<EntityStore> commandBuffer,
@NonNullDecl PlaceBlockEvent event
) {
if (config.get().isDebugMode()) {
return;
}
// By default, block players from breaking blocks
event.setCancelled(true);
}
@NullableDecl
@Override
public Query<EntityStore> getQuery() {
return Archetype.empty();
}
}