use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class PlatformHelper method getPlayerLanguage.
public String getPlayerLanguage(Player player) {
if (!(player instanceof CraftPlayer)) {
return "en_US";
}
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
try {
Field field = entityPlayer.getClass().getDeclaredField("locale");
String lang = field.get(entityPlayer).toString();
if (lang == null) {
return "en_US";
}
return lang;
} catch (Exception e) {
return "en_US";
}
}
use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class PlatformHelper method playParticleEffect.
/**
* @param location the {@link Location} around which players must be to see the effect
* @param effectName list of effects: https://gist.github.com/riking/5759002
* @param offsetX the amount to be randomly offset by in the X axis
* @param offsetY the amount to be randomly offset by in the Y axis
* @param offsetZ the amount to be randomly offset by in the Z axis
* @param speed the speed of the particles
* @param count the number of particles
* @param radius the radius around the location
*/
public void playParticleEffect(Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius, int... data) {
Validate.notNull(location, "Location cannot be null");
Validate.notNull(effectName, "Effect cannot be null");
Validate.notNull(location.getWorld(), "World cannot be null");
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(effectName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count);
radius = radius * radius;
for (Player player : location.getWorld().getPlayers()) {
if (MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), location) <= radius) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
}
use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class PlatformHelper method getPlayerLanguage.
public String getPlayerLanguage(Player player) {
if (!(player instanceof CraftPlayer)) {
return "en_US";
}
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
try {
Field field = entityPlayer.getClass().getDeclaredField("locale");
String lang = field.get(entityPlayer).toString();
if (lang == null) {
return "en_US";
}
return lang;
} catch (Exception e) {
return "en_US";
}
}
use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class PlatformHelper method playParticleEffect.
/**
* @param location the {@link Location} around which players must be to see the effect
* @param effectName list of effects: https://gist.github.com/riking/5759002
* @param offsetX the amount to be randomly offset by in the X axis
* @param offsetY the amount to be randomly offset by in the Y axis
* @param offsetZ the amount to be randomly offset by in the Z axis
* @param speed the speed of the particles
* @param count the number of particles
* @param radius the radius around the location
*/
public void playParticleEffect(Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius, int... data) {
EnumParticle effect;
try {
effect = EnumParticle.valueOf(effectName);
} catch (IllegalArgumentException e) {
effect = EnumParticle.a(effectName);
}
Validate.notNull(location, "Location cannot be null");
Validate.notNull(effect, "Effect cannot be null");
Validate.notNull(location.getWorld(), "World cannot be null");
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(effect, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, data);
radius = radius * radius;
for (Player player : location.getWorld().getPlayers()) {
if ((int) MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), location) <= radius) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
}
use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project MyPet by xXKeyleXx.
the class PlatformHelper method getPlayerLanguage.
public String getPlayerLanguage(Player player) {
if (!(player instanceof CraftPlayer)) {
return "en_US";
}
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
Object lang = ReflectionUtil.getFieldValue(EntityPlayer_locale_FIELD, entityPlayer);
if (lang == null) {
return "en_US";
}
return lang.toString();
}
Aggregations