Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Release v1.7 getTextureID
Browse files Browse the repository at this point in the history
Added:
- %getTextureID_Or_PlayerName%
- %getTextureID_Or_Empty%
- %getTextureID_Or_Null%
- %getTextureID_Or_Steve%
- %getTextureID_Or_Alex%
  • Loading branch information
xknat committed Dec 13, 2022
1 parent 4560445 commit 0fd5668
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 33 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
# SRPlaceholderAPIExpansion
PlaceholderAPI expansion for SkinsRestorer placeholders
PlaceholderAPI expansion for SkinsRestorer placeholders

https://api.extendedclip.com/expansions/skinsrestorer/


### Placeholders
%skinsrestorer_test% - returns "success" if the expansion is working

%skinsrestorer_getSkinName% - returns the skin name of the player

#### getTextureUrl
- %skinsrestorer_getTextureUrl_Or_PlayerName%
- %skinsrestorer_getTextureUrl_Or_Empty%
- %skinsrestorer_getTextureUrl_Or_Null%
- %skinsrestorer_getTextureUrl_Or_Steve%
- %skinsrestorer_getTextureUrl_Or_Alex%

#### getTextureID
- %skinsrestorer_getTextureID_Or_PlayerName%
- %skinsrestorer_getTextureID_Or_Empty%
- %skinsrestorer_getTextureID_Or_Null%
- %skinsrestorer_getTextureID_Or_Steve%
- %skinsrestorer_getTextureID_Or_Alex%

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.extendedclip.placeholderapi.expansion.skinsrestorer</groupId>
<artifactId>skinsrestorer-expansion</artifactId>
<version>1.6</version>
<version>1.7</version>

<name>Expansion-SkinsRestorer</name>
<description>SkinsRestorer expansion for PlaceholderAPI</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class SkinsRestorerExpansion extends PlaceholderExpansion {
private SRWrapper wrapper;
Expand Down Expand Up @@ -42,8 +43,9 @@ public boolean register() {
* @return Possible-null String
*/
@Override
public String onRequest(OfflinePlayer offlinePlayer, String params) {
if (params.equals("test")) {
public @Nullable String onRequest(OfflinePlayer offlinePlayer, @NotNull String params) {
params = params.toLowerCase();
if (params.equalsIgnoreCase("test")) {
return "success";
}

Expand All @@ -52,7 +54,7 @@ public String onRequest(OfflinePlayer offlinePlayer, String params) {
return "Player can't be null";

// %getSkinName%
if (params.equals("getSkinName")) {
if (params.equalsIgnoreCase("getSkinName")) {
String name = wrapper.getSkinName(p);

if (name != null) {
Expand All @@ -65,49 +67,48 @@ public String onRequest(OfflinePlayer offlinePlayer, String params) {
}
}

// %getTextureUrl_Or_PlayerName%
if (params.equals("getTextureUrl_Or_PlayerName")) {
String url = wrapper.getSkinTextureUrl(wrapper.getSkinName(p));
if (params.toLowerCase().startsWith("gettextureurl_"))
return getSkinTextureUrl(p, params.toLowerCase().replace("gettextureurl_", ""));

// getSkinTextureID
if (params.toLowerCase().startsWith("gettextureid_"))
return getSkinTextureUrl(p, params.toLowerCase().replace("gettextureid_", ""))
.replace("https://textures.minecraft.net/texture/", "")
.replace("http://textures.minecraft.net/texture/", "");

if (url == null || url.equals("null"))
url = p;
return null;
}
public String getSkinTextureUrl(String p, String params) {
String url = wrapper.getSkinTextureUrl(wrapper.getSkinName(p));

//noinspection ConstantConditions
if (url != null || ("null").equals(url)) {
return url;
}

// %getTextureUrl_Or_Empty%
if (params.equals("getTextureUrl_Or_Empty")) {
String url = wrapper.getSkinTextureUrl(wrapper.getSkinName(p));

if (url == null || url.equals("null"))
url = "";
// %getTextureUrl_Or_PlayerName%
if (params.equalsIgnoreCase("Or_PlayerName")) {
return p;
}

return url;
// %getTextureUrl_Or_Empty%
if (params.equalsIgnoreCase("Or_Empty")) {
return "";
}

// %getTextureUrl_Or_Null%
if (params.equals("getTextureUrl_Or_Null")) {
return wrapper.getSkinTextureUrl(wrapper.getSkinName(p));
if (params.equalsIgnoreCase("Or_Null")) {
return null;
}

// %getTextureUrl_Or_Steve%
if (params.equals("getTextureUrl_Or_Steve")) {
String url = wrapper.getSkinTextureUrl(wrapper.getSkinName(p));

if (url == null || url.equals("null"))
url = "http://textures.minecraft.net/texture/6d3b06c38504ffc0229b9492147c69fcf59fd2ed7885f78502152f77b4d50de1";

return url;
if (params.equalsIgnoreCase("Or_Steve")) {
return "http://textures.minecraft.net/texture/6d3b06c38504ffc0229b9492147c69fcf59fd2ed7885f78502152f77b4d50de1";
}

// %getTextureUrl_Or_Alex%
if (params.equals("getTextureUrl_Or_Alex")) {
String url = wrapper.getSkinTextureUrl(wrapper.getSkinName(p));

if (url == null || url.equals("null"))
url = "http://textures.minecraft.net/texture/fb9ab3483f8106ecc9e76bd47c71312b0f16a58784d606864f3b3e9cb1fd7b6c";

return url;
if (params.endsWith("Or_Alex")) {
return "http://textures.minecraft.net/texture/fb9ab3483f8106ecc9e76bd47c71312b0f16a58784d606864f3b3e9cb1fd7b6c";
}

return null;
Expand Down

0 comments on commit 0fd5668

Please sign in to comment.