diff --git a/pom.xml b/pom.xml index 51c04b3..d5345a6 100644 --- a/pom.xml +++ b/pom.xml @@ -58,8 +58,8 @@ 2.0.9 - 1.21-R0.1-SNAPSHOT - 2.5.0-SNAPSHOT + 1.21.1-R0.1-SNAPSHOT + 2.5.1-SNAPSHOT ${build.version}-SNAPSHOT @@ -173,7 +173,7 @@ - + org.spigotmc.... spigot 1.20.6-R0.1-SNAPSHOT @@ -191,7 +191,12 @@ 1.21-R0.1-SNAPSHOT provided - + + org.spigotmc...... + spigot + 1.21.1-R0.1-SNAPSHOT + provided + org.spigotmc. spigot diff --git a/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java b/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java index f79a802..dcdf779 100644 --- a/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java +++ b/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java @@ -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; @@ -327,7 +329,8 @@ private void grantAdv(User user, List 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 it = Bukkit.advancementIterator(); while (it.hasNext()) { @@ -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); } diff --git a/src/main/java/world/bentobox/boxed/listeners/EnderPearlListener.java b/src/main/java/world/bentobox/boxed/listeners/EnderPearlListener.java index 0a835e9..926bd67 100644 --- a/src/main/java/world/bentobox/boxed/listeners/EnderPearlListener.java +++ b/src/main/java/world/bentobox/boxed/listeners/EnderPearlListener.java @@ -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; @@ -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; @@ -29,6 +32,7 @@ public class EnderPearlListener implements Listener { private final Boxed addon; + private Set movingPlayer = new HashSet<>(); /** * @param addon addon @@ -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) @@ -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 @@ -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()); } diff --git a/src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java b/src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java index d893d40..bffcfe8 100644 --- a/src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java +++ b/src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java @@ -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); diff --git a/src/main/java/world/bentobox/boxed/nms/v1_21_1_R0_1_SNAPSHOT/GetMetaData.java b/src/main/java/world/bentobox/boxed/nms/v1_21_1_R0_1_SNAPSHOT/GetMetaData.java new file mode 100644 index 0000000..f28677f --- /dev/null +++ b/src/main/java/world/bentobox/boxed/nms/v1_21_1_R0_1_SNAPSHOT/GetMetaData.java @@ -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 +} \ No newline at end of file diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml index edb836e..3b7a42a 100755 --- a/src/main/resources/addon.yml +++ b/src/main/resources/addon.yml @@ -1,7 +1,7 @@ name: Boxed main: world.bentobox.boxed.Boxed version: ${version}${build.number} -api-version: 2.5.0 +api-version: 2.5.1 metrics: true icon: "COMPOSTER" repository: "BentoBoxWorld/Boxed"