Use equalsIgnoreCase() instead of equals(), and use == for compaing

worlds.

Fixes #815
This commit is contained in:
GJ 2013-03-10 17:07:07 -04:00
parent 8059636b62
commit 9eba2c683b
9 changed files with 16 additions and 16 deletions

View File

@ -104,7 +104,7 @@ public class PartyCommand implements CommandExecutor {
} }
// Party leader commands // Party leader commands
if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) { if (!mcMMOPlayer.getParty().getLeader().equalsIgnoreCase(player.getName())) {
sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true; return true;
} }

View File

@ -35,7 +35,7 @@ public class PartyInfoCommand implements CommandExecutor {
StringBuilder memberList = new StringBuilder(); StringBuilder memberList = new StringBuilder();
for (OfflinePlayer member : playerParty.getMembers()) { for (OfflinePlayer member : playerParty.getMembers()) {
if (playerParty.getLeader().equals(member.getName())) { if (playerParty.getLeader().equalsIgnoreCase(member.getName())) {
memberList.append(ChatColor.GOLD).append(member.getName()).append(" "); memberList.append(ChatColor.GOLD).append(member.getName()).append(" ");
} }
else if (member.isOnline()) { else if (member.isOnline()) {

View File

@ -40,7 +40,7 @@ public class PartyRenameCommand implements CommandExecutor {
return true; return true;
} }
if (!member.getName().equals(leaderName)) { if (!member.getName().equalsIgnoreCase(leaderName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName)); member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
} }
} }

View File

@ -92,7 +92,7 @@ public class PlayerProfile {
} }
else { else {
for (HudType type : HudType.values()) { for (HudType type : HudType.values()) {
if (type.toString().equals(huds.get(1).get(0))) { if (type.toString().equalsIgnoreCase(huds.get(1).get(0))) {
hudType = type; hudType = type;
} }
} }
@ -186,7 +186,7 @@ public class PlayerProfile {
// Find if the line contains the player we want. // Find if the line contains the player we want.
String[] character = line.split(":"); String[] character = line.split(":");
if (!character[0].equals(playerName)) { if (!character[0].equalsIgnoreCase(playerName)) {
continue; continue;
} }
@ -400,7 +400,7 @@ public class PlayerProfile {
// While not at the end of the file // While not at the end of the file
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
// Read the line in and copy it to the output it's not the player we want to edit // Read the line in and copy it to the output it's not the player we want to edit
if (!line.split(":")[0].equals(playerName)) { if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
writer.append(line).append("\r\n"); writer.append(line).append("\r\n");
} }
else { else {

View File

@ -75,7 +75,7 @@ public final class PartyManager {
List<Player> nearMembers = new ArrayList<Player>(); List<Player> nearMembers = new ArrayList<Player>();
if (party != null) { if (party != null) {
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
if (!player.getName().equals(member.getName()) && Misc.isNear(player.getLocation(), member.getLocation(), range)) { if (!player.getName().equalsIgnoreCase(member.getName()) && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member); nearMembers.add(member);
} }
} }
@ -150,7 +150,7 @@ public final class PartyManager {
public static Party getPlayerParty(String playerName) { public static Party getPlayerParty(String playerName) {
for (Party party : parties) { for (Party party : parties) {
for (OfflinePlayer member : party.getMembers()) { for (OfflinePlayer member : party.getMembers()) {
if (member.getName().equals(playerName)) { if (member.getName().equalsIgnoreCase(playerName)) {
return party; return party;
} }
} }
@ -184,7 +184,7 @@ public final class PartyManager {
} }
else { else {
// If the leaving player was the party leader, appoint a new leader from the party members // If the leaving player was the party leader, appoint a new leader from the party members
if (party.getLeader().equals(player.getName())) { if (party.getLeader().equalsIgnoreCase(player.getName())) {
String newLeader = members.get(0).getName(); String newLeader = members.get(0).getName();
party.setLeader(newLeader); party.setLeader(newLeader);
} }
@ -374,10 +374,10 @@ public final class PartyManager {
String leaderName = party.getLeader(); String leaderName = party.getLeader();
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
if (member.getName().equals(playerName)) { if (member.getName().equalsIgnoreCase(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.Owner.Player")); member.sendMessage(LocaleLoader.getString("Party.Owner.Player"));
} }
else if (member.getName().equals(leaderName)) { else if (member.getName().equalsIgnoreCase(leaderName)) {
member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader")); member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader"));
} }
else { else {
@ -396,7 +396,7 @@ public final class PartyManager {
* @return true if the player can invite * @return true if the player can invite
*/ */
public static boolean canInvite(Player player, Party party) { public static boolean canInvite(Player player, Party party) {
if (party.isLocked() && !party.getLeader().equals(player.getName())) { if (party.isLocked() && !party.getLeader().equalsIgnoreCase(player.getName())) {
return false; return false;
} }

View File

@ -42,7 +42,7 @@ public class MctopCommandAsyncTask implements Runnable {
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
@Override @Override
public void run() { public void run() {
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
} }
else { else {

View File

@ -55,7 +55,7 @@ public class SQLConversionTask implements Runnable {
playerName = character[0]; playerName = character[0];
// Check for things we don't want put in the DB // Check for things we don't want put in the DB
if (playerName == null || playerName.equals("null") || playerName.equals("#Storage place for user information")) { if (playerName == null || playerName.equalsIgnoreCase("null") || playerName.equalsIgnoreCase("#Storage place for user information")) {
continue; continue;
} }

View File

@ -45,7 +45,7 @@ public class ArcheryManager extends SkillManager {
Location shooterLocation = player.getLocation(); Location shooterLocation = player.getLocation();
Location targetLocation = target.getLocation(); Location targetLocation = target.getLocation();
if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) { if (shooterLocation.getWorld() != targetLocation.getWorld()) {
return; return;
} }

View File

@ -77,7 +77,7 @@ public final class Misc {
* @return true if the distance between <code>first</code> and <code>second</code> is less than <code>maxDistance</code>, false otherwise * @return true if the distance between <code>first</code> and <code>second</code> is less than <code>maxDistance</code>, false otherwise
*/ */
public static boolean isNear(Location first, Location second, double maxDistance) { public static boolean isNear(Location first, Location second, double maxDistance) {
if (!first.getWorld().equals(second.getWorld())) { if (first.getWorld() != second.getWorld()) {
return false; return false;
} }