Skip to content

Commit

Permalink
Merge pull request #129 from weaves7/master
Browse files Browse the repository at this point in the history
Permissions bug fix and more loading info
  • Loading branch information
weaves7 authored Jan 3, 2022
2 parents 78f9872 + 4f2d812 commit 6c985c9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
12 changes: 11 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<url>https://ci.ender.zone/plugin/repository/everything/</url>
</repository>
<repository>
<id>rutger-repo</id>
<url>http://www.rutgerkok.nl/repo</url>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
Expand All @@ -43,7 +43,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations-java5</artifactId>
<version>RELEASE</version>
<version>22.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public static void setupOperations(Map<String, String> allSignOperations, String
boolean failedOp = false;
List<String> tempCheckedSignOperation = new LinkedList<>();

for (String tempOperationString : allSignOperations.get(sKey).split(",")) {
for (String tempOperationString : allSignOperations.get(sKey).split("(,(?![^{]*}))")) { //Matches commas outside of curly braces
List<String> bits = signshopUtil.getParameters(tempOperationString.trim());
String op = bits.get(0);
Object opinstance = getInstance(packageName + "." + op.trim());
Expand Down Expand Up @@ -875,8 +875,8 @@ private enum LanguageSpelling {
RUSSIAN("russian", "ru_RU"),
SPANISH("spanish", "es_ES");

String oldName;
String localeName;
final String oldName;
final String localeName;

LanguageSpelling(String oldName, String localeName) {
this.oldName = oldName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private Storage(File ymlFile) {

// Load into memory, this also removes invalid signs (hence the backup)
Boolean needToSave = Load();

if(needToSave) {
File backupTo = new File(ymlFile.getPath()+".bak");
if(backupTo.exists())
Expand Down Expand Up @@ -216,11 +217,13 @@ private boolean loadSellerFromSettings(String key, HashMap<String,List<String>>
}

private Boolean Load() {
SignShop.log("Loading and validating shops, please wait...",Level.INFO);
FileConfiguration yml = YamlConfiguration.loadConfiguration(ymlfile);
ConfigurationSection sellersection = yml.getConfigurationSection("sellers");
if(sellersection == null)
if(sellersection == null) {
SignShop.log("There are no shops available. This is likely your first startup with SignShop.",Level.INFO);
return false;

}
Map<String,HashMap<String,List<String>>> tempSellers = configUtil.fetchHashmapInHashmapwithList("sellers", yml);
if(tempSellers == null) {
SignShop.log("Invalid sellers.yml format detected. Old sellers format is no longer supported."
Expand All @@ -229,6 +232,7 @@ private Boolean Load() {
return false;
}
if (tempSellers.isEmpty()) {
SignShop.log("Loaded zero valid shops.",Level.INFO);
return false;
}

Expand All @@ -240,6 +244,7 @@ private Boolean Load() {
}

Bukkit.getPluginManager().registerEvents(this, SignShop.getInstance());
SignShop.log("Loaded " + shopCount() + " valid shops.", Level.INFO);
return needSave;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public boolean isOp(World world, String perm) {
if (isOpRaw())
return true;
String fullperm = (perm.isEmpty() ? "SignShop.SuperAdmin" : "SignShop.SuperAdmin." + perm);
return SignShop.usePermissions() && Vault.getPermission().playerHas(world.toString(), getOfflinePlayer(), fullperm.toLowerCase());
return SignShop.usePermissions() && Vault.getPermission().playerHas(world.getName(), getOfflinePlayer(), fullperm.toLowerCase());
}

private boolean isOpRaw() {
Expand Down Expand Up @@ -188,7 +188,7 @@ public boolean hasPerm(String perm, World world, Boolean OPOperation) {
setOp(false);
// Having Signshop.Superadmin while Permissions are in use should allow you to do everything with SignShop
// And since the node is explicitly given to a player, the OPOverride setting is not relevant
if (SignShop.usePermissions() && Vault.getPermission().playerHas(world.toString(), getOfflinePlayer(), "signshop.superadmin")) {
if (SignShop.usePermissions() && Vault.getPermission().playerHas(world.getName(), getOfflinePlayer(), "signshop.superadmin")) {
setOp(isOP);
return true;
}
Expand All @@ -197,7 +197,7 @@ public boolean hasPerm(String perm, World world, Boolean OPOperation) {
if (SignShop.usePermissions() && OPOverride && isOP)
return true;
// Using Permissions so check his permissions and restore his OP if he has it
else if (SignShop.usePermissions() && Vault.getPermission().playerHas(world.toString(), getOfflinePlayer(), perm.toLowerCase())) {
else if (SignShop.usePermissions() && Vault.getPermission().playerHas(world.getName(), getOfflinePlayer(), perm.toLowerCase())) {
setOp(isOP);
return true;
// Not using Permissions but he is OP, so he's allowed
Expand Down

0 comments on commit 6c985c9

Please sign in to comment.