完成了初版

This commit is contained in:
zhangyuheng 2024-02-15 02:49:28 +08:00
parent d52cd2d9d6
commit 52e87c6e79
13 changed files with 1587 additions and 179 deletions

View File

@ -4,6 +4,7 @@ import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.dtos.PlayerPrivilegeDTO;
import cn.lunadeer.dominion.utils.Notification;
import cn.lunadeer.dominion.utils.XLogger;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import javax.annotation.Nullable;
@ -64,6 +65,10 @@ public class Cache {
DominionDTO dominion = player_current_dominion.get(player.getUniqueId());
if (dominion != null) {
if (!isInDominion(dominion, player)) {
// glow
if (player.isGlowing()) {
player.setGlowing(false);
}
Notification.info(player, "您已离开领地:" + dominion.getName());
Notification.info(player, dominion.getLeaveMessage());
player_current_dominion.put(player.getUniqueId(), null);
@ -84,12 +89,42 @@ public class Cache {
in_dominions.sort(Comparator.comparingInt(DominionDTO::getId));
dominion = in_dominions.get(in_dominions.size() - 1);
player_current_dominion.put(player.getUniqueId(), dominion);
// glow
PlayerPrivilegeDTO privilege = getPlayerPrivilege(player, dominion);
if (privilege != null) {
if (privilege.getGlow()) {
if (player.isGlowing()) {
player.setGlowing(true);
}
}
} else {
if (dominion.getGlow()) {
if (player.isGlowing()) {
player.setGlowing(true);
}
}
}
Notification.info(player, "您正在进入领地:" + dominion.getName());
Notification.info(player, dominion.getJoinMessage());
}
return dominion;
}
public DominionDTO getDominion(Location loc) {
String world = loc.getWorld().getName();
List<DominionDTO> dominions = world_dominions.get(world);
if (dominions == null) return null;
List<DominionDTO> in_dominions = new ArrayList<>();
for (DominionDTO d : dominions) {
if (isInDominion(d, loc.getX(), loc.getY(), loc.getZ())) {
in_dominions.add(d);
}
}
if (in_dominions.size() == 0) return null;
in_dominions.sort(Comparator.comparingInt(DominionDTO::getId));
return in_dominions.get(in_dominions.size() - 1);
}
/**
* 获取玩家在指定领地的特权
* 如果玩家不存在特权则返回null
@ -113,6 +148,13 @@ public class Cache {
z >= dominion.getZ1() && z <= dominion.getZ2();
}
private static boolean isInDominion(@Nullable DominionDTO dominion, double x, double y, double z) {
if (dominion == null) return false;
return x >= dominion.getX1() && x <= dominion.getX2() &&
y >= dominion.getY1() && y <= dominion.getY2() &&
z >= dominion.getZ1() && z <= dominion.getZ2();
}
public static Cache instance;
private Map<String, List<DominionDTO>> world_dominions; // 所有领地
private Map<UUID, Map<Integer, PlayerPrivilegeDTO>> player_uuid_to_privilege; // 玩家所有的特权

View File

@ -1,5 +1,6 @@
package cn.lunadeer.dominion;
import cn.lunadeer.dominion.events.EnvironmentEvents;
import cn.lunadeer.dominion.events.PlayerEvents;
import cn.lunadeer.dominion.utils.ConfigManager;
import cn.lunadeer.dominion.utils.Database;
@ -23,6 +24,7 @@ public final class Dominion extends JavaPlugin {
Cache.instance = new Cache();
Bukkit.getPluginManager().registerEvents(new PlayerEvents(), this);
Bukkit.getPluginManager().registerEvents(new EnvironmentEvents(), this);
Objects.requireNonNull(Bukkit.getPluginCommand("dominion")).setExecutor(new Commands());
XLogger.info("领地插件已启动");

View File

@ -15,19 +15,42 @@ public class Helper {
public static List<String> dominionFlags() {
return Arrays.asList(
"anchor", "animal_killing", "anvil", "beacon", "bed", "brew", "button", "cake", "container", "craft",
"creeper_explode", "diode", "door", "dye", "egg", "enchant", "ender_pearl", "feed", "fire_spread",
"flow_in_protection", "glow", "grow", "honey", "hook", "ignite", "mob_killing", "move", "place",
"pressure", "riding", "shear", "shoot", "tnt_explode", "trade", "vehicle_destroy", "wither_spawn",
"harvest");
"anchor", "animal_killing", "anvil",
"beacon", "bed", "brew", "break", "button",
"cake", "container", "craft", "creeper_explode", "comparer",
"door", "dye",
"egg", "enchant", "ender_pearl",
"feed", "fire_spread", "flow_in_protection",
"glow",
"honey", "hook", "harvest",
"ignite",
"lever",
"monster_killing", "move",
"place", "pressure",
"riding", "repeater",
"shear", "shoot",
"tnt_explode", "trade",
"vehicle_destroy",
"wither_spawn");
}
public static List<String> playerPrivileges() {
return Arrays.asList(
"admin", "anchor", "animal_killing", "anvil", "beacon", "bed", "brew", "button", "cake", "container", "craft",
"diode", "door", "dye", "egg", "enchant", "ender_pearl", "feed", "glow", "honey", "hook", "ignite",
"mob_killing", "move", "place", "pressure", "riding", "shear", "shoot", "trade", "vehicle_destroy",
"harvest");
"admin", "anchor", "animal_killing", "anvil",
"beacon", "bed", "brew", "break", "button",
"cake", "container", "craft", "comparer",
"door", "dye",
"egg", "enchant", "ender_pearl",
"feed",
"glow",
"honey", "hook", "harvest",
"ignite",
"lever",
"monster_killing", "move",
"place", "pressure", "riding", "repeater",
"shear", "shoot",
"trade",
"vehicle_destroy");
}
public static List<String> playerDominions(CommandSender sender) {

View File

@ -43,12 +43,13 @@ public class FlagsController {
case "beacon": return dominion.setBeacon(value);
case "bed": return dominion.setBed(value);
case "brew": return dominion.setBrew(value);
case "break": return dominion.setBreak(value);
case "button": return dominion.setButton(value);
case "cake": return dominion.setCake(value);
case "container": return dominion.setContainer(value);
case "craft": return dominion.setCraft(value);
case "creeper_explode": return dominion.setCreeperExplode(value);
case "diode": return dominion.setDiode(value);
case "comparer": return dominion.setComparer(value);
case "door": return dominion.setDoor(value);
case "dye": return dominion.setDye(value);
case "egg": return dominion.setEgg(value);
@ -58,22 +59,23 @@ public class FlagsController {
case "fire_spread": return dominion.setFireSpread(value);
case "flow_in_protection": return dominion.setFlowInProtection(value);
case "glow": return dominion.setGlow(value);
case "grow": return dominion.setGrow(value);
case "harvest": return dominion.setHarvest(value);
case "honey": return dominion.setHoney(value);
case "hook": return dominion.setHook(value);
case "ignite": return dominion.setIgnite(value);
case "mob_killing": return dominion.setMobKilling(value);
case "lever": return dominion.setLever(value);
case "mob_killing": return dominion.setMonsterKilling(value);
case "move": return dominion.setMove(value);
case "place": return dominion.setPlace(value);
case "pressure": return dominion.setPressure(value);
case "riding": return dominion.setRiding(value);
case "repeater": return dominion.setRepeater(value);
case "shear": return dominion.setShear(value);
case "shoot": return dominion.setShoot(value);
case "tnt_explode": return dominion.setTntExplode(value);
case "trade": return dominion.setTrade(value);
case "vehicle_destroy": return dominion.setVehicleDestroy(value);
case "wither_spawn": return dominion.setWitherSpawn(value);
case "harvest": return dominion.setHarvest(value);
default:
Notification.error(operator, "未知的领地权限 " + flag);
return null;

View File

@ -77,7 +77,7 @@ public class PrivilegeController {
public static boolean setPrivilege(Player operator, String player_name, String flag, boolean value, String dominionName) {
DominionDTO dominion = DominionDTO.select(dominionName);
if (dominion == null) {
Notification.error(operator, "领地 " + dominionName + " 不存在");
Notification.error(operator, "领地 " + dominionName + " 不存在,无法设置特权");
return false;
}
if (noAuthToChangeFlags(operator, dominion)) return false;
@ -88,7 +88,7 @@ public class PrivilegeController {
}
PlayerPrivilegeDTO privilege = PlayerPrivilegeDTO.select(player.getUuid(), dominion.getId());
if (privilege == null) {
privilege = createPlayerPrivilege(operator, player.getUuid(), dominion.getId());
privilege = createPlayerPrivilege(operator, player.getUuid(), dominion);
if (privilege == null) return false;
}
switch (flag) {
@ -110,6 +110,9 @@ public class PrivilegeController {
case "brew":
privilege.setBrew(value);
break;
case "break":
privilege.setBreak(value);
break;
case "button":
privilege.setButton(value);
break;
@ -122,8 +125,8 @@ public class PrivilegeController {
case "craft":
privilege.setCraft(value);
break;
case "diode":
privilege.setDiode(value);
case "comparer":
privilege.setComparer(value);
break;
case "door":
privilege.setDoor(value);
@ -146,6 +149,9 @@ public class PrivilegeController {
case "glow":
privilege.setGlow(value);
break;
case "harvest":
privilege.setHarvest(value);
break;
case "honey":
privilege.setHoney(value);
break;
@ -156,7 +162,7 @@ public class PrivilegeController {
privilege.setIgnite(value);
break;
case "mob_killing":
privilege.setMobKilling(value);
privilege.setMonsterKilling(value);
break;
case "move":
privilege.setMove(value);
@ -170,6 +176,9 @@ public class PrivilegeController {
case "riding":
privilege.setRiding(value);
break;
case "repeater":
privilege.setRepeater(value);
break;
case "shear":
privilege.setShear(value);
break;
@ -182,9 +191,6 @@ public class PrivilegeController {
case "vehicle_destroy":
privilege.setVehicleDestroy(value);
break;
case "harvest":
privilege.setHarvest(value);
break;
default:
Notification.error(operator, "未知的领地权限 " + flag);
return false;
@ -193,8 +199,24 @@ public class PrivilegeController {
return true;
}
private static PlayerPrivilegeDTO createPlayerPrivilege(Player operator, UUID player, Integer domID) {
PlayerPrivilegeDTO privilege = new PlayerPrivilegeDTO(player, false, domID);
private static PlayerPrivilegeDTO createPlayerPrivilege(Player operator, UUID player, DominionDTO dom) {
PlayerPrivilegeDTO privilege = new PlayerPrivilegeDTO(player, dom.getId(),
dom.getAnchor(), dom.getAnimalKilling(), dom.getAnvil(),
dom.getBeacon(), dom.getBed(), dom.getBrew(), dom.getBreak(), dom.getButton(),
dom.getCake(), dom.getContainer(), dom.getCraft(), dom.getComparer(),
dom.getDoor(), dom.getDye(),
dom.getEgg(), dom.getEnchant(), dom.getEnderPearl(),
dom.getFeed(),
dom.getGlow(),
dom.getHoney(), dom.getHook(),
dom.getIgnite(),
dom.getLever(),
dom.getMonsterKilling(), dom.getMove(),
dom.getPlace(), dom.getPressure(),
dom.getRiding(), dom.getRepeater(),
dom.getShear(), dom.getShoot(),
dom.getTrade(),
dom.getVehicleDestroy(), dom.getHarvest());
privilege = PlayerPrivilegeDTO.insert(privilege);
if (privilege == null) {
Notification.error(operator, "创建玩家特权关联玩家时失败");

View File

@ -37,12 +37,13 @@ public class DominionDTO {
rs.getBoolean("beacon"),
rs.getBoolean("bed"),
rs.getBoolean("brew"),
rs.getBoolean("break"),
rs.getBoolean("button"),
rs.getBoolean("cake"),
rs.getBoolean("container"),
rs.getBoolean("craft"),
rs.getBoolean("creeper_explode"),
rs.getBoolean("diode"),
rs.getBoolean("comparer"),
rs.getBoolean("door"),
rs.getBoolean("dye"),
rs.getBoolean("egg"),
@ -52,22 +53,24 @@ public class DominionDTO {
rs.getBoolean("fire_spread"),
rs.getBoolean("flow_in_protection"),
rs.getBoolean("glow"),
rs.getBoolean("grow"),
rs.getBoolean("harvest"),
rs.getBoolean("honey"),
rs.getBoolean("hook"),
rs.getBoolean("ignite"),
rs.getBoolean("mob_killing"),
rs.getBoolean("lever"),
rs.getBoolean("monster_killing"),
rs.getBoolean("move"),
rs.getBoolean("place"),
rs.getBoolean("pressure"),
rs.getBoolean("riding"),
rs.getBoolean("repeater"),
rs.getBoolean("shear"),
rs.getBoolean("shoot"),
rs.getBoolean("tnt_explode"),
rs.getBoolean("trade"),
rs.getBoolean("vehicle_destroy"),
rs.getBoolean("wither_spawn"),
rs.getBoolean("harvest"));
rs.getBoolean("wither_spawn")
);
dominions.add(dominion);
}
if (sql.contains("UPDATE") || sql.contains("DELETE") || sql.contains("INSERT")) {
@ -178,12 +181,13 @@ public class DominionDTO {
"beacon = " + dominion.getBeacon() + ", " +
"bed = " + dominion.getBed() + ", " +
"brew = " + dominion.getBrew() + ", " +
"break = " + dominion.getBreak() + ", " +
"button = " + dominion.getButton() + ", " +
"cake = " + dominion.getCake() + ", " +
"container = " + dominion.getContainer() + ", " +
"craft = " + dominion.getCraft() + ", " +
"creeper_explode = " + dominion.getCreeperExplode() + ", " + // dom only
"diode = " + dominion.getDiode() + ", " +
"comparer = " + dominion.getComparer() + ", " +
"door = " + dominion.getDoor() + ", " +
"dye = " + dominion.getDye() + ", " +
"egg = " + dominion.getEgg() + ", " +
@ -193,22 +197,23 @@ public class DominionDTO {
"fire_spread = " + dominion.getFireSpread() + ", " + // dom only
"flow_in_protection = " + dominion.getFlowInProtection() + ", " + // dom only
"glow = " + dominion.getGlow() + ", " +
"grow = " + dominion.getGrow() + ", " +
"harvest = " + dominion.getHarvest() + ", " +
"honey = " + dominion.getHoney() + ", " +
"hook = " + dominion.getHook() + ", " +
"ignite = " + dominion.getIgnite() + ", " +
"mob_killing = " + dominion.getMobKilling() + ", " +
"lever = " + dominion.getLever() + ", " +
"monster_killing = " + dominion.getMonsterKilling() + ", " +
"move = " + dominion.getMove() + ", " +
"place = " + dominion.getPlace() + ", " +
"pressure = " + dominion.getPressure() + ", " +
"riding = " + dominion.getRiding() + ", " +
"repeater = " + dominion.getRepeater() + ", " +
"shear = " + dominion.getShear() + ", " +
"shoot = " + dominion.getShoot() + ", " +
"tnt_explode = " + dominion.getTntExplode() + ", " + // dom only
"trade = " + dominion.getTrade() + ", " +
"vehicle_destroy = " + dominion.getVehicleDestroy() + ", " +
"wither_spawn = " + dominion.getWitherSpawn() + ", " + // dom only
"harvest = " + dominion.getHarvest() +
"wither_spawn = " + dominion.getWitherSpawn() + " " + // dom only
" WHERE id = " + dominion.getId() +
" RETURNING *;";
List<DominionDTO> dominions = query(sql);
@ -221,14 +226,22 @@ public class DominionDTO {
Integer parentDomId,
String joinMessage, String leaveMessage,
Boolean anchor, Boolean animalKilling, Boolean anvil,
Boolean beacon, Boolean bed, Boolean brew, Boolean button, Boolean cake,
Boolean container, Boolean craft, Boolean creeperExplode, Boolean diode,
Boolean door, Boolean dye, Boolean egg, Boolean enchant, Boolean enderPearl,
Boolean feed, Boolean fireSpread, Boolean flowInProtection, Boolean glow,
Boolean grow, Boolean honey, Boolean hook, Boolean ignite, Boolean mobKilling,
Boolean move, Boolean place, Boolean pressure, Boolean riding, Boolean shear,
Boolean shoot, Boolean tntExplode, Boolean trade, Boolean vehicleDestroy,
Boolean witherSpawn, Boolean harvest) {
Boolean beacon, Boolean bed, Boolean brew, Boolean breakBlock, Boolean button,
Boolean cake, Boolean container, Boolean craft, Boolean creeperExplode, Boolean comparer,
Boolean door, Boolean dye,
Boolean egg, Boolean enchant, Boolean enderPearl,
Boolean feed, Boolean fireSpread, Boolean flowInProtection,
Boolean glow,
Boolean harvest, Boolean honey, Boolean hook,
Boolean ignite,
Boolean lever,
Boolean monsterKilling, Boolean move,
Boolean place, Boolean pressure,
Boolean riding, Boolean repeater,
Boolean shear, Boolean shoot,
Boolean tntExplode, Boolean trade,
Boolean vehicleDestroy,
Boolean witherSpawn) {
this.id = id;
this.owner = owner;
this.name = name;
@ -248,12 +261,13 @@ public class DominionDTO {
this.beacon = beacon;
this.bed = bed;
this.brew = brew;
this.breakBlock = breakBlock;
this.button = button;
this.cake = cake;
this.container = container;
this.craft = craft;
this.creeperExplode = creeperExplode;
this.diode = diode;
this.comparer = comparer;
this.door = door;
this.dye = dye;
this.egg = egg;
@ -263,22 +277,23 @@ public class DominionDTO {
this.fireSpread = fireSpread;
this.flowInProtection = flowInProtection;
this.glow = glow;
this.grow = grow;
this.harvest = harvest;
this.honey = honey;
this.hook = hook;
this.ignite = ignite;
this.mobKilling = mobKilling;
this.lever = lever;
this.monsterKilling = monsterKilling;
this.move = move;
this.place = place;
this.pressure = pressure;
this.riding = riding;
this.repeater = repeater;
this.shear = shear;
this.shoot = shoot;
this.tntExplode = tntExplode;
this.trade = trade;
this.vehicleDestroy = vehicleDestroy;
this.witherSpawn = witherSpawn;
this.harvest = harvest;
}
@ -287,13 +302,13 @@ public class DominionDTO {
Integer parentDomId) {
this(id, owner, name, world, x1, y1, z1, x2, y2, z2, parentDomId,
"欢迎", "再见",
false, false, false, false,
false, false, false, false, false, false,
false, false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false, true,
false, false, false, false, false,
false, false, false, false, false, false,
false, false, false, false);
false, false, false, false, true,
true, false, false, false, false, false,
false, true, false, false, false, false,
false, false, false, false, false, false);
}
public DominionDTO(UUID owner, String name, String world,
@ -320,12 +335,13 @@ public class DominionDTO {
private Boolean beacon = false;
private Boolean bed = false;
private Boolean brew = false;
private Boolean breakBlock = false;
private Boolean button = false;
private Boolean cake = false;
private Boolean container = false;
private Boolean craft = false;
private Boolean creeperExplode = false;
private Boolean diode = false;
private Boolean comparer = false;
private Boolean door = false;
private Boolean dye = false;
private Boolean egg = false;
@ -335,15 +351,16 @@ public class DominionDTO {
private Boolean fireSpread = false;
private Boolean flowInProtection = false;
private Boolean glow = false;
private Boolean grow = false;
private Boolean honey = false;
private Boolean hook = false;
private Boolean ignite = false;
private Boolean mobKilling = false;
private Boolean lever = false;
private Boolean monsterKilling = false;
private Boolean move = true;
private Boolean place = false;
private Boolean pressure = false;
private Boolean riding = false;
private Boolean repeater = false;
private Boolean shear = false;
private Boolean shoot = false;
private Boolean tntExplode = false;
@ -514,6 +531,15 @@ public class DominionDTO {
return update(this);
}
public Boolean getBreak() {
return breakBlock;
}
public DominionDTO setBreak(Boolean breakBlock) {
this.breakBlock = breakBlock;
return update(this);
}
public Boolean getButton() {
return button;
}
@ -559,12 +585,12 @@ public class DominionDTO {
return update(this);
}
public Boolean getDiode() {
return diode;
public Boolean getComparer() {
return comparer;
}
public DominionDTO setDiode(Boolean diode) {
this.diode = diode;
public DominionDTO setComparer(Boolean comparer) {
this.comparer = comparer;
return update(this);
}
@ -649,15 +675,6 @@ public class DominionDTO {
return update(this);
}
public Boolean getGrow() {
return grow;
}
public DominionDTO setGrow(Boolean grow) {
this.grow = grow;
return update(this);
}
public Boolean getHoney() {
return honey;
}
@ -685,12 +702,21 @@ public class DominionDTO {
return update(this);
}
public Boolean getMobKilling() {
return mobKilling;
public Boolean getLever() {
return lever;
}
public DominionDTO setMobKilling(Boolean mobKilling) {
this.mobKilling = mobKilling;
public DominionDTO setLever(Boolean lever) {
this.lever = lever;
return update(this);
}
public Boolean getMonsterKilling() {
return monsterKilling;
}
public DominionDTO setMonsterKilling(Boolean monsterKilling) {
this.monsterKilling = monsterKilling;
return update(this);
}
@ -730,6 +756,15 @@ public class DominionDTO {
return update(this);
}
public Boolean getRepeater() {
return repeater;
}
public DominionDTO setRepeater(Boolean repeater) {
this.repeater = repeater;
return update(this);
}
public Boolean getShear() {
return shear;
}

View File

@ -25,7 +25,7 @@ public class PlayerPrivilegeDTO {
public static PlayerPrivilegeDTO select(UUID playerUUID, Integer dom_id) {
String sql = "SELECT * FROM player_privilege WHERE player_uuid = '" + playerUUID + "' " +
"AND dom_id = " + dom_id + ";";
List<PlayerPrivilegeDTO> p = query(sql);
List<PlayerPrivilegeDTO> p = query(sql);
if (p.size() == 0) return null;
return p.get(0);
}
@ -41,7 +41,7 @@ public class PlayerPrivilegeDTO {
query(sql);
}
public static List<PlayerPrivilegeDTO> selectAll(){
public static List<PlayerPrivilegeDTO> selectAll() {
String sql = "SELECT * FROM player_privilege;";
return query(sql);
}
@ -56,11 +56,12 @@ public class PlayerPrivilegeDTO {
private Boolean beacon;
private Boolean bed;
private Boolean brew;
private Boolean breakBlock;
private Boolean button;
private Boolean cake;
private Boolean container;
private Boolean craft;
private Boolean diode;
private Boolean comparer;
private Boolean door;
private Boolean dye;
private Boolean egg;
@ -71,11 +72,13 @@ public class PlayerPrivilegeDTO {
private Boolean honey;
private Boolean hook;
private Boolean ignite;
private Boolean mobKilling;
private Boolean lever;
private Boolean monsterKilling;
private Boolean move;
private Boolean place;
private Boolean pressure;
private Boolean riding;
private Boolean repeater;
private Boolean shear;
private Boolean shoot;
private Boolean trade;
@ -122,6 +125,10 @@ public class PlayerPrivilegeDTO {
return brew;
}
public Boolean getBreak() {
return breakBlock;
}
public Boolean getButton() {
return button;
}
@ -138,8 +145,8 @@ public class PlayerPrivilegeDTO {
return craft;
}
public Boolean getDiode() {
return diode;
public Boolean getComparer() {
return comparer;
}
public Boolean getDoor() {
@ -182,8 +189,12 @@ public class PlayerPrivilegeDTO {
return ignite;
}
public Boolean getMobKilling() {
return mobKilling;
public Boolean getLever() {
return lever;
}
public Boolean getMonsterKilling() {
return monsterKilling;
}
public Boolean getMove() {
@ -202,6 +213,10 @@ public class PlayerPrivilegeDTO {
return riding;
}
public Boolean getRepeater() {
return repeater;
}
public Boolean getShear() {
return shear;
}
@ -252,6 +267,11 @@ public class PlayerPrivilegeDTO {
return update(this);
}
public PlayerPrivilegeDTO setBreak(Boolean breakBlock) {
this.breakBlock = breakBlock;
return update(this);
}
public PlayerPrivilegeDTO setButton(Boolean button) {
this.button = button;
return update(this);
@ -272,8 +292,8 @@ public class PlayerPrivilegeDTO {
return update(this);
}
public PlayerPrivilegeDTO setDiode(Boolean diode) {
this.diode = diode;
public PlayerPrivilegeDTO setComparer(Boolean comparer) {
this.comparer = comparer;
return update(this);
}
@ -327,8 +347,13 @@ public class PlayerPrivilegeDTO {
return update(this);
}
public PlayerPrivilegeDTO setMobKilling(Boolean mobKilling) {
this.mobKilling = mobKilling;
public PlayerPrivilegeDTO setLever(Boolean lever) {
this.lever = lever;
return update(this);
}
public PlayerPrivilegeDTO setMonsterKilling(Boolean monsterKilling) {
this.monsterKilling = monsterKilling;
return update(this);
}
@ -352,6 +377,11 @@ public class PlayerPrivilegeDTO {
return update(this);
}
public PlayerPrivilegeDTO setRepeater(Boolean repeater) {
this.repeater = repeater;
return update(this);
}
public PlayerPrivilegeDTO setShear(Boolean shear) {
this.shear = shear;
return update(this);
@ -384,12 +414,21 @@ public class PlayerPrivilegeDTO {
private PlayerPrivilegeDTO(Integer id, UUID playerUUID, Boolean admin, Integer domID,
Boolean anchor, Boolean animalKilling, Boolean anvil,
Boolean beacon, Boolean bed, Boolean brew, Boolean button, Boolean cake,
Boolean container, Boolean craft, Boolean diode, Boolean door, Boolean dye,
Boolean egg, Boolean enchant, Boolean enderPearl, Boolean feed, Boolean glow,
Boolean honey, Boolean hook, Boolean ignite, Boolean mobKilling, Boolean move,
Boolean place, Boolean pressure, Boolean riding, Boolean shear, Boolean shoot,
Boolean trade, Boolean vehicleDestroy, Boolean harvest) {
Boolean beacon, Boolean bed, Boolean brew, Boolean breakBlock, Boolean button,
Boolean cake, Boolean container, Boolean craft, Boolean comparer,
Boolean door, Boolean dye,
Boolean egg, Boolean enchant, Boolean enderPearl,
Boolean feed,
Boolean glow,
Boolean harvest, Boolean honey, Boolean hook,
Boolean ignite,
Boolean lever,
Boolean monsterKilling, Boolean move,
Boolean place, Boolean pressure,
Boolean riding, Boolean repeater,
Boolean shear, Boolean shoot,
Boolean trade,
Boolean vehicleDestroy) {
this.id = id;
this.playerUUID = playerUUID;
this.admin = admin;
@ -400,11 +439,12 @@ public class PlayerPrivilegeDTO {
this.beacon = beacon;
this.bed = bed;
this.brew = brew;
this.breakBlock = breakBlock;
this.button = button;
this.cake = cake;
this.container = container;
this.craft = craft;
this.diode = diode;
this.comparer = comparer;
this.door = door;
this.dye = dye;
this.egg = egg;
@ -412,30 +452,58 @@ public class PlayerPrivilegeDTO {
this.enderPearl = enderPearl;
this.feed = feed;
this.glow = glow;
this.harvest = harvest;
this.honey = honey;
this.hook = hook;
this.ignite = ignite;
this.mobKilling = mobKilling;
this.lever = lever;
this.monsterKilling = monsterKilling;
this.move = move;
this.place = place;
this.pressure = pressure;
this.riding = riding;
this.repeater = repeater;
this.shear = shear;
this.shoot = shoot;
this.trade = trade;
this.vehicleDestroy = vehicleDestroy;
this.harvest = harvest;
}
public PlayerPrivilegeDTO(UUID playerUUID, Boolean admin, Integer domID) {
this(null, playerUUID, admin, domID,
false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false);
public PlayerPrivilegeDTO(UUID playerUUID, Integer domID,
Boolean anchor, Boolean animalKilling, Boolean anvil,
Boolean beacon, Boolean bed, Boolean brew, Boolean breakBlock, Boolean button,
Boolean cake, Boolean container, Boolean craft, Boolean comparer,
Boolean door, Boolean dye,
Boolean egg, Boolean enchant, Boolean enderPearl,
Boolean feed,
Boolean glow,
Boolean harvest, Boolean honey, Boolean hook,
Boolean ignite,
Boolean lever,
Boolean monsterKilling, Boolean move,
Boolean place, Boolean pressure,
Boolean riding, Boolean repeater,
Boolean shear, Boolean shoot,
Boolean trade,
Boolean vehicleDestroy
) {
this(null, playerUUID, false, domID,
anchor, animalKilling, anvil,
beacon, bed, brew, breakBlock, button,
cake, container, craft, comparer,
door, dye,
egg, enchant, enderPearl,
feed,
glow,
harvest, honey, hook,
ignite,
lever,
monsterKilling, move,
place, pressure,
riding, repeater,
shear, shoot,
trade,
vehicleDestroy);
}
private static List<PlayerPrivilegeDTO> query(String sql) {
@ -454,11 +522,12 @@ public class PlayerPrivilegeDTO {
rs.getBoolean("beacon"),
rs.getBoolean("bed"),
rs.getBoolean("brew"),
rs.getBoolean("break"),
rs.getBoolean("button"),
rs.getBoolean("cake"),
rs.getBoolean("container"),
rs.getBoolean("craft"),
rs.getBoolean("diode"),
rs.getBoolean("comparer"),
rs.getBoolean("door"),
rs.getBoolean("dye"),
rs.getBoolean("egg"),
@ -466,23 +535,25 @@ public class PlayerPrivilegeDTO {
rs.getBoolean("ender_pearl"),
rs.getBoolean("feed"),
rs.getBoolean("glow"),
rs.getBoolean("harvest"),
rs.getBoolean("honey"),
rs.getBoolean("hook"),
rs.getBoolean("ignite"),
rs.getBoolean("mob_killing"),
rs.getBoolean("lever"),
rs.getBoolean("monster_killing"),
rs.getBoolean("move"),
rs.getBoolean("place"),
rs.getBoolean("pressure"),
rs.getBoolean("riding"),
rs.getBoolean("repeater"),
rs.getBoolean("shear"),
rs.getBoolean("shoot"),
rs.getBoolean("trade"),
rs.getBoolean("vehicle_destroy"),
rs.getBoolean("harvest")
rs.getBoolean("vehicle_destroy")
);
players.add(player);
}
if (sql.contains("UPDATE") || sql.contains("DELETE") || sql.contains("INSERT")){
if (sql.contains("UPDATE") || sql.contains("DELETE") || sql.contains("INSERT")) {
// 如果是更新操作重新加载缓存
Cache.instance.loadPlayerPrivileges();
}
@ -503,11 +574,12 @@ public class PlayerPrivilegeDTO {
"beacon = " + player.getBeacon() + ", " +
"bed = " + player.getBed() + ", " +
"brew = " + player.getBrew() + ", " +
"break = " + player.getBreak() + ", " +
"button = " + player.getButton() + ", " +
"cake = " + player.getCake() + ", " +
"container = " + player.getContainer() + ", " +
"craft = " + player.getCraft() + ", " +
"diode = " + player.getDiode() + ", " +
"comparer = " + player.getComparer() + ", " +
"door = " + player.getDoor() + ", " +
"dye = " + player.getDye() + ", " +
"egg = " + player.getEgg() + ", " +
@ -515,19 +587,21 @@ public class PlayerPrivilegeDTO {
"ender_pearl = " + player.getEnderPearl() + ", " +
"feed = " + player.getFeed() + ", " +
"glow = " + player.getGlow() + ", " +
"harvest = " + player.getHarvest() + ", " +
"honey = " + player.getHoney() + ", " +
"hook = " + player.getHook() + ", " +
"ignite = " + player.getIgnite() + ", " +
"mob_killing = " + player.getMobKilling() + ", " +
"lever = " + player.getLever() + ", " +
"monster_killing = " + player.getMonsterKilling() + ", " +
"move = " + player.getMove() + ", " +
"place = " + player.getPlace() + ", " +
"pressure = " + player.getPressure() + ", " +
"riding = " + player.getRiding() + ", " +
"repeater = " + player.getRepeater() + ", " +
"shear = " + player.getShear() + ", " +
"shoot = " + player.getShoot() + ", " +
"trade = " + player.getTrade() + ", " +
"vehicle_destroy = " + player.getVehicleDestroy() + ", " +
"harvest = " + player.getHarvest() + " " +
"vehicle_destroy = " + player.getVehicleDestroy() + " " +
"WHERE id = " + player.getId() + " " +
"RETURNING *;";
List<PlayerPrivilegeDTO> players = query(sql);

View File

@ -0,0 +1,22 @@
package cn.lunadeer.dominion.events;
import cn.lunadeer.dominion.Cache;
import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.dtos.PlayerPrivilegeDTO;
import org.bukkit.entity.Player;
public class Apis {
public static boolean hasPermission(Player player, DominionDTO dom) {
if (dom == null) {
return true;
}
if (dom.getOwner().equals(player.getUniqueId())) {
return true;
}
PlayerPrivilegeDTO privilege = Cache.instance.getPlayerPrivilege(player, dom);
if (privilege != null) {
return privilege.getAdmin();
}
return false;
}
}

View File

@ -0,0 +1,103 @@
package cn.lunadeer.dominion.events;
import cn.lunadeer.dominion.Cache;
import cn.lunadeer.dominion.dtos.DominionDTO;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.Objects;
public class EnvironmentEvents implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) // creeper_explode
public void onEntityExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (entity.getType() != EntityType.CREEPER && entity.getType() != EntityType.WITHER_SKULL){
return;
}
DominionDTO dom = Cache.instance.getDominion(event.getLocation());
if (dom == null) {
return;
}
if (dom.getCreeperExplode()) {
return;
}
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST) // fire_spread
public void onFireSpread(BlockIgniteEvent event){
Player player = event.getPlayer();
if (player != null) {
// 如果点燃事件没有玩家触发那么就是火焰蔓延
return;
}
DominionDTO dom = Cache.instance.getDominion(event.getBlock().getLocation());
if (dom == null) {
return;
}
if (dom.getFireSpread()) {
return;
}
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST) // flow_in_protection
public void onLiquidFlowIn(BlockFromToEvent event) {
Location from = event.getBlock().getLocation();
Location to = event.getToBlock().getLocation();
DominionDTO dom_to = Cache.instance.getDominion(to);
if (dom_to == null) {
return;
}
DominionDTO dom_from = Cache.instance.getDominion(from);
if (dom_from != null){
if (Objects.equals(dom_from.getId(), dom_to.getId())){
return;
}
}
if (dom_to.getFlowInProtection()) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST) // tnt_explode
public void onTntExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (entity.getType() != EntityType.MINECART_TNT && entity.getType() != EntityType.PRIMED_TNT){
return;
}
DominionDTO dom = Cache.instance.getDominion(event.getLocation());
if (dom == null) {
return;
}
if (dom.getTntExplode()) {
return;
}
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST) // wither_spawn
public void onWitherSpawn(CreatureSpawnEvent event){
Entity entity = event.getEntity();
if (entity.getType() != EntityType.WITHER) {
return;
}
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
if (dom == null) {
return;
}
if (dom.getWitherSpawn()) {
return;
}
event.setCancelled(true);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -92,6 +92,15 @@ public class DominionFlagInfo {
.append(Button.createRed("", "/dominion set brew true " + dominion.getName() + " " + page))
.append("使用酿造台"));
}
if (dominion.getBreak()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set break false " + dominion.getName() + " " + page))
.append("破坏方块"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set break true " + dominion.getName() + " " + page))
.append("破坏方块"));
}
if (dominion.getButton()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set button false " + dominion.getName() + " " + page))
@ -122,11 +131,11 @@ public class DominionFlagInfo {
if (dominion.getCraft()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set craft false " + dominion.getName() + " " + page))
.append("合成"));
.append("工作台"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set craft true " + dominion.getName() + " " + page))
.append("合成"));
.append("工作台"));
}
if (dominion.getCreeperExplode()) {
view.add(Line.create()
@ -137,14 +146,14 @@ public class DominionFlagInfo {
.append(Button.createRed("", "/dominion set creeper_explode true " + dominion.getName() + " " + page))
.append("苦力怕爆炸"));
}
if (dominion.getDiode()) {
if (dominion.getComparer()){
view.add(Line.create()
.append(Button.createGreen("", "/dominion set diode false " + dominion.getName() + " " + page))
.append("中继器交互"));
.append(Button.createGreen("", "/dominion set comparer false " + dominion.getName() + " " + page))
.append("比较器交互"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set diode true " + dominion.getName() + " " + page))
.append("中继器交互"));
.append(Button.createRed("", "/dominion set comparer true " + dominion.getName() + " " + page))
.append("比较器交互"));
}
if (dominion.getDoor()) {
view.add(Line.create()
@ -227,14 +236,14 @@ public class DominionFlagInfo {
.append(Button.createRed("", "/dominion set glow true " + dominion.getName() + " " + page))
.append("发光"));
}
if (dominion.getGrow()) {
if (dominion.getHarvest()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set grow false " + dominion.getName() + " " + page))
.append("植物生长"));
.append(Button.createGreen("", "/dominion set harvest false " + dominion.getName() + " " + page))
.append("收获"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set grow true " + dominion.getName() + " " + page))
.append("植物生长"));
.append(Button.createRed("", "/dominion set harvest true " + dominion.getName() + " " + page))
.append("收获"));
}
if (dominion.getHoney()) {
view.add(Line.create()
@ -248,11 +257,11 @@ public class DominionFlagInfo {
if (dominion.getHook()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set hook false " + dominion.getName() + " " + page))
.append("子交互"));
.append("使用钓"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set hook true " + dominion.getName() + " " + page))
.append("子交互"));
.append("使用钓"));
}
if (dominion.getIgnite()) {
view.add(Line.create()
@ -263,14 +272,23 @@ public class DominionFlagInfo {
.append(Button.createRed("", "/dominion set ignite true " + dominion.getName() + " " + page))
.append("点燃"));
}
if (dominion.getMobKilling()) {
if (dominion.getLever()){
view.add(Line.create()
.append(Button.createGreen("", "/dominion set mob_killing false " + dominion.getName() + " " + page))
.append("生物伤害"));
.append(Button.createGreen("", "/dominion set lever false " + dominion.getName() + " " + page))
.append("使用拉杆"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set mob_killing true " + dominion.getName() + " " + page))
.append("生物伤害"));
.append(Button.createRed("", "/dominion set lever true " + dominion.getName() + " " + page))
.append("使用拉杆"));
}
if (dominion.getMonsterKilling()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set monster_killing false " + dominion.getName() + " " + page))
.append("怪物伤害"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set monster_killing true " + dominion.getName() + " " + page))
.append("怪物伤害"));
}
if (dominion.getMove()) {
view.add(Line.create()
@ -302,11 +320,20 @@ public class DominionFlagInfo {
if (dominion.getRiding()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set riding false " + dominion.getName() + " " + page))
.append("骑乘"));
.append("骑乘载具"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set riding true " + dominion.getName() + " " + page))
.append("骑乘"));
.append("骑乘载具"));
}
if (dominion.getRepeater()){
view.add(Line.create()
.append(Button.createGreen("", "/dominion set repeater false " + dominion.getName() + " " + page))
.append("中继器交互"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set repeater true " + dominion.getName() + " " + page))
.append("中继器交互"));
}
if (dominion.getShear()) {
view.add(Line.create()
@ -320,11 +347,11 @@ public class DominionFlagInfo {
if (dominion.getShoot()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set shoot false " + dominion.getName() + " " + page))
.append(""));
.append("箭/雪球"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set shoot true " + dominion.getName() + " " + page))
.append(""));
.append("箭/雪球"));
}
if (dominion.getTntExplode()) {
view.add(Line.create()
@ -362,15 +389,6 @@ public class DominionFlagInfo {
.append(Button.createRed("", "/dominion set wither_spawn true " + dominion.getName() + " " + page))
.append("凋零生成"));
}
if (dominion.getHarvest()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set harvest false " + dominion.getName() + " " + page))
.append("收获"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set harvest true " + dominion.getName() + " " + page))
.append("收获"));
}
view.showOn(player, page);
}
}

View File

@ -107,6 +107,15 @@ public class PrivilegeInfo {
.append(Button.createRed("", "/dominion set_privilege " + playerName + " brew true " + dominion.getName() + " " + page))
.append("使用酿造台"));
}
if (privilege.getBreak()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " break false " + dominion.getName() + " " + page))
.append("破坏方块"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " break true " + dominion.getName() + " " + page))
.append("破坏方块"));
}
if (privilege.getButton()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " button false " + dominion.getName() + " " + page))
@ -137,20 +146,20 @@ public class PrivilegeInfo {
if (privilege.getCraft()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " craft false " + dominion.getName() + " " + page))
.append("合成"));
.append("工作台"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " craft true " + dominion.getName() + " " + page))
.append("合成"));
.append("工作台"));
}
if (privilege.getDiode()) {
if (privilege.getComparer()){
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " diode false " + dominion.getName() + " " + page))
.append("中继器交互"));
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " comparer false " + dominion.getName() + " " + page))
.append("比较器交互"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " diode true " + dominion.getName() + " " + page))
.append("中继器交互"));
.append(Button.createRed("", "/dominion set_privilege " + playerName + " comparer true " + dominion.getName() + " " + page))
.append("比较器交互"));
}
if (privilege.getDoor()) {
view.add(Line.create()
@ -215,6 +224,15 @@ public class PrivilegeInfo {
.append(Button.createRed("", "/dominion set_privilege " + playerName + " glow true " + dominion.getName() + " " + page))
.append("发光"));
}
if (privilege.getHarvest()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " harvest false " + dominion.getName() + " " + page))
.append("收获"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " harvest true " + dominion.getName() + " " + page))
.append("收获"));
}
if (privilege.getHoney()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " honey false " + dominion.getName() + " " + page))
@ -227,11 +245,11 @@ public class PrivilegeInfo {
if (privilege.getHook()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " hook false " + dominion.getName() + " " + page))
.append("子交互"));
.append("使用钓"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " hook true " + dominion.getName() + " " + page))
.append("子交互"));
.append("使用钓"));
}
if (privilege.getIgnite()) {
view.add(Line.create()
@ -242,14 +260,23 @@ public class PrivilegeInfo {
.append(Button.createRed("", "/dominion set_privilege " + playerName + " ignite true " + dominion.getName() + " " + page))
.append("点燃"));
}
if (privilege.getMobKilling()) {
if (privilege.getLever()){
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " mob_killing false " + dominion.getName() + " " + page))
.append("生物伤害"));
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " lever false " + dominion.getName() + " " + page))
.append("使用拉杆"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " mob_killing true " + dominion.getName() + " " + page))
.append("生物伤害"));
.append(Button.createRed("", "/dominion set_privilege " + playerName + " lever true " + dominion.getName() + " " + page))
.append("使用拉杆"));
}
if (privilege.getMonsterKilling()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " monster_killing false " + dominion.getName() + " " + page))
.append("怪物伤害"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " monster_killing true " + dominion.getName() + " " + page))
.append("怪物伤害"));
}
if (privilege.getMove()) {
view.add(Line.create()
@ -281,11 +308,20 @@ public class PrivilegeInfo {
if (privilege.getRiding()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " riding false " + dominion.getName() + " " + page))
.append("骑乘"));
.append("骑乘载具"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " riding true " + dominion.getName() + " " + page))
.append("骑乘"));
.append("骑乘载具"));
}
if (privilege.getRepeater()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " repeater false " + dominion.getName() + " " + page))
.append("中继器交互"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " repeater true " + dominion.getName() + " " + page))
.append("中继器交互"));
}
if (privilege.getShear()) {
view.add(Line.create()
@ -299,11 +335,11 @@ public class PrivilegeInfo {
if (privilege.getShoot()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " shoot false " + dominion.getName() + " " + page))
.append(""));
.append("箭/雪球"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " shoot true " + dominion.getName() + " " + page))
.append(""));
.append("箭/雪球"));
}
if (privilege.getTrade()) {
view.add(Line.create()
@ -323,15 +359,6 @@ public class PrivilegeInfo {
.append(Button.createRed("", "/dominion set_privilege " + playerName + " vehicle_destroy true " + dominion.getName() + " " + page))
.append("破坏载具"));
}
if (privilege.getHarvest()) {
view.add(Line.create()
.append(Button.createGreen("", "/dominion set_privilege " + playerName + " harvest false " + dominion.getName() + " " + page))
.append("收获"));
} else {
view.add(Line.create()
.append(Button.createRed("", "/dominion set_privilege " + playerName + " harvest true " + dominion.getName() + " " + page))
.append("收获"));
}
view.showOn(player, page);
}
}

View File

@ -69,12 +69,13 @@ public class Database {
" beacon BOOLEAN NOT NULL DEFAULT FALSE," +
" bed BOOLEAN NOT NULL DEFAULT FALSE," +
" brew BOOLEAN NOT NULL DEFAULT FALSE," +
" break BOOLEAN NOT NULL DEFAULT FALSE," +
" button BOOLEAN NOT NULL DEFAULT FALSE," +
" cake BOOLEAN NOT NULL DEFAULT FALSE," +
" container BOOLEAN NOT NULL DEFAULT FALSE," +
" craft BOOLEAN NOT NULL DEFAULT FALSE," +
" creeper_explode BOOLEAN NOT NULL DEFAULT FALSE," +
" diode BOOLEAN NOT NULL DEFAULT FALSE," +
" comparer BOOLEAN NOT NULL DEFAULT FALSE," +
" door BOOLEAN NOT NULL DEFAULT FALSE," +
" dye BOOLEAN NOT NULL DEFAULT FALSE," +
" egg BOOLEAN NOT NULL DEFAULT FALSE," +
@ -83,23 +84,24 @@ public class Database {
" feed BOOLEAN NOT NULL DEFAULT FALSE," +
" fire_spread BOOLEAN NOT NULL DEFAULT FALSE," +
" flow_in_protection BOOLEAN NOT NULL DEFAULT FALSE," +
" glow BOOLEAN NOT NULL DEFAULT FALSE," +
" grow BOOLEAN NOT NULL DEFAULT FALSE," +
" glow BOOLEAN NOT NULL DEFAULT TRUE," +
" harvest BOOLEAN NOT NULL DEFAULT FALSE," +
" honey BOOLEAN NOT NULL DEFAULT FALSE," +
" hook BOOLEAN NOT NULL DEFAULT FALSE," +
" ignite BOOLEAN NOT NULL DEFAULT FALSE," +
" mob_killing BOOLEAN NOT NULL DEFAULT FALSE," +
" lever BOOLEAN NOT NULL DEFAULT FALSE," +
" monster_killing BOOLEAN NOT NULL DEFAULT FALSE," +
" move BOOLEAN NOT NULL DEFAULT TRUE," +
" place BOOLEAN NOT NULL DEFAULT FALSE," +
" pressure BOOLEAN NOT NULL DEFAULT FALSE," +
" riding BOOLEAN NOT NULL DEFAULT FALSE," +
" repeater BOOLEAN NOT NULL DEFAULT FALSE," +
" shear BOOLEAN NOT NULL DEFAULT FALSE," +
" shoot BOOLEAN NOT NULL DEFAULT FALSE," +
" tnt_explode BOOLEAN NOT NULL DEFAULT FALSE," +
" trade BOOLEAN NOT NULL DEFAULT FALSE," +
" vehicle_destroy BOOLEAN NOT NULL DEFAULT FALSE," +
" wither_spawn BOOLEAN NOT NULL DEFAULT FALSE," +
" harvest BOOLEAN NOT NULL DEFAULT FALSE," +
" FOREIGN KEY (owner) REFERENCES player_name(uuid)," +
" FOREIGN KEY (parent_dom_id) REFERENCES dominion(id)" +
@ -118,31 +120,34 @@ public class Database {
" beacon BOOLEAN NOT NULL DEFAULT FALSE," +
" bed BOOLEAN NOT NULL DEFAULT FALSE," +
" brew BOOLEAN NOT NULL DEFAULT FALSE," +
" break BOOLEAN NOT NULL DEFAULT FALSE," +
" button BOOLEAN NOT NULL DEFAULT FALSE," +
" cake BOOLEAN NOT NULL DEFAULT FALSE," +
" container BOOLEAN NOT NULL DEFAULT FALSE," +
" craft BOOLEAN NOT NULL DEFAULT FALSE," +
" diode BOOLEAN NOT NULL DEFAULT FALSE," +
" comparer BOOLEAN NOT NULL DEFAULT FALSE," +
" door BOOLEAN NOT NULL DEFAULT FALSE," +
" dye BOOLEAN NOT NULL DEFAULT FALSE," +
" egg BOOLEAN NOT NULL DEFAULT FALSE," +
" enchant BOOLEAN NOT NULL DEFAULT FALSE," +
" ender_pearl BOOLEAN NOT NULL DEFAULT FALSE," +
" feed BOOLEAN NOT NULL DEFAULT FALSE," +
" glow BOOLEAN NOT NULL DEFAULT FALSE," +
" glow BOOLEAN NOT NULL DEFAULT TRUE," +
" harvest BOOLEAN NOT NULL DEFAULT FALSE," +
" honey BOOLEAN NOT NULL DEFAULT FALSE," +
" hook BOOLEAN NOT NULL DEFAULT FALSE," +
" ignite BOOLEAN NOT NULL DEFAULT FALSE," +
" mob_killing BOOLEAN NOT NULL DEFAULT FALSE," +
" lever BOOLEAN NOT NULL DEFAULT FALSE," +
" monster_killing BOOLEAN NOT NULL DEFAULT FALSE," +
" move BOOLEAN NOT NULL DEFAULT TRUE," +
" place BOOLEAN NOT NULL DEFAULT FALSE," +
" pressure BOOLEAN NOT NULL DEFAULT FALSE," +
" riding BOOLEAN NOT NULL DEFAULT FALSE," +
" repeater BOOLEAN NOT NULL DEFAULT FALSE," +
" shear BOOLEAN NOT NULL DEFAULT FALSE," +
" shoot BOOLEAN NOT NULL DEFAULT FALSE," +
" trade BOOLEAN NOT NULL DEFAULT FALSE," +
" vehicle_destroy BOOLEAN NOT NULL DEFAULT FALSE," +
" harvest BOOLEAN NOT NULL DEFAULT FALSE," +
" UNIQUE (player_uuid, dom_id)," +
" FOREIGN KEY (player_uuid) REFERENCES player_name(uuid)," +