mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 10:37:41 +01:00
Further progress on the port.
This commit is contained in:
parent
5657ee6c90
commit
d19db5f86f
@ -22,11 +22,13 @@
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockDamageLevel;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
@ -52,10 +54,17 @@ public WorldGuardBlockListener(WorldGuardPlugin plugin) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onBlockDamage(BlockDamageEvent event) {
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!plugin.itemDurability && event.getDamageLevel() == BlockDamageLevel.BROKEN) {
|
||||||
|
ItemStack held = player.getItemInHand();
|
||||||
|
held.setDamage((byte)-1);
|
||||||
|
player.setItemInHand(held);
|
||||||
|
}
|
||||||
|
|
||||||
if (plugin.useRegions) {
|
if (plugin.useRegions && event.getDamageLevel() == BlockDamageLevel.BROKEN) {
|
||||||
Vector pt = BukkitUtil.toVector(event.getBlock());
|
Vector pt = BukkitUtil.toVector(event.getBlock());
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
|
|
||||||
@ -73,10 +82,11 @@ public void onBlockDamage(BlockDamageEvent event) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onBlockFlow(BlockFromToEvent event) {
|
public void onBlockFlow(BlockFromToEvent event) {
|
||||||
World world = event.getBlock().getWorld();
|
World world = event.getBlock().getWorld();
|
||||||
Block blockFrom = event.getFromBlock();
|
Block blockFrom = event.getBlock();
|
||||||
Block blockTo = event.getBlock();
|
Block blockTo = event.getToBlock();
|
||||||
|
|
||||||
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
|
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
|
||||||
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
|
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
|
||||||
@ -107,7 +117,16 @@ public void onBlockFlow(BlockFromToEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.allowedLavaSpreadOver != null && isLava) {
|
if (plugin.preventWaterDamage.size() > 0 && isWater) {
|
||||||
|
int targetId = world.getBlockTypeIdAt(
|
||||||
|
blockTo.getX(), blockTo.getY(), blockTo.getZ());
|
||||||
|
if (plugin.preventWaterDamage.contains(targetId)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.allowedLavaSpreadOver.size() > 0 && isLava) {
|
||||||
int targetId = world.getBlockTypeIdAt(
|
int targetId = world.getBlockTypeIdAt(
|
||||||
blockTo.getX(), blockTo.getY() - 1, blockTo.getZ());
|
blockTo.getX(), blockTo.getY() - 1, blockTo.getZ());
|
||||||
if (!plugin.allowedLavaSpreadOver.contains(targetId)) {
|
if (!plugin.allowedLavaSpreadOver.contains(targetId)) {
|
||||||
@ -122,6 +141,7 @@ public void onBlockFlow(BlockFromToEvent event) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onBlockIgnite(BlockIgniteEvent event) {
|
public void onBlockIgnite(BlockIgniteEvent event) {
|
||||||
IgniteCause cause = event.getCause();
|
IgniteCause cause = event.getCause();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
@ -135,32 +155,31 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableAllFire) {
|
if (plugin.disableFireSpread) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.blockLighter && cause == IgniteCause.FLINT_AND_STEEL) {
|
if (plugin.blockLighter && cause == IgniteCause.FLINT_AND_STEEL) {
|
||||||
event.setCancelled(!plugin.hasPermission(player, "/uselighter")
|
|
||||||
&& !plugin.hasPermission(player, "/lighter"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.stopFireSpread && isFireSpread) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.fireNoSpreadBlocks.size() > 0 && isFireSpread) {
|
if (plugin.fireSpreadDisableToggle && isFireSpread) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.disableFireSpreadBlocks.size() > 0 && isFireSpread) {
|
||||||
int x = block.getX();
|
int x = block.getX();
|
||||||
int y = block.getY();
|
int y = block.getY();
|
||||||
int z = block.getZ();
|
int z = block.getZ();
|
||||||
|
|
||||||
if (plugin.fireNoSpreadBlocks.contains(world.getBlockAt(x, y - 1, z))
|
if (plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y - 1, z))
|
||||||
|| plugin.fireNoSpreadBlocks.contains(world.getBlockAt(x + 1, y, z))
|
|| plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x + 1, y, z))
|
||||||
|| plugin.fireNoSpreadBlocks.contains(world.getBlockAt(x - 1, y, z))
|
|| plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x - 1, y, z))
|
||||||
|| plugin.fireNoSpreadBlocks.contains(world.getBlockAt(x, y, z - 1))
|
|| plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z - 1))
|
||||||
|| plugin.fireNoSpreadBlocks.contains(world.getBlockAt(x, y, z + 1))) {
|
|| plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z + 1))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -189,6 +208,7 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
int id = event.getChangedTypeId();
|
int id = event.getChangedTypeId();
|
||||||
|
|
||||||
@ -213,6 +233,7 @@ public void onBlockPhysics(BlockPhysicsEvent event) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
Block blockPlaced = event.getBlock();
|
Block blockPlaced = event.getBlock();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -222,7 +243,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
|||||||
Vector pt = new Vector(blockPlaced.getX(),
|
Vector pt = new Vector(blockPlaced.getX(),
|
||||||
blockPlaced.getY(), blockPlaced.getZ());
|
blockPlaced.getY(), blockPlaced.getZ());
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
|
|
||||||
if (!plugin.hasPermission(player, "/regionbypass")
|
if (!plugin.hasPermission(player, "/regionbypass")
|
||||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||||
@ -255,6 +276,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onBlockRightClick(BlockRightClickEvent event) {
|
public void onBlockRightClick(BlockRightClickEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
@ -41,7 +41,8 @@ public class WorldGuardEntityListener extends EntityListener {
|
|||||||
public WorldGuardEntityListener(WorldGuardPlugin plugin) {
|
public WorldGuardEntityListener(WorldGuardPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
||||||
Entity defender = event.getEntity();
|
Entity defender = event.getEntity();
|
||||||
DamageCause type = event.getCause();
|
DamageCause type = event.getCause();
|
||||||
@ -70,7 +71,7 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableWaterDamage && type == DamageCause.DROWNING) {
|
if (plugin.disableDrowningDamage && type == DamageCause.DROWNING) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -83,6 +84,7 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
Entity attacker = event.getDamager();
|
Entity attacker = event.getDamager();
|
||||||
Entity defender = event.getEntity();
|
Entity defender = event.getEntity();
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
@ -32,7 +30,6 @@
|
|||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.blocks.ItemType;
|
import com.sk89q.worldedit.blocks.ItemType;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditAPI;
|
import com.sk89q.worldedit.bukkit.WorldEditAPI;
|
||||||
@ -41,7 +38,6 @@
|
|||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditNotInstalled;
|
|
||||||
import com.sk89q.worldguard.*;
|
import com.sk89q.worldguard.*;
|
||||||
import com.sk89q.worldguard.domains.*;
|
import com.sk89q.worldguard.domains.*;
|
||||||
import com.sk89q.worldguard.protection.*;
|
import com.sk89q.worldguard.protection.*;
|
||||||
@ -76,19 +72,15 @@ public WorldGuardPlayerListener(WorldGuardPlugin plugin) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onPlayerJoin(PlayerEvent event) {
|
public void onPlayerJoin(PlayerEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (plugin.stopFireSpread) {
|
if (plugin.fireSpreadDisableToggle) {
|
||||||
player.sendMessage(ChatColor.YELLOW
|
player.sendMessage(ChatColor.YELLOW
|
||||||
+ "Fire spread is currently globally disabled.");
|
+ "Fire spread is currently globally disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.loginProtection > 0 || plugin.spawnProtection > 0
|
|
||||||
|| plugin.kickOnDeath || plugin.teleportToHome || plugin.exactRespawn) {
|
|
||||||
plugin.recentLogins.put(player.getName(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.inGroup(player, "wg-invincible")) {
|
if (plugin.inGroup(player, "wg-invincible")) {
|
||||||
plugin.invinciblePlayers.add(player.getName());
|
plugin.invinciblePlayers.add(player.getName());
|
||||||
}
|
}
|
||||||
@ -103,11 +95,11 @@ public void onPlayerJoin(PlayerEvent event) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onPlayerQuit(PlayerEvent event) {
|
public void onPlayerQuit(PlayerEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
plugin.invinciblePlayers.remove(player.getName());
|
plugin.invinciblePlayers.remove(player.getName());
|
||||||
plugin.amphibiousPlayers.remove(player.getName());
|
plugin.amphibiousPlayers.remove(player.getName());
|
||||||
plugin.recentLogins.remove(player.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,11 +107,12 @@ public void onPlayerQuit(PlayerEvent event) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onPlayerItem(PlayerItemEvent event) {
|
public void onPlayerItem(PlayerItemEvent event) {
|
||||||
if (plugin.useRegions && event.isBlock()) {
|
if (plugin.useRegions && !event.isBlock() && event.getBlockClicked() != null) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getBlockClicked();
|
Block block = event.getBlockClicked();
|
||||||
Vector pt = toVector(block);
|
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
|
|
||||||
if (!plugin.hasPermission(player, "/regionbypass")
|
if (!plugin.hasPermission(player, "/regionbypass")
|
||||||
@ -137,6 +130,7 @@ public void onPlayerItem(PlayerItemEvent event) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
@ -156,6 +150,7 @@ public void onPlayerLogin(PlayerLoginEvent event) {
|
|||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onPlayerCommand(PlayerChatEvent event) {
|
public void onPlayerCommand(PlayerChatEvent event) {
|
||||||
if (handleCommand(event)) {
|
if (handleCommand(event)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -173,22 +168,24 @@ public boolean handleCommand(PlayerChatEvent event) {
|
|||||||
|
|
||||||
if (split[0].equalsIgnoreCase("/stopfire") &&
|
if (split[0].equalsIgnoreCase("/stopfire") &&
|
||||||
plugin.hasPermission(player, "/stopfire")) {
|
plugin.hasPermission(player, "/stopfire")) {
|
||||||
if (!plugin.stopFireSpread) {
|
if (!plugin.fireSpreadDisableToggle) {
|
||||||
plugin.getServer().broadcastMessage(ChatColor.YELLOW
|
plugin.getServer().broadcastMessage(ChatColor.YELLOW
|
||||||
+ "Fire spread has been globally disabled by " + player.getName() + ".");
|
+ "Fire spread has been globally disabled by " + player.getName() + ".");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Fire spread was already globally disabled.");
|
player.sendMessage(ChatColor.YELLOW + "Fire spread was already globally disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.fireSpreadDisableToggle = true;
|
||||||
} else if (split[0].equalsIgnoreCase("/allowfire")
|
} else if (split[0].equalsIgnoreCase("/allowfire")
|
||||||
&& plugin.hasPermission(player, "/stopfire")) {
|
&& plugin.hasPermission(player, "/stopfire")) {
|
||||||
if (plugin.stopFireSpread) {
|
if (plugin.fireSpreadDisableToggle) {
|
||||||
plugin.getServer().broadcastMessage(ChatColor.YELLOW
|
plugin.getServer().broadcastMessage(ChatColor.YELLOW
|
||||||
+ "Fire spread has been globally re-enabled by " + player.getName() + ".");
|
+ "Fire spread has been globally re-enabled by " + player.getName() + ".");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Fire spread was already globally enabled.");
|
player.sendMessage(ChatColor.YELLOW + "Fire spread was already globally enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.stopFireSpread = false;
|
plugin.fireSpreadDisableToggle = false;
|
||||||
} else if (split[0].equalsIgnoreCase("/god")
|
} else if (split[0].equalsIgnoreCase("/god")
|
||||||
&& plugin.hasPermission(player, "/god")) {
|
&& plugin.hasPermission(player, "/god")) {
|
||||||
// Allow setting other people invincible
|
// Allow setting other people invincible
|
||||||
@ -258,7 +255,9 @@ public boolean handleCommand(PlayerChatEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Same type?
|
// Same type?
|
||||||
if (item2.getTypeId() == item.getTypeId()) {
|
// Blocks store their color in the damage value
|
||||||
|
if (item2.getTypeId() == item.getTypeId() &&
|
||||||
|
(item.getTypeId() != 35 || item.getDamage() == item2.getDamage())) {
|
||||||
// This stack won't fit in the parent stack
|
// This stack won't fit in the parent stack
|
||||||
if (item2.getAmount() > needed) {
|
if (item2.getAmount() > needed) {
|
||||||
item.setAmount(64);
|
item.setAmount(64);
|
||||||
|
@ -22,26 +22,21 @@
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginLoader;
|
import org.bukkit.plugin.PluginLoader;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
import com.sk89q.worldguard.protection.CSVDatabase;
|
import com.sk89q.worldguard.protection.*;
|
||||||
import com.sk89q.worldguard.protection.FlatRegionManager;
|
|
||||||
import com.sk89q.worldguard.protection.ProtectionDatabase;
|
|
||||||
import com.sk89q.worldguard.protection.RegionManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin for Bukkit.
|
* Plugin for Bukkit.
|
||||||
@ -59,44 +54,51 @@ public class WorldGuardPlugin extends JavaPlugin {
|
|||||||
new WorldGuardEntityListener(this);
|
new WorldGuardEntityListener(this);
|
||||||
|
|
||||||
RegionManager regionManager = new FlatRegionManager();
|
RegionManager regionManager = new FlatRegionManager();
|
||||||
ProtectionDatabase regionLoader =
|
ProtectionDatabase regionLoader;
|
||||||
new CSVDatabase(new File("worldguard-regions.txt"));
|
|
||||||
|
|
||||||
Set<String> invinciblePlayers = new HashSet<String>();
|
Set<String> invinciblePlayers = new HashSet<String>();
|
||||||
Set<String> amphibiousPlayers = new HashSet<String>();
|
Set<String> amphibiousPlayers = new HashSet<String>();
|
||||||
Map<String,Long> recentLogins = new HashMap<String,Long>();
|
boolean fireSpreadDisableToggle;
|
||||||
Map<String,Long> lastSpawn = new HashMap<String,Long>();
|
|
||||||
|
// Configuration follows
|
||||||
boolean stopFireSpread = false;
|
|
||||||
|
|
||||||
boolean useRegions = false;
|
|
||||||
boolean enforceOneSession;
|
boolean enforceOneSession;
|
||||||
boolean blockCreepers;
|
boolean itemDurability;
|
||||||
boolean blockTNT;
|
Set<Integer> itemDropBlacklist;
|
||||||
boolean blockLighter;
|
|
||||||
boolean preventLavaFire;
|
boolean classicWater;
|
||||||
boolean disableAllFire;
|
|
||||||
boolean simulateSponge;
|
boolean simulateSponge;
|
||||||
int spongeRadius;
|
int spongeRadius;
|
||||||
Set<Integer> fireNoSpreadBlocks;
|
|
||||||
Set<Integer> allowedLavaSpreadOver;
|
|
||||||
Set<Integer> itemDropBlacklist;
|
|
||||||
Set<Integer> preventWaterDamage;
|
|
||||||
boolean classicWater;
|
|
||||||
boolean noPhysicsGravel;
|
boolean noPhysicsGravel;
|
||||||
boolean noPhysicsSand;
|
boolean noPhysicsSand;
|
||||||
boolean allowPortalAnywhere;
|
boolean allowPortalAnywhere;
|
||||||
|
Set<Integer> preventWaterDamage;
|
||||||
|
|
||||||
|
boolean blockTNT;
|
||||||
|
boolean blockLighter;
|
||||||
|
|
||||||
|
boolean disableFireSpread;
|
||||||
|
Set<Integer> disableFireSpreadBlocks;
|
||||||
|
boolean preventLavaFire;
|
||||||
|
Set<Integer> allowedLavaSpreadOver;
|
||||||
|
|
||||||
|
boolean blockCreeperExplosions;
|
||||||
|
|
||||||
|
int loginProtection;
|
||||||
|
int spawnProtection;
|
||||||
|
boolean kickOnDeath;
|
||||||
|
boolean exactRespawn;
|
||||||
|
boolean teleportToHome;
|
||||||
|
|
||||||
boolean disableFallDamage;
|
boolean disableFallDamage;
|
||||||
boolean disableLavaDamage;
|
boolean disableLavaDamage;
|
||||||
boolean disableFireDamage;
|
boolean disableFireDamage;
|
||||||
boolean disableWaterDamage;
|
boolean disableDrowningDamage;
|
||||||
boolean disableSuffocationDamage;
|
boolean disableSuffocationDamage;
|
||||||
boolean teleportOnSuffocation;
|
boolean teleportOnSuffocation;
|
||||||
int loginProtection;
|
|
||||||
int spawnProtection;
|
boolean useRegions;
|
||||||
boolean teleportToHome;
|
|
||||||
boolean exactRespawn;
|
|
||||||
boolean kickOnDeath;
|
|
||||||
int regionWand = 287;
|
int regionWand = 287;
|
||||||
|
|
||||||
public WorldGuardPlugin(PluginLoader pluginLoader, Server instance,
|
public WorldGuardPlugin(PluginLoader pluginLoader, Server instance,
|
||||||
@ -104,26 +106,40 @@ public WorldGuardPlugin(PluginLoader pluginLoader, Server instance,
|
|||||||
super(pluginLoader, instance, desc, folder, plugin, cLoader);
|
super(pluginLoader, instance, desc, folder, plugin, cLoader);
|
||||||
|
|
||||||
logger.info("WorldGuard " + desc.getVersion() + " loaded.");
|
logger.info("WorldGuard " + desc.getVersion() + " loaded.");
|
||||||
|
|
||||||
|
folder.mkdirs();
|
||||||
|
|
||||||
|
regionLoader = new CSVDatabase(new File(folder, "regions.txt"));
|
||||||
loadConfiguration();
|
loadConfiguration();
|
||||||
registerEvents();
|
registerEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
//loadConfiguration();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT,
|
registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal);
|
||||||
playerListener, Priority.Normal, this);
|
registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND,
|
registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Priority.Normal);
|
||||||
playerListener, Priority.Normal, this);
|
registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_DAMAGED,
|
registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal);
|
||||||
blockListener, Priority.Normal, this);
|
registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Normal);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_RIGHTCLICKED,
|
|
||||||
blockListener, Priority.Normal, this);
|
registerEvent(Event.Type.ENTITY_DAMAGEDBY_BLOCK, entityListener, Priority.Normal);
|
||||||
|
registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal);
|
||||||
|
|
||||||
|
registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal);
|
||||||
|
registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.Normal);
|
||||||
|
registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal);
|
||||||
|
registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal);
|
||||||
|
registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerEvent(Event.Type type, Listener listener, Priority priority) {
|
||||||
|
getServer().getPluginManager().registerEvent(type, listener, priority, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,30 +148,9 @@ private void registerEvents() {
|
|||||||
public void loadConfiguration() {
|
public void loadConfiguration() {
|
||||||
Configuration config = getConfiguration();
|
Configuration config = getConfiguration();
|
||||||
|
|
||||||
try {
|
|
||||||
regionLoader.load();
|
|
||||||
regionManager.setRegions(regionLoader.getRegions());
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.warning("WorldGuard: Failed to load regions: "
|
|
||||||
+ e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
recentLogins.clear();
|
|
||||||
|
|
||||||
// Load basic options
|
|
||||||
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
||||||
|
itemDurability = config.getBoolean("protection.item-durability", true);
|
||||||
blockCreepers = config.getBoolean("mobs.block-creeper-explosions", false);
|
|
||||||
|
|
||||||
blockTNT = config.getBoolean("ignition.block-tnt", false);
|
|
||||||
blockLighter = config.getBoolean("ignition.block-lighter", false);
|
|
||||||
|
|
||||||
preventLavaFire = config.getBoolean("fire.disable-lava-fire-spread", true);
|
|
||||||
disableAllFire = config.getBoolean("fire.disable-fire-spread", false);
|
|
||||||
preventWaterDamage = new HashSet<Integer>(config.getIntList("physics.disable-water-damage-blocks", null));
|
|
||||||
itemDropBlacklist = new HashSet<Integer>(config.getIntList("protection.item-drop-blacklist", null));
|
itemDropBlacklist = new HashSet<Integer>(config.getIntList("protection.item-drop-blacklist", null));
|
||||||
fireNoSpreadBlocks = new HashSet<Integer>(config.getIntList("fire.disable-fire-spread", null));
|
|
||||||
allowedLavaSpreadOver = new HashSet<Integer>(config.getIntList("fire.lava-spread-blocks", null));
|
|
||||||
|
|
||||||
classicWater = config.getBoolean("simulation.classic-water", false);
|
classicWater = config.getBoolean("simulation.classic-water", false);
|
||||||
simulateSponge = config.getBoolean("simulation.sponge.enable", true);
|
simulateSponge = config.getBoolean("simulation.sponge.enable", true);
|
||||||
@ -164,80 +159,41 @@ public void loadConfiguration() {
|
|||||||
noPhysicsGravel = config.getBoolean("physics.no-physics-gravel", false);
|
noPhysicsGravel = config.getBoolean("physics.no-physics-gravel", false);
|
||||||
noPhysicsSand = config.getBoolean("physics.no-physics-sand", false);
|
noPhysicsSand = config.getBoolean("physics.no-physics-sand", false);
|
||||||
allowPortalAnywhere = config.getBoolean("physics.allow-portal-anywhere", false);
|
allowPortalAnywhere = config.getBoolean("physics.allow-portal-anywhere", false);
|
||||||
|
preventWaterDamage = new HashSet<Integer>(config.getIntList("physics.disable-water-damage-blocks", null));
|
||||||
|
|
||||||
disableFallDamage = config.getBoolean("player-damage.disable-fall-damage", false);
|
blockTNT = config.getBoolean("ignition.block-tnt", false);
|
||||||
disableLavaDamage = config.getBoolean("player-damage.disable-lava-damage", false);
|
blockLighter = config.getBoolean("ignition.block-lighter", false);
|
||||||
disableFireDamage = config.getBoolean("player-damage.disable-fire-damage", false);
|
|
||||||
disableWaterDamage = config.getBoolean("player-damage.disable-water-damage", false);
|
preventLavaFire = config.getBoolean("fire.disable-lava-fire-spread", true);
|
||||||
disableSuffocationDamage = config.getBoolean("player-damage.disable-suffocation-damage", false);
|
disableFireSpread = config.getBoolean("fire.disable-all-fire-spread", false);
|
||||||
teleportOnSuffocation = config.getBoolean("player-damage.teleport-on-suffocation", false);
|
disableFireSpreadBlocks = new HashSet<Integer>(config.getIntList("fire.disable-fire-spread-blocks", null));
|
||||||
|
allowedLavaSpreadOver = new HashSet<Integer>(config.getIntList("fire.lava-spread-blocks", null));
|
||||||
|
|
||||||
|
blockCreeperExplosions = config.getBoolean("mobs.block-creeper-explosions", false);
|
||||||
|
|
||||||
loginProtection = config.getInt("spawn.login-protection", 3);
|
loginProtection = config.getInt("spawn.login-protection", 3);
|
||||||
spawnProtection = config.getInt("spawn.spawn-protection", 0);
|
spawnProtection = config.getInt("spawn.spawn-protection", 0);
|
||||||
kickOnDeath = config.getBoolean("spawn.kick-on-death", false);
|
kickOnDeath = config.getBoolean("spawn.kick-on-death", false);
|
||||||
teleportToHome = config.getBoolean("spawn.teleport-to-home-on-death", false);
|
|
||||||
exactRespawn = config.getBoolean("spawn.exact-respawn", false);
|
exactRespawn = config.getBoolean("spawn.exact-respawn", false);
|
||||||
|
teleportToHome = config.getBoolean("spawn.teleport-to-home-on-death", false);
|
||||||
|
|
||||||
|
disableFallDamage = config.getBoolean("player-damage.disable-fall-damage", false);
|
||||||
|
disableLavaDamage = config.getBoolean("player-damage.disable-lava-damage", false);
|
||||||
|
disableFireDamage = config.getBoolean("player-damage.disable-fire-damage", false);
|
||||||
|
disableDrowningDamage = config.getBoolean("player-damage.disable-water-damage", false);
|
||||||
|
disableSuffocationDamage = config.getBoolean("player-damage.disable-suffocation-damage", false);
|
||||||
|
teleportOnSuffocation = config.getBoolean("player-damage.teleport-on-suffocation", false);
|
||||||
|
|
||||||
useRegions = config.getBoolean("regions.enable", true);
|
useRegions = config.getBoolean("regions.enable", true);
|
||||||
regionWand = config.getInt("regions.wand", 287);
|
regionWand = config.getInt("regions.wand", 287);
|
||||||
|
|
||||||
/*
|
|
||||||
// Console log configuration
|
|
||||||
boolean logConsole = properties.getBoolean("log-console", true);
|
|
||||||
|
|
||||||
// Database log configuration
|
|
||||||
boolean logDatabase = properties.getBoolean("log-database", false);
|
|
||||||
String dsn = properties.getString("log-database-dsn", "jdbc:mysql://localhost:3306/minecraft");
|
|
||||||
String user = properties.getString("log-database-user", "root");
|
|
||||||
String pass = properties.getString("log-database-pass", "");
|
|
||||||
String table = properties.getString("log-database-table", "blacklist_events");
|
|
||||||
|
|
||||||
// File log configuration
|
|
||||||
boolean logFile = properties.getBoolean("log-file", false);
|
|
||||||
String logFilePattern = properties.getString("log-file-path", "worldguard/logs/%Y-%m-%d.log");
|
|
||||||
int logFileCacheSize = Math.max(1, properties.getInt("log-file-open-files", 10));
|
|
||||||
|
|
||||||
// Load the blacklist
|
|
||||||
try {
|
try {
|
||||||
// If there was an existing blacklist, close loggers
|
regionLoader.load();
|
||||||
if (blacklist != null) {
|
regionManager.setRegions(regionLoader.getRegions());
|
||||||
blacklist.getLogger().close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// First load the blacklist data from worldguard-blacklist.txt
|
|
||||||
Blacklist blist = new Blacklist();
|
|
||||||
blist.load(new File("worldguard-blacklist.txt"));
|
|
||||||
|
|
||||||
// If the blacklist is empty, then set the field to null
|
|
||||||
// and save some resources
|
|
||||||
if (blist.isEmpty()) {
|
|
||||||
this.blacklist = null;
|
|
||||||
} else {
|
|
||||||
this.blacklist = blist;
|
|
||||||
logger.log(Level.INFO, "WorldGuard: Blacklist loaded.");
|
|
||||||
|
|
||||||
BlacklistLogger blacklistLogger = blist.getLogger();
|
|
||||||
|
|
||||||
if (logDatabase) {
|
|
||||||
blacklistLogger.addHandler(new DatabaseLoggerHandler(dsn, user, pass, table));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logConsole) {
|
|
||||||
blacklistLogger.addHandler(new ConsoleLoggerHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logFile) {
|
|
||||||
FileLoggerHandler handler =
|
|
||||||
new FileLoggerHandler(logFilePattern, logFileCacheSize);
|
|
||||||
blacklistLogger.addHandler(handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
logger.log(Level.WARNING, "WorldGuard blacklist does not exist.");
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.log(Level.WARNING, "Could not load WorldGuard blacklist: "
|
logger.warning("WorldGuard: Failed to load regions: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// Print an overview of settings
|
// Print an overview of settings
|
||||||
if (config.getBoolean("summary-on-start", true)) {
|
if (config.getBoolean("summary-on-start", true)) {
|
||||||
@ -249,12 +205,12 @@ public void loadConfiguration() {
|
|||||||
: "WorldGuard: Lighters are PERMITTED.");
|
: "WorldGuard: Lighters are PERMITTED.");
|
||||||
logger.log(Level.INFO, preventLavaFire ? "WorldGuard: Lava fire is blocked."
|
logger.log(Level.INFO, preventLavaFire ? "WorldGuard: Lava fire is blocked."
|
||||||
: "WorldGuard: Lava fire is PERMITTED.");
|
: "WorldGuard: Lava fire is PERMITTED.");
|
||||||
if (disableAllFire) {
|
if (disableFireSpread) {
|
||||||
logger.log(Level.INFO, "WorldGuard: All fire spread is disabled.");
|
logger.log(Level.INFO, "WorldGuard: All fire spread is disabled.");
|
||||||
} else {
|
} else {
|
||||||
if (fireNoSpreadBlocks != null) {
|
if (disableFireSpreadBlocks != null) {
|
||||||
logger.log(Level.INFO, "WorldGuard: Fire spread is limited to "
|
logger.log(Level.INFO, "WorldGuard: Fire spread is limited to "
|
||||||
+ fireNoSpreadBlocks.size() + " block types.");
|
+ disableFireSpreadBlocks.size() + " block types.");
|
||||||
} else {
|
} else {
|
||||||
logger.log(Level.INFO, "WorldGuard: Fire spread is UNRESTRICTED.");
|
logger.log(Level.INFO, "WorldGuard: Fire spread is UNRESTRICTED.");
|
||||||
}
|
}
|
||||||
@ -266,8 +222,8 @@ boolean inGroup(Player player, String group) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasPermission(Player player, String hasPermission) {
|
boolean hasPermission(Player player, String perm) {
|
||||||
return true;
|
return !perm.equals("/regionbypass");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> getGroups(Player player) {
|
List<String> getGroups(Player player) {
|
||||||
|
Loading…
Reference in New Issue
Block a user