Correct the WrappedGameProfile unit test.
Dieser Commit ist enthalten in:
Ursprung
4bd9a1f01e
Commit
b3cda21fe5
@ -40,18 +40,21 @@ public final class PluginContext {
|
|||||||
/**
|
/**
|
||||||
* Lookup the plugin that this method invocation belongs to, and return its file name.
|
* Lookup the plugin that this method invocation belongs to, and return its file name.
|
||||||
* @param element - the method invocation.
|
* @param element - the method invocation.
|
||||||
* @return Pluing name, or NULL if not found.
|
* @return Plugin name, or NULL if not found.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static String getPluginName(StackTraceElement element) {
|
public static String getPluginName(StackTraceElement element) {
|
||||||
try {
|
try {
|
||||||
|
if (Bukkit.getServer() == null)
|
||||||
|
return null;
|
||||||
CodeSource codeSource = Class.forName(element.getClassName()).getProtectionDomain().getCodeSource();
|
CodeSource codeSource = Class.forName(element.getClassName()).getProtectionDomain().getCodeSource();
|
||||||
|
|
||||||
if (codeSource != null) {
|
if (codeSource != null) {
|
||||||
String encoding = codeSource.getLocation().getPath();
|
String encoding = codeSource.getLocation().getPath();
|
||||||
File path = new File(URLDecoder.decode(encoding, "UTF-8"));
|
File path = new File(URLDecoder.decode(encoding, "UTF-8"));
|
||||||
|
File plugins = getPluginFolder();
|
||||||
if (folderContains(getPluginFolder(), path)) {
|
|
||||||
|
if (plugins != null && folderContains(plugins, path)) {
|
||||||
return path.getName();
|
return path.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,12 +91,12 @@ public final class PluginContext {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the folder that contains every plugin on the server.
|
* Retrieve the folder that contains every plugin on the server.
|
||||||
* @return Folder with every plugin.
|
* @return Folder with every plugin, or NULL if Bukkit has not been initialized yet.
|
||||||
*/
|
*/
|
||||||
private static File getPluginFolder() {
|
private static File getPluginFolder() {
|
||||||
File folder = pluginFolder;
|
File folder = pluginFolder;
|
||||||
|
|
||||||
if (folder == null) {
|
if (folder == null && Bukkit.getServer() != null) {
|
||||||
Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
|
Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
|
||||||
|
|
||||||
if (plugins.length > 0) {
|
if (plugins.length > 0) {
|
||||||
|
@ -2,10 +2,13 @@ package com.comphenix.protocol.wrappers;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.comphenix.protocol.BukkitInitialization;
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
|
||||||
public class WrappedGameProfileTest {
|
public class WrappedGameProfileTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@ -13,15 +16,16 @@ public class WrappedGameProfileTest {
|
|||||||
BukkitInitialization.initializePackage();
|
BukkitInitialization.initializePackage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testSkinUpdate() {
|
public void testSkinUpdate() {
|
||||||
final String nullUUID = "00000000-0000-0000-0000-000000000000";
|
final UUID uuid = UUID.nameUUIDFromBytes("123".getBytes(Charsets.UTF_8));
|
||||||
|
|
||||||
assertEquals(null, new WrappedGameProfile((String)null, "Test").getId());
|
assertEquals(null, new WrappedGameProfile((String)null, "Test").getId());
|
||||||
assertEquals(nullUUID, new WrappedGameProfile("", "Test").getId());
|
assertEquals(uuid, new WrappedGameProfile("123", "Test").getUUID());
|
||||||
assertEquals(nullUUID, new WrappedGameProfile("0", "Test").getId());
|
|
||||||
assertEquals(nullUUID, new WrappedGameProfile("00-0", "Test").getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void testNullFailure() {
|
public void testNullFailure() {
|
||||||
new WrappedGameProfile((String)null, null);
|
new WrappedGameProfile((String)null, null);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren