Skip to content

Commit

Permalink
properly check the permissions lol
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Aug 23, 2024
1 parent 5c0c7cc commit d00bb4f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {

val buildNumber: String? = System.getenv("BUILD_NUMBER")

rootProject.version = if (buildNumber != null) "${libs.versions.minecraft.get()}-$buildNumber" else "3.7"
rootProject.version = if (buildNumber != null) "${libs.versions.minecraft.get()}-$buildNumber" else "3.7.1"

val isSnapshot = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,18 @@ public final boolean isCrateEventValid(@NotNull final KeyType keyType, final boo
if (MiscUtils.isLogging()) {
final String fileName = crate.getFileName();

if (this.player.hasPermission(this.config.getProperty(ConfigKeys.use_new_permission_system) ? "crazycrates.deny.open." + fileName : "crazycrates.open." + fileName)) {
this.plugin.getComponentLogger().warn("{} could not open {} due to having the permission preventing them from opening the crate.", this.player.getName(), fileName);
if (this.config.getProperty(ConfigKeys.use_new_permission_system)) {
if (this.player.hasPermission("crazycrates.deny.open." + fileName)) {
this.plugin.getComponentLogger().warn("{} could not open {} due to having the permission preventing them from opening the crate.", this.player.getName(), fileName);
} else {
this.plugin.getComponentLogger().warn("{} could not open {} due to no valid prizes being found which led to the event being cancelled.", this.player.getName(), fileName);
}
} else {
this.plugin.getComponentLogger().warn("{} could not open {} due to no valid prizes being found which led to the event being cancelled.", this.player.getName(), fileName);
if (!this.player.hasPermission("crazycrates.open." + fileName)) {
this.plugin.getComponentLogger().warn("{} could not open {} due to having the permission preventing them from opening the crate.", this.player.getName(), fileName);
} else {
this.plugin.getComponentLogger().warn("{} could not open {} due to no valid prizes being found which led to the event being cancelled.", this.player.getName(), fileName);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,28 @@ public void onCrateOpen(CrateOpenEvent event) {
}
}

if (player.hasPermission(this.config.getProperty(ConfigKeys.use_new_permission_system) ? "crazycrates.deny.open." + fileName : "crazycrates.open." + fileName)) {
Messages.no_crate_permission.sendMessage(player, "{crate}", fancyName);
if (this.config.getProperty(ConfigKeys.use_new_permission_system)) {
if (player.hasPermission("crazycrates.deny.open." + fileName)) {
Messages.no_crate_permission.sendMessage(player, "{crate}", fancyName);

this.crateManager.removePlayerFromOpeningList(player);
this.crateManager.removeCrateInUse(player);
this.crateManager.removePlayerFromOpeningList(player);
this.crateManager.removeCrateInUse(player);

event.setCancelled(true);

event.setCancelled(true);
return;
}
} else {
if (!player.hasPermission("crazycrates.open." + fileName)) {
Messages.no_crate_permission.sendMessage(player, "{crate}", fancyName);

return;
this.crateManager.removePlayerFromOpeningList(player);
this.crateManager.removeCrateInUse(player);

event.setCancelled(true);

return;
}
}

this.crateManager.addPlayerToOpeningList(player, crate);
Expand Down

0 comments on commit d00bb4f

Please sign in to comment.