mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2024-12-24 14:48:53 +08:00
Merge branch 'master' into dynmap-impl
# Conflicts: # pom.xml
This commit is contained in:
commit
aa31a45cec
@ -8,15 +8,13 @@
|
||||
|
||||
### [统计页面](https://bstats.org/plugin/bukkit/Dominion/21445) | [Hangar](https://hangar.papermc.io/zhangyuheng/Dominion)
|
||||
|
||||
[![CodeFactor](https://www.codefactor.io/repository/github/deergiteamirror/dominion/badge/master)](https://www.codefactor.io/repository/github/deergiteamirror/dominion/overview/master)
|
||||
|
||||
</div>
|
||||
|
||||
## 简介
|
||||
|
||||
鉴于 Residence 插件的作者项目较多,维护压力大,无法及时跟进新版本以及适配Folia核心。故开发此插件,旨在平替纯净版生存服Residence的使用。
|
||||
|
||||
请注意,本插件仍然处于测试阶段,因此可能存在一定的行为控制漏洞。如果遇到此类遗漏的行为控制欢迎即使发送邮件或添加QQ告知,感激不尽。
|
||||
**请注意,本插件目前处于中期测试稳定阶段,绝大多数bug或漏洞已被修复,目前已具备完全可用性。但不排除仍然存在某些问题,如果遇到任何 BUG 欢迎及时发送邮件或添加QQ群告知,感激不尽。**
|
||||
|
||||
## 说明
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>Dominion</artifactId>
|
||||
<version>1.36.1-dynmap-beta</version>
|
||||
<version>1.37.0-dynmap-beta</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Dominion</name>
|
||||
|
@ -11,15 +11,17 @@ import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static cn.lunadeer.dominion.DominionNode.getLocInDominionDTO;
|
||||
import static cn.lunadeer.dominion.DominionNode.getLocInDominionNode;
|
||||
|
||||
public class Cache {
|
||||
|
||||
@ -64,25 +66,21 @@ public class Cache {
|
||||
int count = 0;
|
||||
if (idToLoad == null) {
|
||||
id_dominions = new ConcurrentHashMap<>();
|
||||
world_dominion_tree = new ConcurrentHashMap<>();
|
||||
dominion_children = new ConcurrentHashMap<>();
|
||||
|
||||
List<DominionDTO> dominions = DominionDTO.selectAll();
|
||||
CompletableFuture<Void> res = dominion_trees.initAsync(dominions);
|
||||
count = dominions.size();
|
||||
Map<String, List<DominionDTO>> world_dominions = new HashMap<>();
|
||||
|
||||
for (DominionDTO d : dominions) {
|
||||
if (!world_dominions.containsKey(d.getWorld())) {
|
||||
world_dominions.put(d.getWorld(), new ArrayList<>());
|
||||
}
|
||||
world_dominions.get(d.getWorld()).add(d);
|
||||
id_dominions.put(d.getId(), d);
|
||||
if (!dominion_children.containsKey(d.getParentDomId())) {
|
||||
dominion_children.put(d.getParentDomId(), new ArrayList<>());
|
||||
}
|
||||
dominion_children.get(d.getParentDomId()).add(d.getId());
|
||||
}
|
||||
for (Map.Entry<String, List<DominionDTO>> entry : world_dominions.entrySet()) {
|
||||
world_dominion_tree.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
||||
}
|
||||
|
||||
res.join(); // 等待树的构建完成
|
||||
} else {
|
||||
DominionDTO dominion = DominionDTO.select(idToLoad);
|
||||
if (dominion == null && id_dominions.containsKey(idToLoad)) {
|
||||
@ -227,7 +225,7 @@ public class Cache {
|
||||
return last_dominion;
|
||||
}
|
||||
}
|
||||
DominionDTO current_dominion = getLocInDominionDTO(world_dominion_tree.get(player.getWorld().getName()), player.getLocation());
|
||||
DominionDTO current_dominion = dominion_trees.getLocInDominionDTO(player.getLocation());
|
||||
int last_dom_id = last_dominion == null ? -1 : last_dominion.getId();
|
||||
int current_dom_id = current_dominion == null ? -1 : current_dominion.getId();
|
||||
if (last_dom_id == current_dom_id) {
|
||||
@ -339,30 +337,8 @@ public class Cache {
|
||||
}
|
||||
}
|
||||
|
||||
public DominionDTO getDominion(Location loc) {
|
||||
return getLocInDominionDTO(world_dominion_tree.get(loc.getWorld().getName()), loc);
|
||||
}
|
||||
|
||||
public List<DominionNode> getDominionTreeByPlayer(String player_name) {
|
||||
List<DominionNode> dominionTree = new ArrayList<>();
|
||||
PlayerDTO player = PlayerDTO.select(player_name);
|
||||
if (player == null) return dominionTree;
|
||||
for (List<DominionNode> tree : world_dominion_tree.values()) {
|
||||
for (DominionNode node : tree) {
|
||||
if (node.getDominion().getOwner().equals(player.getUuid())) {
|
||||
dominionTree.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dominionTree;
|
||||
}
|
||||
|
||||
public List<DominionNode> getAllDominionTree() {
|
||||
List<DominionNode> dominionTree = new ArrayList<>();
|
||||
for (List<DominionNode> tree : world_dominion_tree.values()) {
|
||||
dominionTree.addAll(tree);
|
||||
}
|
||||
return dominionTree;
|
||||
public DominionDTO getDominionByLoc(Location loc) {
|
||||
return dominion_trees.getLocInDominionDTO(loc);
|
||||
}
|
||||
|
||||
public GroupDTO getGroup(Integer id) {
|
||||
@ -453,8 +429,8 @@ public class Cache {
|
||||
|
||||
public static Cache instance;
|
||||
private ConcurrentHashMap<Integer, DominionDTO> id_dominions;
|
||||
private ConcurrentHashMap<String, List<DominionNode>> world_dominion_tree;
|
||||
private ConcurrentHashMap<Integer, GroupDTO> id_groups;
|
||||
private final WorldDominionTreeSectored dominion_trees = new WorldDominionTreeSectored();
|
||||
private ConcurrentHashMap<UUID, ConcurrentHashMap<Integer, MemberDTO>> player_uuid_to_member; // 玩家所有的特权
|
||||
private final Map<UUID, Integer> player_current_dominion_id; // 玩家当前所在领地
|
||||
private ConcurrentHashMap<Integer, List<Integer>> dominion_children;
|
||||
@ -469,4 +445,116 @@ public class Cache {
|
||||
public final Map<UUID, LocalDateTime> NextTimeAllowTeleport = new java.util.HashMap<>();
|
||||
|
||||
private Map<UUID, List<ResMigration.ResidenceNode>> residence_data = null;
|
||||
|
||||
private static class WorldDominionTreeSectored {
|
||||
/*
|
||||
D | C
|
||||
--+--
|
||||
B | A
|
||||
*/
|
||||
|
||||
private ConcurrentHashMap<String, List<DominionNode>> world_dominion_tree_sector_a; // x >= 0, z >= 0
|
||||
private ConcurrentHashMap<String, List<DominionNode>> world_dominion_tree_sector_b; // x <= 0, z >= 0
|
||||
private ConcurrentHashMap<String, List<DominionNode>> world_dominion_tree_sector_c; // x >= 0, z <= 0
|
||||
private ConcurrentHashMap<String, List<DominionNode>> world_dominion_tree_sector_d; // x <= 0, z <= 0
|
||||
|
||||
public DominionDTO getLocInDominionDTO(@NotNull Location loc) {
|
||||
List<DominionNode> nodes = getNodes(loc);
|
||||
if (nodes == null) return null;
|
||||
if (nodes.isEmpty()) return null;
|
||||
DominionNode dominionNode = getLocInDominionNode(nodes, loc);
|
||||
return dominionNode == null ? null : dominionNode.getDominion();
|
||||
}
|
||||
|
||||
|
||||
public List<DominionNode> getNodes(Location loc) {
|
||||
return getNodes(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ());
|
||||
}
|
||||
|
||||
public List<DominionNode> getNodes(String world, int x, int z) {
|
||||
if (x >= 0 && z >= 0) {
|
||||
return world_dominion_tree_sector_a.get(world);
|
||||
}
|
||||
if (x <= 0 && z >= 0) {
|
||||
return world_dominion_tree_sector_b.get(world);
|
||||
}
|
||||
if (x >= 0) {
|
||||
return world_dominion_tree_sector_c.get(world);
|
||||
}
|
||||
return world_dominion_tree_sector_d.get(world);
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> initAsync(List<DominionDTO> dominions) {
|
||||
return CompletableFuture.runAsync(() -> init(dominions));
|
||||
}
|
||||
|
||||
|
||||
private void init(List<DominionDTO> dominions) {
|
||||
world_dominion_tree_sector_a = new ConcurrentHashMap<>();
|
||||
world_dominion_tree_sector_b = new ConcurrentHashMap<>();
|
||||
world_dominion_tree_sector_c = new ConcurrentHashMap<>();
|
||||
world_dominion_tree_sector_d = new ConcurrentHashMap<>();
|
||||
|
||||
Map<String, List<DominionDTO>> world_dominions_sector_a = new HashMap<>();
|
||||
Map<String, List<DominionDTO>> world_dominions_sector_b = new HashMap<>();
|
||||
Map<String, List<DominionDTO>> world_dominions_sector_c = new HashMap<>();
|
||||
Map<String, List<DominionDTO>> world_dominions_sector_d = new HashMap<>();
|
||||
for (DominionDTO d : dominions) {
|
||||
// 对每个世界的领地进行四个象限的划分
|
||||
if (!world_dominions_sector_a.containsKey(d.getWorld()) ||
|
||||
!world_dominions_sector_b.containsKey(d.getWorld()) ||
|
||||
!world_dominions_sector_c.containsKey(d.getWorld()) ||
|
||||
!world_dominions_sector_d.containsKey(d.getWorld())) {
|
||||
world_dominions_sector_a.put(d.getWorld(), new ArrayList<>());
|
||||
world_dominions_sector_b.put(d.getWorld(), new ArrayList<>());
|
||||
world_dominions_sector_c.put(d.getWorld(), new ArrayList<>());
|
||||
world_dominions_sector_d.put(d.getWorld(), new ArrayList<>());
|
||||
}
|
||||
if (d.getX1() >= 0 && d.getZ1() >= 0) {
|
||||
world_dominions_sector_a.get(d.getWorld()).add(d);
|
||||
} else if (d.getX1() <= 0 && d.getZ1() >= 0) {
|
||||
if (d.getX2() >= 0) {
|
||||
world_dominions_sector_a.get(d.getWorld()).add(d);
|
||||
world_dominions_sector_b.get(d.getWorld()).add(d);
|
||||
} else {
|
||||
world_dominions_sector_b.get(d.getWorld()).add(d);
|
||||
}
|
||||
} else if (d.getX1() >= 0 && d.getZ1() <= 0) {
|
||||
if (d.getZ2() >= 0) {
|
||||
world_dominions_sector_a.get(d.getWorld()).add(d);
|
||||
world_dominions_sector_c.get(d.getWorld()).add(d);
|
||||
} else {
|
||||
world_dominions_sector_c.get(d.getWorld()).add(d);
|
||||
}
|
||||
} else {
|
||||
if (d.getX2() >= 0 && d.getZ2() >= 0) {
|
||||
world_dominions_sector_a.get(d.getWorld()).add(d);
|
||||
world_dominions_sector_b.get(d.getWorld()).add(d);
|
||||
world_dominions_sector_c.get(d.getWorld()).add(d);
|
||||
world_dominions_sector_d.get(d.getWorld()).add(d);
|
||||
} else if (d.getX2() >= 0 && d.getZ2() <= 0) {
|
||||
world_dominions_sector_c.get(d.getWorld()).add(d);
|
||||
world_dominions_sector_d.get(d.getWorld()).add(d);
|
||||
} else if (d.getZ2() >= 0 && d.getX2() <= 0) {
|
||||
world_dominions_sector_b.get(d.getWorld()).add(d);
|
||||
world_dominions_sector_d.get(d.getWorld()).add(d);
|
||||
} else {
|
||||
world_dominions_sector_d.get(d.getWorld()).add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, List<DominionDTO>> entry : world_dominions_sector_a.entrySet()) {
|
||||
world_dominion_tree_sector_a.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, List<DominionDTO>> entry : world_dominions_sector_b.entrySet()) {
|
||||
world_dominion_tree_sector_b.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, List<DominionDTO>> entry : world_dominions_sector_c.entrySet()) {
|
||||
world_dominion_tree_sector_c.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, List<DominionDTO>> entry : world_dominions_sector_d.entrySet()) {
|
||||
world_dominion_tree_sector_d.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,13 +66,6 @@ public class DominionNode {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static DominionDTO getLocInDominionDTO(@Nullable List<DominionNode> nodes, @NotNull Location loc) {
|
||||
if (nodes == null) return null;
|
||||
if (nodes.isEmpty()) return null;
|
||||
DominionNode dominionNode = getLocInDominionNode(nodes, loc);
|
||||
return dominionNode == null ? null : dominionNode.getDominion();
|
||||
}
|
||||
|
||||
public static boolean isInDominion(@Nullable DominionDTO dominion, Location location) {
|
||||
if (dominion == null) return false;
|
||||
if (!Objects.equals(dominion.getWorld(), location.getWorld().getName())) return false;
|
||||
|
@ -37,7 +37,7 @@ public class Apis {
|
||||
player.setResponse(new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "无法获取你的位置信息"));
|
||||
return null;
|
||||
}
|
||||
DominionDTO dominion = Cache.instance.getDominion(location);
|
||||
DominionDTO dominion = Cache.instance.getDominionByLoc(location);
|
||||
if (dominion == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import static cn.lunadeer.dominion.controllers.Apis.notOwner;
|
||||
public class DominionController {
|
||||
|
||||
public static List<DominionDTO> all(Player owner) {
|
||||
return DominionDTO.selectAll(owner.getUniqueId());
|
||||
return DominionDTO.selectByOwner(owner.getUniqueId());
|
||||
}
|
||||
|
||||
public static List<DominionDTO> all() {
|
||||
|
@ -65,18 +65,13 @@ public class DominionDTO {
|
||||
return query(sql);
|
||||
}
|
||||
|
||||
public static List<DominionDTO> selectAll(String world) {
|
||||
String sql = "SELECT * FROM dominion WHERE world = ? AND id > 0;";
|
||||
return query(sql, world);
|
||||
}
|
||||
|
||||
public static List<DominionDTO> search(String name) {
|
||||
String sql = "SELECT * FROM dominion WHERE name LIKE ? AND id > 0;";
|
||||
return query(sql, "%" + name + "%");
|
||||
}
|
||||
|
||||
public static List<DominionDTO> selectAll(UUID owner) {
|
||||
String sql = "SELECT * FROM dominion WHERE owner = ? AND id > 0;";
|
||||
public static List<DominionDTO> selectByOwner(UUID owner) {
|
||||
String sql = "SELECT * FROM dominion WHERE owner = ? AND id > 0 ORDER BY id DESC;";
|
||||
return query(sql, owner.toString());
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class Apis {
|
||||
if (inv.getLocation() == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Cache.instance.getDominion(inv.getLocation());
|
||||
return Cache.instance.getDominionByLoc(inv.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class EnvironmentEvents implements Listener {
|
||||
) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getLocation());
|
||||
checkFlag(dom, Flag.CREEPER_EXPLODE, event);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (entity.getType() != EntityType.ENDER_DRAGON) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getLocation());
|
||||
checkFlag(dom, Flag.DRAGON_BREAK_BLOCK, event);
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class EnvironmentEvents implements Listener {
|
||||
// 如果点燃事件没有玩家触发,那么就是火焰蔓延
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getBlock().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getBlock().getLocation());
|
||||
checkFlag(dom, Flag.FIRE_SPREAD, event);
|
||||
}
|
||||
|
||||
@ -63,11 +63,11 @@ public class EnvironmentEvents implements Listener {
|
||||
public void onLiquidFlowIn(BlockFromToEvent event) {
|
||||
Location from = event.getBlock().getLocation();
|
||||
Location to = event.getToBlock().getLocation();
|
||||
DominionDTO dom_to = Cache.instance.getDominion(to);
|
||||
DominionDTO dom_to = Cache.instance.getDominionByLoc(to);
|
||||
if (dom_to == null) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom_from = Cache.instance.getDominion(from);
|
||||
DominionDTO dom_from = Cache.instance.getDominionByLoc(from);
|
||||
if (dom_from != null) {
|
||||
if (Objects.equals(dom_from.getId(), dom_to.getId())) {
|
||||
return;
|
||||
@ -82,7 +82,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (entity instanceof Player) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
if (dom == null) {
|
||||
return;
|
||||
}
|
||||
@ -101,7 +101,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (entity.getType() != EntityType.MINECART_TNT && entity.getType() != EntityType.PRIMED_TNT) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getLocation());
|
||||
checkFlag(dom, Flag.TNT_EXPLODE, event);
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (block.getType() != FARMLAND) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.TRAMPLE, event);
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (entity.getType() != EntityType.WITHER) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
checkFlag(dom, Flag.WITHER_SPAWN, event);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (entity.getType() != EntityType.ENDERMAN) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
checkFlag(dom, Flag.ENDER_MAN, event);
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (entity.getType() != EntityType.ENDERMAN) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
checkFlag(dom, Flag.ENDER_MAN, event);
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (!(entity instanceof Monster)) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
checkFlag(dom, Flag.MONSTER_SPAWN, event);
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (!(entity instanceof Animals)) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
checkFlag(dom, Flag.ANIMAL_SPAWN, event);
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ public class EnvironmentEvents implements Listener {
|
||||
if (entity.getType() != EntityType.VILLAGER) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
checkFlag(dom, Flag.VILLAGER_SPAWN, event);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player bukkitPlayer = (Player) event.getDamager();
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getEntity().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getEntity().getLocation());
|
||||
checkFlag(dom, Flag.ANIMAL_KILLING, bukkitPlayer, event);
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ public class PlayerEvents implements Listener {
|
||||
if (!(Tag.BEDS.isTagged(block.getType()))) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.BED, bukkitPlayer, event);
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ public class PlayerEvents implements Listener {
|
||||
}
|
||||
|
||||
public static boolean onBreak(Player player, Location location) {
|
||||
DominionDTO dom = Cache.instance.getDominion(location);
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(location);
|
||||
return checkFlag(dom, Flag.BREAK_BLOCK, player, null);
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public class PlayerEvents implements Listener {
|
||||
if (!Tag.BUTTONS.isTagged(block.getType())) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.BUTTON, player, event);
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.CAKE, player, event);
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ public class PlayerEvents implements Listener {
|
||||
if (loc == null) {
|
||||
dom = null;
|
||||
} else {
|
||||
dom = Cache.instance.getDominion(loc);
|
||||
dom = Cache.instance.getDominionByLoc(loc);
|
||||
}
|
||||
return checkFlag(dom, Flag.CONTAINER, player, null);
|
||||
}
|
||||
@ -292,7 +292,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getClickedBlock().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getClickedBlock().getLocation());
|
||||
checkFlag(dom, Flag.COMPARER, player, event);
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getClickedBlock().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getClickedBlock().getLocation());
|
||||
checkFlag(dom, Flag.DOOR, player, event);
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.DRAGON_EGG, player, event);
|
||||
}
|
||||
|
||||
@ -334,7 +334,7 @@ public class PlayerEvents implements Listener {
|
||||
if (!(entity instanceof Colorable)) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
checkFlag(dom, Flag.DYE, player, event);
|
||||
}
|
||||
|
||||
@ -351,7 +351,7 @@ public class PlayerEvents implements Listener {
|
||||
if (!(Tag.SIGNS.isTagged(block.getType()))) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.EDIT_SIGN, player, event);
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ public class PlayerEvents implements Listener {
|
||||
public void onSignEdit(SignChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.EDIT_SIGN, player, event);
|
||||
}
|
||||
|
||||
@ -412,7 +412,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getRightClicked().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getRightClicked().getLocation());
|
||||
checkFlag(dom, Flag.FEED, player, event);
|
||||
}
|
||||
|
||||
@ -438,7 +438,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.HARVEST, player, event);
|
||||
}
|
||||
|
||||
@ -456,7 +456,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.HONEY, player, event);
|
||||
}
|
||||
|
||||
@ -467,7 +467,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(caught.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(caught.getLocation());
|
||||
checkFlag(dom, Flag.HOOK, player, event);
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ public class PlayerEvents implements Listener {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getBlock().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getBlock().getLocation());
|
||||
checkFlag(dom, Flag.IGNITE, player, event);
|
||||
}
|
||||
|
||||
@ -514,7 +514,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.LEVER, player, event);
|
||||
}
|
||||
|
||||
@ -529,7 +529,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player bukkitPlayer = (Player) event.getDamager();
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
checkFlag(dom, Flag.MONSTER_KILLING, bukkitPlayer, event);
|
||||
}
|
||||
|
||||
@ -601,7 +601,7 @@ public class PlayerEvents implements Listener {
|
||||
}
|
||||
|
||||
public static boolean onPlace(Player player, Location location) {
|
||||
DominionDTO dom = Cache.instance.getDominion(location);
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(location);
|
||||
return checkFlag(dom, Flag.PLACE, player, null);
|
||||
}
|
||||
|
||||
@ -618,7 +618,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.PRESSURE, player, event);
|
||||
}
|
||||
|
||||
@ -628,7 +628,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getMount().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getMount().getLocation());
|
||||
checkFlag(dom, Flag.RIDING, player, event);
|
||||
}
|
||||
|
||||
@ -643,14 +643,14 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(block.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
|
||||
checkFlag(dom, Flag.REPEATER, player, event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // shear
|
||||
public void onShear(PlayerShearEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getEntity().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getEntity().getLocation());
|
||||
checkFlag(dom, Flag.SHEAR, player, event);
|
||||
}
|
||||
|
||||
@ -688,7 +688,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getAttacker();
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getVehicle().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getVehicle().getLocation());
|
||||
checkFlag(dom, Flag.VEHICLE_DESTROY, player, event);
|
||||
}
|
||||
|
||||
@ -702,7 +702,7 @@ public class PlayerEvents implements Listener {
|
||||
if (!(entity instanceof Vehicle)) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
||||
checkFlag(dom, Flag.VEHICLE_SPAWN, player, event);
|
||||
}
|
||||
|
||||
@ -715,7 +715,7 @@ public class PlayerEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getDamager();
|
||||
DominionDTO dom = Cache.instance.getDominion(event.getEntity().getLocation());
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(event.getEntity().getLocation());
|
||||
checkFlag(dom, Flag.VILLAGER_KILLING, player, event);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cn.lunadeer.dominion.tuis;
|
||||
|
||||
import cn.lunadeer.dominion.Cache;
|
||||
import cn.lunadeer.dominion.DominionNode;
|
||||
import cn.lunadeer.dominion.dtos.DominionDTO;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.ListView;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.components.Button;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.components.Line;
|
||||
@ -23,7 +24,7 @@ public class AllDominion {
|
||||
if (notOp(player)) return;
|
||||
int page = getPage(args, 1);
|
||||
|
||||
List<DominionNode> allDominions = Cache.instance.getAllDominionTree();
|
||||
List<DominionNode> allDominions = DominionNode.BuildNodeTree(-1, DominionDTO.selectAll());
|
||||
|
||||
ListView view = ListView.create(10, "/dominion all_dominion");
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cn.lunadeer.dominion.tuis.dominion;
|
||||
|
||||
import cn.lunadeer.dominion.Cache;
|
||||
import cn.lunadeer.dominion.DominionNode;
|
||||
import cn.lunadeer.dominion.dtos.DominionDTO;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.ListView;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.ViewStyles;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.components.Button;
|
||||
@ -27,7 +28,7 @@ public class DominionList {
|
||||
|
||||
view.title("我的领地列表");
|
||||
view.navigator(Line.create().append(Button.create("主菜单").setExecuteCommand("/dominion menu").build()).append("我的领地"));
|
||||
view.addLines(BuildTreeLines(Cache.instance.getDominionTreeByPlayer(player.getName()), 0));
|
||||
view.addLines(BuildTreeLines(DominionNode.BuildNodeTree(-1, DominionDTO.selectByOwner(player.getUniqueId())), 0));
|
||||
List<String> admin_dominions = playerAdminDominions(sender);
|
||||
if (admin_dominions.size() != 0) {
|
||||
view.add(Line.create().append(""));
|
||||
|
Loading…
Reference in New Issue
Block a user