Permalink
Browse files

fixed backward compatibility(with ver 1.2.2)

corected errors handling code
changed version to 1.2.4
  • Loading branch information...
1 parent 66b8a3c commit b96c07568f1f312c4ed1064733d5426efae4b9a4 @Rutr committed Jun 5, 2012
View
@@ -1,2 +1,4 @@
/target/
-/nbproject/private/
+/nbproject/private/
+/build/
+/dist/
@@ -3,7 +3,7 @@ annotation.processing.enabled.in.editor=false
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=AZRank
-application.vendor=Ucze\u01449
+application.vendor=Rutr
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
@@ -30,7 +30,9 @@ file.reference.AZRank-src=src
file.reference.bukkit-1.2.5-R3.0.jar=lib/bukkit-1.2.5-R3.0.jar
file.reference.Vault.jar=lib/Vault.jar
includes=**
+jar.archive.disabled=${jnlp.enabled}
jar.compress=false
+jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.Vault.jar}:\
${file.reference.bukkit-1.2.5-R3.0.jar}
@@ -57,6 +59,15 @@ javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
+jnlp.codebase.type=no.codebase
+jnlp.descriptor=application
+jnlp.enabled=false
+jnlp.mixed.code=default
+jnlp.offline-allowed=false
+jnlp.signed=false
+jnlp.signing=
+jnlp.signing.alias=
+jnlp.signing.keystore=
main.class=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
@@ -414,19 +414,15 @@ public boolean setGroups(String name, String[] oldGroups) {
try {
return permBridge.setPlayersGroups(name, oldGroups);
} catch(Exception e) {
- log.severe("[AZRank][ERROR]" + e.getMessage());
+ log.severe("[AZRank][Exception]when setting group|" + e.getMessage());
+ e.printStackTrace();
return false;
}
}
@Deprecated
public boolean setGroup(String name, String group) {
- try {
- String[] groups ={group};
- return permBridge.setPlayersGroups(name, groups);
- } catch(Exception e) {
- log.severe("[AZRank][ERROR]" + e.getMessage());
- return false;
- }
+ String[] groups ={group};
+ return setGroups(name,groups);
}
@Deprecated
@@ -22,19 +22,17 @@ protected Cfg(AZRank plugin) {
this.plugin = plugin;
}
+ @SuppressWarnings("CallToThreadDumpStack")
protected boolean loadConfig() {
try {
config.load(plugin.yml);
} catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
return false;
} catch (IOException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
return false;
} catch (InvalidConfigurationException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
return false;
}
@@ -53,10 +53,19 @@ public void run() {
plugin.database.set("users." + userName, null);
plugin.save();
} else {
- plugin.log.severe("[AZRank][ERROR]" + "Permissions Manger didnt changed groups.\nYou should manualy remove groups in permissions manager, and later in database.yml");
+ String oldGroupsS="[";
+ if (oldGroups.size() > 0) {
+ oldGroupsS += oldGroups.get(0); // start with the first element
+ for (int i=1; i<oldGroups.size(); i++) {
+ oldGroupsS += ", " + oldGroups.get(i);
+ }
+ }
+ oldGroupsS+="]";
+ plugin.log.severe("[AZRank][ERROR]F " + "Failed to restore group for "+userName+" to "+oldGroupsS+".\nYou should manualy retore player groups in permissions manager, and later in database.yml");
}
} catch (Exception e) {
- plugin.log.severe("[AZRank][ERROR]" + e.getMessage());
+ plugin.log.severe("[AZRank][ERROR]E " + e.getMessage());
+ e.printStackTrace();
}
} else {
@@ -28,25 +28,54 @@ public String getName() {
@Override
public String[] getPlayersGroups(String player){
- return pp.getPlayerGroups((String) null, player);
+ String[] groups = pp.getPlayerGroups((String) null, player);
+ if(groups == null)
+ {
+ String world=plugin.getServer().getWorlds().get(0).getName();
+ return pp.getPlayerGroups(world, player);
+ }
+ else
+ return groups;
}
public boolean setPlayersGroups(String player, String[] groups){
String[] oldGroups=pp.getPlayerGroups((String) null,player);
int i=0;
+ String defaultWorld=plugin.getServer().getWorlds().get(0).getName();
+ if(oldGroups==null)
+ { //to backward compatybility
+
+ oldGroups=pp.getPlayerGroups(defaultWorld,player);
+ }
for(String group : oldGroups)
{
- if(!pp.playerRemoveGroup((String) null,player, group))
- plugin.debugmsg("i cant remove group: "+ group + " from player: "+player);
+ if(!pp.playerRemoveGroup((String) null, player, group))
+ {
+ if(!pp.playerRemoveGroup(defaultWorld, player, group))
+ plugin.debugmsg("Failed to remove group: "+ group + " from player: "+player);
+ else{
+ plugin.debugmsg("Globaly failed, Removed localy group: "+ group + " from player: "+player+" w:"+defaultWorld);
+ i++;
+ }
+ }
else
i++;
}
+
int j=0;
for(String group : groups)
{
if(!pp.playerAddGroup((String) null,player, group))
- plugin.debugmsg("i cant add group: "+ group + " to player: "+player);
+ {
+ if(!pp.playerAddGroup(defaultWorld,player, group))
+ plugin.debugmsg("Failed to add group: "+ group + " to player: "+player);
+ else
+ {
+ plugin.debugmsg("Globaly failed, Added localy group: "+ group + " from player: "+player+" w:"+defaultWorld);
+ j++;
+ }
+ }
else
j++;
}
View
@@ -2,7 +2,7 @@ author: Rutr
description: Easier method to set the groups of players
main: pl.azpal.azrank.AZRank
name: AZRank
-version: 1.2.3
+version: 1.2.4
depend: [Vault]
commands:
azrank:

0 comments on commit b96c075

Please sign in to comment.