mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2024-12-30 09:44:36 +08:00
新增盔甲架、展示框权限控制(归属到普通容器)
This commit is contained in:
parent
be3fd701b1
commit
da8aa007d4
@ -120,10 +120,10 @@
|
|||||||
|
|
||||||
## 指令
|
## 指令
|
||||||
|
|
||||||
### 玩家指令
|
|
||||||
|
|
||||||
以下指令尖括号`<>`表示必填参数,方括号`[]`表示可选参数。
|
以下指令尖括号`<>`表示必填参数,方括号`[]`表示可选参数。
|
||||||
|
|
||||||
|
### 玩家指令
|
||||||
|
|
||||||
| 指令名 | 指令 |
|
| 指令名 | 指令 |
|
||||||
|------------|-------------------------------------------------------------|
|
|------------|-------------------------------------------------------------|
|
||||||
| 打开交互菜单 | `/dominion menu` |
|
| 打开交互菜单 | `/dominion menu` |
|
||||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>cn.lunadeer</groupId>
|
<groupId>cn.lunadeer</groupId>
|
||||||
<artifactId>Dominion</artifactId>
|
<artifactId>Dominion</artifactId>
|
||||||
<version>1.11.9-beta</version>
|
<version>1.11.10-beta</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Dominion</name>
|
<name>Dominion</name>
|
||||||
|
@ -7,6 +7,7 @@ import cn.lunadeer.dominion.dtos.PlayerPrivilegeDTO;
|
|||||||
import cn.lunadeer.dominion.utils.Notification;
|
import cn.lunadeer.dominion.utils.Notification;
|
||||||
import io.papermc.paper.event.entity.EntityDyeEvent;
|
import io.papermc.paper.event.entity.EntityDyeEvent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -22,6 +23,7 @@ import org.bukkit.event.inventory.InventoryOpenEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.spigotmc.event.entity.EntityMountEvent;
|
import org.spigotmc.event.entity.EntityMountEvent;
|
||||||
|
|
||||||
public class PlayerEvents implements Listener {
|
public class PlayerEvents implements Listener {
|
||||||
@ -314,6 +316,29 @@ public class PlayerEvents implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查是否有容器权限
|
||||||
|
private static boolean hasContainerPermission(Player player) {
|
||||||
|
DominionDTO dom = Cache.instance.getPlayerCurrentDominion(player);
|
||||||
|
if (dom == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (Apis.hasPermission(player, dom)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PlayerPrivilegeDTO privilege = Cache.instance.getPlayerPrivilege(player, dom);
|
||||||
|
if (privilege != null) {
|
||||||
|
if (privilege.getContainer()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dom.getContainer()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Notification.error(player, "你没有使用容器/盔甲架/展示框的权限");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST) // container
|
@EventHandler(priority = EventPriority.HIGHEST) // container
|
||||||
public void openContainer(InventoryOpenEvent event) {
|
public void openContainer(InventoryOpenEvent event) {
|
||||||
if (event.getInventory().getType() != InventoryType.CHEST &&
|
if (event.getInventory().getType() != InventoryType.CHEST &&
|
||||||
@ -325,24 +350,47 @@ public class PlayerEvents implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player bukkitPlayer = (Player) event.getPlayer();
|
Player bukkitPlayer = (Player) event.getPlayer();
|
||||||
DominionDTO dom = Cache.instance.getPlayerCurrentDominion(bukkitPlayer);
|
if (hasContainerPermission(bukkitPlayer)) {
|
||||||
if (dom == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Apis.hasPermission(bukkitPlayer, dom)) {
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST) // container (armor stand)
|
||||||
|
public void manipulateArmorStand(PlayerArmorStandManipulateEvent event) {
|
||||||
|
Player bukkitPlayer = event.getPlayer();
|
||||||
|
if (hasContainerPermission(bukkitPlayer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlayerPrivilegeDTO privilege = Cache.instance.getPlayerPrivilege(bukkitPlayer, dom);
|
event.setCancelled(true);
|
||||||
if (privilege != null) {
|
}
|
||||||
if (privilege.getContainer()) {
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST) // container (item frame)
|
||||||
|
public void putSomeOnItemFrame(PlayerInteractEntityEvent event) {
|
||||||
|
Entity entity = event.getRightClicked();
|
||||||
|
if (!(entity instanceof ItemFrame)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
Player bukkitPlayer = event.getPlayer();
|
||||||
if (dom.getContainer()) {
|
if (hasContainerPermission(bukkitPlayer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST) // container (item frame)
|
||||||
|
public void removeSomeOnItemFrame(EntityDamageByEntityEvent event) {
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
if (!(entity instanceof ItemFrame)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(event.getDamager() instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player bukkitPlayer = (Player) event.getDamager();
|
||||||
|
if (hasContainerPermission(bukkitPlayer)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
Notification.error(bukkitPlayer, "你没有使用容器的权限");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,11 +122,11 @@ public class DominionFlagInfo {
|
|||||||
if (dominion.getContainer()) {
|
if (dominion.getContainer()) {
|
||||||
view.add(Line.create()
|
view.add(Line.create()
|
||||||
.append(Button.createGreen("☑", "/dominion set container false " + dominion.getName() + " " + page))
|
.append(Button.createGreen("☑", "/dominion set container false " + dominion.getName() + " " + page))
|
||||||
.append("箱子/木桶/潜影盒"));
|
.append("箱子/木桶/潜影盒/盔甲架/展示框"));
|
||||||
} else {
|
} else {
|
||||||
view.add(Line.create()
|
view.add(Line.create()
|
||||||
.append(Button.createRed("☐", "/dominion set container true " + dominion.getName() + " " + page))
|
.append(Button.createRed("☐", "/dominion set container true " + dominion.getName() + " " + page))
|
||||||
.append("箱子/木桶/潜影盒"));
|
.append("箱子/木桶/潜影盒/盔甲架/展示框"));
|
||||||
}
|
}
|
||||||
if (dominion.getCraft()) {
|
if (dominion.getCraft()) {
|
||||||
view.add(Line.create()
|
view.add(Line.create()
|
||||||
|
@ -146,11 +146,11 @@ public class PrivilegeInfo {
|
|||||||
if (privilege.getContainer()) {
|
if (privilege.getContainer()) {
|
||||||
view.add(Line.create()
|
view.add(Line.create()
|
||||||
.append(Button.createGreen("☑", "/dominion set_privilege " + playerName + " container false " + dominion.getName() + " " + page))
|
.append(Button.createGreen("☑", "/dominion set_privilege " + playerName + " container false " + dominion.getName() + " " + page))
|
||||||
.append("箱子/木桶/潜影盒"));
|
.append("箱子/木桶/潜影盒/盔甲架/展示框"));
|
||||||
} else {
|
} else {
|
||||||
view.add(Line.create()
|
view.add(Line.create()
|
||||||
.append(Button.createRed("☐", "/dominion set_privilege " + playerName + " container true " + dominion.getName() + " " + page))
|
.append(Button.createRed("☐", "/dominion set_privilege " + playerName + " container true " + dominion.getName() + " " + page))
|
||||||
.append("箱子/木桶/潜影盒"));
|
.append("箱子/木桶/潜影盒/盔甲架/展示框"));
|
||||||
}
|
}
|
||||||
if (privilege.getCraft()) {
|
if (privilege.getCraft()) {
|
||||||
view.add(Line.create()
|
view.add(Line.create()
|
||||||
|
Loading…
Reference in New Issue
Block a user