Skip to content

Commit

Permalink
Less usage of player.getName()
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 9, 2014
1 parent eeb5c7f commit 3d03f92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/main/java/net/citizensnpcs/commands/NPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,9 @@ public void create(CommandContext args, CommandSender sender, NPC npc) throws Co
}

// Initialize necessary traits
if (!Setting.SERVER_OWNS_NPCS.asBoolean())
npc.getTrait(Owner.class).setOwner(sender.getName());
if (!Setting.SERVER_OWNS_NPCS.asBoolean()) {
npc.getTrait(Owner.class).setOwner(sender);
}
npc.getTrait(MobType.class).setType(type);

Location spawnLoc = null;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/citizensnpcs/trait/text/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import net.citizensnpcs.Settings.Setting;
Expand Down Expand Up @@ -35,7 +36,7 @@
import com.google.common.collect.Maps;

public class Text extends Trait implements Runnable, Toggleable, Listener, ConversationAbandonedListener {
private final Map<String, Date> cooldowns = Maps.newHashMap();
private final Map<UUID, Date> cooldowns = Maps.newHashMap();
private int currentIndex;
private String itemInHandPattern = "default";
private final Plugin plugin;
Expand Down Expand Up @@ -135,12 +136,12 @@ public void run() {
continue;
Player player = (Player) search;
// If the cooldown is not expired, do not send text
Date cooldown = cooldowns.get(player.getName());
Date cooldown = cooldowns.get(player.getUniqueId());
if (cooldown != null) {
if (!new Date().after(cooldown)) {
return;
}
cooldowns.remove(player.getName());
cooldowns.remove(player.getUniqueId());
}
if (!sendText(player))
return;
Expand All @@ -152,7 +153,7 @@ public void run() {
return;
long millisecondsDelta = TimeUnit.MILLISECONDS.convert(secondsDelta, TimeUnit.SECONDS);
wait.setTime(wait.getTime() + millisecondsDelta);
cooldowns.put(player.getName(), wait);
cooldowns.put(player.getUniqueId(), wait);
}
}

Expand Down

0 comments on commit 3d03f92

Please sign in to comment.