use of cn.nukkit.level.Level in project Nukkit by Nukkit.
the class DoubleChestInventory method onClose.
@Override
public void onClose(Player who) {
if (this.getViewers().size() == 1) {
BlockEventPacket pk1 = new BlockEventPacket();
pk1.x = (int) this.right.getHolder().getX();
pk1.y = (int) this.right.getHolder().getY();
pk1.z = (int) this.right.getHolder().getZ();
pk1.case1 = 1;
pk1.case2 = 0;
Level level = this.right.getHolder().getLevel();
if (level != null) {
level.addSound(this.right.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTCLOSED);
level.addChunkPacket((int) this.right.getHolder().getX() >> 4, (int) this.right.getHolder().getZ() >> 4, pk1);
}
BlockEventPacket pk2 = new BlockEventPacket();
pk2.x = (int) this.left.getHolder().getX();
pk2.y = (int) this.left.getHolder().getY();
pk2.z = (int) this.left.getHolder().getZ();
pk2.case1 = 1;
pk2.case2 = 0;
level = this.left.getHolder().getLevel();
if (level != null) {
level.addSound(this.left.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTCLOSED);
level.addChunkPacket((int) this.left.getHolder().getX() >> 4, (int) this.left.getHolder().getZ() >> 4, pk2);
}
}
this.left.viewers.remove(who);
this.right.viewers.remove(who);
super.onClose(who);
}
use of cn.nukkit.level.Level in project Nukkit by Nukkit.
the class DoubleChestInventory method onOpen.
@Override
public void onOpen(Player who) {
super.onOpen(who);
this.left.viewers.add(who);
this.right.viewers.add(who);
if (this.getViewers().size() == 1) {
BlockEventPacket pk1 = new BlockEventPacket();
pk1.x = (int) this.left.getHolder().getX();
pk1.y = (int) this.left.getHolder().getY();
pk1.z = (int) this.left.getHolder().getZ();
pk1.case1 = 1;
pk1.case2 = 2;
Level level = this.left.getHolder().getLevel();
if (level != null) {
level.addSound(this.left.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN);
level.addChunkPacket((int) this.left.getHolder().getX() >> 4, (int) this.left.getHolder().getZ() >> 4, pk1);
}
BlockEventPacket pk2 = new BlockEventPacket();
pk2.x = (int) this.right.getHolder().getX();
pk2.y = (int) this.right.getHolder().getY();
pk2.z = (int) this.right.getHolder().getZ();
pk2.case1 = 1;
pk2.case2 = 2;
level = this.right.getHolder().getLevel();
if (level != null) {
level.addSound(this.right.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN);
level.addChunkPacket((int) this.right.getHolder().getX() >> 4, (int) this.right.getHolder().getZ() >> 4, pk2);
}
}
}
use of cn.nukkit.level.Level in project Nukkit by Nukkit.
the class ChestInventory method onOpen.
@Override
public void onOpen(Player who) {
super.onOpen(who);
if (this.getViewers().size() == 1) {
BlockEventPacket pk = new BlockEventPacket();
pk.x = (int) this.getHolder().getX();
pk.y = (int) this.getHolder().getY();
pk.z = (int) this.getHolder().getZ();
pk.case1 = 1;
pk.case2 = 2;
Level level = this.getHolder().getLevel();
if (level != null) {
level.addSound(this.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN);
level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk);
}
}
}
use of cn.nukkit.level.Level in project Nukkit by Nukkit.
the class Server method forceShutdown.
public void forceShutdown() {
if (this.hasStopped) {
return;
}
try {
if (!this.isRunning) {
// todo sendUsage
}
// clean shutdown of console thread asap
this.console.shutdown();
this.hasStopped = true;
this.shutdown();
if (this.rcon != null) {
this.rcon.close();
}
this.getLogger().debug("Disabling all plugins");
this.pluginManager.disablePlugins();
for (Player player : new ArrayList<>(this.players.values())) {
player.close(player.getLeaveMessage(), (String) this.getConfig("settings.shutdown-message", "Server closed"));
}
this.getLogger().debug("Unloading all levels");
for (Level level : this.levelArray) {
this.unloadLevel(level, true);
}
this.getLogger().debug("Removing event handlers");
HandlerList.unregisterAll();
this.getLogger().debug("Stopping all tasks");
this.scheduler.cancelAllTasks();
this.scheduler.mainThreadHeartbeat(Integer.MAX_VALUE);
this.getLogger().debug("Closing console");
this.console.interrupt();
this.getLogger().debug("Stopping network interfaces");
for (SourceInterface interfaz : this.network.getInterfaces()) {
interfaz.shutdown();
this.network.unregisterInterface(interfaz);
}
this.getLogger().debug("Disabling timings");
Timings.stopServer();
// todo other things
} catch (Exception e) {
// todo remove this?
this.logger.logException(e);
this.logger.emergency("Exception happened while shutting down, exit the process");
System.exit(1);
}
}
use of cn.nukkit.level.Level in project Nukkit by Nukkit.
the class Server method reload.
public void reload() {
this.logger.info("Reloading...");
this.logger.info("Saving levels...");
for (Level level : this.levelArray) {
level.save();
}
this.pluginManager.disablePlugins();
this.pluginManager.clearPlugins();
this.commandMap.clearCommands();
this.logger.info("Reloading properties...");
this.properties.reload();
this.maxPlayers = this.getPropertyInt("max-players", 20);
if (this.getPropertyBoolean("hardcore", false) && this.getDifficulty() < 3) {
this.setPropertyInt("difficulty", difficulty = 3);
}
this.banByIP.load();
this.banByName.load();
this.reloadWhitelist();
this.operators.reload();
for (BanEntry entry : this.getIPBans().getEntires().values()) {
this.getNetwork().blockAddress(entry.getName(), -1);
}
this.pluginManager.registerInterface(JavaPluginLoader.class);
this.pluginManager.loadPlugins(this.pluginPath);
this.enablePlugins(PluginLoadOrder.STARTUP);
this.enablePlugins(PluginLoadOrder.POSTWORLD);
Timings.reset();
}
Aggregations