use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class FoodLevelChangeListener method onFoodLevelChangeEvent.
@EventHandler
public void onFoodLevelChangeEvent(FoodLevelChangeEvent event) {
if (!(event.getEntity() instanceof Player)) {
return;
}
Player player = (Player) event.getEntity();
World bukkitWorld = player.getWorld();
BuildWorld buildWorld = worldManager.getBuildWorld(bukkitWorld.getName());
if (buildWorld != null && buildWorld.getStatus() == WorldStatus.ARCHIVE) {
event.setCancelled(true);
}
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class EditInventory method addTimeItem.
private void addTimeItem(Inventory inventory, BuildWorld buildWorld) {
World bukkitWorld = Bukkit.getWorld(buildWorld.getName());
XMaterial xMaterial = XMaterial.WHITE_STAINED_GLASS;
String value = plugin.getString("worldeditor_time_lore_unknown");
BuildWorld.Time time = getWorldTime(bukkitWorld);
switch(time) {
case SUNRISE:
xMaterial = XMaterial.ORANGE_STAINED_GLASS;
value = plugin.getString("worldeditor_time_lore_sunrise");
break;
case NOON:
xMaterial = XMaterial.YELLOW_STAINED_GLASS;
value = plugin.getString("worldeditor_time_lore_noon");
break;
case NIGHT:
xMaterial = XMaterial.BLUE_STAINED_GLASS;
value = plugin.getString("worldeditor_time_lore_night");
break;
}
ArrayList<String> lore = new ArrayList<>();
String finalValue = value;
plugin.getStringList("worldeditor_time_lore").forEach(line -> lore.add(line.replace("%time%", finalValue)));
inventoryManager.addItemStack(inventory, 23, xMaterial, plugin.getString("worldeditor_time_item"), lore);
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class EditInventory method changeTime.
private void changeTime(Player player, BuildWorld buildWorld) {
World bukkitWorld = Bukkit.getWorld(buildWorld.getName());
if (bukkitWorld == null) {
return;
}
BuildWorld.Time time = getWorldTime(bukkitWorld);
switch(time) {
case SUNRISE:
bukkitWorld.setTime(configValues.getNoonTime());
break;
case NOON:
bukkitWorld.setTime(configValues.getNightTime());
break;
case NIGHT:
bukkitWorld.setTime(configValues.getSunriseTime());
break;
}
openInventory(player, buildWorld);
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class EditInventory method removeEntities.
private void removeEntities(Player player, BuildWorld buildWorld) {
World bukkitWorld = Bukkit.getWorld(buildWorld.getName());
if (bukkitWorld == null) {
return;
}
AtomicInteger entitiesRemoved = new AtomicInteger();
bukkitWorld.getEntities().stream().filter(entity -> !IGNORED_ENTITIES.contains(entity.getType())).forEach(entity -> {
entity.remove();
entitiesRemoved.incrementAndGet();
});
player.closeInventory();
player.sendMessage(plugin.getString("worldeditor_butcher_removed").replace("%amount%", String.valueOf(entitiesRemoved.get())));
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class GameRuleInventory method onInventoryClick.
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (!inventoryManager.checkIfValidClick(event, "worldeditor_gamerules_title")) {
return;
}
ItemStack itemStack = event.getCurrentItem();
if (itemStack == null) {
return;
}
Player player = (Player) event.getWhoClicked();
BuildWorld buildWorld = plugin.getPlayerManager().getSelectedWorld().get(player.getUniqueId());
if (buildWorld == null) {
player.closeInventory();
player.sendMessage(plugin.getString("worlds_edit_error"));
return;
}
GameRules gameRules = plugin.getGameRules();
switch(itemStack.getType()) {
case PLAYER_HEAD:
int slot = event.getSlot();
if (slot == 36) {
gameRules.decrementInv(player);
} else if (slot == 44) {
gameRules.incrementInv(player);
}
break;
case FILLED_MAP:
case MAP:
World bukkitWorld = Bukkit.getWorld(buildWorld.getName());
gameRules.toggleGameRule(event, bukkitWorld);
break;
default:
XSound.BLOCK_CHEST_OPEN.play(player);
plugin.getEditInventory().openInventory(player, buildWorld);
return;
}
XSound.ENTITY_CHICKEN_EGG.play(player);
openInventory(player, buildWorld);
}
Aggregations