Compare commits
No commits in common. "master" and "1.2" have entirely different histories.
13 changed files with 32 additions and 409 deletions
|
@ -4,10 +4,8 @@ Just a simple Vanish plugin
|
||||||
|
|
||||||
Permissions:
|
Permissions:
|
||||||
|
|
||||||
/vanish - sloudpl.vanish
|
/Vanish command - sloudpl.vanish
|
||||||
|
|
||||||
/vanish player - sloudpl.vanish.others
|
/Vanish player - sloudpl.vanish.others
|
||||||
|
|
||||||
/sloudvanish reload - sloudpl.reload
|
|
||||||
|
|
||||||
To see vanished players - sloudpl.vanish.see
|
To see vanished players - sloudpl.vanish.see
|
4
pom.xml
4
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>pl.sloudpl</groupId>
|
<groupId>pl.sloudpl</groupId>
|
||||||
<artifactId>SloudVanish</artifactId>
|
<artifactId>SloudVanish</artifactId>
|
||||||
<version>1.3</version>
|
<version>1.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SloudVanish</name>
|
<name>SloudVanish</name>
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
<version>1.12-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package pl.sloudpl.simplevanish;
|
package pl.sloudpl.simplevanish;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
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.SloudVanishCMD;
|
|
||||||
import pl.sloudpl.simplevanish.cmds.SloudVanishCMD1_16;
|
|
||||||
import pl.sloudpl.simplevanish.cmds.VanishCommand;
|
import pl.sloudpl.simplevanish.cmds.VanishCommand;
|
||||||
import pl.sloudpl.simplevanish.cmds.VanishCommand1_16;
|
|
||||||
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 pl.sloudpl.simplevanish.events.onPlayerDamage;
|
||||||
import pl.sloudpl.simplevanish.utils.UpdateChecker;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public final class SimpleVanish extends JavaPlugin {
|
public final class SimpleVanish extends JavaPlugin {
|
||||||
|
|
||||||
public Set<UUID> inVanishList = new HashSet<>();
|
public ArrayList<Player> inVanishList = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
@ -28,32 +22,14 @@ public final class SimpleVanish extends JavaPlugin {
|
||||||
|
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
|
||||||
if (isVersionAtMost_1_16_0()) {
|
new VanishCommand(this);
|
||||||
|
|
||||||
new VanishCommand(this);
|
|
||||||
new SloudVanishCMD(this);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
new VanishCommand1_16(this);
|
|
||||||
new SloudVanishCMD1_16(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
new onJoinEvent(this);
|
new onJoinEvent(this);
|
||||||
new onLeaveEvent(this);
|
new onLeaveEvent(this);
|
||||||
new onPlayerDamage(this);
|
|
||||||
|
|
||||||
new UpdateChecker(this, 108713).getLatestVersion(version -> {
|
if(getConfig().getBoolean("vanish-damage")){
|
||||||
String current = this.getDescription().getVersion();
|
new onPlayerDamage(this);
|
||||||
if (!current.equalsIgnoreCase(version)) {
|
}
|
||||||
getLogger().warning("§cA new version of §eSloudVanish §cis available!");
|
|
||||||
getLogger().warning("§7Current: §e" + current + " §7| Latest: §a" + version);
|
|
||||||
getLogger().warning("§bDownload: https://www.spigotmc.org/resources/sloudvanish.108713/");
|
|
||||||
} else {
|
|
||||||
getLogger().info("§aSloudVanish is up to date (v" + current + ").");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,32 +39,4 @@ public final class SimpleVanish extends JavaPlugin {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVersionAtMost_1_16_0() {
|
|
||||||
String version = Bukkit.getBukkitVersion();
|
|
||||||
String[] mainParts = version.split("-")[0].split("\\.");
|
|
||||||
|
|
||||||
try {
|
|
||||||
int major = Integer.parseInt(mainParts[0]);
|
|
||||||
int minor = Integer.parseInt(mainParts[1]);
|
|
||||||
int patch = mainParts.length > 2 ? Integer.parseInt(mainParts[2]) : 0;
|
|
||||||
|
|
||||||
if (major < 1) {
|
|
||||||
return true;
|
|
||||||
} else if (major == 1) {
|
|
||||||
if (minor < 16) {
|
|
||||||
return true;
|
|
||||||
} else if (minor == 16) {
|
|
||||||
return patch == 0;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
package pl.sloudpl.simplevanish.cmds;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import pl.sloudpl.simplevanish.SimpleVanish;
|
|
||||||
|
|
||||||
public class SloudVanishCMD implements CommandExecutor {
|
|
||||||
|
|
||||||
SimpleVanish plugin;
|
|
||||||
|
|
||||||
public SloudVanishCMD(SimpleVanish plugin){
|
|
||||||
this.plugin = plugin;
|
|
||||||
plugin.getCommand("sloudvanish").setExecutor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
|
||||||
|
|
||||||
if(args.length == 1){
|
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("reload")){
|
|
||||||
if(sender.hasPermission("sloudpl.reload")){
|
|
||||||
|
|
||||||
plugin.reloadConfig();
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Config was reloaded!");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("noperms")));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /sloudvanish reload");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /sloudvanish reload");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
package pl.sloudpl.simplevanish.cmds;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import pl.sloudpl.simplevanish.SimpleVanish;
|
|
||||||
import pl.sloudpl.simplevanish.utils.ColorUtils;
|
|
||||||
|
|
||||||
public class SloudVanishCMD1_16 implements CommandExecutor {
|
|
||||||
|
|
||||||
SimpleVanish plugin;
|
|
||||||
|
|
||||||
public SloudVanishCMD1_16(SimpleVanish plugin){
|
|
||||||
this.plugin = plugin;
|
|
||||||
plugin.getCommand("sloudvanish").setExecutor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
|
||||||
|
|
||||||
if(args.length == 1){
|
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("reload")){
|
|
||||||
if(sender.hasPermission("sloudpl.reload")){
|
|
||||||
|
|
||||||
plugin.reloadConfig();
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Config was reloaded!");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("noperms"))));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /sloudvanish reload");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /sloudvanish reload");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -39,14 +39,14 @@ public class VanishCommand implements CommandExecutor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(plugin.inVanishList.contains(player.getUniqueId())){
|
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")){
|
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.getUniqueId());
|
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")));
|
||||||
|
|
||||||
|
@ -59,13 +59,13 @@ public class VanishCommand implements CommandExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.inVanishList.add(player.getUniqueId());
|
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")) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!plugin.inVanishList.contains(player.getUniqueId())) {
|
if (!plugin.inVanishList.contains(player)) {
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -92,14 +92,14 @@ public class VanishCommand implements CommandExecutor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(plugin.inVanishList.contains(target.getUniqueId())){
|
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")){
|
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.getUniqueId());
|
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")));
|
||||||
|
|
||||||
|
@ -114,13 +114,13 @@ public class VanishCommand implements CommandExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.inVanishList.add(target.getUniqueId());
|
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")) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!plugin.inVanishList.contains(target.getUniqueId())) {
|
if (!plugin.inVanishList.contains(target)) {
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,147 +0,0 @@
|
||||||
package pl.sloudpl.simplevanish.cmds;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import pl.sloudpl.simplevanish.SimpleVanish;
|
|
||||||
import pl.sloudpl.simplevanish.utils.ColorUtils;
|
|
||||||
|
|
||||||
public class VanishCommand1_16 implements CommandExecutor {
|
|
||||||
|
|
||||||
SimpleVanish plugin;
|
|
||||||
|
|
||||||
public VanishCommand1_16(SimpleVanish plugin){
|
|
||||||
this.plugin = plugin;
|
|
||||||
plugin.getCommand("vanish").setExecutor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
|
|
||||||
|
|
||||||
if(args.length == 0){
|
|
||||||
|
|
||||||
if(!(sender instanceof Player)){
|
|
||||||
sender.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("whenconsole"))));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if(!player.hasPermission("sloudpl.vanish")){
|
|
||||||
player.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("noperms"))));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(plugin.inVanishList.contains(player.getUniqueId())){
|
|
||||||
for(Player other : Bukkit.getOnlinePlayers()){
|
|
||||||
other.showPlayer(player);
|
|
||||||
if(plugin.getConfig().getBoolean("vanish-message-enabled")){
|
|
||||||
other.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", player.getName()))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.inVanishList.remove(player.getUniqueId());
|
|
||||||
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
|
||||||
player.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanish"))));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
for(Player other : Bukkit.getOnlinePlayers()){
|
|
||||||
if(!other.hasPermission("sloudpl.vanish.see")){
|
|
||||||
other.hidePlayer(player);
|
|
||||||
if(plugin.getConfig().getBoolean("vanish-message-enabled")){
|
|
||||||
other.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", player.getName()))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.inVanishList.add(player.getUniqueId());
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false));
|
|
||||||
if(plugin.getConfig().getBoolean("actionbar")) {
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!plugin.inVanishList.contains(player.getUniqueId())) {
|
|
||||||
cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String actionmsg = ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("actionbarmsg")));
|
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(actionmsg));
|
|
||||||
}
|
|
||||||
}.runTaskTimer(plugin, 0L, 40L);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanish"))));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(args.length == 1){
|
|
||||||
|
|
||||||
if(!sender.hasPermission("sloudpl.vanish.others")){
|
|
||||||
sender.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("noperms"))));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player target = Bukkit.getPlayerExact(args[0]);
|
|
||||||
if(target == null){
|
|
||||||
sender.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("playerdoesntexist"))));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(plugin.inVanishList.contains(target.getUniqueId())){
|
|
||||||
for(Player other : Bukkit.getOnlinePlayers()){
|
|
||||||
other.showPlayer(target);
|
|
||||||
if(plugin.getConfig().getBoolean("vanish-message-enabled")){
|
|
||||||
other.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanishmsg").replace("[Player]", target.getName()))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.inVanishList.remove(target.getUniqueId());
|
|
||||||
target.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
|
||||||
target.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("unvanish"))));
|
|
||||||
|
|
||||||
String otherUnVanishMessage = plugin.getConfig().getString("other.unvanish");
|
|
||||||
sender.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', otherUnVanishMessage.replace("[Target]", target.getName()))));
|
|
||||||
} else {
|
|
||||||
for(Player other : Bukkit.getOnlinePlayers()){
|
|
||||||
if(!other.hasPermission("sloudpl.vanish.see")){
|
|
||||||
other.hidePlayer(target);
|
|
||||||
if(plugin.getConfig().getBoolean("vanish-message-enabled")){
|
|
||||||
other.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanishmsg").replace("[Player]", target.getName()))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.inVanishList.add(target.getUniqueId());
|
|
||||||
target.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false));
|
|
||||||
if(plugin.getConfig().getBoolean("actionbar")) {
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!plugin.inVanishList.contains(target.getUniqueId())) {
|
|
||||||
cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String actionmsg = ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("actionbarmsg")));
|
|
||||||
target.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(actionmsg));
|
|
||||||
}
|
|
||||||
}.runTaskTimer(plugin, 0L, 40L);
|
|
||||||
}
|
|
||||||
target.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("vanish"))));
|
|
||||||
|
|
||||||
String otherVanishMessage = plugin.getConfig().getString("other.vanish");
|
|
||||||
sender.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', otherVanishMessage.replace("[Target]", target.getName()))));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ColorUtils.convertHexColors(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("usage"))));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +1,11 @@
|
||||||
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;
|
||||||
|
@ -22,14 +19,11 @@ public class onJoinEvent implements Listener {
|
||||||
public void PlayerJoin(PlayerJoinEvent e){
|
public void PlayerJoin(PlayerJoinEvent e){
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
|
|
||||||
for(UUID uuid : plugin.inVanishList){
|
for(Player vanished : plugin.inVanishList){
|
||||||
Player vanished = Bukkit.getPlayer(uuid);
|
if(!player.hasPermission("sloudpl.vanish.see")){
|
||||||
if(vanished != null){
|
player.hidePlayer(vanished);
|
||||||
if(!player.hasPermission("sloudpl.vanish.see")){
|
} else {
|
||||||
player.hidePlayer(vanished);
|
player.showPlayer(vanished);
|
||||||
} else {
|
|
||||||
player.showPlayer(vanished);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ public class onLeaveEvent implements Listener {
|
||||||
|
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
|
|
||||||
if(plugin.inVanishList.contains(player.getUniqueId())){
|
if(plugin.inVanishList.contains(player)){
|
||||||
|
|
||||||
plugin.inVanishList.remove(player.getUniqueId());
|
plugin.inVanishList.remove(player);
|
||||||
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||||
e.setQuitMessage(null);
|
e.setQuitMessage(null);
|
||||||
|
|
||||||
|
|
|
@ -18,17 +18,13 @@ public class onPlayerDamage implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void PlayerDamage(EntityDamageByEntityEvent e){
|
public void PlayerDamage(EntityDamageByEntityEvent e){
|
||||||
|
|
||||||
if(plugin.getConfig().getBoolean("vanish-damage")){
|
if(e.getDamager() instanceof Player){
|
||||||
|
|
||||||
if(e.getDamager() instanceof Player){
|
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package pl.sloudpl.simplevanish.utils;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class ColorUtils {
|
|
||||||
|
|
||||||
public static String convertHexColors(String text) {
|
|
||||||
Pattern pattern = Pattern.compile("&#([0-9A-Fa-f]{6})");
|
|
||||||
Matcher matcher = pattern.matcher(text);
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String hex = matcher.group(1);
|
|
||||||
Color color = new Color(
|
|
||||||
Integer.valueOf(hex.substring(0, 2), 16),
|
|
||||||
Integer.valueOf(hex.substring(2, 4), 16),
|
|
||||||
Integer.valueOf(hex.substring(4, 6), 16)
|
|
||||||
);
|
|
||||||
matcher.appendReplacement(sb, ChatColor.of(color).toString());
|
|
||||||
}
|
|
||||||
matcher.appendTail(sb);
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package pl.sloudpl.simplevanish.utils;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import pl.sloudpl.simplevanish.SimpleVanish;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class UpdateChecker {
|
|
||||||
private final SimpleVanish plugin;
|
|
||||||
private final int resourceId;
|
|
||||||
|
|
||||||
public UpdateChecker(SimpleVanish plugin, int resourceId) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.resourceId = resourceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getLatestVersion(Consumer<String> callback) {
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
|
||||||
try {
|
|
||||||
URL url = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + resourceId);
|
|
||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("GET");
|
|
||||||
conn.setConnectTimeout(5000);
|
|
||||||
conn.setReadTimeout(5000);
|
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
|
|
||||||
String version = reader.readLine();
|
|
||||||
callback.accept(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
plugin.getLogger().warning("Failed to check for updates: " + e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,9 +2,8 @@ name: SloudVanish
|
||||||
version: '${project.version}'
|
version: '${project.version}'
|
||||||
main: pl.sloudpl.simplevanish.SimpleVanish
|
main: pl.sloudpl.simplevanish.SimpleVanish
|
||||||
author: SloudPL
|
author: SloudPL
|
||||||
api-version: '1.13'
|
api-version: 1.13
|
||||||
commands:
|
commands:
|
||||||
vanish:
|
vanish:
|
||||||
description: Vanish
|
description: Vanish
|
||||||
aliases: [v]
|
aliases: [v]
|
||||||
sloudvanish:
|
|
Loading…
Add table
Reference in a new issue