GameProfile API Sync.
This commit is contained in:
@@ -3,15 +3,16 @@ package appeng.client.render.items;
|
|||||||
import net.minecraft.client.renderer.ItemRenderer;
|
import net.minecraft.client.renderer.ItemRenderer;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
|
import appeng.api.implementations.items.IBiometricCard;
|
||||||
import appeng.api.util.AEColor;
|
import appeng.api.util.AEColor;
|
||||||
import appeng.client.texture.ExtraItemTextures;
|
import appeng.client.texture.ExtraItemTextures;
|
||||||
import appeng.util.Platform;
|
|
||||||
|
|
||||||
public class ToolBiometricCardRender implements IItemRenderer
|
public class ToolBiometricCardRender implements IItemRenderer
|
||||||
{
|
{
|
||||||
@@ -74,8 +75,13 @@ public class ToolBiometricCardRender implements IItemRenderer
|
|||||||
float u = ExtraItemTextures.White.getIcon().getInterpolatedU( 8.1 );
|
float u = ExtraItemTextures.White.getIcon().getInterpolatedU( 8.1 );
|
||||||
float v = ExtraItemTextures.White.getIcon().getInterpolatedV( 8.1 );
|
float v = ExtraItemTextures.White.getIcon().getInterpolatedV( 8.1 );
|
||||||
|
|
||||||
NBTTagCompound myTag = Platform.openNbtData( item );
|
String username = "";
|
||||||
String username = myTag.getString( "username" );
|
if ( item.getItem() instanceof IBiometricCard )
|
||||||
|
{
|
||||||
|
GameProfile gp = (( IBiometricCard) item.getItem() ).getProfile(item);
|
||||||
|
if ( gp != null )
|
||||||
|
username = gp.getName();
|
||||||
|
}
|
||||||
int hash = username.length() > 0 ? username.hashCode() : 0;
|
int hash = username.length() > 0 ? username.hashCode() : 0;
|
||||||
|
|
||||||
GL11.glScalef( 1F / 16F, 1F / 16F, 1F );
|
GL11.glScalef( 1F / 16F, 1F / 16F, 1F );
|
||||||
|
|||||||
+9
-15
@@ -8,6 +8,8 @@ import java.util.List;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.common.config.ConfigCategory;
|
import net.minecraftforge.common.config.ConfigCategory;
|
||||||
@@ -227,17 +229,6 @@ public class WorldSettings extends Configuration
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername(int id)
|
|
||||||
{
|
|
||||||
ConfigCategory playerList = this.getCategory( "players" );
|
|
||||||
for (Entry<String, Property> fish : playerList.entrySet())
|
|
||||||
{
|
|
||||||
if ( fish.getValue().isIntValue() && fish.getValue().getInt() == id )
|
|
||||||
return fish.getKey();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNextOrderedValue(String name)
|
public int getNextOrderedValue(String name)
|
||||||
{
|
{
|
||||||
Property p = this.get( "orderedValues", name, 0 );
|
Property p = this.get( "orderedValues", name, 0 );
|
||||||
@@ -246,18 +237,21 @@ public class WorldSettings extends Configuration
|
|||||||
return myValue;
|
return myValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerID(String username)
|
public int getPlayerID(GameProfile profile)
|
||||||
{
|
{
|
||||||
ConfigCategory playerList = this.getCategory( "players" );
|
ConfigCategory playerList = this.getCategory( "players" );
|
||||||
if ( playerList == null || username == null || username.length() == 0 )
|
|
||||||
|
if ( playerList == null || profile == null || !profile.isComplete() )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
Property prop = playerList.get( username );
|
String uuid = profile.getId().toString();
|
||||||
|
|
||||||
|
Property prop = playerList.get( uuid );
|
||||||
if ( prop != null && prop.isIntValue() )
|
if ( prop != null && prop.isIntValue() )
|
||||||
return prop.getInt();
|
return prop.getInt();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playerList.put( username, prop = new Property( username, "" + nextPlayer(), Property.Type.INTEGER ) );
|
playerList.put( uuid, prop = new Property( uuid, "" + nextPlayer(), Property.Type.INTEGER ) );
|
||||||
save();
|
save();
|
||||||
return prop.getInt();
|
return prop.getInt();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package appeng.core.features.registries;
|
package appeng.core.features.registries;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import appeng.api.features.IPlayerRegistry;
|
import appeng.api.features.IPlayerRegistry;
|
||||||
import appeng.core.WorldSettings;
|
import appeng.core.WorldSettings;
|
||||||
@@ -8,7 +10,7 @@ public class PlayerRegistry implements IPlayerRegistry
|
|||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getID(String username)
|
public int getID(GameProfile username)
|
||||||
{
|
{
|
||||||
return WorldSettings.getInstance().getPlayerID( username );
|
return WorldSettings.getInstance().getPlayerID( username );
|
||||||
}
|
}
|
||||||
@@ -16,13 +18,7 @@ public class PlayerRegistry implements IPlayerRegistry
|
|||||||
@Override
|
@Override
|
||||||
public int getID(EntityPlayer player)
|
public int getID(EntityPlayer player)
|
||||||
{
|
{
|
||||||
return WorldSettings.getInstance().getPlayerID( player.getCommandSenderName() );
|
return WorldSettings.getInstance().getPlayerID( player.getGameProfile() );
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsername(int id)
|
|
||||||
{
|
|
||||||
return WorldSettings.getInstance().getUsername( id );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package appeng.items.tools;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
import appeng.api.config.SecurityPermissions;
|
import appeng.api.config.SecurityPermissions;
|
||||||
@@ -33,8 +36,8 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||||||
@Override
|
@Override
|
||||||
public String getItemStackDisplayName(ItemStack is)
|
public String getItemStackDisplayName(ItemStack is)
|
||||||
{
|
{
|
||||||
String username = getUsername( is );
|
GameProfile username = getProfile( is );
|
||||||
return username.length() > 0 ? super.getItemStackDisplayName( is ) + " - " + username : super.getItemStackDisplayName( is );
|
return username != null ? super.getItemStackDisplayName( is ) + " - " + username.getName() : super.getItemStackDisplayName( is );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,20 +69,17 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||||||
|
|
||||||
private void encode(ItemStack is, EntityPlayer p)
|
private void encode(ItemStack is, EntityPlayer p)
|
||||||
{
|
{
|
||||||
String username = getUsername( is );
|
GameProfile username = getProfile( is );
|
||||||
if ( p.getCommandSenderName().equals( username ) )
|
|
||||||
setUsername( is, "" );
|
if (username != null && username.equals(p.getGameProfile()))
|
||||||
|
setProfile( is, null );
|
||||||
else
|
else
|
||||||
setUsername( is, p.getCommandSenderName() );
|
setProfile( is, p.getGameProfile() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack is, EntityPlayer p, List l, boolean b)
|
public void addInformation(ItemStack is, EntityPlayer p, List l, boolean b)
|
||||||
{
|
{
|
||||||
// String username = getUsername( is );
|
|
||||||
// if ( username.length() > 0 )
|
|
||||||
// l.add( username );
|
|
||||||
|
|
||||||
EnumSet<SecurityPermissions> perms = getPermissions( is );
|
EnumSet<SecurityPermissions> perms = getPermissions( is );
|
||||||
if ( perms.isEmpty() )
|
if ( perms.isEmpty() )
|
||||||
l.add( GuiText.NoPermissions.getLocal() );
|
l.add( GuiText.NoPermissions.getLocal() );
|
||||||
@@ -100,10 +100,12 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsername(ItemStack is)
|
public GameProfile getProfile(ItemStack is)
|
||||||
{
|
{
|
||||||
NBTTagCompound tag = Platform.openNbtData( is );
|
NBTTagCompound tag = Platform.openNbtData( is );
|
||||||
return tag.getString( "username" );
|
if ( tag.hasKey("profile") )
|
||||||
|
return NBTUtil.func_152459_a(tag.getCompoundTag("profile") );
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,10 +131,18 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUsername(ItemStack itemStack, String username)
|
public void setProfile(ItemStack itemStack, GameProfile profile)
|
||||||
{
|
{
|
||||||
NBTTagCompound tag = Platform.openNbtData( itemStack );
|
NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||||
tag.setString( "username", username );
|
|
||||||
|
if ( profile!= null )
|
||||||
|
{
|
||||||
|
NBTTagCompound pNBT = new NBTTagCompound();
|
||||||
|
NBTUtil.func_152460_a( pNBT, profile );
|
||||||
|
tag.setTag( "profile", pNBT );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tag.removeTag("profile");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -153,6 +163,6 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||||||
@Override
|
@Override
|
||||||
public void registerPermissions(ISecurityRegister register, IPlayerRegistry pr, ItemStack is)
|
public void registerPermissions(ISecurityRegister register, IPlayerRegistry pr, ItemStack is)
|
||||||
{
|
{
|
||||||
register.addPlayer( pr.getID( getUsername( is ) ), getPermissions( is ) );
|
register.addPlayer( pr.getID( getProfile( is ) ), getPermissions( is ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -56,7 +56,7 @@ public class SecurityCache implements IGridCache, ISecurityGrid
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(EntityPlayer player, SecurityPermissions perm)
|
public boolean hasPermission(EntityPlayer player, SecurityPermissions perm)
|
||||||
{
|
{
|
||||||
return hasPermission( player == null ? -1 : WorldSettings.getInstance().getPlayerID( player.getCommandSenderName() ), perm );
|
return hasPermission( player == null ? -1 : WorldSettings.getInstance().getPlayerID( player.getGameProfile() ), perm );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class AENetworkProxy implements IGridBlock
|
|||||||
}
|
}
|
||||||
else if ( node != null && owner != null )
|
else if ( node != null && owner != null )
|
||||||
{
|
{
|
||||||
node.setPlayerID( WorldSettings.getInstance().getPlayerID( owner.getCommandSenderName() ) );
|
node.setPlayerID( WorldSettings.getInstance().getPlayerID( owner.getGameProfile() ) );
|
||||||
owner = null;
|
owner = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package appeng.me.storage;
|
package appeng.me.storage;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.config.AccessRestriction;
|
import appeng.api.config.AccessRestriction;
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
@@ -113,7 +115,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
|||||||
if ( input.getItem() instanceof IBiometricCard )
|
if ( input.getItem() instanceof IBiometricCard )
|
||||||
{
|
{
|
||||||
IBiometricCard tbc = (IBiometricCard) input.getItem();
|
IBiometricCard tbc = (IBiometricCard) input.getItem();
|
||||||
String newUser = tbc.getUsername( input.getItemStack() );
|
GameProfile newUser = tbc.getProfile( input.getItemStack() );
|
||||||
|
|
||||||
int PlayerID = AEApi.instance().registries().players().getID( newUser );
|
int PlayerID = AEApi.instance().registries().players().getID( newUser );
|
||||||
if ( securityTile.getOwner() == PlayerID )
|
if ( securityTile.getOwner() == PlayerID )
|
||||||
@@ -123,7 +125,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
|||||||
{
|
{
|
||||||
if ( ais.isMeaninful() )
|
if ( ais.isMeaninful() )
|
||||||
{
|
{
|
||||||
String thisUser = tbc.getUsername( ais.getItemStack() );
|
GameProfile thisUser = tbc.getProfile( ais.getItemStack() );
|
||||||
if ( thisUser.equals( newUser ) )
|
if ( thisUser.equals( newUser ) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user