List of usage examples for net.minecraftforge.common UsernameCache getLastKnownUsername
@Nullable public static String getLastKnownUsername(UUID uuid)
May be null
From source file:buildcraftAdditions.utils.PlayerUtils.java
License:GNU General Public License
public static String getPlayerName(UUID uuid) { String name = null;//from w w w .j a v a2 s.c om if (uuid != null) name = UsernameCache.getLastKnownUsername(uuid); return name != null ? name : ""; }
From source file:com.smithsmodding.smithscore.common.player.management.PlayerManager.java
/** * Method used to handle new players logging into the Server * * @param event The event fired when a player logs in. *///from w w w . ja va2s.c o m @SubscribeEvent public void onPlayerJoinServer(PlayerEvent.PlayerLoggedInEvent event) { SmithsCore.getLogger().info("Updating player UUID list"); EntityPlayer player = event.player; if (!commonSidedJoinedMap.containsKey(player.getGameProfile().getId())) { commonSidedJoinedMap.put(player.getGameProfile().getId(), UsernameCache.getLastKnownUsername(player.getGameProfile().getId())); SmithsCore.getRegistry().getCommonBus().post(new PlayersConnectedUpdatedEvent(this)); } if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { serverSidedJoinedMap.put(player.getGameProfile().getId(), player); } else { commonSidedOnlineMap.add(player.getGameProfile().getId()); } SmithsCore.getRegistry().getCommonBus().post(new PlayersOnlineUpdatedEvent(this)); }
From source file:com.smithsmodding.smithscore.common.player.management.PlayerManager.java
/** * Method used to create a list of all players that connected to this server before smithscore was installed. *//*from w ww . j a v a2 s . c o m*/ private void refreshPlayerUUIDList() { File file = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld() .getSaveHandler().getWorldDirectory(), "playerdata"); commonSidedJoinedMap = new HashMap<UUID, String>(); serverSidedJoinedMap = new HashMap<UUID, EntityPlayer>(); if (file.isDirectory()) { for (File search : file.listFiles()) { if (search.getName().contains(".dat")) { try { SmithsCore.getLogger().info("Adding player UUID to list"); UUID id = UUID.fromString(search.getName().replaceFirst("[.][^.]+$", "")); commonSidedJoinedMap.put(id, UsernameCache.getLastKnownUsername( UUID.fromString(search.getName().replaceFirst("[.][^.]+$", "")))); serverSidedJoinedMap.put(id, FMLCommonHandler.instance().getMinecraftServerInstance() .getPlayerList().getPlayerByUUID(id)); } catch (Exception e) { SmithsCore.getLogger().error(e.getStackTrace()); } } } } }
From source file:com.spawck.hs2.tileentity.TileEntityHS.java
License:GNU General Public License
public String getOwnerName() { if (ownerUUID != null) { return UsernameCache.getLastKnownUsername(ownerUUID); }//from ww w. ja v a 2 s . com return "Unknown"; }
From source file:me.denyol.blockbank.gui.slots.SlotCounterfeitDetector.java
License:Open Source License
@Override public void onSlotChanged() { super.onSlotChanged(); ItemStack stack = this.inventory.getStackInSlot(getSlotIndex()); if (stack != null && lastSlotSize < stack.stackSize) { if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey("Owner")) return; else {//from w w w .ja v a2 s . co m UUID uuid = UUID.fromString(stack.getTagCompound().getString("Owner")); String username = UsernameCache.getLastKnownUsername(uuid); if (username != null) { NBTTagList lore = new NBTTagList(); lore.appendTag(new NBTTagString("Created by: " + username)); NBTTagCompound tag = stack.getTagCompound(); NBTTagCompound display = new NBTTagCompound(); display.setTag("Lore", lore); tag.setTag("display", display); stack.setTagCompound(tag); } } } else { this.lastSlotSize = 0; } }
From source file:vazkii.botania.common.item.relic.ItemRelic.java
License:Open Source License
public void updateRelic(ItemStack stack, EntityPlayer player) { if (stack == null || !(stack.getItem() instanceof IRelic)) return;//www .j a v a2s. c o m boolean rightPlayer = true; if (hasUUID(stack)) { // Sync to username todo is this worth 'optimizing'? if (UsernameCache.containsUUID(getSoulbindUUID(stack))) { bindToUsername(UsernameCache.getLastKnownUsername(getSoulbindUUID(stack)), stack); } else { bindToUsername("", stack); } // UUID trumps username rightPlayer = getSoulbindUUID(stack).equals(player.getUniqueID()); } else { if ("".equals(getSoulbindUsername(stack))) { // New user bindToUUID(player.getUniqueID(), stack); player.addStat(((IRelic) stack.getItem()).getBindAchievement(), 1); } else { if (player.getName().equals(getSoulbindUsername(stack))) { // Old relic, correct owner, convert to UUID bindToUUID(player.getUniqueID(), stack); } else { // Old relic, wrong owner, damage rightPlayer = false; } } } if (!rightPlayer && player.ticksExisted % 10 == 0 && (!(stack.getItem() instanceof ItemRelic) || ((ItemRelic) stack.getItem()).shouldDamageWrongPlayer())) player.attackEntityFrom(damageSource(), 2); }