mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-21 23:51:42 +01:00
[trunk] added new config settings to disable weather. you can disable storm / thunder and lightning seperately.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1284 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
71f1a44013
commit
2ccc2234d4
@ -345,6 +345,9 @@ public class Settings implements IConf
|
||||
epPlayerSettings.put("protect.disable.firedmg", config.getBoolean("protect.disable.firedmg", false));
|
||||
epPlayerSettings.put("protect.disable.build", config.getBoolean("protect.disable.build", false));
|
||||
epPlayerSettings.put("protect.disable.lightning", config.getBoolean("protect.disable.lightning", false));
|
||||
epPlayerSettings.put("protect.disable.weather.lightning", config.getBoolean("protect.disable.weather.lightning", false));
|
||||
epPlayerSettings.put("protect.disable.weather.storm", config.getBoolean("protect.disable.weather.storm", false));
|
||||
epPlayerSettings.put("protect.disable.weather.thunder", config.getBoolean("protect.disable.weather.thunder", false));
|
||||
return epPlayerSettings;
|
||||
|
||||
}
|
||||
|
@ -382,10 +382,11 @@ protect:
|
||||
warn-on-build-disallow: false
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#disable weather options
|
||||
weather:
|
||||
storm: false
|
||||
thunder: false
|
||||
lightning: false
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
|
@ -20,6 +20,7 @@ public class EssentialsProtect extends JavaPlugin
|
||||
private EssentialsProtectBlockListener blockListener = null;
|
||||
private EssentialsProtectPlayerListener playerListener = null;
|
||||
private EssentialsProtectEntityListener entityListener = null;
|
||||
private EssentialsProtectWeatherListener weatherListener = null;
|
||||
public static final String AUTHORS = Essentials.AUTHORS;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
public static HashMap<String, Boolean> genSettings = null;
|
||||
@ -33,7 +34,6 @@ public class EssentialsProtect extends JavaPlugin
|
||||
public static ArrayList<Integer> onUseAlert = null;
|
||||
public static ArrayList<Integer> onBreakAlert = null;
|
||||
|
||||
|
||||
public EssentialsProtect()
|
||||
{
|
||||
}
|
||||
@ -48,6 +48,7 @@ public class EssentialsProtect extends JavaPlugin
|
||||
playerListener = new EssentialsProtectPlayerListener(this);
|
||||
blockListener = new EssentialsProtectBlockListener(this);
|
||||
entityListener = new EssentialsProtectEntityListener(this);
|
||||
weatherListener = new EssentialsProtectWeatherListener(this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.BLOCK_FROMTO, blockListener, Priority.Highest, this);
|
||||
@ -58,9 +59,12 @@ public class EssentialsProtect extends JavaPlugin
|
||||
pm.registerEvent(Type.ENTITY_TARGET, entityListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
|
||||
|
||||
pm.registerEvent(Type.WEATHER_CHANGE, weatherListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.THUNDER_CHANGE, weatherListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.LIGHTNING_STRIKE, weatherListener, Priority.Highest, this);
|
||||
loadSettings();
|
||||
if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion())) {
|
||||
if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion()))
|
||||
{
|
||||
logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version.");
|
||||
}
|
||||
logger.info("Loaded " + this.getDescription().getName() + " build " + this.getDescription().getVersion() + " maintained by " + AUTHORS);
|
||||
@ -76,7 +80,7 @@ public class EssentialsProtect extends JavaPlugin
|
||||
{
|
||||
genSettings.clear();
|
||||
dataSettings.clear();
|
||||
|
||||
|
||||
blockListener = null;
|
||||
playerListener = null;
|
||||
entityListener = null;
|
||||
|
@ -0,0 +1,60 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherEvent;
|
||||
import org.bukkit.event.weather.WeatherListener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsProtectWeatherListener extends WeatherListener
|
||||
{
|
||||
private EssentialsProtect parent;
|
||||
|
||||
public EssentialsProtectWeatherListener(EssentialsProtect parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWeatherChange(WeatherChangeEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if(EssentialsProtect.playerSettings.get("protect.disable.weather.storm") && event.toWeatherState())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightningStrike(LightningStrikeEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if(EssentialsProtect.playerSettings.get("protect.disable.weather.lightning"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onThunderChange(ThunderChangeEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if(EssentialsProtect.playerSettings.get("protect.disable.weather.thunder") && event.toThunderState())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user