From cf58beb7b585ed852fc23dfbae3a9239994dca80 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Fri, 17 Apr 2015 19:21:55 +0800 Subject: [PATCH] Various fixes. Closes #1970 * Update POM to be able to compile ! Fix rank ladder fetching ! Fix when swapping group, the position of group changed unexpectedly --- pom.xml | 2 +- .../java/ru/tehkode/permissions/PermissionGroup.java | 2 +- .../java/ru/tehkode/permissions/PermissionUser.java | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index dfa83c31e..dc4596b2d 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ com.zachsthings netevents - 1.0 + 1.1-SNAPSHOT provided diff --git a/src/main/java/ru/tehkode/permissions/PermissionGroup.java b/src/main/java/ru/tehkode/permissions/PermissionGroup.java index f6bd29cfe..75b2a074c 100644 --- a/src/main/java/ru/tehkode/permissions/PermissionGroup.java +++ b/src/main/java/ru/tehkode/permissions/PermissionGroup.java @@ -108,7 +108,7 @@ public void setRank(int rank) { * @return Name of rank ladder as String */ public String getRankLadder() { - return this.getOwnOption("rank-ladder", "", "default"); + return this.getOwnOption("rank-ladder", null, "default"); } /** diff --git a/src/main/java/ru/tehkode/permissions/PermissionUser.java b/src/main/java/ru/tehkode/permissions/PermissionUser.java index 570fd9abb..030622da7 100644 --- a/src/main/java/ru/tehkode/permissions/PermissionUser.java +++ b/src/main/java/ru/tehkode/permissions/PermissionUser.java @@ -19,6 +19,7 @@ package ru.tehkode.permissions; import com.google.common.collect.Maps; +import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import ru.tehkode.permissions.events.PermissionEntityEvent; @@ -487,10 +488,15 @@ protected int getPromoterRankAndCheck(PermissionUser promoter, String ladderName } protected void swapGroups(PermissionGroup src, PermissionGroup dst) { + Validate.notNull(src); + Validate.notNull(dst); + List groups = new ArrayList<>(this.getParents()); + int indexOfSrcGroup = groups.indexOf(src); + + Validate.isTrue(indexOfSrcGroup != -1); - groups.remove(src); - groups.add(dst); + groups.set(indexOfSrcGroup, dst); this.setParents(groups); }