-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor some code, use api.ashcon.app if rate limited
- Loading branch information
Showing
7 changed files
with
190 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/ru/leymooo/simpleskins/utils/SkinApplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ru.leymooo.simpleskins.utils; | ||
|
||
import com.velocitypowered.api.proxy.Player; | ||
import com.velocitypowered.api.util.GameProfile; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class SkinApplier { | ||
|
||
public static GameProfile createProfileWithSkin(GameProfile original, GameProfile.Property toApply) { | ||
List<GameProfile.Property> properties = createProperties(original.getProperties(), toApply); | ||
return new GameProfile(original.getId(), original.getName(), properties); | ||
} | ||
|
||
public static void applySkin(Player player, GameProfile.Property property) { | ||
player.setGameProfileProperties(createProperties(player.getGameProfileProperties(), property)); | ||
} | ||
|
||
private static List<GameProfile.Property> createProperties(List<GameProfile.Property> original, GameProfile.Property property) { | ||
List<GameProfile.Property> properties = new ArrayList<>(original); | ||
boolean applied = false; | ||
for (int i = 0; i < properties.size(); i++) { | ||
GameProfile.Property lproperty = properties.get(i); | ||
if ("textures".equals(lproperty.getName())) { | ||
properties.set(i, property); | ||
applied = true; | ||
} | ||
} | ||
if (!applied) { | ||
properties.add(property); | ||
} | ||
return properties; | ||
} | ||
} |
Oops, something went wrong.