Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
fix the showkit shit
Browse files Browse the repository at this point in the history
  • Loading branch information
superischroma committed Jan 5, 2020
1 parent c705a7b commit 07b44ad
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
41 changes: 40 additions & 1 deletion Essentials/src/com/earth2me/essentials/TFMHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -61,12 +62,50 @@ public boolean isAdmin(Player player)
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ private String getLocal(final Server server, final User user, final long radius)
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)");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public void run(final Server server, final User user, final String commandLabel,
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);
}
}
}
Expand Down

0 comments on commit 07b44ad

Please sign in to comment.