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
util
API Gotchas
Common API mistakes and their corrections. Read this before writing Hytale plugins!
Example Code
// ❌ WRONG: Message.append() does not exist
Message.raw("Hello").append(Message.raw(" World"));
// ✅ CORRECT: Use Message.join()
Message.join(Message.raw("Hello"), Message.raw(" World"));
// ❌ WRONG: Color.AQUA does not exist
Message.raw("text").color(Color.AQUA);
// ✅ CORRECT: Use Color.CYAN
Message.raw("text").color(Color.CYAN);
// ❌ WRONG: PlayerChatEvent.getPlayer()
public void onChat(PlayerChatEvent event) {
Player p = event.getPlayer(); // Does not exist!
}
// ✅ CORRECT: Use getSender() which returns PlayerRef
public void onChat(PlayerChatEvent event) {
PlayerRef sender = event.getSender();
sender.sendMessage(...);
}
// ❌ WRONG: Teleport.createForPlayer() may not exist
Teleport.createForPlayer(world, pos, rot);
// ✅ CORRECT: Use constructor directly
new Teleport(world, position, rotation);
// ❌ WRONG: Modifying MovementSettings without syncing
settings.canFly = true;
// Player still cant fly!
// ✅ CORRECT: Must call update() to sync to client
settings.canFly = true;
movementManager.update(playerRef.getPacketHandler());
// ❌ WRONG: setPosition for teleport
transform.setPosition(new Vector3d(x, y, z));
// May not sync properly!
// ✅ CORRECT: teleportPosition for teleport
transform.teleportPosition(new Vector3d(x, y, z));
Thread Safety
N/A
Common Mistakes
All the mistakes listed in the code example are common pitfalls found in documentation that does not match the actual API.