Skip to content

Commit

Permalink
Added World edit support (#431)
Browse files Browse the repository at this point in the history
* Added WorldEdit Support

* Changed Schematics to WorldEdit

* Made schematics center

* Made the schematics actually center

* Change default Settings
  • Loading branch information
PeachesMLG authored Oct 4, 2021
1 parent 38cd1bf commit 0e4ecec
Show file tree
Hide file tree
Showing 50 changed files with 2,104 additions and 490 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
compileOnly("com.github.OmerBenGera:WildStackerAPI:master")
compileOnly("com.songoda:UltimateStacker:2.1.7")
compileOnly("com.songoda:EpicSpawners:7.0.8")
compileOnly("com.sk89q:WorldEdit:7.2.6")

// Enable lombok annotation processing
annotationProcessor("org.projectlombok:lombok:1.18.20")
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void onEnable() {
// Initialize the API
IridiumSkyblockAPI.initializeAPI(this);

this.schematicManager = new SchematicManager(new File(getDataFolder(), "schematics"));
this.schematicManager = new SchematicManager();

this.spawnerStackerSupport = setupSpawnerSupport();
this.blockStackerSupport = setupBlockStackerSupport();
Expand Down Expand Up @@ -564,15 +564,15 @@ private void saveSchematics() {
return;
}

saveFile(schematicFolder, "desert.iridiumschem");
saveFile(schematicFolder, "mushroom.iridiumschem");
saveFile(schematicFolder, "jungle.iridiumschem");
saveFile(schematicFolder, "desert_nether.iridiumschem");
saveFile(schematicFolder, "mushroom_nether.iridiumschem");
saveFile(schematicFolder, "jungle_nether.iridiumschem");
saveFile(schematicFolder, "desert_end.iridiumschem");
saveFile(schematicFolder, "mushroom_end.iridiumschem");
saveFile(schematicFolder, "jungle_end.iridiumschem");
saveFile(schematicFolder, "desert.schem");
saveFile(schematicFolder, "mushroom.schem");
saveFile(schematicFolder, "jungle.schem");
saveFile(schematicFolder, "desert_nether.schem");
saveFile(schematicFolder, "mushroom_nether.schem");
saveFile(schematicFolder, "jungle_nether.schem");
saveFile(schematicFolder, "desert_end.schem");
saveFile(schematicFolder, "mushroom_end.schem");
saveFile(schematicFolder, "jungle_end.schem");
}

private void saveFile(File parent, String name) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class Commands {
public MembersCommand membersCommand = new MembersCommand();
public MissionCommand missionCommand = new MissionCommand();
public PermissionsCommand permissionsCommand = new PermissionsCommand();
public PositionCommand positionCommand = new PositionCommand();
public PrivateCommand privateCommand = new PrivateCommand();
public PromoteCommand promoteCommand = new PromoteCommand();
public PublicCommand publicCommand = new PublicCommand();
Expand All @@ -51,7 +50,6 @@ public class Commands {
public ReloadCommand reloadCommand = new ReloadCommand();
public RenameCommand renameCommand = new RenameCommand();
public RewardsCommand rewardsCommand = new RewardsCommand();
public SaveSchematicCommand saveSchematicCommand = new SaveSchematicCommand();
public SetHomeCommand setHomeCommand = new SetHomeCommand();
public SetWarpCommand setWarpCommand = new SetWarpCommand();
public SettingsCommand settingsCommand = new SettingsCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,22 @@ public static class GeneratorSettings {
@NoArgsConstructor
public static class IslandRegenSettings {

public double moneyPrice = 5000.0;
public int crystalPrice = 100;
public double moneyPrice = 0;
public int crystalPrice = 0;
public boolean clearInventories = false;
public boolean clearEnderChests = false;
public boolean resetIslandBank = true;
public boolean resetVaultBalances = true;
public boolean resetIslandBank = false;
public boolean resetVaultBalances = false;
public boolean resetUpgrades = true;
public boolean resetMissions = true;
public boolean resetBoosters = true;
public boolean clearWarps = true;
public boolean resetBorderColour = true;
public boolean resetPermissions = false;
public boolean resetPermissions = true;
public boolean unbanAll = false;
public boolean giveUpInvites = false;
public boolean giveUpInvites = true;
public boolean kickMembers = false;
public boolean makeIslandPrivate = true;
public boolean makeIslandPrivate = false;

}

Expand All @@ -158,9 +158,9 @@ public static class IslandRegenSettings {
@NoArgsConstructor
public static class IslandDeleteSettings {

public boolean clearInventories = true;
public boolean clearEnderChests = true;
public boolean resetVaultBalances = true;
public boolean clearInventories = false;
public boolean clearEnderChests = false;
public boolean resetVaultBalances = false;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ public class Schematics {
public Map<String, SchematicConfig> schematics = ImmutableMap.<String, SchematicConfig>builder()
.put("desert", new SchematicConfig(new Item(XMaterial.PLAYER_HEAD, 11, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGY0OTNkZDgwNjUzM2Q5ZDIwZTg0OTUzOTU0MzY1ZjRkMzY5NzA5Y2ViYzlkZGVmMDIyZDFmZDQwZDg2YTY4ZiJ9fX0=", 1, "&b&lDesert Island", Collections.singletonList("&7A starter desert island.")),
-1.5, 95, -0.5, 90, new SchematicWorld(XBiome.DESERT,
"desert.iridiumschem", 90.0
"desert.schem", 90.0
), new SchematicWorld(XBiome.NETHER_WASTES,
"desert_nether.iridiumschem", 90.0
"desert_nether.schem", 90.0
), new SchematicWorld(XBiome.THE_END,
"desert_end.iridiumschem", 90.0
"desert_end.schem", 90.0
)))
.put("jungle", new SchematicConfig(new Item(XMaterial.PLAYER_HEAD, 13, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjgzYWRmNDU2MGRlNDc0MTQwNDA5M2FjNjFjMzNmYjU1NmIzZDllZTUxNDBmNjIwMzYyNTg5ZmRkZWRlZmEyZCJ9fX0=", 1, "&b&lJungle Island", Collections.singletonList("&7A starter jungle island.")),
1.5, 95, 0.5, 90, new SchematicWorld(XBiome.JUNGLE,
"jungle.iridiumschem", 90.0
"jungle.schem", 90.0
), new SchematicWorld(XBiome.NETHER_WASTES,
"jungle_nether.iridiumschem", 90.0
"jungle_nether.schem", 90.0
), new SchematicWorld(XBiome.THE_END,
"jungle_end.iridiumschem", 90.0
"jungle_end.schem", 90.0
)))
.put("mushroom", new SchematicConfig(new Item(XMaterial.PLAYER_HEAD, 15, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWE0NWQxYjQxN2NiZGRjMjE3NjdiMDYwNDRlODk5YjI2NmJmNzhhNjZlMjE4NzZiZTNjMDUxNWFiNTVkNzEifX19", 1, "&b&lMushroom Island", Collections.singletonList("&7A starter mushroom island.")),
-1.5, 95, -0.5, 90, new SchematicWorld(XBiome.MUSHROOM_FIELDS,
"mushroom.iridiumschem", 90.0
"mushroom.schem", 90.0
), new SchematicWorld(XBiome.NETHER_WASTES,
"mushroom_nether.iridiumschem", 90.0
"mushroom_nether.schem", 90.0
), new SchematicWorld(XBiome.THE_END,
"mushroom_end.iridiumschem", 90.0
"mushroom_end.schem", 90.0
)))
.build();

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/iridium/iridiumskyblock/database/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -53,9 +52,6 @@ public final class User {

private Island currentIslandVisiting;

private Location schematicPos1;
private Location schematicPos2;

private BukkitTask teleportingTask;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.iridium.iridiumskyblock.managers;

import com.google.common.collect.ImmutableMap;
import com.iridium.iridiumcore.dependencies.nbtapi.NBTCompound;
import com.iridium.iridiumcore.dependencies.nbtapi.NBTItem;
import com.iridium.iridiumcore.dependencies.paperlib.PaperLib;
Expand Down Expand Up @@ -174,7 +175,7 @@ private void teleportHome(@NotNull Player player, @NotNull Island island) {
*/
public void teleportWarp(@NotNull Player player, @NotNull IslandWarp islandWarp, int delay) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().teleportingWarp
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix))
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix))
.replace("%name%", islandWarp.getName())
);
if (delay < 1) {
Expand Down Expand Up @@ -251,12 +252,11 @@ public boolean makeIsland(Player player, String name, Schematics.SchematicConfig
user.setIslandRank(IslandRank.OWNER);

// Paste schematic and then teleport the player (this needs to be done sync)
Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () ->
pasteSchematic(island, schematic).thenRun(() -> {
teleportHome(player, island);
completableFuture.complete(island);
})
);
Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> {
pasteSchematic(island, schematic);
teleportHome(player, island);
completableFuture.complete(island);
});
});
return completableFuture;
}
Expand Down Expand Up @@ -344,38 +344,34 @@ public void regenerateIsland(@NotNull Island island, User user, @NotNull Schemat
island.setVisitable(false);
}

pasteSchematic(island, schematicConfig).thenRun(() -> {
pasteSchematic(island, schematicConfig);

Location islandHome = island.getCenter(IridiumSkyblock.getInstance().getIslandManager().getWorld()).add(schematicConfig.xHome, schematicConfig.yHome, schematicConfig.zHome);
islandHome.setYaw(schematicConfig.yawHome);
island.setHome(islandHome);
Location islandHome = island.getCenter(IridiumSkyblock.getInstance().getIslandManager().getWorld()).add(schematicConfig.xHome, schematicConfig.yHome, schematicConfig.zHome);
islandHome.setYaw(schematicConfig.yawHome);
island.setHome(islandHome);

getEntities(island, getWorld(), getNetherWorld(), getEndWorld()).thenAccept(entities -> Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> {
for (Entity entity : entities) {
if (entity instanceof Player) {
teleportHome((Player) entity, island, 0);
} else {
entity.remove();
}
getEntities(island, getWorld(), getNetherWorld(), getEndWorld()).thenAccept(entities -> Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> {
for (Entity entity : entities) {
if (entity instanceof Player) {
teleportHome((Player) entity, island, 0);
} else {
entity.remove();
}
})
);
});
}
})
);
}

private CompletableFuture<Void> pasteSchematic(@NotNull Island island, @NotNull Schematics.SchematicConfig schematicConfig) {
private void pasteSchematic(@NotNull Island island, @NotNull Schematics.SchematicConfig schematicConfig) {
setIslandBiome(island, schematicConfig.overworld.biome);
setIslandBiome(island, schematicConfig.nether.biome);
setIslandBiome(island, schematicConfig.end.biome);
CompletableFuture<Void> completableFuture = new CompletableFuture<>();
IridiumSkyblock.getInstance().getSchematicManager().pasteSchematic(island, getWorld(), schematicConfig.overworld, IridiumSkyblock.getInstance().getConfiguration().schematicPastingDelay).thenRun(() ->
IridiumSkyblock.getInstance().getSchematicManager().pasteSchematic(island, getNetherWorld(), schematicConfig.nether, IridiumSkyblock.getInstance().getConfiguration().schematicPastingDelay).thenRun(() ->
IridiumSkyblock.getInstance().getSchematicManager().pasteSchematic(island, getEndWorld(), schematicConfig.end, IridiumSkyblock.getInstance().getConfiguration().schematicPastingDelay).thenRun(() ->
completableFuture.complete(null)
)
)
IridiumSkyblock.getInstance().getSchematicManager().pasteSchematic(island, ImmutableMap.<World, Schematics.SchematicWorld>builder()
.put(getWorld(), schematicConfig.overworld)
.put(getNetherWorld(), schematicConfig.nether)
.put(getEndWorld(), schematicConfig.end)
.build()
);
return completableFuture;
}

/**
Expand Down
Loading

0 comments on commit 0e4ecec

Please sign in to comment.