Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.7.2 #94

Merged
merged 7 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.21-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.4.0-SNAPSHOT</bentobox.version>
<spigot.version>1.21.1-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.5.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>2.7.1</build.version>
<build.version>2.7.2</build.version>

<sonar.projectKey>BentoBoxWorld_Boxed</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down Expand Up @@ -173,7 +173,7 @@
</dependency>
<!-- Spigot NMS. Used for chunk deletion and pasting. -->

<dependency>
<dependency>
<groupId>org.spigotmc....</groupId>
<artifactId>spigot</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
Expand All @@ -191,7 +191,12 @@
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.spigotmc......</groupId>
<artifactId>spigot</artifactId>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc.</groupId>
<artifactId>spigot</artifactId>
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/world/bentobox/boxed/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,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("Area height")
@ConfigComment("It is the y coordinate of the bedrock block in the blueprint.")
@ConfigEntry(path = "world.area-height")
Expand Down Expand Up @@ -1761,4 +1770,35 @@ public void setIgnoreAdvancements(boolean ignoreAdvancements) {
this.ignoreAdvancements = ignoreAdvancements;
}

/**
* @return the concurrentIslands
*/
public int getConcurrentIslands() {
if (concurrentIslands <= 0) {
return BentoBox.getInstance().getSettings().getIslandNumber();
}
return this.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 @@ -45,6 +45,8 @@
*/
public class AdvancementListener implements Listener {

private static final Material[] MATS = Material.values();

private final Boxed addon;
private final Advancement netherAdvancement;
private final Advancement netherFortressAdvancement;
Expand Down Expand Up @@ -327,7 +329,8 @@ private void grantAdv(User user, List<String> list) {

private void clearAdv(User user) {
// Clear Statistics
Arrays.stream(Statistic.values()).forEach(s -> resetStats(user, s));
Bukkit.getScheduler().runTaskAsynchronously(addon.getPlugin(),
() -> Arrays.stream(Statistic.values()).forEach(s -> resetStats(user, s)));
// Clear advancements
Iterator<Advancement> it = Bukkit.advancementIterator();
while (it.hasNext()) {
Expand All @@ -340,8 +343,9 @@ private void clearAdv(User user) {

private void resetStats(User user, Statistic s) {
switch(s.getType()) {
case BLOCK -> Arrays.stream(Material.values()).filter(Material::isBlock).forEach(m -> user.getPlayer().setStatistic(s, m, 0));
case ITEM -> Arrays.stream(Material.values()).filter(Material::isItem).forEach(m -> user.getPlayer().setStatistic(s, m, 0));
case BLOCK ->
Arrays.stream(MATS).filter(Material::isBlock).forEach(m -> user.getPlayer().setStatistic(s, m, 0));
case ITEM -> Arrays.stream(MATS).filter(Material::isItem).forEach(m -> user.getPlayer().setStatistic(s, m, 0));
case ENTITY -> Arrays.stream(EntityType.values()).filter(EntityType::isAlive).forEach(m -> user.getPlayer().setStatistic(s, m, 0));
case UNTYPED -> user.getPlayer().setStatistic(s, 0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package world.bentobox.boxed.listeners;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import org.bukkit.GameMode;
import org.bukkit.Location;
Expand All @@ -15,6 +17,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;

import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
Expand All @@ -29,6 +32,7 @@
public class EnderPearlListener implements Listener {

private final Boxed addon;
private Set<Player> movingPlayer = new HashSet<>();

/**
* @param addon addon
Expand All @@ -38,7 +42,11 @@ public EnderPearlListener(Boxed addon) {
}

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent e) {
public void onPlayerTeleport(PlayerTeleportEvent e) {
if (e.getCause() == TeleportCause.ENDER_PEARL && movingPlayer.contains(e.getPlayer())) {
movingPlayer.remove(e.getPlayer());
return; // Allow the teleport this one time
}
if (!addon.inWorld(e.getFrom()) || !e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)
|| (e.getTo() != null && !addon.inWorld(e.getTo()))
|| addon.getIslands().getSpawn(e.getFrom().getWorld()).map(spawn -> spawn.onIsland(e.getTo())).orElse(false)
Expand Down Expand Up @@ -91,7 +99,7 @@ public void onEnderPearlLand(ProjectileHitEvent e) {
if (!toIsland.onIsland(l)) {
// Moving is allowed
moveBox(u, fromIsland, l);
Util.teleportAsync(player, l);
Util.teleportAsync(player, l, TeleportCause.ENDER_PEARL);
}
} else {
// Different box. This is never allowed. Cancel the throw
Expand All @@ -117,6 +125,7 @@ private void moveBox(User u, Island fromIsland, Location l) {
fromIsland.setProtectionCenter(l);
fromIsland.setSpawnPoint(l.getWorld().getEnvironment(), l);
u.getPlayer().playSound(l, Sound.ENTITY_GENERIC_EXPLODE, 2F, 2F);
movingPlayer.add(u.getPlayer());
} catch (IOException e1) {
addon.logError("Could not move box " + e1.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,7 @@ private static String nmsData(Block block) {
throw new IllegalStateException("Class " + clazz.getName() + " does not implement AbstractGetMetaData");
}
} catch (Exception e) {
e.printStackTrace();
BentoBox.getInstance().logWarning("No metadata handler found for " + bukkitVersion + " in Boxed.");
BentoBox.getInstance().logError("No metadata handler found for " + bukkitVersion + " in Boxed (yet).");
handler = new world.bentobox.boxed.nms.fallback.GetMetaData();
}
return handler.nmsData(block);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package world.bentobox.boxed.nms.v1_21_1_R0_1_SNAPSHOT;

public class GetMetaData extends world.bentobox.boxed.nms.v1_21_R0_1_SNAPSHOT.GetMetaData {
// Identical to 1.21
}
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Boxed
main: world.bentobox.boxed.Boxed
version: ${version}${build.number}
api-version: 1.24
api-version: 2.5.1
metrics: true
icon: "COMPOSTER"
repository: "BentoBoxWorld/Boxed"
Expand Down
Loading