Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Noogear authored Aug 28, 2024
1 parent 0070da3 commit f778256
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/me/pta/ProtectionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.*;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
Expand Down Expand Up @@ -69,6 +70,14 @@ public void onBlockFade(BlockFadeEvent event) {
}
}

//方块间接被破坏(可能是用于铁砧的)
@EventHandler
public void onBlockDamage(BlockDamageEvent event) {
if (event.getBlock().getWorld().getName().equals(world)) {
event.setCancelled(true);
}
}


//生物破坏农田
@EventHandler
Expand Down Expand Up @@ -198,6 +207,22 @@ public void onEntityMount(EntityMountEvent event) {
}
}

//玩家能强制在床上睡觉,即使在末地和地狱
@EventHandler
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
if (event.getPlayer().getWorld().getName().equals(world)) {
event.setUseBed(Result.ALLOW);
}
}

//禁止玩家修改告示牌
@EventHandler
public void onSignOpen(PlayerSignOpenEvent event) {
if (event.getPlayer().getWorld().getName().equals(world) && !event.getPlayer().hasPermission("protectall.op")) {
event.setCancelled(true);
}
}

//切换世界和登录时强制设置游戏模式
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Expand Down

0 comments on commit f778256

Please sign in to comment.