Browse Source

Adjusted pom.xml

master
Stefatorus 4 years ago
parent
commit
cdf58cc674
  1. 144
      ERCoupons/pom.xml
  2. 125
      ERCoupons/src/com/entryrise/coupons/mineutils/HeadUtils.java

144
ERCoupons/pom.xml

@ -1,72 +1,72 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cx.sfy</groupId>
<artifactId>templateplugin</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>TemplatePlugin</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.description>Template Plugin Description</plugin.description>
</properties>
<build>
<finalName>${project.name}</finalName>
<directory>target</directory>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>resources</directory>
<filtering>true</filtering>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
<plugins>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>mikeprimm-repo</id>
<url>http://repo.mikeprimm.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<!-- Peasants don't update or use new features :D -->
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.13</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.entryrise</groupId>
<artifactId>coupons</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>ERCoupons</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.description>EntryRise coupon tool</plugin.description>
</properties>
<build>
<finalName>${project.name}</finalName>
<directory>target</directory>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>resources</directory>
<filtering>true</filtering>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
<plugins>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>mikeprimm-repo</id>
<url>http://repo.mikeprimm.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<!-- Peasants don't update or use new features :D -->
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.13</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

125
ERCoupons/src/com/entryrise/coupons/mineutils/HeadUtils.java

@ -1,63 +1,62 @@
package com.entryrise.coupons.mineutils;
import java.lang.reflect.Field;
import java.util.Base64;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
public class HeadUtils {
public static ItemStack getSkull(String skinURL) {
ItemStack head = getSkullItem();
if(skinURL.isEmpty())return head;
ItemMeta headMeta = head.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
byte[] encodedData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", skinURL).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
Field profileField = null;
try {
profileField = headMeta.getClass().getDeclaredField("profile");
} catch (NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
profileField.setAccessible(true);
try {
profileField.set(headMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
head.setItemMeta(headMeta);
return head;
}
@SuppressWarnings("deprecation")
public static ItemStack getPlayerSkull(String username) {
ItemStack head = getSkullItem();
ItemMeta imeta = head.getItemMeta();
SkullMeta smeta = (SkullMeta) imeta;
smeta.setOwner(username);
head.setItemMeta(smeta);
return head;
}
public static Material getSkull() {
Material mat = Material.getMaterial("SKULL_ITEM");
return (mat != null) ? mat : Material.getMaterial("PLAYER_HEAD");
}
public static ItemStack getSkullItem() {
return new ItemStack(getSkull(), 1, (short) 3);
}
}
package com.entryrise.coupons.mineutils;
import java.lang.reflect.Field;
import java.util.Base64;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
public class HeadUtils {
public static ItemStack getSkull(String skinURL) {
ItemStack head = getSkullItem();
if(skinURL.isEmpty())return head;
ItemMeta headMeta = head.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
byte[] encodedData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", skinURL).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
Field profileField = null;
try {
profileField = headMeta.getClass().getDeclaredField("profile");
} catch (NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
profileField.setAccessible(true);
try {
profileField.set(headMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
head.setItemMeta(headMeta);
return head;
}
public static ItemStack getPlayerSkull(String username) {
ItemStack head = getSkullItem();
ItemMeta imeta = head.getItemMeta();
SkullMeta smeta = (SkullMeta) imeta;
smeta.setOwner(username);
head.setItemMeta(smeta);
return head;
}
public static Material getSkull() {
Material mat = Material.getMaterial("SKULL_ITEM");
return (mat != null) ? mat : Material.getMaterial("PLAYER_HEAD");
}
public static ItemStack getSkullItem() {
return new ItemStack(getSkull(), 1, (short) 3);
}
}

Loading…
Cancel
Save