Skip to content

Commit

Permalink
flip the config option
Browse files Browse the repository at this point in the history
This now, decides if true to use the new permission change otherwise use the old one
  • Loading branch information
ryderbelserion committed Aug 23, 2024
1 parent b3b3805 commit 5c0c7cc
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Added:
- Added a toggle, which allows you to revert the chance made previously.
- crazycrates.open.<crate_name> -> crazycrates.deny.open.<crate_name>
- The configuration option can be found in the `config.yml` i.e. `root.use-old-permission-system`
- The configuration option can be found in the `config.yml` i.e. `root.use-new-permission-system`
- This option likely won't be here forever, one of the systems will be default. You'll be notified when that happens.
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ 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_old_permission_system) ? "crazycrates.open." + fileName : "crazycrates.deny.open." + fileName)) {
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);
} 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 @@ -98,13 +98,13 @@ public void registerComments(CommentsConfiguration conf) {
"",
"It feels right to make a toggle for it regardless.",
"",
"true -> crazycrates.open.<crate-name>",
"false -> crazycrates.deny.open.<crate_name>",
"false -> crazycrates.open.<crate-name>",
"true -> crazycrates.deny.open.<crate_name>",
"",
"Eventually, one of these options will be either removed or kept.",
"Changing this option requires you to restart your server!"
})
public static final Property<Boolean> use_old_permission_system = newProperty("root.use-old-permission-system", false);
public static final Property<Boolean> use_new_permission_system = newProperty("root.use-new-permission-system", false);

@Comment({
"This option will tell the plugin to send all messages as action bars or messages in chat.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void onCrateOpen(CrateOpenEvent event) {
}
}

if (player.hasPermission(this.config.getProperty(ConfigKeys.use_old_permission_system) ? "crazycrates.open." + fileName : "crazycrates.deny.open." + fileName)) {
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);

this.crateManager.removePlayerFromOpeningList(player);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.badbones69.crazycrates.support;

import ch.jalu.configme.SettingsManager;
import com.badbones69.crazycrates.CrazyCrates;
import com.badbones69.crazycrates.api.objects.Crate;
import com.badbones69.crazycrates.config.ConfigManager;
import com.badbones69.crazycrates.config.impl.ConfigKeys;
import com.badbones69.crazycrates.tasks.crates.CrateManager;
import com.ryderbelserion.vital.paper.api.bStats;
import us.crazycrew.crazycrates.api.enums.types.CrateType;
Expand All @@ -15,8 +12,6 @@ public class MetricsWrapper extends bStats {

private final CrateManager crateManager;

private final SettingsManager config = ConfigManager.getConfig();

/**
* Creates a new Metrics instance.
*
Expand All @@ -43,7 +38,5 @@ public void start() {

addCustomChart(chart);
});

addCustomChart(new SimplePie("use_old_permission_system", () -> String.valueOf(this.config.getProperty(ConfigKeys.use_old_permission_system))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,11 @@ public void loadCrates() {

final PluginManager server = this.plugin.getServer().getPluginManager();

final boolean isOldSystemEnabled = this.config.getProperty(ConfigKeys.use_old_permission_system);
final boolean isNewSystemEnabled = this.config.getProperty(ConfigKeys.use_new_permission_system);

final String node = isOldSystemEnabled ? "crazycrates.open." + crateName : "crazycrates.deny.open." + crateName;
final String description = isOldSystemEnabled ? "Lets you open " + crateName : "Prevents you from opening " + crateName;
final PermissionDefault permissionDefault = isOldSystemEnabled ? PermissionDefault.TRUE : PermissionDefault.FALSE;
final String node = isNewSystemEnabled ? "crazycrates.deny.open." + crateName : "crazycrates.open." + crateName;
final String description = isNewSystemEnabled ? "Prevents you from opening " + crateName : "Lets you open " + crateName;
final PermissionDefault permissionDefault = isNewSystemEnabled ? PermissionDefault.FALSE : PermissionDefault.TRUE;

if (server.getPermission(node) == null) {
final Permission permission = new Permission(node, description, permissionDefault);
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ root:
#
# It feels right to make a toggle for it regardless.
#
# true -> crazycrates.open.<crate-name>
# false -> crazycrates.deny.open.<crate_name>
# false -> crazycrates.open.<crate-name>
# true -> crazycrates.deny.open.<crate_name>
#
# Eventually, one of these options will be either removed or kept.
# Changing this option requires you to restart your server!
use-old-permission-system: false
use-new-permission-system: false
# This option will tell the plugin to send all messages as action bars or messages in chat.
#
# send_message -> sends messages in chat.
Expand Down

0 comments on commit 5c0c7cc

Please sign in to comment.