Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String[] applyFormat(String format, Player player) {
- List<String> formats = new ArrayList<String>();
- int i;
- while (format.indexOf("%") > -1) {
- i = format.indexOf("%");
- format = format.substring(i);
- if (format.indexOf("%name%") == 0) {
- format = format.replaceFirst("%name%","");
- formats.add(player.getName());
- }
- else if (format.indexOf("%displayname%") == 0) {
- format = format.replaceFirst("%displayname%","");
- formats.add(player.getDisplayName());
- }
- else if (format.indexOf("%prefix%") == 0) {
- format = format.replaceFirst("%prefix%","");
- Importer importer = null;
- File pexfile = new File("plugins/PermissionsEx/permissions.yml");
- File ppfile = new File("plugins/PowerPerms/config.yml");
- if (pexfile.exists()) importer = new PermissionsExImporter(pexfile);
- else if (ppfile.exists()) importer = new PowerPermsImporter(ppfile);
- String prefix = importer != null ? importer.getPrefix(player.getUniqueId()) : new String("");
- formats.add(prefix);
- }
- else if (format.indexOf("%suffix%") == 0) {
- format = format.replaceFirst("%suffix%","");
- Importer importer = null;
- File pexfile = new File("plugins/PermissionsEx/permissions.yml");
- File ppfile = new File("plugins/PowerPerms/config.yml");
- if (pexfile.exists()) importer = new PermissionsExImporter(pexfile);
- else if (ppfile.exists()) importer = new PowerPermsImporter(ppfile);
- String suffix = importer != null ? importer.getSuffix(player.getUniqueId()) : new String("");
- formats.add(suffix);
- }
- else if (format.indexOf("%rank%") == 0) {
- format = format.replaceFirst("%rank%","");
- Importer importer = null;
- File pexfile = new File("plugins/PermissionsEx/permissions.yml");
- File ppfile = new File("plugins/PowerPerms/config.yml");
- if (pexfile.exists()) importer = new PermissionsExImporter(pexfile);
- else if (ppfile.exists()) importer = new PowerPermsImporter(ppfile);
- String rank = importer != null ? importer.getRank(player.getUniqueId()) : new String("");
- formats.add(rank);
- }
- else if (format.indexOf("%rank%") == 0) {
- format = format.replaceFirst("%world%","");
- formats.add(player.getWorld().getName());
- }
- }
- Bukkit.broadcastMessage(formats.get(0));
- return formats.toArray(new String[32]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement