Moved to maven

This commit is contained in:
stijnb1234 2020-11-16 18:52:42 +01:00
parent 833b55d6ca
commit 78c68f4f32
32 changed files with 382 additions and 2739 deletions

113
.gitignore vendored Normal file
View file

@ -0,0 +1,113 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# Common working directory
run/

View file

@ -1,11 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" name="MCTPAudio:jar">
<output-path>$PROJECT_DIR$/out/artifacts/MCTPAudio_jar</output-path>
<root id="archive" name="MCTPAudio.jar">
<element id="module-output" name="MCTPAudio" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/menuapi-1.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/mp3agic-0.9.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/Java-WebSocket-1.3.8.jar" path-in-jar="/" />
</root>
</artifact>
</component>

16
.idea/compiler.xml generated Normal file
View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="MCTPAudio" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="MCTPAudio" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>

2
.idea/discord.xml generated
View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="true" />
<option name="show" value="PROJECT_FILES" />
</component>
<component name="ProjectNotificationSettings">
<option name="askShowProject" value="false" />

35
.idea/jarRepositories.xml generated Normal file
View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="sonatype" />
<option name="name" value="sonatype" />
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="spigotmc-repo" />
<option name="name" value="spigotmc-repo" />
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="sk89q-repo" />
<option name="name" value="sk89q-repo" />
<option name="url" value="https://maven.enginehub.org/repo/" />
</remote-repository>
</component>
</project>

View file

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="Java-WebSocket-1.3.8">
<CLASSES>
<root url="jar://$USER_HOME$/Downloads/Java-WebSocket-1.3.8.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="spigot-1.14.4">
<CLASSES>
<root url="jar://$USER_HOME$/Downloads/spigot-1.14.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Downloads/spigot-1.14.4.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="spigot-1.16.3">
<CLASSES>
<root url="jar://$USER_HOME$/Downloads/spigot-1.16.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Downloads/spigot-1.16.3.jar!/" />
</SOURCES>
</library>
</component>

7
.idea/misc.xml generated
View file

@ -5,6 +5,13 @@
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
</list>
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
@ -9,14 +9,17 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Java-WebSocket-1.3.8" level="project" />
<orderEntry type="module-library" scope="PROVIDED">
<library>
<CLASSES>
@ -62,6 +65,77 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" scope="PROVIDED" name="spigot-1.16.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
<orderEntry type="library" name="Maven: org.java-websocket:Java-WebSocket:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: com.mpatric:mp3agic:0.9.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.5-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.5-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.5-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-default_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.13.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-http:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-spec:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-annotations:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-cio:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-io:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-services:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-logging:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-odf:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zipdriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bouncycastle:bcprov-jdk15on:1.63" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-tardriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-bzip2:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-gzip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-xz:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.tukaani:xz:1.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip-raes:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-base_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access-swing:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-file:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-jar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-ibm437:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-impl_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-console:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-default:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-swing:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-macosx:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-spec:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino-runtime:1.7.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.raidstone:WorldGuardEvents:1.15.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:17.0.0" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.8.0" level="project" />
</component>
</module>

113
pom.xml Normal file
View file

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>me.mctp</groupId>
<artifactId>MCTPAudio</artifactId>
<version>1.2</version>
<packaging>jar</packaging>
<name>MCTPAudio</name>
<description>De audio plugin van MCThemeParks.</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>https://sbdplugins.nl</url>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>com.mpatric</groupId>
<artifactId>mp3agic</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.raidstone</groupId>
<artifactId>WorldGuardEvents</artifactId>
<version>1.15.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>
</project>

View file

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Main-Class: me.mctp.Main

View file

@ -6,7 +6,6 @@ import me.mctp.listener.WGListener;
import me.mctp.managers.WGManager;
import me.mctp.radio.Playlist;
import me.mctp.socket.Client;
import nl.iobyte.menuapi.MenuAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.Listener;
@ -39,7 +38,7 @@ public class Main extends JavaPlugin implements Listener {
pl = this;
client = new Client("ws://bots.d-group.nl:8166");
client = new Client("ws://173.249.31.58:8166");
client.connect();
getCommand("audio").setExecutor(new MCTPAudioCMD());
@ -50,8 +49,6 @@ public class Main extends JavaPlugin implements Listener {
playlist = new Playlist();
MenuAPI.register(this);
Bukkit.getLogger().info(prefix + " __ __ ____ _____ ____ _ _ _ ");
Bukkit.getLogger().info(prefix + " | \\/ |/ ___|_ _| _ \\ / \\ _ _ __| (_) ___ ");
Bukkit.getLogger().info(prefix + " | |\\/| | | | | | |_) / _ \\| | | |/ _` | |/ _ \\ ");

View file

@ -72,6 +72,8 @@ public class WGListener implements Listener {
/** Hue detection */
@EventHandler
public void onRegionEnter(RegionsEnteredEvent e) {
if (e.getPlayer() == null) return;
Set<String> list2 = Main.getPlugin().getConfig().getConfigurationSection("HueRegions").getKeys(false);
if (!Collections.disjoint(list2, e.getRegionsNames())) {
@ -91,7 +93,7 @@ public class WGListener implements Listener {
Integer brightness = null;
if (configDataSplit.length == 5) brightness = Integer.parseInt(configDataSplit[4]);
if (!PinManager.hasPin(Objects.requireNonNull(e.getPlayer()).getUniqueId())) return;
if (!PinManager.hasPin(e.getPlayer().getUniqueId())) return;
JSONObject data = new JSONObject();
data.put("task", "HUE");

View file

@ -5,7 +5,7 @@ import java.util.UUID;
import java.util.WeakHashMap;
public class PinManager {
private static WeakHashMap<UUID, String> pins = new WeakHashMap<>();
private static final WeakHashMap<UUID, String> pins = new WeakHashMap<>();
/**
* Get the pin of a player

View file

@ -13,7 +13,7 @@ import org.json.simple.JSONObject;
import java.io.IOException;
public class Playlist {
private me.mctp.api.maps.Playlist<String> songList = new me.mctp.api.maps.Playlist<>();
private final me.mctp.api.maps.Playlist<String> songList = new me.mctp.api.maps.Playlist<>();
private boolean running = false;
private BukkitTask currentTimer;
@ -66,6 +66,8 @@ public class Playlist {
public void nextSong() {
if (currentTimer != null) return;
if (songList.isEmpty()) return;
//Get song
String nextURL = songList.getRandom();
if (nextURL == null) return;

View file

@ -3,7 +3,7 @@ package me.mctp.utils;
import com.mpatric.mp3agic.InvalidDataException;
import com.mpatric.mp3agic.Mp3File;
import com.mpatric.mp3agic.UnsupportedTagException;
import org.bukkit.craftbukkit.libs.org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.io.FileOutputStream;
@ -26,7 +26,7 @@ public class HeadUtil {
}
}
return result.toString().replaceAll(".", "");
return result.toString().replaceAll("\\.", "");
}
private static String downloadFromUrl(URL url, String localFilename) throws IOException {

View file

@ -16,7 +16,7 @@ import java.util.stream.Collectors;
public class SpigotPlayerSelector {
private String selector;
private final String selector;
public SpigotPlayerSelector(String selector) {
this.selector = selector;
@ -150,7 +150,7 @@ public class SpigotPlayerSelector {
}
}
return result.toString().replaceAll(".", "");
return result.toString().replaceAll("\\.", "");
}
}

View file

@ -1,10 +1,10 @@
main: me.mctp.Main
name: MCTPAudio
version: 1.2
api-version: 1.14
author: MaybeFromNL_SBDeveloper
version: ${project.version}
main: me.mctp.Main
api-version: 1.16
authors: [ SBDeveloper ]
depend: [ WorldGuard ]
description: Copyright MaybeFromNL & SBDeveloper
depend: ['WorldGuard']
commands:
mctpaudio:

View file

@ -1,57 +0,0 @@
package me.mctp.utils;
import me.mctp.xutils.SkullUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class MultiPageGUI {
private List<Inventory> inventories = new ArrayList<>();
public MultiPageGUI(String title, int itemsPerPage, List<ItemStack> items) {
if (!title.contains("%page%")) {
throw new IllegalArgumentException("Title must contain %page% for the page.");
}
int invSize = itemsPerPage + 9;
if (itemsPerPage%9 != 0) {
throw new IllegalArgumentException("ItemsPerPage must be divisible by 9.");
}
int neededInvs = ((int) Math.ceil(items.size() / invSize));
for (int i = 0; i < neededInvs; i++) {
//Create inv
Inventory inv = Bukkit.createInventory(null, invSize - 1, title.replace("%page%", String.valueOf(i + 1)));
inventories.add(inv);
//Add navigation
ItemStack previous = SkullUtils.getSkull(UUID.fromString("a68f0b64-8d14-4000-a95f-4b9ba14f8df9"));
ItemMeta previousMeta = previous.getItemMeta();
previousMeta.setDisplayName(ChatColor.GOLD + "<< Vorige Pagina");
previous.setItemMeta(previousMeta);
ItemStack close = new ItemStack(Material.BARRIER, 1);
ItemMeta closeMeta = close.getItemMeta();
closeMeta.setDisplayName(ChatColor.RED + "Sluit Menu");
close.setItemMeta(closeMeta);
ItemStack next = SkullUtils.getSkull(UUID.fromString("50c8510b-5ea0-4d60-be9a-7d542d6cd156"));
ItemMeta nextMeta = next.getItemMeta();
nextMeta.setDisplayName(ChatColor.GOLD + "Volgende Pagina >>");
next.setItemMeta(nextMeta);
inv.setItem(itemsPerPage, previous);
inv.setItem(itemsPerPage + 4, close);
inv.setItem(itemsPerPage + 8, next);
}
}
}

View file

@ -1,144 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Crypto Morin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package me.mctp.xutils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.concurrent.CompletableFuture;
/**
* <b>ReflectionUtils</b> - Reflection handler for NMS and CraftBukkit.<br>
* Caches the packet related methods and is asynchronous.
* <p>
* This class does not handle null checks as most of the requests are from the
* other utility classes that already handle null checks.
* <p>
* <a href="https://wiki.vg/Protocol">Clientbound Packets</a> are considered fake
* updates to the client without changing the actual data. Since all the data is handled
* by the server.
*
* @author Crypto Morin
* @version 1.0.2
*/
public class ReflectionUtils {
/**
* We use reflection mainly to avoid writing a new class for version barrier.
* The version barrier is for NMS that uses the Minecraft version as the main package name.
* <p>
* E.g. EntityPlayer in 1.15 is in the class {@code net.minecraft.server.v1_15_R1}
* but in 1.14 it's in {@code net.minecraft.server.v1_14_R1}
* In order to maintain cross-version compatibility we cannot import these classes.
*/
public static final String VERSION = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
public static final String CRAFTBUKKIT = "org.bukkit.craftbukkit." + VERSION + '.';
public static final String NMS = "net.minecraft.server." + VERSION + '.';
private static final MethodHandle PLAYER_CONNECTION;
private static final MethodHandle GET_HANDLE;
private static final MethodHandle SEND_PACKET;
static {
Class<?> entityPlayer = getNMSClass("EntityPlayer");
Class<?> craftPlayer = getCraftClass("entity.CraftPlayer");
Class<?> playerConnection = getNMSClass("PlayerConnection");
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle sendPacket = null;
MethodHandle getHandle = null;
MethodHandle connection = null;
try {
connection = lookup.findGetter(entityPlayer, "playerConnection", playerConnection);
getHandle = lookup.findVirtual(craftPlayer, "getHandle", MethodType.methodType(entityPlayer));
sendPacket = lookup.findVirtual(playerConnection, "sendPacket", MethodType.methodType(void.class, getNMSClass("Packet")));
} catch (NoSuchMethodException | NoSuchFieldException | IllegalAccessException ex) {
ex.printStackTrace();
}
PLAYER_CONNECTION = connection;
SEND_PACKET = sendPacket;
GET_HANDLE = getHandle;
}
/**
* Get a NMS (net.minecraft.server) class.
*
* @param name the name of the class.
* @return the class.
* @since 1.0.0
*/
@Nullable
public static Class<?> getNMSClass(@Nonnull String name) {
try {
return Class.forName(NMS + name);
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
return null;
}
}
/**
* Sends a packet to the player asynchronously.
* Packets are thread-safe.
*
* @param player the player to send the packet to.
* @param packets the packets to send.
* @return the async thread handling the packet.
* @since 1.0.0
*/
@Nonnull
public static CompletableFuture<Void> sendPacket(@Nonnull Player player, @Nonnull Object... packets) {
return CompletableFuture.runAsync(() -> {
try {
Object handle = GET_HANDLE.invoke(player);
Object connection = PLAYER_CONNECTION.invoke(handle);
if (player.isOnline()) {
for (Object packet : packets) SEND_PACKET.invoke(connection, packet);
}
} catch (Throwable throwable) {
throwable.printStackTrace();
}
});
}
/**
* Get a CraftBukkit class.
*
* @param name the name of the class.
* @return a class.
* @since 1.0.0
*/
@Nullable
public static Class<?> getCraftClass(@Nonnull String name) {
try {
return Class.forName(CRAFTBUKKIT + name);
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
return null;
}
}
}

View file

@ -1,123 +0,0 @@
package me.mctp.xutils;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mojang.authlib.GameProfile;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
/**
* This class is currently unused until I find a solution.
*/
@SuppressWarnings("unused")
final class SkullCacheListener {
protected static final Map<UUID, String> CACHE = new HashMap<>();
private static final String SESSION = "https://sessionserver.mojang.com/session/minecraft/profile/";
/**
* https://api.mojang.com/users/profiles/minecraft/Username gives the ID
* https://api.mojang.com/user/profiles/ID without dashes/names gives the names used for the unique ID.
* https://sessionserver.mojang.com/session/minecraft/profile/ID example data:
* <p>
* <pre>
* {
* "id": "Without dashes -",
* "name": "",
* "properties": [
* {
* "name": "textures",
* "value": ""
* }
* ]
* }
* </pre>
*/
@Nullable
public static String getSkinValue(@Nonnull String id) {
Objects.requireNonNull(id, "Player UUID cannot be null");
try {
JsonParser parser = new JsonParser();
URL properties = new URL(SESSION + id); // + "?unsigned=false"
try (InputStreamReader readProperties = new InputStreamReader(properties.openStream())) {
JsonObject jObjectP = parser.parse(readProperties).getAsJsonObject();
if (mojangError(jObjectP)) return null;
JsonObject textureProperty = jObjectP.get("properties").getAsJsonArray().get(0).getAsJsonObject();
//String signature = textureProperty.get("signature").getAsString();
return textureProperty.get("value").getAsString();
}
} catch (IOException | IllegalStateException e) {
System.err.println("Could not get skin data from session servers! " + e.getMessage());
e.printStackTrace();
return null;
}
}
@Nullable
public static String getIdFromUsername(@Nonnull String username) {
Validate.notEmpty(username, "Cannot get UUID of a null or empty username");
int len = username.length();
if (len < 3 || len > 16) throw new IllegalArgumentException("Username cannot be less than 3 and longer than 16 characters: " + username);
try {
URL convertName = new URL("https://api.mojang.com/users/profiles/minecraft/" + username);
JsonParser parser = new JsonParser();
try (InputStreamReader idReader = new InputStreamReader(convertName.openStream())) {
JsonElement jElement = parser.parse(idReader);
if (!jElement.isJsonObject()) return null;
JsonObject jObject = jElement.getAsJsonObject();
if (mojangError(jObject)) return null;
return jObject.get("id").getAsString();
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private static boolean mojangError(@Nonnull JsonObject jsonObject) {
if (!jsonObject.has("error")) return false;
String err = jsonObject.get("error").getAsString();
String msg = jsonObject.get("errorMessage").getAsString();
System.err.println("Mojang Error " + err + ": " + msg);
return true;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
GameProfile profile = new GameProfile(player.getUniqueId(), player.getName());
ItemStack head = XMaterial.PLAYER_HEAD.parseItem();
SkullMeta meta = (SkullMeta) head.getItemMeta();
try {
SkullUtils.GAME_PROFILE.invoke(meta, profile);
} catch (Throwable ex) {
ex.printStackTrace();
}
head.setItemMeta(meta);
// If you don't add it to the players inventory, it won't be cached. That's the problem.
// Or is the inventory cached? I tested this with multiple inventories and other inventories load immediately after an inventory with
// the skull in it is opened once.
player.getInventory().addItem(head);
}
}

View file

@ -1,191 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Crypto Morin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package me.mctp.xutils;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.util.Base64;
import java.util.Objects;
import java.util.UUID;
import java.util.regex.Pattern;
/**
* <b>SkullUtils</b> - Apply skull texture from different sources.<br>
* Skull Meta: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/SkullMeta.html
* Mojang API: https://wiki.vg/Mojang_API
*
* @author Crypto Morin
* @version 3.0.1
* @see XMaterial
*/
public class SkullUtils {
protected static final MethodHandle GAME_PROFILE;
private static final String VALUE_PROPERTY = "{\"textures\":{\"SKIN\":{\"url\":\"";
private static final boolean SUPPORTS_UUID = XMaterial.supports(12);
private static final String TEXTURES = "https://textures.minecraft.net/texture/";
private static final Pattern BASE64 = Pattern.compile("(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?");
static {
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle gameProfile = null;
try {
Class<?> craftSkull = ReflectionUtils.getCraftClass("inventory.CraftMetaSkull");
Field profileField = craftSkull.getDeclaredField("profile");
profileField.setAccessible(true);
gameProfile = lookup.unreflectSetter(profileField);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
GAME_PROFILE = gameProfile;
}
@SuppressWarnings("deprecation")
@Nonnull
public static ItemStack getSkull(@Nonnull UUID id) {
ItemStack head = XMaterial.PLAYER_HEAD.parseItem();
SkullMeta meta = (SkullMeta) head.getItemMeta();
if (SUPPORTS_UUID) meta.setOwningPlayer(Bukkit.getOfflinePlayer(id));
else meta.setOwner(id.toString());
head.setItemMeta(meta);
return head;
}
@Nonnull
public static SkullMeta applyCachedSkin(@Nonnull ItemMeta head, @Nonnull UUID identifier) {
String base64 = SkullCacheListener.CACHE.get(identifier);
SkullMeta meta = (SkullMeta) head;
return getSkullByValue(meta, base64);
}
@SuppressWarnings("deprecation")
@Nonnull
public static SkullMeta applySkin(@Nonnull ItemMeta head, @Nonnull OfflinePlayer identifier) {
SkullMeta meta = (SkullMeta) head;
if (SUPPORTS_UUID) {
meta.setOwningPlayer(identifier);
} else {
meta.setOwner(identifier.getName());
}
return meta;
}
@Nonnull
public static SkullMeta applySkin(@Nonnull ItemMeta head, @Nonnull UUID identifier) {
return applySkin(head, Bukkit.getOfflinePlayer(identifier));
}
@SuppressWarnings("deprecation")
@Nonnull
public static SkullMeta applySkin(@Nonnull ItemMeta head, @Nonnull String identifier) {
SkullMeta meta = (SkullMeta) head;
if (isUsername(identifier)) return applySkin(head, Bukkit.getOfflinePlayer(identifier));
if (identifier.contains("textures.minecraft.net")) return getValueFromTextures(meta, identifier);
if (identifier.length() > 100 && isBase64(identifier)) return getSkullByValue(meta, identifier);
return getTexturesFromUrlValue(meta, identifier);
}
@Nonnull
private static SkullMeta getSkullByValue(@Nonnull SkullMeta head, @Nonnull String value) {
Validate.notEmpty(value, "Skull value cannot be null or empty");
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", value));
try {
GAME_PROFILE.invoke(head, profile);
} catch (Throwable ex) {
ex.printStackTrace();
}
return head;
}
@Nonnull
private static SkullMeta getValueFromTextures(@Nonnull SkullMeta head, @Nonnull String url) {
return getSkullByValue(head, encodeBase64(VALUE_PROPERTY + url + "\"}}}"));
}
@Nonnull
private static SkullMeta getTexturesFromUrlValue(@Nonnull SkullMeta head, @Nonnull String urlValue) {
return getValueFromTextures(head, TEXTURES + urlValue);
}
@Nonnull
private static String encodeBase64(@Nonnull String str) {
return Base64.getEncoder().encodeToString(str.getBytes());
}
private static boolean isBase64(@Nonnull String base64) {
return BASE64.matcher(base64).matches();
}
@Nullable
public static String getSkinValue(@Nonnull ItemStack skull) {
Objects.requireNonNull(skull, "Skull ItemStack cannot be null");
SkullMeta meta = (SkullMeta) skull.getItemMeta();
GameProfile profile = null;
try {
Field profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profile = (GameProfile) profileField.get(meta);
} catch (SecurityException | NoSuchFieldException | IllegalAccessException ex) {
ex.printStackTrace();
}
if (profile != null && !profile.getProperties().get("textures").isEmpty())
for (Property property : profile.getProperties().get("textures"))
if (!property.getValue().isEmpty())
return property.getValue();
return null;
}
private static boolean isUsername(@Nullable String name) {
if (Strings.isNullOrEmpty(name)) return false;
int len = name.length();
if (len < 3 || len > 16) return false;
// For some reasons Apache's Lists.charactersOf is faster than character indexing for small strings.
for (char ch : Lists.charactersOf(name)) {
if (ch != '_' && !(ch >= 'A' && ch <= 'Z') && !(ch >= 'a' && ch <= 'z') && !(ch >= '0' && ch <= '9')) return false;
}
return true;
}
}

File diff suppressed because it is too large Load diff