将“无权限”提示修改为action bar提示,避免刷屏
All checks were successful
Java CI-CD with Maven / build (push) Successful in 8m4s
All checks were successful
Java CI-CD with Maven / build (push) Successful in 8m4s
优化没有移动权限时的传送逻辑
This commit is contained in:
parent
d9787a9b32
commit
8b1d5d4291
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>Dominion</artifactId>
|
||||
<version>1.28.8-beta</version>
|
||||
<version>1.28.11-beta</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Dominion</name>
|
||||
|
@ -8,6 +8,11 @@ import cn.lunadeer.dominion.dtos.PlayerPrivilegeDTO;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -57,8 +62,12 @@ public class Apis {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
TextComponent msg = Component.text(String.format("你没有 %s (%s) 权限", flag.getDisplayName(), flag.getDescription())).hoverEvent(Component.text(flag.getDescription()));
|
||||
Notification.error(player, msg);
|
||||
TextComponent msg = Component.text(
|
||||
String.format("你没有 %s (%s) 权限", flag.getDisplayName(), flag.getDescription()),
|
||||
Style.style(TextColor.color(0xFF0000), TextDecoration.BOLD))
|
||||
.hoverEvent(Component.text(flag.getDescription()));
|
||||
// Notification.error(player, msg);
|
||||
player.sendActionBar(msg);
|
||||
if (event != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import cn.lunadeer.dominion.Cache;
|
||||
import cn.lunadeer.dominion.dtos.DominionDTO;
|
||||
import cn.lunadeer.dominion.dtos.Flag;
|
||||
import cn.lunadeer.dominion.dtos.PlayerDTO;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Teleport;
|
||||
import io.papermc.paper.event.entity.EntityDyeEvent;
|
||||
import org.bukkit.Location;
|
||||
@ -513,15 +514,23 @@ public class PlayerEvents implements Listener {
|
||||
// find min distance
|
||||
int min = Math.min(Math.min(x1, x2), Math.min(z1, z2));
|
||||
if (min == x1) {
|
||||
to.setX(dom.getX1() - 1);
|
||||
to.setX(dom.getX1() - 2);
|
||||
} else if (min == x2) {
|
||||
to.setX(dom.getX2() + 1);
|
||||
to.setX(dom.getX2() + 2);
|
||||
} else if (min == z1) {
|
||||
to.setZ(dom.getZ1() - 1);
|
||||
to.setZ(dom.getZ1() - 2);
|
||||
} else {
|
||||
to.setZ(dom.getZ2() + 1);
|
||||
to.setZ(dom.getZ2() + 2);
|
||||
}
|
||||
Teleport.doTeleportSafely(player, to);
|
||||
Teleport.doTeleportSafely(player, to).thenAccept((success) -> {
|
||||
if (!success) {
|
||||
Notification.warn(player, "传送失败,你将被传送到复活点");
|
||||
player.teleportAsync(player.getBedSpawnLocation() == null ?
|
||||
player.getWorld().getSpawnLocation() :
|
||||
player.getBedSpawnLocation()
|
||||
, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user