LINKEDHASHMAP ORDER IS ALL RRRRAAAAAAAAA (non i'm not angry :@)

This commit is contained in:
Michel Roux 2012-05-09 18:02:27 +02:00
parent bf82bc2995
commit 346533098d
3 changed files with 9 additions and 8 deletions

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -207,7 +208,7 @@ public class SimplyPlugin extends JavaPlugin {
return calculateGroupPermissions(default_group, world); return calculateGroupPermissions(default_group, world);
} }
Map<String, Boolean> perms = new HashMap<String, Boolean>(); Map<String, Boolean> perms = new LinkedHashMap<String, Boolean>();
List<String> groups = config.getPlayerGroups(player); List<String> groups = config.getPlayerGroups(player);
if (groups.isEmpty()) groups.add(default_group); if (groups.isEmpty()) groups.add(default_group);
perms.putAll(config.getPlayerPermissions(player)); perms.putAll(config.getPlayerPermissions(player));
@ -227,7 +228,7 @@ public class SimplyPlugin extends JavaPlugin {
private Map<String, Boolean> calculateGroupPermissions(String group, String world) { private Map<String, Boolean> calculateGroupPermissions(String group, String world) {
if (getNode("groups/" + group) == null) { if (getNode("groups/" + group) == null) {
return new HashMap<String, Boolean>(); return new LinkedHashMap<String, Boolean>();
} }
Map<String, Boolean> perms = config.getGroupPermissions(group); Map<String, Boolean> perms = config.getGroupPermissions(group);

View File

@ -1,7 +1,7 @@
package net.crystalyx.bukkit.simplyperms.io; package net.crystalyx.bukkit.simplyperms.io;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -106,7 +106,7 @@ public class ConfigFile implements PermsConfig {
@Override @Override
public Map<String, Boolean> getPlayerPermissions(String player, String world) { public Map<String, Boolean> getPlayerPermissions(String player, String world) {
Map<String, Boolean> finalPerms = new HashMap<String, Boolean>(); Map<String, Boolean> finalPerms = new LinkedHashMap<String, Boolean>();
String permNode = (!world.isEmpty()) ? "users/" + player + "/worlds/" + world : "users/" + player + "/permissions"; String permNode = (!world.isEmpty()) ? "users/" + player + "/worlds/" + world : "users/" + player + "/permissions";
if (plugin.getNode(permNode) != null) { if (plugin.getNode(permNode) != null) {
for (Entry<String, Object> permPlayer : plugin.getNode(permNode).getValues(false).entrySet()) { for (Entry<String, Object> permPlayer : plugin.getNode(permNode).getValues(false).entrySet()) {
@ -193,7 +193,7 @@ public class ConfigFile implements PermsConfig {
@Override @Override
public Map<String, Boolean> getGroupPermissions(String group, String world) { public Map<String, Boolean> getGroupPermissions(String group, String world) {
if (group.isEmpty()) group = getDefaultGroup(); if (group.isEmpty()) group = getDefaultGroup();
Map<String, Boolean> finalPerms = new HashMap<String, Boolean>(); Map<String, Boolean> finalPerms = new LinkedHashMap<String, Boolean>();
String permNode = (!world.isEmpty()) ? "groups/" + group + "/worlds/" + world : "groups/" + group + "/permissions"; String permNode = (!world.isEmpty()) ? "groups/" + group + "/worlds/" + world : "groups/" + group + "/permissions";
if (plugin.getNode(permNode) != null) { if (plugin.getNode(permNode) != null) {
for (Entry<String, Object> permGroup : plugin.getNode(permNode).getValues(false).entrySet()) { for (Entry<String, Object> permGroup : plugin.getNode(permNode).getValues(false).entrySet()) {
@ -262,7 +262,7 @@ public class ConfigFile implements PermsConfig {
return plugin.getNode("messages").getValues(false); return plugin.getNode("messages").getValues(false);
} }
else { else {
return new HashMap<String, Object>(); return new LinkedHashMap<String, Object>();
} }
} }

View File

@ -5,7 +5,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.sql.Connection; import java.sql.Connection;
@ -244,7 +244,7 @@ public class ConfigSQL implements PermsConfig {
@Override @Override
public Map<String, Boolean> getPlayerPermissions(String player, String world) { public Map<String, Boolean> getPlayerPermissions(String player, String world) {
Map<String, Boolean> results = new HashMap<String, Boolean>(); Map<String, Boolean> results = new LinkedHashMap<String, Boolean>();
if (init()) { if (init()) {
try { try {
PreparedStatement sql = connection.prepareStatement("SELECT " + column_permission + ", " + column_value + " FROM " + table_players + " WHERE " + column_playerid + " = LOWER(?) AND " + column_world + " = ?"); PreparedStatement sql = connection.prepareStatement("SELECT " + column_permission + ", " + column_value + " FROM " + table_players + " WHERE " + column_playerid + " = LOWER(?) AND " + column_world + " = ?");