mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-02-10 08:31:26 +01:00
Fixes some code style issues in Compatibility module
This commit is contained in:
parent
3b92b69cc6
commit
3afc2aa6a4
@ -58,8 +58,8 @@ public enum ClassMapping {
|
||||
private final String packageName;
|
||||
private final String className;
|
||||
|
||||
ClassMapping(String packageName) {
|
||||
this(null, packageName);
|
||||
ClassMapping(String className) {
|
||||
this(null, className);
|
||||
}
|
||||
|
||||
ClassMapping(String packageName, String className) {
|
||||
@ -72,17 +72,17 @@ public enum ClassMapping {
|
||||
}
|
||||
|
||||
public Class<?> getClazz(String sub) {
|
||||
String name = sub == null ? className : className + "$" + sub;
|
||||
String name = sub == null ? this.className : this.className + "$" + sub;
|
||||
|
||||
try {
|
||||
if (className.startsWith("Craft")) {
|
||||
if (this.className.startsWith("Craft")) {
|
||||
return Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString()
|
||||
+ (packageName == null ? "" : "." + packageName) + "." + name);
|
||||
+ (this.packageName == null ? "" : "." + this.packageName) + "." + name);
|
||||
}
|
||||
|
||||
return Class.forName("net.minecraft." + (
|
||||
ServerVersion.isServerVersionAtLeast(ServerVersion.V1_17) && packageName != null
|
||||
? packageName : "server." + ServerVersion.getServerVersionString()) + "." + name);
|
||||
ServerVersion.isServerVersionAtLeast(ServerVersion.V1_17) && this.packageName != null
|
||||
? this.packageName : "server." + ServerVersion.getServerVersionString()) + "." + name);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import java.util.UUID;
|
||||
* NOTE: this is automatically initialized through SongodaCore
|
||||
*/
|
||||
public class ClientVersion {
|
||||
static HashMap<UUID, ServerVersion> players = new HashMap<>();
|
||||
private static final HashMap<UUID, ServerVersion> players = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Check to see what client version this player is connected to the server
|
||||
|
@ -165,7 +165,7 @@ public enum CompatibleBiome {
|
||||
}
|
||||
|
||||
CompatibleBiome() {
|
||||
versions.add(v(ServerVersion.UNKNOWN, name()));
|
||||
this.versions.add(v(ServerVersion.UNKNOWN, name()));
|
||||
}
|
||||
|
||||
CompatibleBiome(ServerVersion version, Version... versions) {
|
||||
@ -178,12 +178,12 @@ public enum CompatibleBiome {
|
||||
}
|
||||
|
||||
public List<Version> getVersions() {
|
||||
return new LinkedList<>(versions);
|
||||
return new LinkedList<>(this.versions);
|
||||
}
|
||||
|
||||
public Biome getBiome() {
|
||||
try {
|
||||
for (Version version : versions) {
|
||||
for (Version version : this.versions) {
|
||||
if (ServerVersion.isServerVersionAtLeast(version.version)) {
|
||||
return Biome.valueOf(version.biome);
|
||||
}
|
||||
|
@ -1356,7 +1356,7 @@ public enum CompatibleMaterial {
|
||||
private final Material material;
|
||||
private final Byte data;
|
||||
// quick test to see if our version is < 1.13
|
||||
protected static final boolean useLegacy = ServerVersion.isServerVersionBelow(ServerVersion.V1_13);
|
||||
private static final boolean useLegacy = ServerVersion.isServerVersionBelow(ServerVersion.V1_13);
|
||||
// map to speed up name->material lookups
|
||||
private static final Map<String, CompatibleMaterial> lookupMap = new HashMap<>();
|
||||
|
||||
@ -1398,20 +1398,20 @@ public enum CompatibleMaterial {
|
||||
this(ServerVersion.UNKNOWN, null, null);
|
||||
}
|
||||
|
||||
CompatibleMaterial(String legacy) {
|
||||
this(ServerVersion.V1_13, null, null, legacy, null);
|
||||
CompatibleMaterial(String legacyMaterial) {
|
||||
this(ServerVersion.V1_13, null, null, legacyMaterial, null);
|
||||
}
|
||||
|
||||
CompatibleMaterial(String legacy, byte legacyData) {
|
||||
this(ServerVersion.V1_13, null, null, legacy, legacyData);
|
||||
CompatibleMaterial(String legacyMaterial, byte legacyData) {
|
||||
this(ServerVersion.V1_13, null, null, legacyMaterial, legacyData);
|
||||
}
|
||||
|
||||
CompatibleMaterial(ServerVersion modernMinimum, String legacy) {
|
||||
this(modernMinimum, null, null, legacy, null);
|
||||
CompatibleMaterial(ServerVersion modernMinimum, String legacyMaterial) {
|
||||
this(modernMinimum, null, null, legacyMaterial, null);
|
||||
}
|
||||
|
||||
CompatibleMaterial(ServerVersion modernMinimum, String legacy, Byte legacyData) {
|
||||
this(modernMinimum, null, null, legacy, legacyData);
|
||||
CompatibleMaterial(ServerVersion modernMinimum, String legacyMaterial, Byte legacyData) {
|
||||
this(modernMinimum, null, null, legacyMaterial, legacyData);
|
||||
}
|
||||
|
||||
CompatibleMaterial(ServerVersion modernMinimum, String modern2, ServerVersion modern2Minimum, String legacyMaterial, Byte legacyData) {
|
||||
@ -1422,35 +1422,35 @@ public enum CompatibleMaterial {
|
||||
this.legacy = legacyMaterial;
|
||||
this.legacyData = legacyData == null ? 0 : legacyData;
|
||||
this.legacyRequiresData = legacyData != null;
|
||||
this.compatibleMaterial = LegacyMaterialAnalouge.lookupAnalouge(modern);
|
||||
this.compatibleMaterial = LegacyMaterialAnalouge.lookupAnalouge(this.modern);
|
||||
|
||||
if (compatibleMaterial != null && ServerVersion.isServerVersionBelow(compatibleMaterial.versionLessThan)) {
|
||||
if (this.compatibleMaterial != null && ServerVersion.isServerVersionBelow(this.compatibleMaterial.versionLessThan)) {
|
||||
// server older than this item: use a proxy
|
||||
material = compatibleMaterial.material;
|
||||
data = compatibleMaterial.data;
|
||||
} else if (ServerVersion.isServerVersionAtLeast(minVersion)) {
|
||||
material = Material.getMaterial(modern);
|
||||
data = null;
|
||||
} else if (modern2 != null && ServerVersion.isServerVersionAtLeast(minVersion2)) {
|
||||
material = Material.getMaterial(modern2);
|
||||
data = null;
|
||||
} else if (legacyMaterial != null && (compatibleMaterial == null || ServerVersion.isServerVersionAtLeast(compatibleMaterial.versionLessThan))) {
|
||||
this.material = this.compatibleMaterial.material;
|
||||
this.data = this.compatibleMaterial.data;
|
||||
} else if (ServerVersion.isServerVersionAtLeast(this.minVersion)) {
|
||||
this.material = Material.getMaterial(this.modern);
|
||||
this.data = null;
|
||||
} else if (modern2 != null && ServerVersion.isServerVersionAtLeast(this.minVersion2)) {
|
||||
this.material = Material.getMaterial(modern2);
|
||||
this.data = null;
|
||||
} else if (legacyMaterial != null && (this.compatibleMaterial == null || ServerVersion.isServerVersionAtLeast(this.compatibleMaterial.versionLessThan))) {
|
||||
// we're using a server that has the legacy value available
|
||||
material = Material.getMaterial(legacyMaterial);
|
||||
data = legacyRequiresData ? this.legacyData : null;
|
||||
} else if (compatibleMaterial != null) {
|
||||
this.material = Material.getMaterial(legacyMaterial);
|
||||
this.data = this.legacyRequiresData ? this.legacyData : null;
|
||||
} else if (this.compatibleMaterial != null) {
|
||||
// no match: use a proxy
|
||||
material = compatibleMaterial.material;
|
||||
data = compatibleMaterial.data;
|
||||
this.material = this.compatibleMaterial.material;
|
||||
this.data = this.compatibleMaterial.data;
|
||||
} else {
|
||||
material = null;
|
||||
data = null;
|
||||
this.material = null;
|
||||
this.data = null;
|
||||
}
|
||||
|
||||
if (material != null && ServerVersion.isServerVersionBelow(ServerVersion.V1_13) && (compatibleMaterial == null || material != compatibleMaterial.material)) {
|
||||
legacyBlockMaterial = LegacyMaterialBlockType.getMaterial(this.modern);
|
||||
if (this.material != null && ServerVersion.isServerVersionBelow(ServerVersion.V1_13) && (this.compatibleMaterial == null || this.material != this.compatibleMaterial.material)) {
|
||||
this.legacyBlockMaterial = LegacyMaterialBlockType.getMaterial(this.modern);
|
||||
} else {
|
||||
legacyBlockMaterial = null;
|
||||
this.legacyBlockMaterial = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1458,14 +1458,14 @@ public enum CompatibleMaterial {
|
||||
* @return the Bukkit Material for this material
|
||||
*/
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
return this.material;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Bukkit Material required to create a block
|
||||
*/
|
||||
public Material getBlockMaterial() {
|
||||
return legacyBlockMaterial != null ? legacyBlockMaterial.getBlockMaterial() : (isBlock() ? material : AIR.material);
|
||||
return this.legacyBlockMaterial != null ? this.legacyBlockMaterial.getBlockMaterial() : (isBlock() ? this.material : AIR.material);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1482,24 +1482,24 @@ public enum CompatibleMaterial {
|
||||
*/
|
||||
public ItemStack getItem(int amount) {
|
||||
if (usesCompatibility()) {
|
||||
return compatibleMaterial.getItem();
|
||||
return this.compatibleMaterial.getItem();
|
||||
}
|
||||
|
||||
return data != null ? new ItemStack(material, amount, data) : new ItemStack(material);
|
||||
return this.data != null ? new ItemStack(this.material, amount, this.data) : new ItemStack(this.material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this material need to use a legacy fallback?
|
||||
*/
|
||||
public boolean usesLegacy() {
|
||||
return legacy != null && ServerVersion.isServerVersionBelow(minVersion);
|
||||
return this.legacy != null && ServerVersion.isServerVersionBelow(this.minVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this material need to use a fallback item on this server?
|
||||
*/
|
||||
public boolean usesCompatibility() {
|
||||
return compatibleMaterial != null && material == compatibleMaterial.material;
|
||||
return this.compatibleMaterial != null && this.material == this.compatibleMaterial.material;
|
||||
//return compatibleMaterial != null && ServerVersion.isServerVersionBelow(compatibleMaterial.versionLessThan);
|
||||
}
|
||||
|
||||
@ -1514,7 +1514,7 @@ public enum CompatibleMaterial {
|
||||
* Get the legacy data value for this material if there is one, or -1 if none
|
||||
*/
|
||||
public byte getData() {
|
||||
return data != null ? data : -1;
|
||||
return this.data != null ? this.data : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1523,7 +1523,7 @@ public enum CompatibleMaterial {
|
||||
* @return true if server is legacy and this item requires data to be defined.
|
||||
*/
|
||||
public boolean usesData() {
|
||||
return data != null;
|
||||
return this.data != null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1840,11 +1840,11 @@ public enum CompatibleMaterial {
|
||||
public void applyToBlock(Block block) {
|
||||
if (block == null) return;
|
||||
|
||||
block.setType(material);
|
||||
block.setType(this.material);
|
||||
|
||||
if (data != null && data != -1 && ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) {
|
||||
if (this.data != null && this.data != -1 && ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) {
|
||||
try {
|
||||
methodSetData.invoke(block, data);
|
||||
methodSetData.invoke(block, this.data);
|
||||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -1860,9 +1860,9 @@ public enum CompatibleMaterial {
|
||||
*/
|
||||
public boolean matches(ItemStack item) {
|
||||
return item != null &&
|
||||
!usesCompatibility() && item.getType() == material &&
|
||||
!usesCompatibility() && item.getType() == this.material &&
|
||||
// eons ago, ItemStack.getData() would return a byte. 1.7 doesn't, though.
|
||||
(data == null || item.getDurability() == data);
|
||||
(this.data == null || item.getDurability() == this.data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1935,21 +1935,21 @@ public enum CompatibleMaterial {
|
||||
* Check to see if this is a material that can exist as a block
|
||||
*/
|
||||
public boolean isBlock() {
|
||||
return material != null && material.isBlock();
|
||||
return this.material != null && this.material.isBlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if this is an item that can be consumed to restore hunger
|
||||
*/
|
||||
public boolean isEdible() {
|
||||
return material != null && material.isEdible();
|
||||
return this.material != null && this.material.isEdible();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the material is a block and can be built on
|
||||
*/
|
||||
public boolean isSolid() {
|
||||
return material != null && material.isSolid();
|
||||
return this.material != null && this.material.isSolid();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1963,21 +1963,21 @@ public enum CompatibleMaterial {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isTransparent() {
|
||||
return material != null && material.isTransparent();
|
||||
return this.material != null && this.material.isTransparent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the material is a block and can catch fire
|
||||
*/
|
||||
public boolean isFlammable() {
|
||||
return material != null && material.isFlammable();
|
||||
return this.material != null && this.material.isFlammable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the material is a block and can be destroyed by burning
|
||||
*/
|
||||
public boolean isBurnable() {
|
||||
return material != null && material.isBurnable();
|
||||
return this.material != null && this.material.isBurnable();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2386,14 +2386,14 @@ public enum CompatibleMaterial {
|
||||
* Check if the material is a block and completely blocks vision
|
||||
*/
|
||||
public boolean isOccluding() {
|
||||
return material != null && material.isOccluding();
|
||||
return this.material != null && this.material.isOccluding();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if this material is affected by gravity.
|
||||
*/
|
||||
public boolean hasGravity() {
|
||||
return material != null && material.hasGravity();
|
||||
return this.material != null && this.material.hasGravity();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3169,8 +3169,6 @@ public enum CompatibleMaterial {
|
||||
|
||||
public static CompatibleMaterial getGlassColor(int color) {
|
||||
switch (color) {
|
||||
case 0:
|
||||
return WHITE_STAINED_GLASS;
|
||||
case 1:
|
||||
return ORANGE_STAINED_GLASS;
|
||||
case 2:
|
||||
@ -3201,6 +3199,8 @@ public enum CompatibleMaterial {
|
||||
return RED_STAINED_GLASS;
|
||||
case 15:
|
||||
return BLACK_STAINED_GLASS;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
return WHITE_STAINED_GLASS;
|
||||
}
|
||||
@ -3208,8 +3208,6 @@ public enum CompatibleMaterial {
|
||||
|
||||
public static CompatibleMaterial getWoolColor(int color) {
|
||||
switch (color) {
|
||||
case 0:
|
||||
return WHITE_WOOL;
|
||||
case 1:
|
||||
return ORANGE_WOOL;
|
||||
case 2:
|
||||
@ -3240,6 +3238,8 @@ public enum CompatibleMaterial {
|
||||
return RED_WOOL;
|
||||
case 15:
|
||||
return BLACK_WOOL;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
return WHITE_WOOL;
|
||||
}
|
||||
@ -3247,8 +3247,6 @@ public enum CompatibleMaterial {
|
||||
|
||||
public static CompatibleMaterial getDyeColor(int color) {
|
||||
switch (color) {
|
||||
case 0:
|
||||
return BLACK_DYE;
|
||||
case 1:
|
||||
return RED_DYE;
|
||||
case 2:
|
||||
@ -3279,6 +3277,8 @@ public enum CompatibleMaterial {
|
||||
return ORANGE_DYE;
|
||||
case 15:
|
||||
return WHITE_DYE;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
return WHITE_DYE;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class CompatibleParticleHandler {
|
||||
final boolean compatibilityMode;
|
||||
final LegacyParticleEffects.Type compatibleEffect;
|
||||
final Object particle;
|
||||
final static Map<String, ParticleType> map = new HashMap<>();
|
||||
static final Map<String, ParticleType> map = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (ParticleType t : values()) {
|
||||
|
@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* TODO: Probably recode to be similar to CompatibleMaterial
|
||||
*
|
||||
* Sounds that are compatible with server versions 1.7+ <br>
|
||||
* TODO: This needs work.
|
||||
* Finished 1.8, finished 1.9 blocks, resume with 1.9 entities<br>
|
||||
@ -1358,19 +1357,19 @@ public enum CompatibleSound {
|
||||
if (DEBUG && find == null) {
|
||||
System.err.println("Sound for " + name() + " not found!");
|
||||
}
|
||||
sound = find;
|
||||
compatibilityMode = find == null;
|
||||
this.sound = find;
|
||||
this.compatibilityMode = find == null;
|
||||
}
|
||||
|
||||
// if the sound only ever changed from 1.8 -> 1.9
|
||||
CompatibleSound(String compatibility_18) {
|
||||
try {
|
||||
compatibilityMode = false;
|
||||
this.compatibilityMode = false;
|
||||
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_9)) {
|
||||
sound = Sound.valueOf(compatibility_18);
|
||||
this.sound = Sound.valueOf(compatibility_18);
|
||||
} else {
|
||||
sound = Sound.valueOf(name());
|
||||
this.sound = Sound.valueOf(name());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.err.println("ERROR loading " + name());
|
||||
@ -1382,8 +1381,8 @@ public enum CompatibleSound {
|
||||
try {
|
||||
for (Version v : versions) {
|
||||
if (v.sound != null && ServerVersion.isServerVersionAtLeast(v.version)) {
|
||||
sound = Sound.valueOf(v.sound);
|
||||
compatibilityMode = v.compatibilityMode;
|
||||
this.sound = Sound.valueOf(v.sound);
|
||||
this.compatibilityMode = v.compatibilityMode;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1404,28 +1403,28 @@ public enum CompatibleSound {
|
||||
}
|
||||
}
|
||||
|
||||
sound = find;
|
||||
compatibilityMode = find == null;
|
||||
this.sound = find;
|
||||
this.compatibilityMode = find == null;
|
||||
}
|
||||
|
||||
CompatibleSound(ServerVersion minVersion, Version... versions) {
|
||||
try {
|
||||
if (ServerVersion.isServerVersionAtLeast(minVersion)) {
|
||||
// should be good to use this sound
|
||||
sound = Sound.valueOf(name());
|
||||
this.sound = Sound.valueOf(name());
|
||||
} else {
|
||||
for (Version v : versions) {
|
||||
if (v.sound != null && ServerVersion.isServerVersionAtLeast(v.version)) {
|
||||
sound = Sound.valueOf(v.sound);
|
||||
compatibilityMode = v.compatibilityMode;
|
||||
this.sound = Sound.valueOf(v.sound);
|
||||
this.compatibilityMode = v.compatibilityMode;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sound = null;
|
||||
this.sound = null;
|
||||
}
|
||||
|
||||
compatibilityMode = false;
|
||||
this.compatibilityMode = false;
|
||||
} catch (Exception ex) {
|
||||
System.err.println("ERROR loading " + name() + " (" + minVersion + ")");
|
||||
for (Version v : versions) {
|
||||
@ -1443,7 +1442,7 @@ public enum CompatibleSound {
|
||||
* @return Either the matching sound or a similar sound
|
||||
*/
|
||||
public Sound getSound() {
|
||||
return sound != null ? sound : UI_BUTTON_CLICK.sound;
|
||||
return this.sound != null ? this.sound : UI_BUTTON_CLICK.sound;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1507,7 +1506,7 @@ public enum CompatibleSound {
|
||||
* @return Returns false if we are using a different sound.
|
||||
*/
|
||||
public boolean usesCompatibility() {
|
||||
return !compatibilityMode;
|
||||
return !this.compatibilityMode;
|
||||
}
|
||||
|
||||
private static Version v(String sound) {
|
||||
|
@ -809,41 +809,41 @@ public enum LegacyMaterialAnalouge {
|
||||
this.compatibleData = compatData;
|
||||
|
||||
if (ServerVersion.isServerVersionBelow(versionLessThan)) {
|
||||
if (legacyMinimumVersion != null && ServerVersion.isServerVersionBelow(legacyMinimumVersion)) {
|
||||
if (this.legacyMinimumVersion != null && ServerVersion.isServerVersionBelow(this.legacyMinimumVersion)) {
|
||||
// fallback material not available, so use its fallback
|
||||
material = Material.getMaterial(compatibleMaterial);
|
||||
data = compatibleData;
|
||||
} else if (modernMaterial == null || ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
|
||||
this.material = Material.getMaterial(this.compatibleMaterial);
|
||||
this.data = this.compatibleData;
|
||||
} else if (this.modernMaterial == null || ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
|
||||
// use legacy material if on legacy
|
||||
material = Material.getMaterial(legacyMaterial);
|
||||
data = legacyData;
|
||||
this.material = Material.getMaterial(legacyMaterial);
|
||||
this.data = legacyData;
|
||||
} else {
|
||||
material = Material.getMaterial(modernMaterial);
|
||||
data = null;
|
||||
this.material = Material.getMaterial(this.modernMaterial);
|
||||
this.data = null;
|
||||
}
|
||||
} else {
|
||||
material = null;
|
||||
data = null;
|
||||
this.material = null;
|
||||
this.data = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
return this.material;
|
||||
}
|
||||
|
||||
public boolean usesData() {
|
||||
return data != null;
|
||||
return this.data != null;
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
return data == null ? 0 : data;
|
||||
return this.data == null ? 0 : this.data;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
if (material == null) {
|
||||
if (this.material == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return data != null ? new ItemStack(material, 1, data) : new ItemStack(material);
|
||||
return this.data != null ? new ItemStack(this.material, 1, this.data) : new ItemStack(this.material);
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ public enum LegacyMaterialBlockType {
|
||||
final String alternateBlockMaterialName;
|
||||
final Material blockMaterial, alternateBlockMaterial;
|
||||
final boolean requiresData; // some blocks require data to render properly (double blocks)
|
||||
final static Map<String, LegacyMaterialBlockType> lookupTable = new HashMap<>();
|
||||
final static Map<String, LegacyMaterialBlockType> reverseLookupTable = new HashMap<>();
|
||||
static final Map<String, LegacyMaterialBlockType> lookupTable = new HashMap<>();
|
||||
static final Map<String, LegacyMaterialBlockType> reverseLookupTable = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (LegacyMaterialBlockType t : values()) {
|
||||
@ -85,29 +85,29 @@ public enum LegacyMaterialBlockType {
|
||||
this.blockMaterialName = blockMaterial;
|
||||
this.alternateBlockMaterialName = alternateMaterial;
|
||||
this.requiresData = requiresData;
|
||||
this.blockMaterial = Material.getMaterial(blockMaterialName);
|
||||
this.alternateBlockMaterial = Material.getMaterial(alternateBlockMaterialName);
|
||||
this.blockMaterial = Material.getMaterial(this.blockMaterialName);
|
||||
this.alternateBlockMaterial = Material.getMaterial(this.alternateBlockMaterialName);
|
||||
this.blockData = data;
|
||||
}
|
||||
|
||||
public String getBlockMaterialName() {
|
||||
return blockMaterialName;
|
||||
return this.blockMaterialName;
|
||||
}
|
||||
|
||||
public String getAlternateMaterialName() {
|
||||
return alternateBlockMaterialName;
|
||||
return this.alternateBlockMaterialName;
|
||||
}
|
||||
|
||||
public Material getBlockMaterial() {
|
||||
return blockMaterial;
|
||||
return this.blockMaterial;
|
||||
}
|
||||
|
||||
public Material getAlternateBlockMaterial() {
|
||||
return alternateBlockMaterial;
|
||||
return this.alternateBlockMaterial;
|
||||
}
|
||||
|
||||
public boolean requiresData() {
|
||||
return requiresData;
|
||||
return this.requiresData;
|
||||
}
|
||||
|
||||
public static LegacyMaterialBlockType getMaterial(String lookup) {
|
||||
|
@ -15,7 +15,6 @@ import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Particle effects for servers 1.8 and below
|
||||
*
|
||||
* TODO: Needs a recode, this class should not have any advanced logic like NMS magic
|
||||
*/
|
||||
public class LegacyParticleEffects {
|
||||
@ -177,7 +176,7 @@ public class LegacyParticleEffects {
|
||||
}
|
||||
final int rangeSquared = 256; // apparently there is no way to override this (unless to make smaller, of course)
|
||||
// collect a list of players to send this packet to
|
||||
List<Player> sendTo = new ArrayList();
|
||||
List<Player> sendTo = new ArrayList<>();
|
||||
if (localOnly == null) {
|
||||
for (Player p : l.getWorld().getPlayers()) {
|
||||
if (p.getLocation().distanceSquared(l) <= rangeSquared) {
|
||||
|
@ -3,15 +3,12 @@ package com.craftaro.core.compatibility;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
public class LegacyPotionEffects {
|
||||
private LegacyPotionEffects() {
|
||||
}
|
||||
|
||||
protected final static Random rand = new Random();
|
||||
|
||||
private final static HashMap<Integer, String> potionEffectNames = new HashMap<Integer, String>() {
|
||||
private static final HashMap<Integer, String> potionEffectNames = new HashMap<Integer, String>() {
|
||||
{
|
||||
put(PotionEffectType.SPEED.getId(), "Speed");
|
||||
put(PotionEffectType.SLOW.getId(), "Slowness");
|
||||
|
@ -109,43 +109,43 @@ public enum MethodMapping {
|
||||
|
||||
public Method getMethod(Class<?> clazz) {
|
||||
try {
|
||||
String methodName = _1_18;
|
||||
String methodName = this._1_18;
|
||||
switch (ServerVersion.getServerVersion()) {
|
||||
case V1_14:
|
||||
if (_1_14 != null) {
|
||||
methodName = _1_14;
|
||||
if (this._1_14 != null) {
|
||||
methodName = this._1_14;
|
||||
}
|
||||
|
||||
break;
|
||||
case V1_17:
|
||||
if (_1_17 != null) {
|
||||
methodName = _1_17;
|
||||
if (this._1_17 != null) {
|
||||
methodName = this._1_17;
|
||||
}
|
||||
|
||||
break;
|
||||
case V1_18:
|
||||
if (_1_18_2 != null) {
|
||||
methodName = _1_18_2;
|
||||
if (this._1_18_2 != null) {
|
||||
methodName = this._1_18_2;
|
||||
}
|
||||
|
||||
break;
|
||||
case V1_19:
|
||||
if (_1_19 != null) {
|
||||
methodName = _1_19;
|
||||
if (this._1_19 != null) {
|
||||
methodName = this._1_19;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
Method method = clazz.getMethod(methodName, parameters);
|
||||
Method method = clazz.getMethod(methodName, this.parameters);
|
||||
method.setAccessible(true);
|
||||
|
||||
return method;
|
||||
} catch (NullPointerException | NoSuchMethodException ex) {
|
||||
if (saneFallback != null && !saneFallback.equals(methodName)) {
|
||||
if (this.saneFallback != null && !this.saneFallback.equals(methodName)) {
|
||||
try {
|
||||
Method method = clazz.getMethod(saneFallback, parameters);
|
||||
Method method = clazz.getMethod(this.saneFallback, this.parameters);
|
||||
method.setAccessible(true);
|
||||
|
||||
return method;
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public enum ServerProject {
|
||||
UNKNOWN, CRAFTBUKKIT, SPIGOT, PAPER, TACO, GLOWSTONE, MOCK_BUKKIT;
|
||||
private final static ServerProject serverProject = checkProject();
|
||||
private static final ServerProject serverProject = checkProject();
|
||||
|
||||
private static ServerProject checkProject() {
|
||||
String serverPath = Bukkit.getServer().getClass().getName();
|
||||
|
@ -6,10 +6,10 @@ import org.bukkit.Bukkit;
|
||||
public enum ServerVersion {
|
||||
UNKNOWN, V1_7, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19, V1_20, V1_21;
|
||||
|
||||
private final static String serverPackageVersion;
|
||||
private final static String serverReleaseVersion;
|
||||
private final static ServerVersion serverVersion;
|
||||
private final static boolean isMocked;
|
||||
private static final String serverPackageVersion;
|
||||
private static final String serverReleaseVersion;
|
||||
private static final ServerVersion serverVersion;
|
||||
private static final boolean isMocked;
|
||||
|
||||
static {
|
||||
if (Bukkit.getServer() != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user