Skip to content

Commit

Permalink
Merge pull request #19 from BentoBoxWorld/develop
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
tastybento authored Nov 24, 2024
2 parents de3fd85 + 41a6ade commit f7005e7
Show file tree
Hide file tree
Showing 25 changed files with 1,940 additions and 1,658 deletions.
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@
</issueManagement>

<distributionManagement>
<snapshotRepository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.org/repository/maven-snapshots</url>
</snapshotRepository>
<repository>
<id>codemc-releases</id>
<url>https://repo.codemc.org/repository/maven-releases</url>
<repository>
<id>bentoboxworld</id>
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
</repository>
</distributionManagement>

Expand All @@ -58,17 +54,17 @@
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.9</powermock.version>
<!-- More visible way to change dependency versions -->
<spigot.version>1.20.1-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
<!-- Might differ from the last Spigot release for short periods
of time -->
<paper.version>1.20.1-R0.1-SNAPSHOT</paper.version>
<bentobox.version>1.24.1-SNAPSHOT</bentobox.version>
<paper.version>1.21.3-R0.1-SNAPSHOT</paper.version>
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.3.0</build.version>
<build.version>1.4.0</build.version>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
Expand Down Expand Up @@ -124,6 +120,10 @@
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>bentoboxworld</id>
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
</repository>
<repository>
<id>codemc</id>
<url>https://repo.codemc.org/repository/maven-snapshots/</url>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/world/bentobox/parkour/Parkour.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package world.bentobox.parkour;

import java.util.ArrayList;
import java.util.HashMap;

import org.bukkit.Material;
Expand Down Expand Up @@ -91,7 +92,7 @@ public void setup() {
adminCommand = new DefaultAdminCommand(this) {
};

parkourRunRecord = new ParkourRunRecord(new HashMap<>(), new HashMap<>());
parkourRunRecord = new ParkourRunRecord(new HashMap<>(), new HashMap<>(), new ArrayList<>());

registerFlag(PARKOUR_CREATIVE);

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/world/bentobox/parkour/ParkourRunRecord.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package world.bentobox.parkour;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.bukkit.Location;

public record ParkourRunRecord(Map<UUID, Location> checkpoints, Map<UUID, Long> timers) {
public record ParkourRunRecord(Map<UUID, Location> checkpoints, Map<UUID, Long> timers, List<UUID> currentlyTeleporting) {
/**
* Clears any current times or checkpoints
* @param uuid UUID of runner
*/
public void clear(UUID uuid) {
checkpoints.remove(uuid);
timers.remove(uuid);
currentlyTeleporting.remove(uuid);
}

}
44 changes: 43 additions & 1 deletion src/main/java/world/bentobox/parkour/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.google.common.base.Enums;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.ConfigComment;
import world.bentobox.bentobox.api.configuration.ConfigEntry;
import world.bentobox.bentobox.api.configuration.StoreAt;
Expand Down Expand Up @@ -138,6 +139,15 @@ public class Settings implements WorldSettings {
@ConfigEntry(path = "world.max-areas")
private int maxIslands = -1;

@ConfigComment("The number of concurrent areas a player can have")
@ConfigComment("A value of 0 will use the BentoBox config.yml default")
@ConfigEntry(path = "world.concurrent-area")
private int concurrentIslands = 0;

@ConfigComment("Disallow team members from having their own area.")
@ConfigEntry(path = "world.disallow-team-member-areas")
private boolean disallowTeamMemberIslands = true;

@ConfigComment("The default game mode for this world. Players will be set to this mode when they create")
@ConfigComment("a new area for example. Options are SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR")
@ConfigEntry(path = "world.default-game-mode")
Expand All @@ -148,7 +158,7 @@ public class Settings implements WorldSettings {
private Biome defaultBiome = Biome.PLAINS;
@ConfigComment("The default biome for the nether world (this may affect what mobs can spawn)")
@ConfigEntry(path = "world.default-nether-biome")
private Biome defaultNetherBiome = Enums.getIfPresent(Biome.class, "NETHER").or(Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.BADLANDS));
private Biome defaultNetherBiome = Biome.NETHER_WASTES;
@ConfigComment("The default biome for the end world (this may affect what mobs can spawn)")
@ConfigEntry(path = "world.default-end-biome")
private Biome defaultEndBiome = Biome.THE_END;
Expand Down Expand Up @@ -1721,4 +1731,36 @@ public Biome getDefaultEndBiome() {
public void setDefaultEndBiome(Biome defaultEndBiome) {
this.defaultEndBiome = defaultEndBiome;
}

/**
* @return the concurrentIslands
*/
@Override
public int getConcurrentIslands() {
if (concurrentIslands <= 0) {
return BentoBox.getInstance().getSettings().getIslandNumber();
}
return concurrentIslands;
}

/**
* @param concurrentIslands the concurrentIslands to set
*/
public void setConcurrentIslands(int concurrentIslands) {
this.concurrentIslands = concurrentIslands;
}

/**
* @return the disallowTeamMemberIslands
*/
public boolean isDisallowTeamMemberIslands() {
return disallowTeamMemberIslands;
}

/**
* @param disallowTeamMemberIslands the disallowTeamMemberIslands to set
*/
public void setDisallowTeamMemberIslands(boolean disallowTeamMemberIslands) {
this.disallowTeamMemberIslands = disallowTeamMemberIslands;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public boolean canExecute(User user, String label, List<String> args) {
Island island = getIslands().getIsland(getWorld(), user);
int rank = Objects.requireNonNull(island).getRank(user);
if (rank < island.getRankCommand(getUsage())) {
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(getPlugin().getRanksManager().getRank(rank)));
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK,
user.getTranslation(RanksManager.getInstance().getRank(rank)));
return false;
}
// Check the name of the score to clear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.managers.RanksManager;
import world.bentobox.parkour.Parkour;
import world.bentobox.parkour.ParkourManager;

Expand Down Expand Up @@ -39,7 +40,7 @@ public boolean canExecute(User user, String label, List<String> args) {
// Check rank to use command
int rank = Objects.requireNonNull(island).getRank(user);
if (rank < island.getRankCommand(getUsage())) {
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(getPlugin().getRanksManager().getRank(rank)));
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(RanksManager.getInstance().getRank(rank)));
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.managers.RanksManager;
import world.bentobox.parkour.Parkour;
import world.bentobox.parkour.ParkourManager;

Expand Down Expand Up @@ -46,7 +47,8 @@ public boolean canExecute(User user, String label, List<String> args) {
Island island = getIslands().getIsland(getWorld(), user);
int rank = Objects.requireNonNull(island).getRank(user);
if (rank < island.getRankCommand(getUsage())) {
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(getPlugin().getRanksManager().getRank(rank)));
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK,
user.getTranslation(RanksManager.getInstance().getRank(rank)));
return false;
}
Optional<Location> start = ((Parkour) getAddon()).getParkourManager().getStart(island);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/world/bentobox/parkour/commands/WarpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

/**
* Warps to a
* @author tastybento
*
* @author tastybento
*/
public class WarpCommand extends CompositeCommand {

Expand Down Expand Up @@ -48,7 +48,7 @@ public boolean canExecute(User user, String label, List<String> args) {
}
if (args.isEmpty()) {
Optional<Island> island = getIslands().getIslandAt(user.getLocation());
if (island.isEmpty() || !((Parkour)getAddon()).inWorld(user.getWorld())) {
if (island.isEmpty() || !((Parkour) getAddon()).inWorld(user.getWorld())) {
user.sendMessage("parkour.errors.not-on-island");
this.showHelp(this, user);
return false;
Expand Down Expand Up @@ -81,18 +81,18 @@ public boolean execute(User user, String label, List<String> args) {
// Teleport user
user.getPlayer().playSound(user.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
user.getPlayer().playSound(warpSpot, Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
Util.teleportAsync(user.getPlayer(), warpSpot.clone().add(new Vector(0.5, 0.5, 0.5)), TeleportCause.COMMAND);
Util.teleportAsync(user.getPlayer(), warpSpot, TeleportCause.COMMAND);
return true;
}

@Override
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
ArrayList<String> options = new ArrayList<>(((Parkour)getAddon()).getParkourManager().getWarps().keySet());
ArrayList<String> options = new ArrayList<>(((Parkour) getAddon()).getParkourManager().getWarps().keySet());
if (options.size() < 10) {
return Optional.of(options);
}
// List is too long; require at least the first letter
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
String lastArg = !args.isEmpty() ? args.get(args.size() - 1) : "";
if (args.isEmpty()) {
return Optional.empty();
}
Expand Down
40 changes: 22 additions & 18 deletions src/main/java/world/bentobox/parkour/gui/CoursesTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

Expand All @@ -25,9 +24,9 @@

/**
* Implements a {@link Tab} that shows course rankings
*
* @author tastybento
* @since 1.0.0
*
*/
public class CoursesTab implements Tab {

Expand All @@ -36,8 +35,9 @@ public class CoursesTab implements Tab {

/**
* Show a tab of settings
*
* @param addon - addon
* @param user - user who is viewing the tab
* @param user - user who is viewing the tab
*/
public CoursesTab(Parkour addon, User user) {
super();
Expand All @@ -47,6 +47,7 @@ public CoursesTab(Parkour addon, User user) {

/**
* Get the icon for this tab
*
* @return panel item
*/
@Override
Expand All @@ -69,6 +70,7 @@ public String getName() {

/**
* Get all the flags as panel items
*
* @return list of all the panel items for this flag type
*/
@Override
Expand All @@ -78,32 +80,34 @@ public String getName() {
List<PanelItem> heads = new ArrayList<>();
// Sort the courses by runs
addon.getParkourManager().getParkourData().stream()
.sorted()
.filter(hs -> Objects.nonNull(hs.getWarpSpot()))
.forEach(hs -> {
UUID owner = addon.getIslands().getIslandById(hs.getUniqueId()).map(Island::getOwner).orElse(null);
if (owner != null) {
heads.add(getHead(hs, owner));
}
});
.sorted()
.filter(hs -> Objects.nonNull(hs.getWarpSpot()))
.forEach(hs -> {
addon.getIslands().getIslandById(hs.getUniqueId()).ifPresent(is -> {
if (is.getOwner() != null) {
heads.add(getHead(hs, is));
}
});
});
return heads;
}

/**
* Get the head panel item
* @param pd - parkour data
* @param playerUUID - the UUID of the owner
*
* @param pd - parkour data
* @param is.getOwner() - the UUID of the owner
* @return PanelItem
*/
private PanelItem getHead(ParkourData pd, UUID playerUUID) {
final String name = addon.getPlayers().getName(playerUUID);
private PanelItem getHead(ParkourData pd, Island is) {
final String name = addon.getPlayers().getName(is.getOwner());
List<String> description = new ArrayList<>();
if (pd.getRunCount() > 0) {
description.add(user.getTranslation("parkour.courses.head-description", "[name]", name, "[runs]", String.valueOf(pd.getRunCount())));
}
if (addon.getIslands().inTeam(addon.getOverWorld(), playerUUID)) {
if (addon.getIslands().inTeam(addon.getOverWorld(), is.getOwner())) {
List<String> memberList = new ArrayList<>();
for (UUID members : addon.getIslands().getMembers(addon.getOverWorld(), playerUUID)) {
for (UUID members : is.getMemberSet()) {
memberList.add(ChatColor.AQUA + addon.getPlayers().getName(members));
}
description.addAll(memberList);
Expand All @@ -115,7 +119,7 @@ private PanelItem getHead(ParkourData pd, UUID playerUUID) {
.clickHandler((panel, user, clickType, slot) -> {
user.sendMessage("parkour.warp.warping");
// Teleport user
Util.teleportAsync(user.getPlayer(), pd.getWarpSpot().clone().add(new Vector(0.5, 1, 0.5)), TeleportCause.COMMAND);
Util.teleportAsync(user.getPlayer(), pd.getWarpSpot(), TeleportCause.COMMAND);
return true;
})
.description(description);
Expand Down
Loading

0 comments on commit f7005e7

Please sign in to comment.