generated from TobiasDeBruijn/BaseBukkitPlugin
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Split the NMS classes into seperate Gradle submodules - Refactored the NMS classes to not depend on the 'core' - On join, players now get checked for if they're premium, if so, their normal skin will be set - package files renamed to fileHandlers - Think that's all? Anyway it works now
- Loading branch information
TheDutchMC
committed
Aug 13, 2020
1 parent
b5016e2
commit 59712f9
Showing
17 changed files
with
285 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apply plugin: 'java' | ||
dependencies { | ||
compileOnly 'org.spigotmc:spigot:1.16.1-R0.1-SNAPSHOT' | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apply plugin: 'java' | ||
dependencies { | ||
compileOnly 'org.spigotmc:spigot:1.16.2-R0.1-SNAPSHOT' | ||
} | ||
|
50 changes: 50 additions & 0 deletions
50
.../java/nl/thedutchmc/SkinFixer/changeSkin/changeGameProfile/ChangeGameProfile_1_16_r2.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,50 @@ | ||
package nl.thedutchmc.SkinFixer.changeSkin.changeGameProfile; | ||
|
||
import java.util.UUID; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; | ||
import org.bukkit.entity.Player; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import com.mojang.authlib.properties.Property; | ||
import com.mojang.authlib.properties.PropertyMap; | ||
|
||
import net.minecraft.server.v1_16_R2.EntityPlayer; | ||
import net.minecraft.server.v1_16_R2.PacketPlayOutPlayerInfo; | ||
import net.minecraft.server.v1_16_R2.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; | ||
|
||
public class ChangeGameProfile_1_16_r2 { | ||
|
||
public static void changeProfile(UUID uuid, String skinValue, String skinSignature) { | ||
Player player = Bukkit.getPlayer(uuid); | ||
|
||
//Fetch the EntityPlayer and their GameProfile | ||
EntityPlayer ep = ((CraftPlayer)player).getHandle(); | ||
GameProfile gp = ep.getProfile(); | ||
|
||
//Get the skin texture property | ||
PropertyMap pm = gp.getProperties(); | ||
|
||
//Check if the propertyMap contains a texture value, if so, remove it. | ||
if(pm.containsKey("textures")) { | ||
Property property = pm.get("textures").iterator().next(); | ||
pm.remove("textures", property); | ||
} | ||
|
||
//Remove the old texture, and set the new one. | ||
pm.put("textures", new Property("textures", skinValue, skinSignature)); | ||
|
||
//Reload the skin for the player itself | ||
reloadSkinForSelf(player); | ||
} | ||
|
||
public static void reloadSkinForSelf(Player player) { | ||
final EntityPlayer ep = ((CraftPlayer) player).getHandle(); | ||
final PacketPlayOutPlayerInfo removeInfo = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, ep); | ||
final PacketPlayOutPlayerInfo addInfo = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, ep); | ||
|
||
ep.playerConnection.sendPacket(removeInfo); | ||
ep.playerConnection.sendPacket(addInfo); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
* | ||
* The settings file is used to specify which projects to include in your build. | ||
* | ||
* Detailed information about configuring a multi-project build in Gradle can be found | ||
* in the user guide at https://docs.gradle.org/5.1.1/userguide/multi_project_builds.html | ||
*/ | ||
|
||
rootProject.name = pluginName | ||
include ':Spigot_1_16_R1' | ||
include ':Spigot_1_16_R2' |
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
74 changes: 74 additions & 0 deletions
74
src/main/java/nl/thedutchmc/SkinFixer/changeSkin/CheckUserAgainstMojang.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,74 @@ | ||
package nl.thedutchmc.SkinFixer.changeSkin; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.apache.http.HttpEntity; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.ParseException; | ||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.entity.ContentType; | ||
import org.apache.http.entity.StringEntity; | ||
import org.apache.http.impl.client.HttpClients; | ||
import org.apache.http.util.EntityUtils; | ||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
import org.json.JSONTokener; | ||
|
||
public class CheckUserAgainstMojang { | ||
|
||
public static String premiumUser(String playername) { | ||
HttpClient httpClient = HttpClients.createDefault(); | ||
HttpPost httpPost = new HttpPost("https://api.mojang.com/profiles/minecraft"); | ||
|
||
String jsonOut = "[\"" + playername + "\"]"; | ||
|
||
StringEntity requestEntity = new StringEntity( | ||
jsonOut, | ||
ContentType.APPLICATION_JSON); | ||
|
||
httpPost.setEntity(requestEntity); | ||
|
||
HttpResponse response = null; | ||
try { | ||
response = httpClient.execute(httpPost); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
HttpEntity entity = response.getEntity(); | ||
|
||
String json = ""; | ||
try { | ||
json = EntityUtils.toString(entity, StandardCharsets.UTF_8); | ||
} catch (ParseException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
JSONTokener tokener = new JSONTokener(json); | ||
JSONArray array = (JSONArray) tokener.nextValue(); | ||
for(Object o : array) { | ||
JSONObject jsonObj = (JSONObject) o; | ||
String uuid = (String) jsonObj.getString("id"); | ||
return insertDashUUID(uuid); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private static String insertDashUUID(String uuid) { | ||
StringBuilder sb = new StringBuilder(uuid); | ||
sb.insert(8, "-"); | ||
sb = new StringBuilder(sb.toString()); | ||
sb.insert(13, "-"); | ||
sb = new StringBuilder(sb.toString()); | ||
sb.insert(18, "-"); | ||
sb = new StringBuilder(sb.toString()); | ||
sb.insert(23, "-"); | ||
|
||
return sb.toString(); | ||
} | ||
} |
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
Oops, something went wrong.