-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from tomudding/legacy
Update legacy version to Minecraft 1.8
- Loading branch information
Showing
7 changed files
with
791 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# If you want to use special characters in this document, such as accented letters, you MUST save the file as UTF-8, not ANSI | ||
# If it is saved as an ANSI file it will return an illegal character error | ||
# If you receive an error while Player Visibility loads, ensure that: | ||
# - No tabs are present: YAML only allows spaces | ||
# - Indents are correct: YAML hierarchy is based entirely on indentation | ||
# - Text with symbols is enclosed in single or double quotation marks | ||
|
||
# When using the dye option please use one of the following options: | ||
# WHITE, ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, | ||
# GRAY, SILVER, CYAN, PURPLE, BLUE, BROWN, GREEN, RED, BLACK | ||
|
||
Enabled-Worlds: | ||
- "world" | ||
- "world 1" | ||
- "world 2" | ||
|
||
enableDye: false | ||
|
||
item: | ||
slot: 8 | ||
on: | ||
item: "SLIME_BALL" | ||
dye: "LIME" | ||
name: "&7Players are &aon!" | ||
lore: "&7Toggle player visibility to &coff" | ||
off: | ||
item: "MAGMA_CREAM" | ||
dye: "GRAY" | ||
name: "&7Players are &coff!" | ||
lore: "&7Toggle player visibility to &aon" | ||
|
||
messages: | ||
actionbar: true | ||
prefix: "&9Visibility > " | ||
toggle: | ||
on: "&7All players are turned &aon!" | ||
off: "&7All players are turned &coff!" | ||
already: | ||
on: "&7All players are already &aon!" | ||
off: "&7All players are already &coff!" | ||
permission: "&cYou don't have the permissions to do that." | ||
cooldown: "&7Please wait 10 seconds before toggling again." | ||
world: "&cYou can't hide/unhide players in this world." | ||
switch: "&cYou can't change this item its place." | ||
|
||
cooldown: 10 | ||
|
||
config: "2.2" |
145 changes: 145 additions & 0 deletions
145
legacy/src/nl/tomudding/plugins/visibility/Visibility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
package nl.tomudding.plugins.visibility; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.logging.Logger; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import nl.tomudding.plugins.visibility.commands.Commands; | ||
import nl.tomudding.plugins.visibility.listeners.PlayerListener; | ||
import nl.tomudding.plugins.visibility.managers.ChatManager; | ||
import nl.tomudding.plugins.visibility.managers.PlayerManager; | ||
|
||
public class Visibility extends JavaPlugin { | ||
|
||
public final Logger logger = Logger.getLogger("Minecraft"); | ||
protected Logger log; | ||
public PlayerManager settings = PlayerManager.getInstance(); | ||
|
||
/** | ||
* Boolean variables | ||
*/ | ||
public static boolean isDyeEnabled = false; | ||
public static boolean actionBar = true; | ||
|
||
/** | ||
* Int variables | ||
*/ | ||
public static int timeCooldown = 10; | ||
public static int itemSlot = 8; | ||
|
||
/** | ||
* String variables | ||
*/ | ||
public static String itemIdOn = "SLIME_BALL"; | ||
public static String itemIdOff = "MAGMA_CREAM"; | ||
public static String dyeColorOn = "LIME"; | ||
public static String dyeColorOff = "GRAY"; | ||
public static String itemNameOn = "&7Players are &aon!"; | ||
public static String itemNameOff = "&7Players are &coff!"; | ||
public static String itemLoreOn = "&7Toggle player visibility to &coff"; | ||
public static String itemLoreOff = "&7Toggle player visibility to &aon"; | ||
|
||
public static String messagePrefix = "&9Visibility > "; | ||
public static String messageCooldown = "&7Please wait 10 seconds before toggling again."; | ||
public static String messagePermission = "&cYou don't have the permissions to do that."; | ||
public static String messageToggleOn = "&7All players are turned &aon!"; | ||
public static String messageToggleOff = "&7All players are turned &coff!"; | ||
public static String messageWorld = "&cYou can't hide/unhide players in this world."; | ||
public static String messageAlreadyOn = "&7All players are already &aon!"; | ||
public static String messageAlreadyOff = "&7All players are already &coff!"; | ||
public static String messageNoSwitch = "&cYou can't change this item its place."; | ||
public static String configVersion = "0.0"; | ||
|
||
/** | ||
* List variables | ||
*/ | ||
public static List<String> enabledWorlds; | ||
public static ArrayList<UUID> inCooldown = new ArrayList<UUID>(); | ||
|
||
public void onEnable() { | ||
ChatManager.getInstance().log("Starting Player Visibility for Bukkit"); | ||
|
||
if (!(getServerVersion().startsWith("v1_8_"))) { | ||
ChatManager.getInstance().log("&c=========================================="); | ||
ChatManager.getInstance().log("&cWARNING: Your server software is not 1.8!"); | ||
ChatManager.getInstance().log("&cWARNING: This plugin requires"); | ||
ChatManager.getInstance().log("&cWARNING: Minecraft version 1.8.*."); | ||
ChatManager.getInstance().log("&c=========================================="); | ||
ChatManager.getInstance().log("Disabling Player Visibility for Bukkit"); | ||
Plugin plugin = Bukkit.getPluginManager().getPlugin("Visibility"); | ||
plugin.getPluginLoader().disablePlugin(plugin); | ||
return; | ||
} | ||
|
||
saveDefaultConfig(); | ||
|
||
this.settings.setup(this); | ||
this.settings.saveData(); | ||
|
||
loadConfig(); | ||
|
||
if (!StringUtils.substring(getDescription().getVersion(), 0, 3).equals(configVersion)) { | ||
ChatManager.getInstance().log("&cWARNING: Config.yml version: "+Visibility.configVersion+". Plugin version: "+getDescription().getVersion()+"!"); | ||
ChatManager.getInstance().log("&cWARNING: Config.yml is not the correct version, delete 'config.yml' and restart the server!"); | ||
} else { | ||
ChatManager.getInstance().log("&aConfig.yml version matches required version."); | ||
} | ||
|
||
getServer().getPluginManager().registerEvents(new PlayerListener(this), this); | ||
getCommand("visibility").setExecutor(new Commands(this)); | ||
getCommand("hide").setExecutor(new Commands(this)); | ||
getCommand("show").setExecutor(new Commands(this)); | ||
|
||
ChatManager.getInstance().log("Player Visibility for Bukkit is now enabled"); | ||
} | ||
|
||
public void onDisable() { | ||
ChatManager.getInstance().log("Disabling Player Visibility for Bukkit"); | ||
ChatManager.getInstance().log("Player Visibility for Bukkit is now disabled"); | ||
} | ||
|
||
public static String getServerVersion() { | ||
return Bukkit.getServer().getClass().getPackage().getName().substring(23); | ||
} | ||
|
||
public static Class<?> getNMSClass(String nmsClassName) throws ClassNotFoundException { | ||
return Class.forName("net.minecraft.server." + Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3] + "." + nmsClassName); | ||
} | ||
|
||
public void loadConfig() { | ||
Visibility.isDyeEnabled = getConfig().getBoolean("enableDye"); | ||
Visibility.actionBar = getConfig().getBoolean("messages.actionbar"); | ||
|
||
Visibility.dyeColorOn = getConfig().getString("item.true.dye"); | ||
Visibility.dyeColorOff = getConfig().getString("item.false.dye"); | ||
Visibility.itemIdOn = getConfig().getString("item.true.item"); | ||
Visibility.itemIdOff = getConfig().getString("item.false.item"); | ||
|
||
Visibility.timeCooldown = getConfig().getInt("cooldown"); | ||
Visibility.itemSlot = getConfig().getInt("item.slot"); | ||
|
||
Visibility.itemNameOn = getConfig().getString("item.true.name"); | ||
Visibility.itemNameOff = getConfig().getString("item.false.name"); | ||
Visibility.itemLoreOn = getConfig().getString("item.true.lore"); | ||
Visibility.itemLoreOff = getConfig().getString("item.false.lore"); | ||
|
||
Visibility.messagePrefix = getConfig().getString("messages.prefix"); | ||
Visibility.messageCooldown = getConfig().getString("messages.cooldown"); | ||
Visibility.messagePermission = getConfig().getString("messages.permission"); | ||
Visibility.messageToggleOn = getConfig().getString("messages.toggle.true"); | ||
Visibility.messageToggleOff = getConfig().getString("messages.toggle.false"); | ||
Visibility.messageWorld = getConfig().getString("messages.world"); | ||
Visibility.messageAlreadyOn = getConfig().getString("messages.toggle.already.true"); | ||
Visibility.messageAlreadyOff = getConfig().getString("messages.toggle.already.false"); | ||
|
||
Visibility.enabledWorlds = getConfig().getStringList("Enabled-Worlds"); | ||
|
||
Visibility.configVersion = getConfig().getString("config"); | ||
} | ||
} |
125 changes: 125 additions & 0 deletions
125
legacy/src/nl/tomudding/plugins/visibility/commands/Commands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package nl.tomudding.plugins.visibility.commands; | ||
|
||
import org.bukkit.Bukkit; | ||
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.scheduler.BukkitScheduler; | ||
|
||
import nl.tomudding.plugins.visibility.Visibility; | ||
import nl.tomudding.plugins.visibility.listeners.PlayerListener; | ||
import nl.tomudding.plugins.visibility.managers.ChatManager; | ||
import nl.tomudding.plugins.visibility.managers.PlayerManager; | ||
|
||
public class Commands implements CommandExecutor { | ||
|
||
private Visibility plugin; | ||
|
||
public Commands(Visibility plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||
if (sender instanceof Player) { | ||
Player player = (Player) sender; | ||
|
||
if (cmd.getName().equalsIgnoreCase("visibility")) { | ||
if (args.length == 0) { | ||
ChatManager.getInstance().sendCommandMessage(player, ChatColor.YELLOW + "---------- " + ChatColor.GRAY + "Player Visibility" + ChatColor.YELLOW + " ----------"); | ||
ChatManager.getInstance().sendCommandMessage(player, ChatColor.GOLD + "/"+cmd.getName().toLowerCase().toString()+"" + ChatColor.DARK_AQUA + " - This help menu"); | ||
ChatManager.getInstance().sendCommandMessage(player, ChatColor.GOLD + "/"+cmd.getName().toLowerCase().toString()+" info" + ChatColor.DARK_AQUA + " - Information about the plugin"); | ||
ChatManager.getInstance().sendCommandMessage(player, ChatColor.GOLD + "/hide" + ChatColor.DARK_AQUA + " - Hide players"); | ||
ChatManager.getInstance().sendCommandMessage(player, ChatColor.GOLD + "/show" + ChatColor.DARK_AQUA + " - Show players"); | ||
return true; | ||
} else if ((args.length == 1) && (args[0].equalsIgnoreCase("info"))) { | ||
ChatManager.getInstance().sendCommandMessage(player, ChatColor.YELLOW + "---------- " + ChatColor.GRAY + "Player Visibility" + ChatColor.YELLOW + " ----------"); | ||
ChatManager.getInstance().sendCommandMessage(player, ChatColor.DARK_AQUA + "Plugin by - " + ChatColor.GOLD + "tomudding"); | ||
ChatManager.getInstance().sendCommandMessage(player, ChatColor.DARK_AQUA + "Plugin version - " + ChatColor.GOLD + plugin.getDescription().getVersion()); | ||
return true; | ||
} | ||
} else if (cmd.getName().equalsIgnoreCase("hide")) { | ||
if (!player.hasPermission("visibility.command.hide")) { ChatManager.getInstance().sendCommandMessage(player, Visibility.messagePermission); return true; } | ||
if (!Visibility.enabledWorlds.contains(player.getLocation().getWorld().getName().toString())) { ChatManager.getInstance().sendCommandMessage(player, Visibility.messageWorld); return true; } | ||
if (PlayerManager.getInstance().getToggleState(player.getUniqueId()) == false) { ChatManager.getInstance().sendCommandMessage(player, Visibility.messageAlreadyOff); return true; } | ||
if (Visibility.inCooldown.contains(player.getUniqueId())) { | ||
ChatManager.getInstance().sendMessage(player, Visibility.messageCooldown); | ||
return true; | ||
} else { | ||
for (Player onlinePlayers : Bukkit.getOnlinePlayers()) { | ||
if (!onlinePlayers.hasPermission("visibility.ignore")) { | ||
player.hidePlayer(onlinePlayers); | ||
} | ||
} | ||
|
||
player.getInventory().setItem(Visibility.itemSlot, PlayerListener.createItemStack(false)); | ||
PlayerManager.getInstance().setToggle(player.getUniqueId(), false); | ||
|
||
if (!player.hasPermission("visibility.cooldown")) { | ||
Visibility.inCooldown.add(player.getUniqueId()); | ||
|
||
BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); | ||
scheduler.scheduleSyncDelayedTask(this.plugin, new Runnable() { | ||
@Override | ||
public void run() { | ||
Visibility.inCooldown.remove(player.getUniqueId()); | ||
} | ||
}, Visibility.timeCooldown * 20); | ||
} | ||
|
||
ChatManager.getInstance().sendMessage(player, Visibility.messageToggleOff); | ||
return true; | ||
} | ||
} else if (cmd.getName().equalsIgnoreCase("show")) { | ||
if (!player.hasPermission("visibility.command.show")) { ChatManager.getInstance().sendCommandMessage(player, Visibility.messagePermission); return true; } | ||
if (!Visibility.enabledWorlds.contains(player.getLocation().getWorld().getName().toString())) { ChatManager.getInstance().sendCommandMessage(player, Visibility.messageWorld); return true; } | ||
if (PlayerManager.getInstance().getToggleState(player.getUniqueId()) == true) { ChatManager.getInstance().sendCommandMessage(player, Visibility.messageAlreadyOn); return true; } | ||
if (Visibility.inCooldown.contains(player.getUniqueId())) { | ||
ChatManager.getInstance().sendMessage(player, Visibility.messageCooldown); | ||
return true; | ||
} else { | ||
for (Player onlinePlayers : Bukkit.getOnlinePlayers()) { | ||
player.showPlayer(onlinePlayers); | ||
} | ||
|
||
player.getInventory().setItem(Visibility.itemSlot, PlayerListener.createItemStack(false)); | ||
PlayerManager.getInstance().setToggle(player.getUniqueId(), false); | ||
|
||
if (!player.hasPermission("visibility.cooldown")) { | ||
Visibility.inCooldown.add(player.getUniqueId()); | ||
|
||
BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); | ||
scheduler.scheduleSyncDelayedTask(this.plugin, new Runnable() { | ||
@Override | ||
public void run() { | ||
Visibility.inCooldown.remove(player.getUniqueId()); | ||
} | ||
}, Visibility.timeCooldown * 20); | ||
} | ||
|
||
ChatManager.getInstance().sendMessage(player, Visibility.messageToggleOn); | ||
return true; | ||
} | ||
} | ||
} else { | ||
if (cmd.getName().equalsIgnoreCase("visibility")) { | ||
if (args.length == 0) { | ||
ChatManager.getInstance().log(ChatColor.YELLOW + "---------- " + ChatColor.GRAY + "Player Visibility" + ChatColor.YELLOW + " ----------"); | ||
ChatManager.getInstance().log(ChatColor.GOLD + "/"+cmd.getName().toLowerCase().toString()+"" + ChatColor.DARK_AQUA + " - This help menu"); | ||
ChatManager.getInstance().log(ChatColor.GOLD + "/"+cmd.getName().toLowerCase().toString()+" info" + ChatColor.DARK_AQUA + " - Information about the plugin"); | ||
return true; | ||
} else if ((args.length == 1) && (args[0].equalsIgnoreCase("info"))) { | ||
ChatManager.getInstance().log(ChatColor.YELLOW + "---------- " + ChatColor.GRAY + "Player Visibility" + ChatColor.YELLOW + " ----------"); | ||
ChatManager.getInstance().log(ChatColor.DARK_AQUA + "Plugin by - " + ChatColor.GOLD + "tomudding"); | ||
ChatManager.getInstance().log(ChatColor.DARK_AQUA + "Plugin version - " + ChatColor.GOLD + plugin.getDescription().getVersion()); | ||
return true; | ||
} | ||
} else if ((cmd.getName().equalsIgnoreCase("hide")) || (cmd.getName().equalsIgnoreCase("show"))) { | ||
ChatManager.getInstance().log("&cThis command is player-only."); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.