mcMMO now supports world blacklisting

This commit is contained in:
nossr50 2019-01-22 09:16:02 -08:00
parent 76ddcc4cf0
commit 726b04f586
9 changed files with 305 additions and 1 deletions

View File

@ -17,6 +17,7 @@ Version 2.1.0
+ Added links to mcMMO related websites to various commands + Added links to mcMMO related websites to various commands
+ Certain elements of mcMMO's UI have been restyled + Certain elements of mcMMO's UI have been restyled
+ Added the tagline "Overhaul Era" to various locations until 3.0.0 comes out + Added the tagline "Overhaul Era" to various locations until 3.0.0 comes out
+ You can now disable mcMMO completely for specific worlds via world_blacklist.txt in /plugins/mcMMO/
! (Scoreboards) Scoreboards are now disabled by default, I don't like them. You can turn them back on in config.yml ! (Scoreboards) Scoreboards are now disabled by default, I don't like them. You can turn them back on in config.yml
+ (Sounds) Rolling now plays a sound (Graceful Roll has a different sound :) ) + (Sounds) Rolling now plays a sound (Graceful Roll has a different sound :) )
+ (Sounds) Activating Super abilities plays a sound (other plays can hear this) + (Sounds) Activating Super abilities plays a sound (other plays can hear this)

View File

@ -0,0 +1,79 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.World;
import java.io.*;
import java.util.ArrayList;
/**
* Blacklist certain features in certain worlds
*/
public class WorldBlacklist {
private static ArrayList<String> blacklist;
private mcMMO plugin;
private final String blackListFileName = "world_blacklist.txt";
public WorldBlacklist(mcMMO plugin)
{
this.plugin = plugin;
blacklist = new ArrayList<>();
init();
}
public void init()
{
//Make the blacklist file if it doesn't exist
File blackListFile = new File(plugin.getDataFolder() + File.separator + blackListFileName);
try {
if(!blackListFile.exists())
blackListFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
//Load up the blacklist
loadBlacklist(blackListFile);
}
private void loadBlacklist(File blackListFile) {
try {
FileReader fileReader = new FileReader(blackListFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String currentLine;
while((currentLine = bufferedReader.readLine()) != null)
{
if(currentLine.length() == 0)
continue;
if(!blacklist.contains(currentLine))
blacklist.add(currentLine);
}
//Close readers
bufferedReader.close();
fileReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
plugin.getLogger().info(blacklist.size()+" entries in mcMMO World Blacklist");
}
public static boolean isWorldBlacklisted(World world)
{
for(String s : blacklist)
{
if(world.getName().equalsIgnoreCase(s))
return true;
}
return false;
}
}

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.datatypes.player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -759,7 +760,8 @@ public class McMMOPlayer {
} }
public void checkGodMode() { public void checkGodMode() {
if (godMode && !Permissions.mcgod(player)) { if (godMode && !Permissions.mcgod(player)
|| godMode && WorldBlacklist.isWorldBlacklisted(player.getWorld())) {
toggleGodMode(); toggleGodMode();
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden")); player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
} }

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
@ -62,6 +63,10 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) { public void onBlockPistonExtend(BlockPistonExtendEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
BlockFace direction = event.getDirection(); BlockFace direction = event.getDirection();
Block movedBlock = event.getBlock(); Block movedBlock = event.getBlock();
movedBlock = movedBlock.getRelative(direction, 2); movedBlock = movedBlock.getRelative(direction, 2);
@ -81,6 +86,10 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) { public void onBlockPistonRetract(BlockPistonRetractEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
// Get opposite direction so we get correct block // Get opposite direction so we get correct block
BlockFace direction = event.getDirection(); BlockFace direction = event.getDirection();
Block movedBlock = event.getBlock().getRelative(direction); Block movedBlock = event.getBlock().getRelative(direction);
@ -100,6 +109,10 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityBlockFormEvent(EntityBlockFormEvent event) public void onEntityBlockFormEvent(EntityBlockFormEvent event)
{ {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if(BlockUtils.shouldBeWatched(event.getBlock().getState())) if(BlockUtils.shouldBeWatched(event.getBlock().getState()))
{ {
mcMMO.getPlaceStore().setTrue(event.getBlock()); mcMMO.getPlaceStore().setTrue(event.getBlock());
@ -113,6 +126,9 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFallingBlock(EntityChangeBlockEvent event) { public void onFallingBlock(EntityChangeBlockEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) { if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) { if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) {
@ -141,6 +157,10 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) { if (!UserManager.hasPlayerDataKey(player)) {
@ -173,6 +193,10 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockMultiPlace(BlockMultiPlaceEvent event) { public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) { if (!UserManager.hasPlayerDataKey(player)) {
@ -193,6 +217,10 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockGrow(BlockGrowEvent event) public void onBlockGrow(BlockGrowEvent event)
{ {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
BlockState blockState = event.getBlock().getState(); BlockState blockState = event.getBlock().getState();
if (!BlockUtils.shouldBeWatched(blockState)) { if (!BlockUtils.shouldBeWatched(blockState)) {
@ -209,6 +237,10 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (event instanceof FakeBlockBreakEvent) { if (event instanceof FakeBlockBreakEvent) {
return; return;
} }
@ -290,6 +322,10 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreakHigher(BlockBreakEvent event) { public void onBlockBreakHigher(BlockBreakEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (event instanceof FakeBlockBreakEvent) { if (event instanceof FakeBlockBreakEvent) {
return; return;
} }
@ -342,6 +378,10 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) { public void onBlockDamage(BlockDamageEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (event instanceof FakeBlockDamageEvent) { if (event instanceof FakeBlockDamageEvent) {
return; return;
} }
@ -408,6 +448,10 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamageHigher(BlockDamageEvent event) { public void onBlockDamageHigher(BlockDamageEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (event instanceof FakeBlockDamageEvent) { if (event instanceof FakeBlockDamageEvent) {
return; return;
} }

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.meta.OldName; import com.gmail.nossr50.datatypes.meta.OldName;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
@ -53,6 +54,10 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShootBow(EntityShootBowEvent event) { public void onEntityShootBow(EntityShootBowEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity projectile = event.getProjectile(); Entity projectile = event.getProjectile();
if (!(projectile instanceof Arrow)) { if (!(projectile instanceof Arrow)) {
@ -71,6 +76,10 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onProjectileLaunch(ProjectileLaunchEvent event) { public void onProjectileLaunch(ProjectileLaunchEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Projectile projectile = event.getEntity(); Projectile projectile = event.getEntity();
if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.bowForceKey)) { if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.bowForceKey)) {
@ -89,6 +98,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) { public void onEntityChangeBlock(EntityChangeBlockEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Block block = event.getBlock(); Block block = event.getBlock();
// When the event is fired for the falling block that changes back to a // When the event is fired for the falling block that changes back to a
@ -128,6 +141,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event instanceof FakeEntityDamageByEntityEvent) { if (event instanceof FakeEntityDamageByEntityEvent) {
return; return;
} }
@ -263,6 +280,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
/* /*
* Process Registered Interactions * Process Registered Interactions
*/ */
@ -403,6 +424,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeathLowest(EntityDeathEvent event) { public void onEntityDeathLowest(EntityDeathEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (Misc.isNPCEntity(entity)) { if (Misc.isNPCEntity(entity)) {
@ -432,6 +457,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (Misc.isNPCEntity(entity)) { if (Misc.isNPCEntity(entity)) {
@ -450,6 +479,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) { public void onCreatureSpawn(CreatureSpawnEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
switch (event.getSpawnReason()) { switch (event.getSpawnReason()) {
@ -482,6 +515,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) { public void onExplosionPrime(ExplosionPrimeEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) { if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
@ -511,6 +548,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnitityExplode(EntityExplodeEvent event) { public void onEnitityExplode(EntityExplodeEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) { if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
@ -541,6 +582,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityExplodeMonitor(EntityExplodeEvent event) { public void onEntityExplodeMonitor(EntityExplodeEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntsafeMetadataKey)) { if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntsafeMetadataKey)) {
@ -558,6 +603,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onFoodLevelChange(FoodLevelChangeEvent event) { public void onFoodLevelChange(FoodLevelChangeEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof Player)) { if (!(entity instanceof Player)) {
@ -651,6 +700,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) { public void onEntityTame(EntityTameEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event instanceof FakeEntityTameEvent) { if (event instanceof FakeEntityTameEvent) {
return; return;
} }
@ -674,6 +727,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event) { public void onEntityTarget(EntityTargetEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
Entity target = event.getTarget(); Entity target = event.getTarget();
@ -705,6 +762,10 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPotionSplash(PotionSplashEvent event) { public void onPotionSplash(PotionSplashEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) { for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) {
if (!effect.getType().equals(PotionEffectType.SATURATION)) { if (!effect.getType().equals(PotionEffectType.SATURATION)) {
return; return;
@ -719,6 +780,10 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPigZapEvent(PigZapEvent event) { public void onPigZapEvent(PigZapEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) { if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) {
event.getPigZombie().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); event.getPigZombie().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
} }

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.events.fake.FakeBrewEvent; import com.gmail.nossr50.events.fake.FakeBrewEvent;
@ -38,6 +39,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) { public void onInventoryOpen(InventoryOpenEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) { if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
@ -55,6 +60,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClose(InventoryCloseEvent event) { public void onInventoryClose(InventoryCloseEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) { if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
@ -72,6 +81,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceBurnEvent(FurnaceBurnEvent event) { public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Block furnaceBlock = event.getBlock(); Block furnaceBlock = event.getBlock();
BlockState furnaceState = furnaceBlock.getState(); BlockState furnaceState = furnaceBlock.getState();
ItemStack smelting = furnaceState instanceof Furnace ? ((Furnace) furnaceState).getInventory().getSmelting() : null; ItemStack smelting = furnaceState instanceof Furnace ? ((Furnace) furnaceState).getInventory().getSmelting() : null;
@ -91,6 +104,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) { public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Block furnaceBlock = event.getBlock(); Block furnaceBlock = event.getBlock();
ItemStack smelting = event.getSource(); ItemStack smelting = event.getSource();
@ -109,6 +126,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceExtractEvent(FurnaceExtractEvent event) { public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Block furnaceBlock = event.getBlock(); Block furnaceBlock = event.getBlock();
if (!ItemUtils.isSmelted(new ItemStack(event.getItemType(), event.getItemAmount()))) { if (!ItemUtils.isSmelted(new ItemStack(event.getItemType(), event.getItemAmount()))) {
@ -127,6 +148,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryClickEventNormal(InventoryClickEvent event) { public void onInventoryClickEventNormal(InventoryClickEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld()))
return;
Inventory inventory = event.getInventory(); Inventory inventory = event.getInventory();
if (!(inventory instanceof BrewerInventory)) { if (!(inventory instanceof BrewerInventory)) {
@ -226,6 +251,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryDragEvent(InventoryDragEvent event) { public void onInventoryDragEvent(InventoryDragEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld()))
return;
Inventory inventory = event.getInventory(); Inventory inventory = event.getInventory();
if (!(inventory instanceof BrewerInventory)) { if (!(inventory instanceof BrewerInventory)) {
@ -269,6 +298,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBrew(BrewEvent event) public void onBrew(BrewEvent event)
{ {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (event instanceof FakeBrewEvent) if (event instanceof FakeBrewEvent)
return; return;
Location location = event.getBlock().getLocation(); Location location = event.getBlock().getLocation();
@ -280,6 +313,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) { public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getSource().getLocation().getWorld()))
return;
Inventory inventory = event.getDestination(); Inventory inventory = event.getDestination();
if (!(inventory instanceof BrewerInventory)) { if (!(inventory instanceof BrewerInventory)) {
@ -324,6 +361,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraftItem(CraftItemEvent event) { public void onCraftItem(CraftItemEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld()))
return;
final HumanEntity whoClicked = event.getWhoClicked(); final HumanEntity whoClicked = event.getWhoClicked();
if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) { if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) {

View File

@ -4,6 +4,7 @@ import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory; import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.PartyChatManager; import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
@ -59,6 +60,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) { public void onPlayerTeleport(PlayerTeleportEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || Config.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) { if (!UserManager.hasPlayerDataKey(player) || Config.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) {
@ -79,6 +84,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerDeathLowest(PlayerDeathEvent event) { public void onPlayerDeathLowest(PlayerDeathEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
String deathMessage = event.getDeathMessage(); String deathMessage = event.getDeathMessage();
if (deathMessage == null) { if (deathMessage == null) {
@ -101,6 +110,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeathMonitor(PlayerDeathEvent event) { public void onPlayerDeathMonitor(PlayerDeathEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
boolean statLossEnabled = HardcoreManager.isStatLossEnabled(); boolean statLossEnabled = HardcoreManager.isStatLossEnabled();
boolean vampirismEnabled = HardcoreManager.isVampirismEnabled(); boolean vampirismEnabled = HardcoreManager.isVampirismEnabled();
@ -165,6 +178,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) { public void onPlayerDropItem(PlayerDropItemEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Item drop = event.getItemDrop(); Item drop = event.getItemDrop();
ItemStack dropStack = drop.getItemStack(); ItemStack dropStack = drop.getItemStack();
@ -185,6 +202,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerFishHighest(PlayerFishEvent event) { public void onPlayerFishHighest(PlayerFishEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) { if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
@ -240,6 +261,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFishMonitor(PlayerFishEvent event) { public void onPlayerFishMonitor(PlayerFishEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) { if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
@ -281,6 +306,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) { public void onPlayerPickupItem(PlayerPickupItemEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) { if (!UserManager.hasPlayerDataKey(player)) {
@ -398,6 +427,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteractLowest(PlayerInteractEvent event) { public void onPlayerInteractLowest(PlayerInteractEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
@ -490,6 +523,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteractMonitor(PlayerInteractEvent event) { public void onPlayerInteractMonitor(PlayerInteractEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
@ -620,6 +657,10 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) { public void onPlayerChat(AsyncPlayerChatEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !UserManager.hasPlayerDataKey(player)) { if (Misc.isNPCEntity(player) || !UserManager.hasPlayerDataKey(player)) {
@ -689,6 +730,10 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) { public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
if (!mcMMO.getHolidayManager().isAprilFirst()) { if (!mcMMO.getHolidayManager().isAprilFirst()) {
return; return;
} }

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain; import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -29,6 +30,10 @@ public class WorldListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event) { public void onStructureGrow(StructureGrowEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return;
if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) { if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) {
return; return;
} }
@ -45,6 +50,10 @@ public class WorldListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) { public void onWorldInit(WorldInitEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return;
World world = event.getWorld(); World world = event.getWorld();
if (!new File(world.getWorldFolder(), "mcmmo_data").exists() || plugin == null) { if (!new File(world.getWorldFolder(), "mcmmo_data").exists() || plugin == null) {
@ -63,6 +72,10 @@ public class WorldListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(WorldUnloadEvent event) { public void onWorldUnload(WorldUnloadEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return;
mcMMO.getPlaceStore().unloadWorld(event.getWorld()); mcMMO.getPlaceStore().unloadWorld(event.getWorld());
} }
@ -73,6 +86,10 @@ public class WorldListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) { public void onChunkUnload(ChunkUnloadEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return;
Chunk chunk = event.getChunk(); Chunk chunk = event.getChunk();
mcMMO.getPlaceStore().chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld()); mcMMO.getPlaceStore().chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());

View File

@ -71,6 +71,9 @@ public class mcMMO extends JavaPlugin {
private static HolidayManager holidayManager; private static HolidayManager holidayManager;
private static UpgradeManager upgradeManager; private static UpgradeManager upgradeManager;
/* Blacklist */
private static WorldBlacklist worldBlacklist;
/* File Paths */ /* File Paths */
private static String mainDirectory; private static String mainDirectory;
private static String flatFileDirectory; private static String flatFileDirectory;
@ -211,6 +214,9 @@ public class mcMMO extends JavaPlugin {
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
} }
//Init the blacklist
worldBlacklist = new WorldBlacklist(this);
} }
/** /**
@ -569,4 +575,8 @@ public class mcMMO extends JavaPlugin {
public static boolean isRetroModeEnabled() { public static boolean isRetroModeEnabled() {
return isRetroModeEnabled; return isRetroModeEnabled;
} }
public static WorldBlacklist getWorldBlacklist() {
return worldBlacklist;
}
} }