use of cn.nukkit.lang.TranslationContainer in project Nukkit by Nukkit.
the class Player method doFirstSpawn.
protected void doFirstSpawn() {
this.spawned = true;
this.getAdventureSettings().update();
this.sendPotionEffects(this);
this.sendData(this);
this.inventory.sendContents(this);
this.inventory.sendArmorContents(this);
SetTimePacket setTimePacket = new SetTimePacket();
setTimePacket.time = this.level.getTime();
this.dataPacket(setTimePacket);
Position pos = this.level.getSafeSpawn(this);
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this, pos);
this.server.getPluginManager().callEvent(respawnEvent);
pos = respawnEvent.getRespawnPosition();
if (this.getHealth() <= 0) {
RespawnPacket respawnPacket = new RespawnPacket();
pos = this.getSpawn();
respawnPacket.x = (float) pos.x;
respawnPacket.y = (float) pos.y;
respawnPacket.z = (float) pos.z;
this.dataPacket(respawnPacket);
} else {
RespawnPacket respawnPacket = new RespawnPacket();
respawnPacket.x = (float) pos.x;
respawnPacket.y = (float) pos.y;
respawnPacket.z = (float) pos.z;
this.dataPacket(respawnPacket);
}
this.sendPlayStatus(PlayStatusPacket.PLAYER_SPAWN);
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(this, new TranslationContainer(TextFormat.YELLOW + "%multiplayer.player.joined", new String[] { this.getDisplayName() }));
this.server.getPluginManager().callEvent(playerJoinEvent);
if (playerJoinEvent.getJoinMessage().toString().trim().length() > 0) {
this.server.broadcastMessage(playerJoinEvent.getJoinMessage());
}
this.noDamageTicks = 60;
this.getServer().sendRecipeList(this);
if (this.gamemode == Player.SPECTATOR) {
InventoryContentPacket inventoryContentPacket = new InventoryContentPacket();
inventoryContentPacket.inventoryId = ContainerIds.CREATIVE;
this.dataPacket(inventoryContentPacket);
} else {
inventory.sendCreativeContents();
}
for (long index : this.usedChunks.keySet()) {
int chunkX = Level.getHashX(index);
int chunkZ = Level.getHashZ(index);
for (Entity entity : this.level.getChunkEntities(chunkX, chunkZ).values()) {
if (this != entity && !entity.closed && entity.isAlive()) {
entity.spawnTo(this);
}
}
}
int experience = this.getExperience();
if (experience != 0) {
this.sendExperience(experience);
}
int level = this.getExperienceLevel();
if (level != 0) {
this.sendExperienceLevel(this.getExperienceLevel());
}
// Prevent PlayerTeleportEvent during player spawn
this.teleport(pos, null);
if (!this.isSpectator()) {
this.spawnToAll();
}
// Weather
if (this.level.isRaining() || this.level.isThundering()) {
this.getLevel().sendWeather(this);
}
this.getLevel().sendWeather(this);
// FoodLevel
PlayerFood food = this.getFoodData();
if (food.getLevel() != food.getMaxLevel()) {
food.sendFoodLevel();
}
}
use of cn.nukkit.lang.TranslationContainer in project Nukkit by Nukkit.
the class PluginsCommand method sendPluginList.
private void sendPluginList(CommandSender sender) {
String list = "";
Map<String, Plugin> plugins = sender.getServer().getPluginManager().getPlugins();
for (Plugin plugin : plugins.values()) {
if (list.length() > 0) {
list += TextFormat.WHITE + ", ";
}
list += plugin.isEnabled() ? TextFormat.GREEN : TextFormat.RED;
list += plugin.getDescription().getFullName();
}
sender.sendMessage(new TranslationContainer("nukkit.command.plugins.success", new String[] { String.valueOf(plugins.size()), list }));
}
use of cn.nukkit.lang.TranslationContainer in project Nukkit by Nukkit.
the class SaveOffCommand method execute.
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
sender.getServer().setAutoSave(false);
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.disabled"));
return true;
}
use of cn.nukkit.lang.TranslationContainer in project Nukkit by Nukkit.
the class SaveOnCommand method execute.
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
sender.getServer().setAutoSave(true);
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.enabled"));
return true;
}
use of cn.nukkit.lang.TranslationContainer in project Nukkit by Nukkit.
the class SayCommand method execute.
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
String senderString;
if (sender instanceof Player) {
senderString = ((Player) sender).getDisplayName();
} else if (sender instanceof ConsoleCommandSender) {
senderString = "Server";
} else {
senderString = sender.getName();
}
String msg = "";
for (String arg : args) {
msg += arg + " ";
}
if (msg.length() > 0) {
msg = msg.substring(0, msg.length() - 1);
}
sender.getServer().broadcastMessage(new TranslationContainer(TextFormat.LIGHT_PURPLE + "%chat.type.announcement", new String[] { senderString, TextFormat.LIGHT_PURPLE + msg }));
return true;
}
Aggregations