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>
<artifactId>SloudVanish</artifactId>
<version>1.1.1</version>
<version>1.2</version>
<packaging>jar</packaging>
<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.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

View file

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

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 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