use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class BuilderInventory method onInventoryClick.
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (!inventoryManager.checkIfValidClick(event, "worldeditor_builders_title")) {
return;
}
Player player = (Player) event.getWhoClicked();
BuildWorld buildWorld = plugin.getPlayerManager().getSelectedWorld().get(player.getUniqueId());
if (buildWorld == null) {
player.closeInventory();
player.sendMessage(plugin.getString("worlds_addbuilder_error"));
return;
}
ItemStack itemStack = event.getCurrentItem();
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null) {
return;
}
Material material = itemStack.getType();
if (material != XMaterial.PLAYER_HEAD.parseMaterial()) {
XSound.BLOCK_CHEST_OPEN.play(player);
plugin.getEditInventory().openInventory(player, buildWorld);
return;
}
int slot = event.getSlot();
switch(slot) {
case 18:
decrementInv(player);
break;
case 22:
XSound.ENTITY_CHICKEN_EGG.play(player);
plugin.getWorldsCommand().getAddBuilderInput(player, false);
return;
case 26:
incrementInv(player);
break;
default:
if (slot == 4) {
return;
}
if (!itemMeta.hasDisplayName()) {
return;
}
if (!event.isShiftClick()) {
return;
}
String builderName = ChatColor.stripColor(itemMeta.getDisplayName());
UUID builderId = UUIDFetcher.getUUID(builderName);
buildWorld.removeBuilder(builderId);
XSound.ENTITY_ENDERMAN_TELEPORT.play(player);
player.sendMessage(plugin.getString("worlds_removebuilder_removed").replace("%builder%", builderName));
}
XSound.ENTITY_CHICKEN_EGG.play(player);
player.openInventory(getInventory(buildWorld, player));
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class DeleteInventory method onInventoryClick.
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (!inventoryManager.checkIfValidClick(event, "delete_title")) {
return;
}
Player player = (Player) event.getWhoClicked();
BuildWorld buildWorld = plugin.getPlayerManager().getSelectedWorld().get(player.getUniqueId());
if (buildWorld == null) {
player.sendMessage(plugin.getString("worlds_delete_error"));
player.closeInventory();
return;
}
int slot = event.getSlot();
if (slot == 11) {
XSound.ENTITY_PLAYER_LEVELUP.play(player);
player.closeInventory();
plugin.getWorldManager().deleteWorld(player, buildWorld);
} else if (slot == 15) {
XSound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR.play(player);
player.closeInventory();
player.sendMessage(plugin.getString("worlds_delete_canceled").replace("%world%", buildWorld.getName()));
}
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class SpawnManager method teleport.
public boolean teleport(Player player) {
if (!spawnExists()) {
return false;
}
BuildWorld buildWorld = worldManager.getBuildWorld(spawnName);
if (buildWorld != null) {
if (!buildWorld.isLoaded()) {
buildWorld.load(player);
}
}
player.setFallDistance(0);
player.teleport(spawn);
Titles.clearTitle(player);
return true;
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class WorldManager method loadWorld.
public BuildWorld loadWorld(String worldName) {
FileConfiguration configuration = worldConfig.getFile();
if (configuration == null) {
return null;
}
String creator = configuration.isString("worlds." + worldName + ".creator") ? configuration.getString("worlds." + worldName + ".creator") : "-";
UUID creatorId = parseCreatorId(configuration, worldName, creator);
WorldType worldType = configuration.isString("worlds." + worldName + ".type") ? WorldType.valueOf(configuration.getString("worlds." + worldName + ".type")) : WorldType.UNKNOWN;
boolean privateWorld = configuration.isBoolean("worlds." + worldName + ".private") && configuration.getBoolean("worlds." + worldName + ".private");
XMaterial material = parseMaterial(configuration, worldName);
WorldStatus worldStatus = WorldStatus.valueOf(configuration.getString("worlds." + worldName + ".status"));
String project = configuration.getString("worlds." + worldName + ".project");
String permission = configuration.getString("worlds." + worldName + ".permission");
long date = configuration.isLong("worlds." + worldName + ".date") ? configuration.getLong("worlds." + worldName + ".date") : -1;
boolean physics = configuration.getBoolean("worlds." + worldName + ".physics");
boolean explosions = !configuration.isBoolean("worlds." + worldName + ".explosions") || configuration.getBoolean("worlds." + worldName + ".explosions");
boolean mobAI = !configuration.isBoolean("worlds." + worldName + ".mobai") || configuration.getBoolean("worlds." + worldName + ".mobai");
String customSpawn = configuration.getString("worlds." + worldName + ".spawn");
boolean blockBreaking = !configuration.isBoolean("worlds." + worldName + ".block-breaking") || configuration.getBoolean("worlds." + worldName + ".block-breaking");
boolean blockPlacement = !configuration.isBoolean("worlds." + worldName + ".block-placement") || configuration.getBoolean("worlds." + worldName + ".block-placement");
boolean blockInteractions = !configuration.isBoolean("worlds." + worldName + ".block-interactions") || configuration.getBoolean("worlds." + worldName + ".block-interactions");
boolean buildersEnabled = configuration.isBoolean("worlds." + worldName + ".builders-enabled") && configuration.getBoolean("worlds." + worldName + ".builders-enabled");
List<Builder> builders = parseBuilders(configuration, worldName);
String chunkGeneratorString = configuration.getString("worlds." + worldName + ".chunk-generator");
ChunkGenerator chunkGenerator = parseChunkGenerator(configuration, worldName);
if (worldType == WorldType.PRIVATE) {
privateWorld = true;
worldType = WorldType.FLAT;
}
BuildWorld buildWorld = new BuildWorld(plugin, worldName, creator, creatorId, worldType, privateWorld, material, worldStatus, project, permission, date, physics, explosions, mobAI, customSpawn, blockBreaking, blockPlacement, blockInteractions, buildersEnabled, builders, chunkGenerator, chunkGeneratorString);
buildWorlds.add(buildWorld);
return buildWorld;
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by einTosti.
the class WorldManager method createTemplateWorld.
/**
* Generate a {@link BuildWorld} with a template.
*
* @param player The player who is creating the world
* @param worldName The name of the world
* @param template The name of the template world
* @param privateWorld Is world going to be a private world?
* @return {@code true} if the world was successfully created, {@code false otherwise}
*/
private boolean createTemplateWorld(Player player, String worldName, String template, boolean privateWorld) {
boolean worldExists = getBuildWorld(worldName) != null;
File worldFile = new File(Bukkit.getWorldContainer(), worldName);
if (worldExists || worldFile.exists()) {
player.sendMessage(plugin.getString("worlds_world_exists"));
return false;
}
File templateFile = new File(plugin.getDataFolder() + File.separator + "templates" + File.separator + template);
if (!templateFile.exists()) {
player.sendMessage(plugin.getString("worlds_template_does_not_exist"));
return false;
}
BuildWorld buildWorld = new BuildWorld(plugin, worldName, player.getName(), player.getUniqueId(), WorldType.TEMPLATE, System.currentTimeMillis(), privateWorld);
buildWorlds.add(buildWorld);
player.sendMessage(plugin.getString("worlds_template_creation_started").replace("%world%", buildWorld.getName()).replace("%template%", template));
FileUtils.copy(templateFile, worldFile);
Bukkit.createWorld(WorldCreator.name(worldName).type(org.bukkit.WorldType.FLAT).generateStructures(false));
player.sendMessage(plugin.getString("worlds_creation_finished"));
return true;
}
Aggregations