mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-12-28 11:04:21 +00:00
fix the showkit shit
This commit is contained in:
parent
c705a7be88
commit
07b44ad5b9
3 changed files with 49 additions and 2 deletions
|
@ -12,6 +12,7 @@ public class TFMHandler
|
|||
{
|
||||
private static Logger logger;
|
||||
private static Function<Player, Boolean> adminProvider;
|
||||
private static Function<Player, Boolean> vanishProvider;
|
||||
|
||||
public static void setLogger(Logger logger)
|
||||
{
|
||||
|
@ -61,12 +62,50 @@ public class TFMHandler
|
|||
return false;
|
||||
}
|
||||
|
||||
adminProvider = (Function<Player, Boolean>)provider;
|
||||
adminProvider = (Function<Player, Boolean>) provider;
|
||||
}
|
||||
|
||||
return adminProvider.apply(player);
|
||||
}
|
||||
|
||||
public boolean isVanished(User user)
|
||||
{
|
||||
return isVanished(user.getBase());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "ConstantConditions"})
|
||||
public boolean isVanished(Player player)
|
||||
{
|
||||
|
||||
if (vanishProvider == 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 vanish service provider!");
|
||||
return false;
|
||||
}
|
||||
|
||||
vanishProvider = (Function<Player, Boolean>) provider;
|
||||
}
|
||||
|
||||
return vanishProvider.apply(player);
|
||||
}
|
||||
|
||||
public static void warning(String warning)
|
||||
{
|
||||
logger.warning(warning);
|
||||
|
|
|
@ -106,6 +106,10 @@ public class Commandnear extends EssentialsCommand {
|
|||
output.append(", ");
|
||||
}
|
||||
User nearbyPlayer = nearbyPlayers.poll();
|
||||
if (getTFMHandler().isVanished(user))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
output.append(nearbyPlayer.getDisplayName()).append("§f(§4").append((long) nearbyPlayer.getLocation().distance(loc)).append("m§f)");
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,11 @@ public class Commandshowkit extends EssentialsCommand {
|
|||
Kit kit = new Kit(kitName, ess);
|
||||
user.sendMessage(tl("kitContains", kitName));
|
||||
for (String s : kit.getItems()) {
|
||||
user.sendMessage(tl("kitItem", s));
|
||||
String item = tl("kitItem", s);
|
||||
if (item.length() >= 50) {
|
||||
item = item.substring(0, 50);
|
||||
}
|
||||
user.sendMessage(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue