diff --git a/pom.xml b/pom.xml index 7629d2e..71ae8f0 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ pl.sloudpl SloudVanish - 1.1.1 + 1.2 jar SloudVanish diff --git a/src/main/java/pl/sloudpl/simplevanish/SimpleVanish.java b/src/main/java/pl/sloudpl/simplevanish/SimpleVanish.java index 9464534..c46f6f8 100644 --- a/src/main/java/pl/sloudpl/simplevanish/SimpleVanish.java +++ b/src/main/java/pl/sloudpl/simplevanish/SimpleVanish.java @@ -6,6 +6,7 @@ import pl.sloudpl.simplevanish.bstats.Metrics; import pl.sloudpl.simplevanish.cmds.VanishCommand; import pl.sloudpl.simplevanish.events.onJoinEvent; import pl.sloudpl.simplevanish.events.onLeaveEvent; +import pl.sloudpl.simplevanish.events.onPlayerDamage; import java.util.ArrayList; @@ -22,9 +23,14 @@ public final class SimpleVanish extends JavaPlugin { saveDefaultConfig(); new VanishCommand(this); + new onJoinEvent(this); new onLeaveEvent(this); + if(getConfig().getBoolean("vanish-damage")){ + new onPlayerDamage(this); + } + } @Override diff --git a/src/main/java/pl/sloudpl/simplevanish/cmds/VanishCommand.java b/src/main/java/pl/sloudpl/simplevanish/cmds/VanishCommand.java index fae6b3d..a918160 100644 --- a/src/main/java/pl/sloudpl/simplevanish/cmds/VanishCommand.java +++ b/src/main/java/pl/sloudpl/simplevanish/cmds/VanishCommand.java @@ -42,7 +42,9 @@ public class VanishCommand implements CommandExecutor { if(plugin.inVanishList.contains(player)){ for(Player other : Bukkit.getOnlinePlayers()){ other.showPlayer(player); - other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", player.getName()))); + if(plugin.getConfig().getBoolean("vanish-message-enabled")){ + other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", player.getName()))); + } } plugin.inVanishList.remove(player); player.removePotionEffect(PotionEffectType.NIGHT_VISION); @@ -52,7 +54,9 @@ public class VanishCommand implements CommandExecutor { for(Player other : Bukkit.getOnlinePlayers()){ if(!other.hasPermission("sloudpl.vanish.see")){ other.hidePlayer(player); - other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", player.getName()))); + if(plugin.getConfig().getBoolean("vanish-message-enabled")){ + other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", player.getName()))); + } } } plugin.inVanishList.add(player); @@ -91,7 +95,9 @@ public class VanishCommand implements CommandExecutor { if(plugin.inVanishList.contains(target)){ for(Player other : Bukkit.getOnlinePlayers()){ other.showPlayer(target); - other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", target.getName()))); + if(plugin.getConfig().getBoolean("vanish-message-enabled")){ + other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", target.getName()))); + } } plugin.inVanishList.remove(target); target.removePotionEffect(PotionEffectType.NIGHT_VISION); @@ -103,7 +109,9 @@ public class VanishCommand implements CommandExecutor { for(Player other : Bukkit.getOnlinePlayers()){ if(!other.hasPermission("sloudpl.vanish.see")){ other.hidePlayer(target); - other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", target.getName()))); + if(plugin.getConfig().getBoolean("vanish-message-enabled")){ + other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", target.getName()))); + } } } plugin.inVanishList.add(target); diff --git a/src/main/java/pl/sloudpl/simplevanish/events/onPlayerDamage.java b/src/main/java/pl/sloudpl/simplevanish/events/onPlayerDamage.java new file mode 100644 index 0000000..1bec8a9 --- /dev/null +++ b/src/main/java/pl/sloudpl/simplevanish/events/onPlayerDamage.java @@ -0,0 +1,35 @@ +package pl.sloudpl.simplevanish.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import pl.sloudpl.simplevanish.SimpleVanish; + +public class onPlayerDamage implements Listener { + + SimpleVanish plugin; + + public onPlayerDamage(SimpleVanish plugin){ + this.plugin = plugin; + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + @EventHandler + public void PlayerDamage(EntityDamageByEntityEvent e){ + + if(e.getDamager() instanceof Player){ + + Player damager = (Player) e.getDamager(); + + if(plugin.inVanishList.contains(damager)){ + + e.setCancelled(true); + + } + + } + + } + +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a3e1685..7bddadb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,6 +2,11 @@ actionbar: false # ActionBar text actionbarmsg: '&cVANISH &aON' +# Enable/Disable damaging players when in vanish +vanish-damage: true +# If the player goes into vanish there is a message that the player left the game when true it will show up when false it will not show up. +# It also works for when player disables vanish and there is the message that the player joined the game. +vanish-message-enabled: true # When player vanishes vanish: '&aYou are now invisibile!' # When player unvanishes