Personal modifications of BloodMoon
This commit is contained in:
parent
372d6ae022
commit
8de9ba6e06
@ -1,6 +1,7 @@
|
||||
name: BloodMoon
|
||||
version: 0.13.2
|
||||
main: uk.co.jacekk.bukkit.bloodmoon.BloodMoon
|
||||
author: wide_load & Xefir Destiny
|
||||
load: startup
|
||||
commands:
|
||||
bloodmoon:
|
||||
|
@ -25,7 +25,6 @@ import uk.co.jacekk.bukkit.bloodmoon.featurelisteners.MoreSpawningListener;
|
||||
import uk.co.jacekk.bukkit.bloodmoon.featurelisteners.SpawnOnKillListener;
|
||||
import uk.co.jacekk.bukkit.bloodmoon.featurelisteners.SpawnOnSleepListener;
|
||||
import uk.co.jacekk.bukkit.bloodmoon.featurelisteners.SuperCreepersListener;
|
||||
import uk.co.jacekk.bukkit.bloodmoon.featurelisteners.SwordDamageListener;
|
||||
import uk.co.jacekk.bukkit.bloodmoon.listeners.EntityListener;
|
||||
import uk.co.jacekk.bukkit.bloodmoon.listeners.PlayerListener;
|
||||
import uk.co.jacekk.bukkit.bloodmoon.listeners.WorldListener;
|
||||
@ -131,10 +130,6 @@ public class BloodMoon extends JavaPlugin {
|
||||
|
||||
// arrow-rate is handled in BloodMoonEntitySkeleton
|
||||
|
||||
if (BloodMoon.config.getBoolean("features.sword-damage.enabled")){
|
||||
this.manager.registerEvents(new SwordDamageListener(this), this);
|
||||
}
|
||||
|
||||
if (BloodMoon.config.getBoolean("features.lock-in-world.enabled") && BloodMoon.config.getBoolean("always-on") == false){
|
||||
this.manager.registerEvents(new LockInWorldListener(), this);
|
||||
}
|
||||
@ -142,15 +137,6 @@ public class BloodMoon extends JavaPlugin {
|
||||
if (BloodMoon.config.getBoolean("features.spawn-on-sleep.enabled")){
|
||||
this.manager.registerEvents(new SpawnOnSleepListener(), this);
|
||||
}
|
||||
|
||||
this.log.info("Enabled.");
|
||||
}
|
||||
|
||||
public void onDisable(){
|
||||
this.log.info("Disabled");
|
||||
|
||||
BloodMoon.config = null;
|
||||
BloodMoon.bloodMoonWorlds = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,15 +44,6 @@ public class BloodMoonConfig {
|
||||
this.configDefaults.put("features.more-exp.enabled", true);
|
||||
this.configDefaults.put("features.more-exp.multiplier", 2);
|
||||
|
||||
this.configDefaults.put("features.sword-damage.enabled", true);
|
||||
this.configDefaults.put("features.sword-damage.mobs", Arrays.asList("ZOMBIE", "SKELETON", "SPIDER", "CREEPER", "ENDERMAN"));
|
||||
this.configDefaults.put("features.sword-damage.chance", 10);
|
||||
this.configDefaults.put("features.sword-damage.damage.diamond", 100);
|
||||
this.configDefaults.put("features.sword-damage.damage.iron", 20);
|
||||
this.configDefaults.put("features.sword-damage.damage.gold", 10);
|
||||
this.configDefaults.put("features.sword-damage.damage.stone", 20);
|
||||
this.configDefaults.put("features.sword-damage.damage.wood", 10);
|
||||
|
||||
this.configDefaults.put("features.super-creepers.enabled", true);
|
||||
this.configDefaults.put("features.super-creepers.power", 4.0D);
|
||||
|
||||
@ -65,6 +56,7 @@ public class BloodMoonConfig {
|
||||
this.configDefaults.put("features.spawn-on-sleep.spawn", Arrays.asList("ZOMBIE"));
|
||||
|
||||
this.configDefaults.put("features.lock-in-world.enabled", true);
|
||||
this.configDefaults.put("message", "The blood moon is rising !");
|
||||
|
||||
if (configFile.exists()){
|
||||
try {
|
||||
@ -142,4 +134,8 @@ public class BloodMoonConfig {
|
||||
return this.getStringList(key).contains(mobName);
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.config.getString("message", this.configDefaults.get("message").toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class BloodMoonTimeMonitor implements Runnable {
|
||||
|
||||
if (worldTime == 123 && Math.random() < (((double) BloodMoon.config.getInt("bloodmoon-chance")) / 100) && BloodMoon.bloodMoonWorlds.contains(worldName) == false){
|
||||
for (Player player : world.getPlayers()){
|
||||
player.sendMessage(ChatColor.RED + "The blood moon is rising !");
|
||||
player.sendMessage(ChatColor.RED + BloodMoon.config.getMessage());
|
||||
}
|
||||
|
||||
BloodMoon.bloodMoonWorlds.add(worldName);
|
||||
|
@ -41,7 +41,7 @@ public class BloodMoonExecuter implements CommandExecutor {
|
||||
BloodMoon.bloodMoonWorlds.add(worldName);
|
||||
|
||||
for (Player worldPlayer : world.getPlayers()){
|
||||
worldPlayer.sendMessage(ChatColor.RED + "[" + player.getName() + "] The blood moon is rising !");
|
||||
worldPlayer.sendMessage(ChatColor.RED + "[" + player.getName() + "]" + BloodMoon.config.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
@ -28,11 +27,6 @@ public class LockInWorldListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerPortal(PlayerPortalEvent event){
|
||||
this.onPlayerTeleport(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event){
|
||||
Player player = event.getPlayer();
|
||||
|
@ -1,73 +0,0 @@
|
||||
package uk.co.jacekk.bukkit.bloodmoon.featurelisteners;
|
||||
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import uk.co.jacekk.bukkit.bloodmoon.BloodMoon;
|
||||
|
||||
public class SwordDamageListener implements Listener {
|
||||
|
||||
private BloodMoon plugin;
|
||||
|
||||
public SwordDamageListener(BloodMoon instance){
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onEntityDamage(EntityDamageEvent event){
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (event.getCause() == DamageCause.ENTITY_ATTACK && BloodMoon.bloodMoonWorlds.contains(entity.getWorld().getName())){
|
||||
if (entity instanceof Creature){
|
||||
Creature creature = (Creature) entity;
|
||||
|
||||
LivingEntity target = creature.getTarget();
|
||||
|
||||
if (target instanceof Player){
|
||||
Player player = (Player) target;
|
||||
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
// 190 character line :D
|
||||
if (BloodMoon.config.isCreatureOnMobList("features.sword-damage.mobs", creature) && plugin.rand.nextInt(100) <= BloodMoon.config.getInt("features.sword-damage.chance")){
|
||||
short damage = item.getDurability();
|
||||
|
||||
switch (item.getType()){
|
||||
case DIAMOND_SWORD:
|
||||
if (damage > BloodMoon.config.getInt("features.sword-damage.damage.diamond")){
|
||||
item.setDurability((short) (item.getDurability() - BloodMoon.config.getInt("features.sword-damage.damage.diamond")));
|
||||
}
|
||||
case IRON_SWORD:
|
||||
if (damage > BloodMoon.config.getInt("features.sword-damage.damage.iron")){
|
||||
item.setDurability((short) (item.getDurability() - BloodMoon.config.getInt("features.sword-damage.damage.iron")));
|
||||
}
|
||||
case GOLD_SWORD:
|
||||
if (damage > BloodMoon.config.getInt("features.sword-damage.damage.gold")){
|
||||
item.setDurability((short) (item.getDurability() - BloodMoon.config.getInt("features.sword-damage.damage.gold")));
|
||||
}
|
||||
case STONE_SWORD:
|
||||
if (damage > BloodMoon.config.getInt("features.sword-damage.damage.stone")){
|
||||
item.setDurability((short) (item.getDurability() - BloodMoon.config.getInt("features.sword-damage.damage.stone")));
|
||||
}
|
||||
case WOOD_SWORD:
|
||||
if (damage > BloodMoon.config.getInt("features.sword-damage.damage.wood")){
|
||||
item.setDurability((short) (item.getDurability() - BloodMoon.config.getInt("features.sword-damage.damage.wood")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import uk.co.jacekk.bukkit.bloodmoon.BloodMoon;
|
||||
@ -20,7 +19,7 @@ public class PlayerListener implements Listener {
|
||||
World toWorld = player.getWorld();
|
||||
|
||||
if (BloodMoon.bloodMoonWorlds.contains(toWorld.getName())){
|
||||
player.sendMessage(ChatColor.RED + "The blood moon is rising !");
|
||||
player.sendMessage(ChatColor.RED + BloodMoon.config.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,20 +28,7 @@ public class PlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (BloodMoon.bloodMoonWorlds.contains(player.getWorld().getName())){
|
||||
player.sendMessage(ChatColor.RED + "The blood moon is rising !");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event){
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
if (event.getMessage().equalsIgnoreCase("/reload")){
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "Due to the way BloodMoon works, /reload can cause a crash.");
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "A fix is being worked on, but for now you will have to restart.");
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "To ignore this and crash the server use /reload force.");
|
||||
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + BloodMoon.config.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user