mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2024-11-30 12:54:33 +01:00
Merge pull request #92 from BentoBoxWorld/91_Enderpearl_bug_and_no_meta_data_error
Bring up to 1.21.1 and fix ender pearl operation. #91
This commit is contained in:
commit
27aff14429
13
pom.xml
13
pom.xml
@ -58,8 +58,8 @@
|
||||
<!-- 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.5.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. -->
|
||||
@ -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>
|
||||
@ -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>
|
||||
|
@ -45,6 +45,8 @@ import world.bentobox.boxed.Boxed;
|
||||
*/
|
||||
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 @@ public class AdvancementListener implements Listener {
|
||||
|
||||
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()) {
|
||||
@ -340,8 +343,9 @@ public class AdvancementListener implements Listener {
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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.EventPriority;
|
||||
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 @@ import world.bentobox.boxed.Boxed;
|
||||
public class EnderPearlListener implements Listener {
|
||||
|
||||
private final Boxed addon;
|
||||
private Set<Player> movingPlayer = new HashSet<>();
|
||||
|
||||
/**
|
||||
* @param addon addon
|
||||
@ -38,7 +42,11 @@ public class EnderPearlListener implements Listener {
|
||||
}
|
||||
|
||||
@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 class EnderPearlListener implements Listener {
|
||||
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 @@ public class EnderPearlListener implements Listener {
|
||||
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());
|
||||
}
|
||||
|
@ -635,8 +635,7 @@ public class NewAreaListener implements Listener {
|
||||
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);
|
||||
|
@ -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
|
||||
}
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user