4 Classes
Andus edited this page 2024-05-26 01:00:55 +02:00

Custom Classes

NPC.java

For creating fake players (for example in Lobby)

Usage:

NPC npc = new NPC(String, PlayerSkin, PlayerSkin, boolean = false);
npc.setInstance(Instance, Pos);

Example usage from LobbyManager:

...
NPC npc = new NPC(player.getUsername(), PlayerSkin.fromUsername(player.getUsername()).getTextures(), PlayerSkin.fromUsername(player.getUsername()).getSignature(), LobbyManager.isLobbyOwner(player));

npc.setInstance(instance, spawnPosition);
...

Explanation:

  • String is for the NPC name (for example some player's username)
  • First PlayerSkin is for the player's skin
  • Second PlayerSkin is for the player's skin signature
  • boolean is used to know if player is the owner of the lobby to make the name gold and add a crown alongside it. (by default it's false, and doesn't need to be set)

PistonPusher.java

Used for pushing block without using pistons (piston packet is sent to players to push the block without showing an actual piston).

Usage:

PistonPusher.push(Instance, Pos, Direction, int);

Example usage from MovingWalls:

PistonPusher.push(instance, pos, Direction.NORTH, 20);

Explanation:

  • Instance defines where is the block
  • Pos defines block's position/coordinates
  • Direction defines on which direction should the block move
  • int defines the number of times the block should be pushed

MCFGServer.java

Used mainly for registering Listeners (Player join, leave, spawn, etc.)

MCFGQueue.java

Stores player UUIDs for a certain queue (players waiting to play in Quick Play).

Example usage from QueueManager:

public static void createQueue(Player player, MCFGModes mode) {
    MCFGQueue newQueue = new MCFGQueue();
    newQueue.setMode(mode);
    newQueue.addPlayer(player.getUuid());
    queues.add(newQueue);
}

MCFGLobby.java

Stores player UUIDs for a specific lobby (players waiting with other players which they picked to play with).

MCFGGameLobby.java

Stores player UUIDs that are playing with each other.

MCFGModes.java

Contains queue/lobby modes:

  • SOLO
  • DUO
  • TRIO

LobbyConverter.java

Converts Queue or Lobby to GameLobby and vice versa.

Example usage:

String lobby = LobbyConverter.toGame(playerList); // Converts Lobby/Queue to GameLobby
...
String gamelobby = LobbyConverter.fromGame(playerList); // Converts GameLobby to Lobby (If it's queue, players are just removed from GameLobby)