mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-28 20:17:50 +01:00
Less usage of player.getName()
This commit is contained in:
parent
94418b0934
commit
e92c980062
@ -329,8 +329,9 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize necessary traits
|
// Initialize necessary traits
|
||||||
if (!Setting.SERVER_OWNS_NPCS.asBoolean())
|
if (!Setting.SERVER_OWNS_NPCS.asBoolean()) {
|
||||||
npc.getTrait(Owner.class).setOwner(sender.getName());
|
npc.getTrait(Owner.class).setOwner(sender);
|
||||||
|
}
|
||||||
npc.getTrait(MobType.class).setType(type);
|
npc.getTrait(MobType.class).setType(type);
|
||||||
|
|
||||||
Location spawnLoc = null;
|
Location spawnLoc = null;
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import net.citizensnpcs.Settings.Setting;
|
import net.citizensnpcs.Settings.Setting;
|
||||||
@ -35,7 +36,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
public class Text extends Trait implements Runnable, Toggleable, Listener, ConversationAbandonedListener {
|
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 int currentIndex;
|
||||||
private String itemInHandPattern = "default";
|
private String itemInHandPattern = "default";
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
@ -135,12 +136,12 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
|
|||||||
continue;
|
continue;
|
||||||
Player player = (Player) search;
|
Player player = (Player) search;
|
||||||
// If the cooldown is not expired, do not send text
|
// 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 (cooldown != null) {
|
||||||
if (!new Date().after(cooldown)) {
|
if (!new Date().after(cooldown)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cooldowns.remove(player.getName());
|
cooldowns.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
if (!sendText(player))
|
if (!sendText(player))
|
||||||
return;
|
return;
|
||||||
@ -152,7 +153,7 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
|
|||||||
return;
|
return;
|
||||||
long millisecondsDelta = TimeUnit.MILLISECONDS.convert(secondsDelta, TimeUnit.SECONDS);
|
long millisecondsDelta = TimeUnit.MILLISECONDS.convert(secondsDelta, TimeUnit.SECONDS);
|
||||||
wait.setTime(wait.getTime() + millisecondsDelta);
|
wait.setTime(wait.getTime() + millisecondsDelta);
|
||||||
cooldowns.put(player.getName(), wait);
|
cooldowns.put(player.getUniqueId(), wait);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user