mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 10:36:43 +00:00
Fixes #114
This commit is contained in:
parent
8b0460f5f1
commit
0bd25df977
@ -20,35 +20,35 @@ public class UserCreationListener implements GameEventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(GameEvent event) {
|
public void handle(GameEvent event) {
|
||||||
|
|
||||||
User user = (User) event.getSource();
|
|
||||||
|
|
||||||
LogManager.LOGGER.fine("(Plugin) Handled User creation event (Cubot Plugin)");
|
|
||||||
|
|
||||||
Cubot cubot = new Cubot();
|
|
||||||
|
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
|
User user = (User) event.getSource();
|
||||||
|
Cubot cubot = new Cubot();
|
||||||
|
cubot.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId());
|
||||||
|
|
||||||
|
Point point = null;
|
||||||
|
while (point == null || cubot.getWorld() == null) {
|
||||||
int spawnX = GameServer.INSTANCE.getConfig().getInt("new_user_worldX") + random.nextInt(5);
|
int spawnX = GameServer.INSTANCE.getConfig().getInt("new_user_worldX") + random.nextInt(5);
|
||||||
int spawnY = GameServer.INSTANCE.getConfig().getInt("new_user_worldY") + random.nextInt(5);
|
int spawnY = GameServer.INSTANCE.getConfig().getInt("new_user_worldY") + random.nextInt(5);
|
||||||
|
|
||||||
cubot.setWorld(GameServer.INSTANCE.getGameUniverse().getWorld(spawnX, spawnY, true));
|
cubot.setWorld(GameServer.INSTANCE.getGameUniverse().getWorld(spawnX, spawnY, true));
|
||||||
|
|
||||||
|
point = cubot.getWorld().getRandomPassableTile();
|
||||||
|
}
|
||||||
|
|
||||||
|
cubot.setX(point.x);
|
||||||
|
cubot.setY(point.y);
|
||||||
cubot.getWorld().getGameObjects().add(cubot);
|
cubot.getWorld().getGameObjects().add(cubot);
|
||||||
cubot.getWorld().incUpdatable();
|
cubot.getWorld().incUpdatable();
|
||||||
|
|
||||||
cubot.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId());
|
|
||||||
|
|
||||||
cubot.setHeldItem(GameServer.INSTANCE.getConfig().getInt("new_user_item"));
|
cubot.setHeldItem(GameServer.INSTANCE.getConfig().getInt("new_user_item"));
|
||||||
|
|
||||||
cubot.setEnergy(GameServer.INSTANCE.getConfig().getInt("battery_max_energy"));
|
cubot.setEnergy(GameServer.INSTANCE.getConfig().getInt("battery_max_energy"));
|
||||||
cubot.setMaxEnergy(GameServer.INSTANCE.getConfig().getInt("battery_max_energy"));
|
cubot.setMaxEnergy(GameServer.INSTANCE.getConfig().getInt("battery_max_energy"));
|
||||||
|
|
||||||
cubot.setParent(user);
|
cubot.setParent(user);
|
||||||
|
|
||||||
Point point = cubot.getWorld().getRandomPassableTile();
|
|
||||||
|
|
||||||
cubot.setX(point.x);
|
|
||||||
cubot.setY(point.y);
|
|
||||||
|
|
||||||
user.setControlledUnit(cubot);
|
user.setControlledUnit(cubot);
|
||||||
|
|
||||||
|
LogManager.LOGGER.fine("(Plugin) Handled User creation event (Cubot Plugin)");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user