Automatically drop the username on leave

This commit is contained in:
Andrzej Pomirski 2014-07-03 18:49:12 +02:00
parent 1bbf293379
commit d1a79425ed
3 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package com.Acrobot.ChestShop.Listeners.Player;
import com.Acrobot.ChestShop.Commands.Toggle;
import com.Acrobot.ChestShop.UUIDs.NameManager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
@ -15,6 +16,8 @@ public class PlayerLeave implements Listener {
if (Toggle.isIgnoring(event.getPlayer())) {
Toggle.setIgnoring(event.getPlayer(), false);
}
NameManager.dropUsername(event.getPlayer());
}
}

View File

@ -162,6 +162,20 @@ public class NameManager {
});
}
public static void dropUsername(final Player player) {
final UUID uuid = player.getUniqueId();
if (usernameToUUID.containsValue(uuid)) {
usernameToUUID.inverse().remove(uuid);
}
String shortName = NameUtil.stripUsername(player.getName());
if (shortToLongName.containsKey(shortName)) {
shortToLongName.remove(shortName);
}
}
public static boolean canUseName(Player player, String name) {
String shortenedName = NameUtil.stripUsername(getUsername(player.getUniqueId()));

View File

@ -505,7 +505,7 @@ public class Updater {
* @return true if Updater should consider the remote version an update, false if not.
*/
public boolean shouldUpdate(String localVersion, String remoteVersion) {
if (getLatestType() != ReleaseType.RELEASE) {
if (localVersion.contains("DEV") || getLatestType() != ReleaseType.RELEASE) {
return false; //Do not download alphas or betas
}