Skip to content

Commit

Permalink
Add workaround for PaperMC's broken Ban API
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeprimm committed Jul 8, 2023
1 parent 3715b11 commit cee25bc
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions spigot/src/main/java/org/dynmap/bukkit/DynmapPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public DynmapPlugin() {
}
}

private boolean banBrokenMsg = false;
/**
* Server access abstraction class
*/
Expand Down Expand Up @@ -315,12 +316,22 @@ public String getServerName() {
}
return getServer().getMotd();
}
private boolean isBanned(OfflinePlayer p) {
try {
if ((!banBrokenMsg) && (p != null) && p.isBanned()) {
return true;
}
} catch (Exception x) {
Log.severe("Server error - broken Ban API - ban check disabled - this may allow banned players to log in!!!", x);
Log.severe("REPORT ERROR TO "+ Bukkit.getServer().getVersion() + " DEVELOPERS - THIS IS NOT DYNMAP ISSUE");
banBrokenMsg = true;
}
return false;
}
@Override
public boolean isPlayerBanned(String pid) {
OfflinePlayer p = getServer().getOfflinePlayer(pid);
if((p != null) && p.isBanned())
return true;
return false;
return isBanned(p);
}
@Override
public boolean isServerThread() {
Expand Down Expand Up @@ -464,7 +475,7 @@ public DynmapPlayer getOfflinePlayer(String name) {
@Override
public Set<String> checkPlayerPermissions(String player, Set<String> perms) {
OfflinePlayer p = getServer().getOfflinePlayer(player);
if(p.isBanned())
if (isBanned(p))
return new HashSet<String>();
Set<String> rslt = permissions.hasOfflinePermissions(player, perms);
if (rslt == null) {
Expand All @@ -478,7 +489,7 @@ public Set<String> checkPlayerPermissions(String player, Set<String> perms) {
@Override
public boolean checkPlayerPermission(String player, String perm) {
OfflinePlayer p = getServer().getOfflinePlayer(player);
if(p.isBanned())
if (isBanned(p))
return false;
boolean rslt = permissions.hasOfflinePermission(player, perm);
return rslt;
Expand Down

0 comments on commit cee25bc

Please sign in to comment.