Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 10, 2018 21:14:50 GMT
I want my plugin to be able to check if a player has a rank. Would i need to add tfm as a library? Also i use eclipse. I dont know how to do this? Thanks in advance!
|
|
fionn
Club 4000 Member
Admin Officer
elmon sucks
Posts: 6,157
| Likes: 4,775
|
Post by fionn on Sept 10, 2018 21:25:51 GMT
you can either pull a marco and grab the codes from the github repository, OR if its a freeOP server, just use the TF mod
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 10, 2018 21:51:15 GMT
In what regards? You can restrict a command to a specific rank in the CommandPermissions. If you want to restrict a block of code or only a certain arg whitelist and myadmin are good examples. Otherwise just use if (plugin.al.isAdmin())
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 10, 2018 22:15:13 GMT
In what regards? You can restrict a command to a specific rank in the CommandPermissions. If you want to restrict a block of code or only a certain arg whitelist and myadmin are good examples. Otherwise just use if (plugin.al.isAdmin()) But do i need to put tfm as a library in my plugin? The plugin i use is not a modified tfm but i need tfm to check for rank. Also is there a way to check for a specific rank?
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 11, 2018 1:13:44 GMT
In what regards? You can restrict a command to a specific rank in the CommandPermissions. If you want to restrict a block of code or only a certain arg whitelist and myadmin are good examples. Otherwise just use if (plugin.al.isAdmin()) But do i need to put tfm as a library in my plugin? The plugin i use is not a modified tfm but i need tfm to check for rank. Also is there a way to check for a specific rank? So you want to check if a person is an admin from an external plugin? Use this code public class SuperAdminProvider { public static final boolean DEBUG = true; private static Logger logger; private static Function<Player, Boolean> superAdminProvider;
public static void setLogger(Logger logger) { SuperAdminProvider.logger = logger; }
public static Plugin getTFM() { final Plugin tfm = Bukkit.getPluginManager().getPlugin("TotalFreedomMod"); if (tfm == null) { logger.warning("Could not resolve plugin: TotalFreedomMod"); }
return tfm; }
@SuppressWarnings("unchecked") public static boolean isSuperAdmin(Player player) {
if (superAdminProvider == null) { final Plugin tfm = getTFM(); if (tfm == null) { return false; }
Object provider = null; for (RegisteredServiceProvider<?> serv : Bukkit.getServicesManager().getRegistrations(tfm)) { if (Function.class.isAssignableFrom(serv.getService())) { provider = serv.getProvider(); } }
if (provider == null) { warning("Could not obtain Super Admin service provider!"); return false; }
superAdminProvider = (Function<Player, Boolean>) provider; }
return superAdminProvider.apply(player); }
public static void debug(String debug) { if (DEBUG) { info(debug); } }
public static void warning(String warning) { logger.warning(warning); }
public static void info(String info) { logger.info(info); } }
That checks if you're a SA and can be used by if (SuperAdminProvider.isSuperAdmin());
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 11, 2018 16:40:23 GMT
But do i need to put tfm as a library in my plugin? The plugin i use is not a modified tfm but i need tfm to check for rank. Also is there a way to check for a specific rank? So you want to check if a person is an admin from an external plugin? Use this code public class SuperAdminProvider { public static final boolean DEBUG = true; private static Logger logger; private static Function<Player, Boolean> superAdminProvider;
public static void setLogger(Logger logger) { SuperAdminProvider.logger = logger; }
public static Plugin getTFM() { final Plugin tfm = Bukkit.getPluginManager().getPlugin("TotalFreedomMod"); if (tfm == null) { logger.warning("Could not resolve plugin: TotalFreedomMod"); }
return tfm; }
@SuppressWarnings("unchecked") public static boolean isSuperAdmin(Player player) {
if (superAdminProvider == null) { final Plugin tfm = getTFM(); if (tfm == null) { return false; }
Object provider = null; for (RegisteredServiceProvider<?> serv : Bukkit.getServicesManager().getRegistrations(tfm)) { if (Function.class.isAssignableFrom(serv.getService())) { provider = serv.getProvider(); } }
if (provider == null) { warning("Could not obtain Super Admin service provider!"); return false; }
superAdminProvider = (Function<Player, Boolean>) provider; }
return superAdminProvider.apply(player); }
public static void debug(String debug) { if (DEBUG) { info(debug); } }
public static void warning(String warning) { logger.warning(warning); }
public static void info(String info) { logger.info(info); } }
That checks if you're a SA and can be used by if (SuperAdminProvider.isSuperAdmin()); Do i add tfm as a library?
|
|
Wild1145
Club 4000 Member
Inactive Player & Inactive Senior Admin
Posts: 10,414
| Likes: 9,680
|
Post by Wild1145 on Sept 11, 2018 18:25:13 GMT
You would need to add TFM as a library yes, that way you can execute TFM methods from your own plugin, such as checking for things like if they are an admin.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 11, 2018 19:06:34 GMT
So you want to check if a person is an admin from an external plugin? Use this code public class SuperAdminProvider { public static final boolean DEBUG = true; private static Logger logger; private static Function<Player, Boolean> superAdminProvider;
public static void setLogger(Logger logger) { SuperAdminProvider.logger = logger; }
public static Plugin getTFM() { final Plugin tfm = Bukkit.getPluginManager().getPlugin("TotalFreedomMod"); if (tfm == null) { logger.warning("Could not resolve plugin: TotalFreedomMod"); }
return tfm; }
@SuppressWarnings("unchecked") public static boolean isSuperAdmin(Player player) {
if (superAdminProvider == null) { final Plugin tfm = getTFM(); if (tfm == null) { return false; }
Object provider = null; for (RegisteredServiceProvider<?> serv : Bukkit.getServicesManager().getRegistrations(tfm)) { if (Function.class.isAssignableFrom(serv.getService())) { provider = serv.getProvider(); } }
if (provider == null) { warning("Could not obtain Super Admin service provider!"); return false; }
superAdminProvider = (Function<Player, Boolean>) provider; }
return superAdminProvider.apply(player); }
public static void debug(String debug) { if (DEBUG) { info(debug); } }
public static void warning(String warning) { logger.warning(warning); }
public static void info(String info) { logger.info(info); } }
That checks if you're a SA and can be used by if (SuperAdminProvider.isSuperAdmin()); Do i add tfm as a library? No the point of that code is that you don't have to add it as library
|
|