Less usage of player.getName()

This commit is contained in:
fullwall 2014-03-09 13:04:27 +08:00
parent 94418b0934
commit e92c980062
2 changed files with 8 additions and 6 deletions

View File

@ -329,8 +329,9 @@ public class NPCCommands {
}
// 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;

View File

@ -5,6 +5,7 @@ import java.util.Date;
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;
@ -35,7 +36,7 @@ import org.bukkit.plugin.Plugin;
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;
@ -135,12 +136,12 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
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;
@ -152,7 +153,7 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
return;
long millisecondsDelta = TimeUnit.MILLISECONDS.convert(secondsDelta, TimeUnit.SECONDS);
wait.setTime(wait.getTime() + millisecondsDelta);
cooldowns.put(player.getName(), wait);
cooldowns.put(player.getUniqueId(), wait);
}
}