use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class EnchantItemListener method monitorItemEnchant.
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void monitorItemEnchant(EnchantItemEvent event) {
if (!IridiumSkyblockAPI.getInstance().isIslandWorld(event.getEnchanter().getWorld()))
return;
Player player = event.getEnchanter();
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
Optional<Island> island = user.getIsland();
XMaterial material = XMaterial.matchXMaterial(event.getItem().getType());
island.ifPresent(value -> IridiumSkyblock.getInstance().getMissionManager().handleMissionUpdates(value, "ENCHANT", material.name(), 1));
}
use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class OceanGenerator method generateChunkData.
/**
* Generates an ocean.
*
* @param world The world that we try to generate
* @param random A random which should be used. We don't need this
* @param chunkX The x position of the chunk
* @param chunkZ The y position of the chunk
* @param biomeGrid The biome grid of the chunk
* @return The data of this chunk. None all the time to generate void
*/
@Override
@NotNull
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biomeGrid) {
SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(world.getSeed()), 8);
final ChunkData chunkData = createChunkData(world);
generator.setScale(0.005D);
XMaterial bottomMaterial = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.oceanFloorBottomMaterial;
XMaterial topMaterial = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.oceanFloorTopMaterial;
int waterHeight = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.waterHeight;
int maxOceanFloorLevel = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.maxOceanFloorLevel;
int minOceanFloorLevel = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.minOceanFloorLevel;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
int currentFloorHeight = (int) ((generator.noise(chunkX * 16 + x, chunkZ * 16 + z, 1.5D, 0.5D, true) + 1) * (maxOceanFloorLevel - minOceanFloorLevel) + minOceanFloorLevel);
// Generate layer of bedrock
chunkData.setBlock(x, LocationUtils.getMinHeight(world), z, Objects.requireNonNull(XMaterial.BEDROCK.parseMaterial()));
// Generate gravel layer
for (int y = LocationUtils.getMinHeight(world) + 1; y < currentFloorHeight; y++) {
chunkData.setBlock(x, y, z, Objects.requireNonNull(bottomMaterial.parseMaterial()));
}
// Generate sand on top of gravel
chunkData.setBlock(x, currentFloorHeight, z, Objects.requireNonNull(topMaterial.parseMaterial()));
// Generate water or lava on top of the floor
XMaterial oceanMaterial = world.getEnvironment() == Environment.NETHER ? XMaterial.LAVA : XMaterial.WATER;
for (int y = currentFloorHeight + 1; y <= waterHeight; y++) {
chunkData.setBlock(x, y, z, Objects.requireNonNull(oceanMaterial.parseMaterial()));
}
}
}
return chunkData;
}
use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class EditWarpCommand method execute.
/**
* Executes the command for the specified {@link CommandSender} with the provided arguments.
* Not called when the command execution was invalid (no permission, no player or command disabled).
* Shows an overview over the members of the Island and allows quick rank management.
*
* @param sender The CommandSender which executes this command
* @param args The arguments used with this command. They contain the sub-command
*/
@Override
public boolean execute(CommandSender sender, String[] args) {
if (args.length < 3) {
sender.sendMessage(StringUtils.color(syntax.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
Player player = (Player) sender;
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
Optional<Island> island = user.getIsland();
if (!island.isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
if (!IridiumSkyblock.getInstance().getIslandManager().getIslandPermission(island.get(), IridiumSkyblock.getInstance().getUserManager().getUser(player), PermissionType.MANAGE_WARPS)) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotManageWarps.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
List<IslandWarp> islandWarps = IridiumSkyblock.getInstance().getDatabaseManager().getIslandWarpTableManager().getEntries(island.get());
Optional<IslandWarp> islandWarp = islandWarps.stream().filter(warp -> warp.getName().equalsIgnoreCase(args[1])).findFirst();
if (!islandWarp.isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().unknownWarp.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
// TODO: Use subcommand system
switch(args[2]) {
case "icon":
if (args.length != 4) {
sender.sendMessage("/is editwarp <name> icon <icon>");
}
Optional<XMaterial> xMaterial = XMaterial.matchXMaterial(args[3]);
if (xMaterial.isPresent()) {
islandWarp.get().setIcon(xMaterial.get());
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().warpIconSet.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return true;
} else {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noSuchMaterial.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
case "description":
if (args.length < 4) {
sender.sendMessage("/is editwarp <name> description <description>");
return false;
}
String description = String.join(" ", Arrays.copyOfRange(args, 3, args.length));
islandWarp.get().setDescription(description);
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().warpDescriptionSet.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return true;
}
return false;
}
use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class BlockPlaceListener method monitorBlockPlace.
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void monitorBlockPlace(BlockPlaceEvent event) {
if (!IridiumSkyblockAPI.getInstance().isIslandWorld(event.getBlock().getWorld()))
return;
Player player = event.getPlayer();
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
XMaterial material = XMaterial.matchXMaterial(event.getBlock().getType());
user.getIsland().ifPresent(island -> {
IridiumSkyblock.getInstance().getMissionManager().handleMissionUpdates(island, "PLACE", material.name(), 1);
IslandBlocks islandBlocks = IridiumSkyblock.getInstance().getIslandManager().getIslandBlock(island, material);
islandBlocks.setAmount(islandBlocks.getAmount() + 1);
if (event.getBlock().getState() instanceof CreatureSpawner) {
CreatureSpawner creatureSpawner = (CreatureSpawner) event.getBlock().getState();
IslandSpawners islandSpawners = IridiumSkyblock.getInstance().getIslandManager().getIslandSpawners(island, creatureSpawner.getSpawnedType());
islandSpawners.setAmount(islandSpawners.getAmount() + 1);
}
});
}
use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class BlockPlaceListener method onBlockPlaceEvent.
@EventHandler(ignoreCancelled = true)
public void onBlockPlaceEvent(BlockPlaceEvent event) {
Player player = event.getPlayer();
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
Optional<Island> island = IridiumSkyblock.getInstance().getIslandManager().getIslandViaLocation(event.getBlock().getLocation());
if (!island.isPresent()) {
World world = event.getBlock().getLocation().getWorld();
if (IridiumSkyblockAPI.getInstance().isIslandWorld(world)) {
if (!user.isBypassing())
event.setCancelled(true);
}
return;
}
XMaterial material = XMaterial.matchXMaterial(event.getBlock().getType());
if (!IridiumSkyblock.getInstance().getIslandManager().getIslandPermission(island.get(), user, PermissionType.BLOCK_PLACE)) {
event.setCancelled(true);
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotPlaceBlocks.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return;
}
int limitUpgradeLevel = IridiumSkyblock.getInstance().getIslandManager().getIslandUpgrade(island.get(), "blocklimit").getLevel();
int blockLimit = IridiumSkyblock.getInstance().getUpgrades().blockLimitUpgrade.upgrades.get(limitUpgradeLevel).limits.getOrDefault(material, 0);
if (blockLimit > 0 && IridiumSkyblock.getInstance().getIslandManager().getIslandBlockAmount(island.get(), material) >= blockLimit) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().blockLimitReached.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix).replace("%limit%", String.valueOf(blockLimit)).replace("%block%", WordUtils.capitalizeFully(material.name().toLowerCase().replace("_", " ")))));
event.setCancelled(true);
}
}
Aggregations