Skip to content

Commit

Permalink
Merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachesMLG committed Sep 23, 2023
2 parents aad4246 + 3a90628 commit 3e77315
Show file tree
Hide file tree
Showing 25 changed files with 344 additions and 104 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "com.iridium"
version = "4.0.3"
version = "4.0.5"
description = "IridiumSkyblock"

repositories {
Expand All @@ -23,7 +23,7 @@ dependencies {
implementation("org.jetbrains:annotations:24.0.1")
implementation("com.j256.ormlite:ormlite-core:6.1")
implementation("com.j256.ormlite:ormlite-jdbc:6.1")
implementation("com.iridium:IridiumTeams:2.0.7")
implementation("com.iridium:IridiumTeams:2.2.0")

// Other dependencies that are not required or already available at runtime
compileOnly("org.projectlombok:lombok:1.18.26")
Expand All @@ -45,7 +45,7 @@ tasks {

shadowJar {
fun relocate(origin: String) =
relocate(origin, "com.iridium.iridiumskyblock.dependencies${origin.substring(origin.lastIndexOf('.'))}")
relocate(origin, "com.iridium.iridiumskyblock.dependencies${origin.substring(origin.lastIndexOf('.'))}")

// Remove the archive classifier suffix
archiveClassifier.set("")
Expand Down Expand Up @@ -97,4 +97,4 @@ publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.iridium.iridiumskyblock.api;

import com.iridium.iridiumskyblock.configs.Schematics;
import com.iridium.iridiumskyblock.database.User;
import lombok.Getter;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Getter

public class IslandCreateEvent extends Event implements Cancellable {

private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
@Nullable
private String islandName;
@NotNull
private final User user;
@NotNull
private Schematics.SchematicConfig schematicConfig;

public IslandCreateEvent(@NotNull User user, @Nullable String islandName, Schematics.@NotNull SchematicConfig schematicConfig) {
this.islandName = islandName;
this.user = user;
this.schematicConfig = schematicConfig;
}

@NotNull
public HandlerList getHandlers() {
return handlers;
}

@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}

/**
* The name of the Island.<br>
* null indicates that the name of the Player is used as the Island name
* because it hasn't been set.
*
* @return the name of the Island or null
*/
@Nullable
public String getIslandName() {
return islandName;
}

/**
*
* Sets the name of the Island.<br>
* set it to null to default to the player's name
*
* @param islandName The name of the island
*/
public void setIslandName(@Nullable String islandName) {
this.islandName = islandName;
}

/**
* Sets the schematic of the new island
*
* @param schematicConfig The schematic configuration of the island
*/

public void setSchematicConfig(Schematics.@NotNull SchematicConfig schematicConfig) {
this.schematicConfig = schematicConfig;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.iridium.iridiumskyblock.api;

import com.iridium.iridiumskyblock.database.Island;
import com.iridium.iridiumskyblock.database.User;
import lombok.Getter;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

@Getter
public class IslandDeleteEvent extends Event implements Cancellable {

private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
@NotNull private final Island island;
@NotNull private final User user;

public IslandDeleteEvent(@NotNull Island island, @NotNull User user) {
this.island = island;
this.user = user;
}

@NotNull
public HandlerList getHandlers() {
return handlers;
}

@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@
public class BiomeCommand extends Command<Island, User> {

public BiomeCommand() {
super(Collections.singletonList("biomes"), "Refresh your Island Biome", "%prefix% &7/is biomes <biome>", "");
super(Collections.singletonList("biomes"), "Refresh your Island Biome", "%prefix% &7/is biomes <biome>", "", 10);
}

@Override
public void execute(User user, String[] args, IridiumTeams<Island, User> iridiumTeams) {
public boolean execute(User user, Island island, String[] args, IridiumTeams<Island, User> iridiumTeams) {
Player player = user.getPlayer();
if (args.length == 0) {
player.openInventory(new BiomeOverviewGUI(player.getOpenInventory().getTopInventory()).getInventory());
return false;
} else {
Optional<String> categoryName = getCategoryName(String.join(" ", args));

if (!categoryName.isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noBiomeCategory
.replace("%prefix%", iridiumTeams.getConfiguration().prefix)
));
return;
return false;
}

player.openInventory(new BiomeCategoryGUI(categoryName.get(), player.getOpenInventory().getTopInventory()).getInventory());
return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@ public class BorderCommand extends Command<Island, User> {
* The default constructor.
*/
public BorderCommand() {
super(Collections.singletonList("border"), "Change the Island Border", "%prefix% &7/is border <color>", "");
super(Collections.singletonList("border"), "Change the Island Border", "%prefix% &7/is border <color>", "", 0);
}

@Override
public void execute(User user, Island island, String[] args, IridiumTeams<Island, User> iridiumTeams) {
public boolean execute(User user, Island island, String[] args, IridiumTeams<Island, User> iridiumTeams) {
Player player = user.getPlayer();
if (!IridiumSkyblock.getInstance().getIslandManager().getTeamPermission(island, IridiumSkyblock.getInstance().getUserManager().getUser(player), "border")) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotManageBorder.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return;
return false;
}

if (args.length == 0) {
player.openInventory(new BorderGUI(player.getOpenInventory().getTopInventory()).getInventory());
return;
return false;
}

Color color = Color.getColor(args[0]);
if (color == null) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().notAColor.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return;
return false;
}

if (!IridiumSkyblock.getInstance().getConfiguration().enabledBorders.getOrDefault(color, true)) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().borderColorDisabled.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return;
return false;
}

island.setColor(color);
Expand All @@ -65,6 +65,8 @@ public void execute(User user, Island island, String[] args, IridiumTeams<Island
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
))
);

return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.iridium.iridiumcore.utils.StringUtils;
import com.iridium.iridiumskyblock.IridiumSkyblock;
import com.iridium.iridiumskyblock.configs.Schematics;
import com.iridium.iridiumskyblock.database.Island;
import com.iridium.iridiumskyblock.database.User;
import com.iridium.iridiumskyblock.gui.RegenGUI;
Expand All @@ -16,48 +17,55 @@
public class RegenCommand extends Command<Island, User> {

public RegenCommand() {
super(Collections.singletonList("regen"), "Regenerate your Island", "%prefix% &7/is regen <schematic>", "");
super(Collections.singletonList("regen"), "Regenerate your Island", "%prefix% &7/is regen <schematic>", "", 300);
}

@Override
public void execute(User user, Island island, String[] args, IridiumTeams<Island, User> iridiumTeams) {
public boolean execute(User user, Island island, String[] args, IridiumTeams<Island, User> iridiumTeams) {
Player player = user.getPlayer();
if (args.length == 0) {
if (!IridiumSkyblock.getInstance().getIslandManager().getTeamPermission(island, IridiumSkyblock.getInstance().getUserManager().getUser(player), "regen")) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotRegenIsland
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
));
return;
return false;
}

player.openInventory(new RegenGUI(player.getOpenInventory().getTopInventory(), player).getInventory());
return;
return false;
}

Optional<String> schematicConfig = IridiumSkyblock.getInstance().getSchematics().schematics.keySet().stream()
Optional<String> schematic = IridiumSkyblock.getInstance().getSchematics().schematics.keySet().stream()
.filter(config -> config.equalsIgnoreCase(args[0]))
.findFirst();
if (!schematicConfig.isPresent()) {
if (!schematic.isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().unknownSchematic
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
));
return;
return false;
}

Schematics.SchematicConfig schematicConfig = IridiumSkyblock.getInstance().getSchematics().schematics.get(schematic.get());

IridiumSkyblock.getInstance().getIslandManager().getTeamMembers(island).stream()
.map(User::getPlayer)
.filter(Objects::nonNull)
.forEach(member -> member.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().regeneratingIsland
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
)));

IridiumSkyblock.getInstance().getIslandManager().generateIsland(island, schematicConfig.get()).thenRun(() -> Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> {
IridiumSkyblock.getInstance().getIslandManager().clearTeamInventory(island);

IridiumSkyblock.getInstance().getIslandManager().generateIsland(island, schematicConfig).thenRun(() -> Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> {

if (IridiumSkyblock.getInstance().getTeamManager().teleport(player, island.getHome(), island)) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().teleportingHome
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
));
}
}));

return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,31 @@

public class VisitCommand extends Command<Island, User> {
public VisitCommand() {
super(Collections.singletonList("visit"), "Visit other islands", "%prefix% &7/is visit", "");
super(Collections.singletonList("visit"), "Visit other islands", "%prefix% &7/is visit", "", 0);
}

@Override
public void execute(User user, String[] args, IridiumTeams<Island, User> iridiumTeams) {
public boolean execute(User user, String[] args, IridiumTeams<Island, User> iridiumTeams) {
Player player = user.getPlayer();
if (args.length == 0) {
player.openInventory(new VisitGUI(player.getOpenInventory().getTopInventory(), iridiumTeams).getInventory());
return;
return false;
}
Optional<Island> island = IridiumSkyblock.getInstance().getTeamManager().getTeamViaNameOrPlayer(args[0]);
if (!island.isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().teamDoesntExistByName
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
));
return;
return false;
}
if (!IridiumSkyblock.getInstance().getIslandManager().canVisit(player, island.get())) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotVisit
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
));
return;
return false;
}
player.teleport(island.get().getHome());
return true;
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/iridium/iridiumskyblock/configs/Biomes.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
public class Biomes {

public Map<String, BiomeCategory> categories = ImmutableMap.<String, BiomeCategory>builder()
.put("Overworld", new BiomeCategory(new Item(XMaterial.GRASS_BLOCK, 20, 1, "&9&lOverworld", Collections.emptyList()), 54))
.put("Nether", new BiomeCategory(new Item(XMaterial.CRIMSON_NYLIUM, 22, 1, "&9&lNether", Collections.emptyList()), 36))
.put("End", new BiomeCategory(new Item(XMaterial.END_STONE, 24, 1, "&9&lEnd", Collections.emptyList()), 36))
.put("Overworld", new BiomeCategory(new Item(XMaterial.GRASS_BLOCK, 11, 1, "&9&lOverworld", Collections.emptyList()), 54))
.put("Nether", new BiomeCategory(new Item(XMaterial.CRIMSON_NYLIUM, 13, 1, "&9&lNether", Collections.emptyList()), 36))
.put("End", new BiomeCategory(new Item(XMaterial.END_STONE, 15, 1, "&9&lEnd", Collections.emptyList()), 36))
.build();
public Map<String, List<BiomeItem>> items = ImmutableMap.<String, List<BiomeItem>>builder()
.put("Overworld", Arrays.asList(
Expand Down
Loading

0 comments on commit 3e77315

Please sign in to comment.