Skip to content

Commit 7f99ea9

Browse files
author
TheProgramSrc
committed
Changelog:
* SimpleItem Code Improvements * Working on SkinTextureManager Cache Changes
1 parent e4d5177 commit 7f99ea9

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>xyz.theprogramsrc</groupId>
88
<artifactId>SuperCoreAPI</artifactId>
9-
<version>4.1.2-BETA_1</version>
9+
<version>4.1.2-BETA_2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>

src/main/java/xyz/theprogramsrc/supercoreapi/spigot/utils/skintexture/SkinTextureManager.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import org.bukkit.Bukkit;
55
import org.bukkit.entity.Player;
6+
import xyz.theprogramsrc.supercoreapi.global.utils.Utils;
67
import xyz.theprogramsrc.supercoreapi.spigot.items.Skulls;
78

89
import java.util.HashMap;
@@ -23,23 +24,25 @@ public SkinTextureManager(){
2324
* @return the skin
2425
*/
2526
public SkinTexture getSkin(Player player) {
26-
if(!this.cache.containsKey(player.getName())){
27+
String key = Utils.encodeBase64(player.getName());
28+
if(!this.cache.containsKey(key)){
2729
SkinTexture skinTexture = Bukkit.getOnlineMode() ? SkinTexture.fromPlayer(player) : SkinTexture.fromMojang(player.getName());
2830
if(skinTexture == null){
2931
return null;
3032
}
31-
this.cache.put(player.getName(), skinTexture);
33+
this.cache.put(key, skinTexture);
3234
}
33-
return this.cache.get(player.getName());
35+
return this.cache.get(key);
3436
}
3537

3638
public SkinTexture getSkin(String url){
37-
if(!this.urls.containsKey(url)){
39+
String key = Utils.encodeBase64(url);
40+
if(!this.urls.containsKey(key)){
3841
SkinTexture texture = SkinTexture.fromURL(url);
39-
this.urls.put(url, texture);
42+
this.urls.put(key, texture);
4043
}
4144

42-
return this.urls.get(url);
45+
return this.urls.get(key);
4346
}
4447

4548
/**

0 commit comments

Comments
 (0)