mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2025-01-12 00:24:27 +08:00
新增生物战利品掉落权限
修复了无法拦截岩浆、水的问题
This commit is contained in:
parent
ca4116d467
commit
93b6759f9d
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>Dominion</artifactId>
|
||||
<version>1.10.6-beta</version>
|
||||
<version>1.11.0-beta</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Dominion</name>
|
||||
|
@ -26,7 +26,7 @@ public class Helper {
|
||||
"harvest", "honey", "hook", "hopper",
|
||||
"ignite",
|
||||
"lever",
|
||||
"monster_killing", "move",
|
||||
"mob_drop_item", "monster_killing", "move",
|
||||
"place", "pressure",
|
||||
"riding", "repeater",
|
||||
"shear", "shoot",
|
||||
|
@ -65,6 +65,7 @@ public class FlagsController {
|
||||
case "hopper": return dominion.setHopper(value);
|
||||
case "ignite": return dominion.setIgnite(value);
|
||||
case "lever": return dominion.setLever(value);
|
||||
case "mob_drop_item": return dominion.setMobDropItem(value);
|
||||
case "monster_killing": return dominion.setMonsterKilling(value);
|
||||
case "move": return dominion.setMove(value);
|
||||
case "place": return dominion.setPlace(value);
|
||||
|
@ -59,6 +59,7 @@ public class DominionDTO {
|
||||
rs.getBoolean("hopper"),
|
||||
rs.getBoolean("ignite"),
|
||||
rs.getBoolean("lever"),
|
||||
rs.getBoolean("mob_drop_item"),
|
||||
rs.getBoolean("monster_killing"),
|
||||
rs.getBoolean("move"),
|
||||
rs.getBoolean("place"),
|
||||
@ -206,6 +207,7 @@ public class DominionDTO {
|
||||
"hopper = " + dominion.getHopper() + ", " +
|
||||
"ignite = " + dominion.getIgnite() + ", " +
|
||||
"lever = " + dominion.getLever() + ", " +
|
||||
"mob_drop_item = " + dominion.getMobDropItem() + ", " + // dom only
|
||||
"monster_killing = " + dominion.getMonsterKilling() + ", " +
|
||||
"move = " + dominion.getMove() + ", " +
|
||||
"place = " + dominion.getPlace() + ", " +
|
||||
@ -241,7 +243,7 @@ public class DominionDTO {
|
||||
Boolean harvest, Boolean honey, Boolean hook, Boolean hopper,
|
||||
Boolean ignite,
|
||||
Boolean lever,
|
||||
Boolean monsterKilling, Boolean move,
|
||||
Boolean mobDropItem, Boolean monsterKilling, Boolean move,
|
||||
Boolean place, Boolean pressure,
|
||||
Boolean riding, Boolean repeater,
|
||||
Boolean shear, Boolean shoot,
|
||||
@ -290,6 +292,7 @@ public class DominionDTO {
|
||||
this.hopper = hopper;
|
||||
this.ignite = ignite;
|
||||
this.lever = lever;
|
||||
this.mobDropItem = mobDropItem;
|
||||
this.monsterKilling = monsterKilling;
|
||||
this.move = move;
|
||||
this.place = place;
|
||||
@ -316,7 +319,7 @@ public class DominionDTO {
|
||||
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, true,
|
||||
false, true, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false);
|
||||
}
|
||||
@ -366,6 +369,7 @@ public class DominionDTO {
|
||||
private Boolean hopper = false;
|
||||
private Boolean ignite = false;
|
||||
private Boolean lever = false;
|
||||
private Boolean mobDropItem = true;
|
||||
private Boolean monsterKilling = false;
|
||||
private Boolean move = true;
|
||||
private Boolean place = false;
|
||||
@ -738,6 +742,15 @@ public class DominionDTO {
|
||||
return update(this);
|
||||
}
|
||||
|
||||
public Boolean getMobDropItem() {
|
||||
return mobDropItem;
|
||||
}
|
||||
|
||||
public DominionDTO setMobDropItem(Boolean mobDropItem) {
|
||||
this.mobDropItem = mobDropItem;
|
||||
return update(this);
|
||||
}
|
||||
|
||||
public Boolean getMonsterKilling() {
|
||||
return monsterKilling;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDropItemEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -75,6 +76,22 @@ public class EnvironmentEvents implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // mob_drop_item
|
||||
public void onMobDropItem(EntityDropItemEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
|
||||
if (dom == null) {
|
||||
return;
|
||||
}
|
||||
if (dom.getMobDropItem()) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // tnt_explode
|
||||
public void onTntExplode(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
@ -865,29 +865,41 @@ public class PlayerEvents implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // place
|
||||
public void onPlace(BlockPlaceEvent event) {
|
||||
public void onPlaceBlock(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
DominionDTO dom = Cache.instance.getPlayerCurrentDominion(player);
|
||||
if (dom == null) {
|
||||
if (onPlace(player)) {
|
||||
return;
|
||||
}
|
||||
if (Apis.hasPermission(player, dom)) {
|
||||
return;
|
||||
}
|
||||
PlayerPrivilegeDTO privilege = Cache.instance.getPlayerPrivilege(player, dom);
|
||||
if (privilege != null) {
|
||||
if (privilege.getPlace()) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (dom.getPlace()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Notification.error(player, "你没有放置方块的权限");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlaceLavaOrWater(PlayerBucketEmptyEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (onPlace(player)) {
|
||||
return;
|
||||
}
|
||||
Notification.error(player, "你没有放置方块的权限");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public static boolean onPlace(Player player) {
|
||||
DominionDTO dom = Cache.instance.getPlayerCurrentDominion(player);
|
||||
if (dom == null) {
|
||||
return false;
|
||||
}
|
||||
if (Apis.hasPermission(player, dom)) {
|
||||
return true;
|
||||
}
|
||||
PlayerPrivilegeDTO privilege = Cache.instance.getPlayerPrivilege(player, dom);
|
||||
if (privilege != null) {
|
||||
return privilege.getPlace();
|
||||
} else {
|
||||
return dom.getPlace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // pressure
|
||||
public void onPressure(PlayerInteractEvent event) {
|
||||
if (event.getClickedBlock() == null) {
|
||||
|
@ -290,6 +290,15 @@ public class DominionFlagInfo {
|
||||
.append(Button.createRed("☐", "/dominion set lever true " + dominion.getName() + " " + page))
|
||||
.append("使用拉杆"));
|
||||
}
|
||||
if (dominion.getMobDropItem()){
|
||||
view.add(Line.create()
|
||||
.append(Button.createGreen("☑", "/dominion set mob_drop_item false " + dominion.getName() + " " + page))
|
||||
.append("生物战利品掉落"));
|
||||
} else {
|
||||
view.add(Line.create()
|
||||
.append(Button.createRed("☐", "/dominion set mob_drop_item true " + dominion.getName() + " " + page))
|
||||
.append("生物战利品掉落"));
|
||||
}
|
||||
if (dominion.getMonsterKilling()) {
|
||||
view.add(Line.create()
|
||||
.append(Button.createGreen("☑", "/dominion set monster_killing false " + dominion.getName() + " " + page))
|
||||
|
@ -186,5 +186,9 @@ public class Database {
|
||||
// 1.10.0
|
||||
sql = "ALTER TABLE dominion ADD COLUMN IF NOT EXISTS trample BOOLEAN NOT NULL DEFAULT FALSE;";
|
||||
query(sql);
|
||||
|
||||
// 1.11.0
|
||||
sql = "ALTER TABLE dominion ADD COLUMN IF NOT EXISTS mob_drop_item BOOLEAN NOT NULL DEFAULT TRUE;";
|
||||
query(sql);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user