mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-27 21:05:35 +01:00
Fix offsets
This commit is contained in:
parent
e026a78622
commit
4214b251cf
@ -31,12 +31,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
setArms(false);
|
||||
setGravity(true);
|
||||
setBasePlate(true);
|
||||
try {
|
||||
ReflectionUtils.callPrivateMethod(EntityArmorStand.class, this, "n", new Class[]{ boolean.class }, new Object[]{ true }); // n() = setMarker()
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// It will still work.
|
||||
}
|
||||
// There is no "Marker" tag in v1_8_R1
|
||||
this.parentPiece = parentPiece;
|
||||
try {
|
||||
ReflectionUtils.setPrivateField(EntityArmorStand.class, this, "bg", Integer.MAX_VALUE);
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
|
||||
import com.gmail.filoghost.holographicdisplays.disk.Configuration;
|
||||
import com.gmail.filoghost.holographicdisplays.util.NMSVersion;
|
||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
||||
|
||||
public class BungeeChannel implements PluginMessageListener {
|
||||
|
||||
@ -103,7 +102,7 @@ public class BungeeChannel implements PluginMessageListener {
|
||||
}
|
||||
|
||||
// OR, if you don't need to send it to a specific player
|
||||
Collection<? extends Player> players = VersionUtils.getOnlinePlayers();
|
||||
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
|
||||
if (players.size() > 0) {
|
||||
players.iterator().next().sendPluginMessage(HolographicDisplays.getInstance(), Configuration.useRedisBungee ? "RedisBungee" : "BungeeCord", b.toByteArray());
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
|
||||
import com.gmail.filoghost.holographicdisplays.api.VisibilityManager;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
||||
|
||||
public class CraftVisibilityManager implements VisibilityManager {
|
||||
|
||||
@ -39,7 +38,7 @@ public class CraftVisibilityManager implements VisibilityManager {
|
||||
boolean oldVisibleByDefault = this.visibleByDefault;
|
||||
this.visibleByDefault = visibleByDefault;
|
||||
|
||||
for (Player player : VersionUtils.getOnlinePlayers()) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
if (playersVisibilityMap != null && playersVisibilityMap.containsKey(player.getName().toLowerCase())) {
|
||||
// Has a specific value set
|
||||
|
@ -13,7 +13,6 @@ import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.object.CraftHologram;
|
||||
import com.gmail.filoghost.holographicdisplays.util.NMSVersion;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Offsets;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||
|
||||
@ -56,6 +55,7 @@ public class CraftItemLine extends CraftTouchableLine implements ItemLine {
|
||||
this.pickupHandler = pickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTouchHandler(TouchHandler touchHandler) {
|
||||
if (nmsItem != null) {
|
||||
Location loc = nmsItem.getBukkitEntityNMS().getLocation();
|
||||
@ -136,12 +136,8 @@ public class CraftItemLine extends CraftTouchableLine implements ItemLine {
|
||||
}
|
||||
|
||||
private double getItemOffset() {
|
||||
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_9_R1)) {
|
||||
return Offsets.ARMOR_STAND_WITH_ITEM_1_9;
|
||||
} else {
|
||||
return Offsets.ARMOR_STAND_WITH_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -10,7 +10,6 @@ import com.gmail.filoghost.holographicdisplays.api.line.TextLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSNameable;
|
||||
import com.gmail.filoghost.holographicdisplays.object.CraftHologram;
|
||||
import com.gmail.filoghost.holographicdisplays.placeholder.PlaceholdersManager;
|
||||
import com.gmail.filoghost.holographicdisplays.util.NMSVersion;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Offsets;
|
||||
|
||||
public class CraftTextLine extends CraftTouchableLine implements TextLine {
|
||||
@ -49,6 +48,7 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTouchHandler(TouchHandler touchHandler) {
|
||||
|
||||
if (nmsNameble != null) {
|
||||
@ -113,12 +113,8 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine {
|
||||
}
|
||||
|
||||
private double getTextOffset() {
|
||||
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_9_R1)) {
|
||||
return Offsets.ARMOR_STAND_ALONE_1_9;
|
||||
} else {
|
||||
return Offsets.ARMOR_STAND_ALONE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -6,7 +6,6 @@ import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
|
||||
import com.gmail.filoghost.holographicdisplays.object.CraftHologram;
|
||||
import com.gmail.filoghost.holographicdisplays.util.NMSVersion;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Offsets;
|
||||
|
||||
/**
|
||||
@ -95,12 +94,8 @@ public class CraftTouchSlimeLine extends CraftHologramLine {
|
||||
}
|
||||
|
||||
private double getSlimeOffset() {
|
||||
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_9_R1)) {
|
||||
return Offsets.ARMOR_STAND_WITH_SLIME_1_9;
|
||||
} else {
|
||||
return Offsets.ARMOR_STAND_WITH_SLIME;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -12,7 +12,6 @@ import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
|
||||
import com.gmail.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer;
|
||||
import com.gmail.filoghost.holographicdisplays.disk.Configuration;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
||||
|
||||
public class PlaceholdersRegister {
|
||||
|
||||
@ -25,7 +24,7 @@ public class PlaceholdersRegister {
|
||||
|
||||
@Override
|
||||
public String update() {
|
||||
return String.valueOf(VersionUtils.getOnlinePlayers().size());
|
||||
return String.valueOf(Bukkit.getOnlinePlayers().size());
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -8,23 +8,44 @@ public class Offsets {
|
||||
|
||||
public static final double
|
||||
|
||||
// For 1.8+, a single armor stand.
|
||||
ARMOR_STAND_ALONE = -0.26,
|
||||
// A single armor stand.
|
||||
ARMOR_STAND_ALONE = getArmorStandAloneOffset(),
|
||||
|
||||
// For 1.8+, an armor stand holding an item.
|
||||
ARMOR_STAND_WITH_ITEM = -1.48,
|
||||
// An armor stand holding an item.
|
||||
ARMOR_STAND_WITH_ITEM = getArmorStandWithItemOffset(),
|
||||
|
||||
// For 1.8+, an armor stand holding a slime.
|
||||
ARMOR_STAND_WITH_SLIME = -1.49,
|
||||
// An armor stand holding a slime.
|
||||
ARMOR_STAND_WITH_SLIME = getArmorStandWithSlimeOffset();
|
||||
|
||||
|
||||
// For 1.9+, a single armor stand.
|
||||
ARMOR_STAND_ALONE_1_9 = -0.29,
|
||||
private static double getArmorStandAloneOffset() {
|
||||
if (NMSVersion.getCurrent() == NMSVersion.v1_8_R1) {
|
||||
// When the NBT tag "Marker" was not implemented
|
||||
return -1.25;
|
||||
} else {
|
||||
return -0.29;
|
||||
}
|
||||
}
|
||||
|
||||
// For 1.9+, an armor stand holding an item.
|
||||
ARMOR_STAND_WITH_ITEM_1_9 = -0.0,
|
||||
|
||||
// For 1.9+, an armor stand holding a slime.
|
||||
ARMOR_STAND_WITH_SLIME_1_9 = -0.01;
|
||||
private static double getArmorStandWithItemOffset() {
|
||||
if (NMSVersion.getCurrent() == NMSVersion.v1_8_R1) {
|
||||
// When the NBT tag "Marker" was not implemented
|
||||
return -1.48;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static double getArmorStandWithSlimeOffset() {
|
||||
if (NMSVersion.getCurrent() == NMSVersion.v1_8_R1) {
|
||||
// When the NBT tag "Marker" was not implemented
|
||||
return -1.48;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,12 @@
|
||||
package com.gmail.filoghost.holographicdisplays.util;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class VersionUtils {
|
||||
|
||||
private static Method getOnlinePlayersMethod;
|
||||
private static boolean getOnlinePlayersUseReflection;
|
||||
|
||||
/**
|
||||
* This method uses a regex to get the NMS package part that changes with every update.
|
||||
* Example: v1_8_R1
|
||||
@ -56,30 +47,6 @@ public class VersionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Collection<? extends Player> getOnlinePlayers() {
|
||||
try {
|
||||
|
||||
if (getOnlinePlayersMethod == null) {
|
||||
getOnlinePlayersMethod = Bukkit.class.getDeclaredMethod("getOnlinePlayers");
|
||||
if (getOnlinePlayersMethod.getReturnType() == Player[].class) {
|
||||
getOnlinePlayersUseReflection = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getOnlinePlayersUseReflection) {
|
||||
return Bukkit.getOnlinePlayers();
|
||||
} else {
|
||||
Player[] playersArray = (Player[]) getOnlinePlayersMethod.invoke(null);
|
||||
return ImmutableList.copyOf(playersArray);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 1 if reference > comparison, 0 if reference == comparison, -1 if reference < comparison
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user