Update to 1.2

Added 2 new options in config for disabling vanish and unvanish chat messages to all players and also added option to disable pvp for vanished players.
This commit is contained in:
SloudPL 2025-06-18 14:11:17 +02:00
parent 6195ee98b8
commit e75f952733
5 changed files with 59 additions and 5 deletions

View file

@ -6,7 +6,7 @@
<groupId>pl.sloudpl</groupId> <groupId>pl.sloudpl</groupId>
<artifactId>SloudVanish</artifactId> <artifactId>SloudVanish</artifactId>
<version>1.1.1</version> <version>1.2</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SloudVanish</name> <name>SloudVanish</name>

View file

@ -6,6 +6,7 @@ import pl.sloudpl.simplevanish.bstats.Metrics;
import pl.sloudpl.simplevanish.cmds.VanishCommand; import pl.sloudpl.simplevanish.cmds.VanishCommand;
import pl.sloudpl.simplevanish.events.onJoinEvent; import pl.sloudpl.simplevanish.events.onJoinEvent;
import pl.sloudpl.simplevanish.events.onLeaveEvent; import pl.sloudpl.simplevanish.events.onLeaveEvent;
import pl.sloudpl.simplevanish.events.onPlayerDamage;
import java.util.ArrayList; import java.util.ArrayList;
@ -22,9 +23,14 @@ public final class SimpleVanish extends JavaPlugin {
saveDefaultConfig(); saveDefaultConfig();
new VanishCommand(this); new VanishCommand(this);
new onJoinEvent(this); new onJoinEvent(this);
new onLeaveEvent(this); new onLeaveEvent(this);
if(getConfig().getBoolean("vanish-damage")){
new onPlayerDamage(this);
}
} }
@Override @Override

View file

@ -42,8 +42,10 @@ public class VanishCommand implements CommandExecutor {
if(plugin.inVanishList.contains(player)){ if(plugin.inVanishList.contains(player)){
for(Player other : Bukkit.getOnlinePlayers()){ for(Player other : Bukkit.getOnlinePlayers()){
other.showPlayer(player); other.showPlayer(player);
if(plugin.getConfig().getBoolean("vanish-message-enabled")){
other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", player.getName()))); other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", player.getName())));
} }
}
plugin.inVanishList.remove(player); plugin.inVanishList.remove(player);
player.removePotionEffect(PotionEffectType.NIGHT_VISION); player.removePotionEffect(PotionEffectType.NIGHT_VISION);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanish"))); player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanish")));
@ -52,9 +54,11 @@ public class VanishCommand implements CommandExecutor {
for(Player other : Bukkit.getOnlinePlayers()){ for(Player other : Bukkit.getOnlinePlayers()){
if(!other.hasPermission("sloudpl.vanish.see")){ if(!other.hasPermission("sloudpl.vanish.see")){
other.hidePlayer(player); other.hidePlayer(player);
if(plugin.getConfig().getBoolean("vanish-message-enabled")){
other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", player.getName()))); other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", player.getName())));
} }
} }
}
plugin.inVanishList.add(player); plugin.inVanishList.add(player);
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false)); player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false));
if(plugin.getConfig().getBoolean("actionbar")) { if(plugin.getConfig().getBoolean("actionbar")) {
@ -91,8 +95,10 @@ public class VanishCommand implements CommandExecutor {
if(plugin.inVanishList.contains(target)){ if(plugin.inVanishList.contains(target)){
for(Player other : Bukkit.getOnlinePlayers()){ for(Player other : Bukkit.getOnlinePlayers()){
other.showPlayer(target); other.showPlayer(target);
if(plugin.getConfig().getBoolean("vanish-message-enabled")){
other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", target.getName()))); other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", target.getName())));
} }
}
plugin.inVanishList.remove(target); plugin.inVanishList.remove(target);
target.removePotionEffect(PotionEffectType.NIGHT_VISION); target.removePotionEffect(PotionEffectType.NIGHT_VISION);
target.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanish"))); target.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanish")));
@ -103,9 +109,11 @@ public class VanishCommand implements CommandExecutor {
for(Player other : Bukkit.getOnlinePlayers()){ for(Player other : Bukkit.getOnlinePlayers()){
if(!other.hasPermission("sloudpl.vanish.see")){ if(!other.hasPermission("sloudpl.vanish.see")){
other.hidePlayer(target); other.hidePlayer(target);
if(plugin.getConfig().getBoolean("vanish-message-enabled")){
other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", target.getName()))); other.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", target.getName())));
} }
} }
}
plugin.inVanishList.add(target); plugin.inVanishList.add(target);
target.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false)); target.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false));
if(plugin.getConfig().getBoolean("actionbar")) { if(plugin.getConfig().getBoolean("actionbar")) {

View file

@ -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);
}
}
}
}

View file

@ -2,6 +2,11 @@
actionbar: false actionbar: false
# ActionBar text # ActionBar text
actionbarmsg: '&cVANISH &aON' 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 # When player vanishes
vanish: '&aYou are now invisibile!' vanish: '&aYou are now invisibile!'
# When player unvanishes # When player unvanishes