Skip to content

Instantly share code, notes, and snippets.

@jamietech
Created June 12, 2013 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamietech/5763670 to your computer and use it in GitHub Desktop.
Save jamietech/5763670 to your computer and use it in GitHub Desktop.
PlayerVanish is a plugin requested by 'braedentraut24' on the Bukkit forums. It allows the console and other players to vanish and unvanish other players easily.

Copyright 2013 jamietech

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

package ch.jamiete.playervanish;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.kitteh.vanish.VanishPlugin;
public class PlayerVanish extends JavaPlugin {
public void onEnable() {
final VanishPlugin vanish = (VanishPlugin) this.getServer().getPluginManager().getPlugin("VanishNoPacket");
if (vanish == null) {
this.getLogger().severe("Failed to find Vanish");
this.getServer().getPluginManager().disablePlugin(this);
return;
}
this.getCommand("playervanish").setExecutor(new CommandExecutor() {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.hasPermission("playervanish.use")) {
if (args.length == 1) {
Player player = PlayerVanish.this.getServer().getPlayer(args[0]);
if (player == null) {
sender.sendMessage(ChatColor.RED + "Couldn't find player '" + args[0] + "'.");
} else {
vanish.getManager().toggleVanishQuiet(player, false);
for (Player p : PlayerVanish.this.getServer().getOnlinePlayers()) {
if (p.hasPermission("playervanish.announce")) {
p.sendMessage(ChatColor.AQUA + sender.getName() + ChatColor.DARK_AQUA + " made " + ChatColor.AQUA + player.getName() + ChatColor.DARK_AQUA + " " + (vanish.getManager().isVanished(player) ? "invisible" : "visible"));
}
}
if (!sender.hasPermission("playervanish.announce")) {
sender.sendMessage(ChatColor.DARK_AQUA + "Made player " + player.getName() + " " + (vanish.getManager().isVanished(player) ? "invisible" : "visible"));
}
}
} else {
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playername>");
}
} else {
sender.sendMessage(ChatColor.RED + "You don't have permission.");
}
return true;
}
});
}
}
name: PlayerVanish
version: 1.0
main: ch.jamiete.playervanish.PlayerVanish
depend: ['VanishNoPacket']
website: http://jamiete.ch
author: jamietech
commands:
playervanish:
aliases: ['pv']
usage: /<command> <playername>
description: Hides a player.
permissions:
playervanish.use:
description: Lets player use /playervanish
default: op
playervanish.announce:
description: Announces player vanishes to this user
default: op
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment