Update 1.2.2

Fixed vanish-damage not working.
This commit is contained in:
SloudPL 2025-06-20 01:39:25 +02:00
parent 9fcbee447d
commit e0ea516a1d
6 changed files with 27 additions and 20 deletions

View file

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

View file

@ -1,6 +1,5 @@
package pl.sloudpl.simplevanish; package pl.sloudpl.simplevanish;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import pl.sloudpl.simplevanish.bstats.Metrics; import pl.sloudpl.simplevanish.bstats.Metrics;
import pl.sloudpl.simplevanish.cmds.VanishCommand; import pl.sloudpl.simplevanish.cmds.VanishCommand;
@ -9,11 +8,13 @@ import pl.sloudpl.simplevanish.events.onLeaveEvent;
import pl.sloudpl.simplevanish.events.onPlayerDamage; import pl.sloudpl.simplevanish.events.onPlayerDamage;
import pl.sloudpl.simplevanish.utils.UpdateChecker; import pl.sloudpl.simplevanish.utils.UpdateChecker;
import java.util.ArrayList; import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public final class SimpleVanish extends JavaPlugin { public final class SimpleVanish extends JavaPlugin {
public ArrayList<Player> inVanishList = new ArrayList<>(); public Set<UUID> inVanishList = new HashSet<>();
@Override @Override
public void onEnable() { public void onEnable() {

View file

@ -39,14 +39,14 @@ public class VanishCommand implements CommandExecutor {
return true; return true;
} }
if(plugin.inVanishList.contains(player)){ if(plugin.inVanishList.contains(player.getUniqueId())){
for(Player other : Bukkit.getOnlinePlayers()){ for(Player other : Bukkit.getOnlinePlayers()){
other.showPlayer(player); other.showPlayer(player);
if(plugin.getConfig().getBoolean("vanish-message-enabled")){ 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.getUniqueId());
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")));
@ -59,13 +59,13 @@ public class VanishCommand implements CommandExecutor {
} }
} }
} }
plugin.inVanishList.add(player); plugin.inVanishList.add(player.getUniqueId());
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")) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (!plugin.inVanishList.contains(player)) { if (!plugin.inVanishList.contains(player.getUniqueId())) {
cancel(); cancel();
return; return;
} }
@ -92,14 +92,14 @@ public class VanishCommand implements CommandExecutor {
return true; return true;
} }
if(plugin.inVanishList.contains(target)){ if(plugin.inVanishList.contains(target.getUniqueId())){
for(Player other : Bukkit.getOnlinePlayers()){ for(Player other : Bukkit.getOnlinePlayers()){
other.showPlayer(target); other.showPlayer(target);
if(plugin.getConfig().getBoolean("vanish-message-enabled")){ 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.getUniqueId());
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")));
@ -114,13 +114,13 @@ public class VanishCommand implements CommandExecutor {
} }
} }
} }
plugin.inVanishList.add(target); plugin.inVanishList.add(target.getUniqueId());
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")) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (!plugin.inVanishList.contains(target)) { if (!plugin.inVanishList.contains(target.getUniqueId())) {
cancel(); cancel();
return; return;
} }

View file

@ -1,11 +1,14 @@
package pl.sloudpl.simplevanish.events; package pl.sloudpl.simplevanish.events;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import pl.sloudpl.simplevanish.SimpleVanish; import pl.sloudpl.simplevanish.SimpleVanish;
import java.util.UUID;
public class onJoinEvent implements Listener { public class onJoinEvent implements Listener {
SimpleVanish plugin; SimpleVanish plugin;
@ -19,11 +22,14 @@ public class onJoinEvent implements Listener {
public void PlayerJoin(PlayerJoinEvent e){ public void PlayerJoin(PlayerJoinEvent e){
Player player = e.getPlayer(); Player player = e.getPlayer();
for(Player vanished : plugin.inVanishList){ for(UUID uuid : plugin.inVanishList){
if(!player.hasPermission("sloudpl.vanish.see")){ Player vanished = Bukkit.getPlayer(uuid);
player.hidePlayer(vanished); if(vanished != null){
} else { if(!player.hasPermission("sloudpl.vanish.see")){
player.showPlayer(vanished); player.hidePlayer(vanished);
} else {
player.showPlayer(vanished);
}
} }
} }
} }

View file

@ -21,9 +21,9 @@ public class onLeaveEvent implements Listener {
Player player = e.getPlayer(); Player player = e.getPlayer();
if(plugin.inVanishList.contains(player)){ if(plugin.inVanishList.contains(player.getUniqueId())){
plugin.inVanishList.remove(player); plugin.inVanishList.remove(player.getUniqueId());
player.removePotionEffect(PotionEffectType.NIGHT_VISION); player.removePotionEffect(PotionEffectType.NIGHT_VISION);
e.setQuitMessage(null); e.setQuitMessage(null);

View file

@ -22,7 +22,7 @@ public class onPlayerDamage implements Listener {
Player damager = (Player) e.getDamager(); Player damager = (Player) e.getDamager();
if(plugin.inVanishList.contains(damager)){ if(plugin.inVanishList.contains(damager.getUniqueId())){
e.setCancelled(true); e.setCancelled(true);