Fix Freeze Exceptions
Dieser Commit ist enthalten in:
Ursprung
88d1f7aa55
Commit
dfb6770453
@ -19,7 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.world.Region;
|
import de.steamwar.bausystem.world.Region;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
@ -55,6 +58,7 @@ public class CommandFreeze extends RegionToggleCommand {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||||
|
if (Core.getVersion() == 12) return;
|
||||||
if (!e.isBuildable()) return;
|
if (!e.isBuildable()) return;
|
||||||
if (!Region.getRegion(e.getBlock().getLocation()).isFreeze()) return;
|
if (!Region.getRegion(e.getBlock().getLocation()).isFreeze()) return;
|
||||||
if (e.getMaterial() == Material.TNT) {
|
if (e.getMaterial() == Material.TNT) {
|
||||||
@ -66,6 +70,12 @@ public class CommandFreeze extends RegionToggleCommand {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
|
if (Core.getVersion() == 15) return;
|
||||||
|
if (e.isCancelled()) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> {
|
||||||
|
e.getBlock().setType(Material.TNT, false);
|
||||||
|
}, 1L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -38,10 +38,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
@ -72,8 +69,9 @@ public class RegionListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||||
Player p = e.getPlayer();
|
if (Core.getVersion() == 12) return;
|
||||||
|
|
||||||
|
Player p = e.getPlayer();
|
||||||
try{
|
try{
|
||||||
if (Welt.noPermission(p, Permission.build)){
|
if (Welt.noPermission(p, Permission.build)){
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
|
||||||
@ -84,6 +82,21 @@ public class RegionListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent e) {
|
||||||
|
if (Core.getVersion() == 15) return;
|
||||||
|
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
try{
|
||||||
|
if (Welt.noPermission(p, Permission.build)){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}catch(NullPointerException ex){
|
||||||
|
//ignored, caused by worldedit brushes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"};
|
private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"};
|
||||||
|
|
||||||
private boolean isWorldEditCommand(String command) {
|
private boolean isWorldEditCommand(String command) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren