Skip to content
Permalink
Browse files

unmodule some other moduled code

Particle, faceLocation, chest sounds, boss bars
  • Loading branch information...
mcmonkey4eva committed Mar 23, 2019
1 parent fce8526 commit fbfe208b7fb6089a898df98dc8631390a0739e95
Showing with 135 additions and 597 deletions.
  1. +0 −2 nmshandler/src/main/java/net/aufdemrand/denizen/nms/abstracts/ImprovedOfflinePlayer.java
  2. +27 −1 nmshandler/src/main/java/net/aufdemrand/denizen/nms/abstracts/ParticleHelper.java
  3. +9 −1 nmshandler/src/main/java/net/aufdemrand/denizen/nms/interfaces/EntityHelper.java
  4. +26 −7 nmshandler/src/main/java/net/aufdemrand/denizen/nms/interfaces/Particle.java
  5. +14 −18 nmshandler/src/main/java/net/aufdemrand/denizen/nms/interfaces/PlayerHelper.java
  6. +0 −4 nmshandler/src/main/java/net/aufdemrand/denizen/nms/interfaces/SoundHelper.java
  7. +4 −4 plugin/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java
  8. +0 −2 plugin/src/main/java/net/aufdemrand/denizen/objects/properties/item/ItemColor.java
  9. +3 −2 plugin/src/main/java/net/aufdemrand/denizen/scripts/commands/world/AnimateChestCommand.java
  10. +47 −0 plugin/src/main/java/net/aufdemrand/denizen/utilities/entity/BossBarHelper.java
  11. +0 −11 v1_10_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/EntityHelper_v1_10_R1.java
  12. +0 −25 v1_10_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/ParticleHelper_v1_10_R1.java
  13. +1 −50 v1_10_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/PlayerHelper_v1_10_R1.java
  14. +0 −10 v1_10_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/SoundHelper_v1_10_R1.java
  15. +0 −36 v1_10_R1/src/main/java/net/aufdemrand/denizen/nms/impl/effects/Particle_v1_10_R1.java
  16. +0 −11 v1_11_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/EntityHelper_v1_11_R1.java
  17. +0 −25 v1_11_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/ParticleHelper_v1_11_R1.java
  18. +1 −50 v1_11_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/PlayerHelper_v1_11_R1.java
  19. +0 −10 v1_11_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/SoundHelper_v1_11_R1.java
  20. +0 −36 v1_11_R1/src/main/java/net/aufdemrand/denizen/nms/impl/effects/Particle_v1_11_R1.java
  21. +0 −11 v1_12_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/EntityHelper_v1_12_R1.java
  22. +0 −25 v1_12_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/ParticleHelper_v1_12_R1.java
  23. +1 −50 v1_12_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/PlayerHelper_v1_12_R1.java
  24. +0 −10 v1_12_R1/src/main/java/net/aufdemrand/denizen/nms/helpers/SoundHelper_v1_12_R1.java
  25. +0 −36 v1_12_R1/src/main/java/net/aufdemrand/denizen/nms/impl/effects/Particle_v1_12_R1.java
  26. +1 −1 v1_13_R2/src/main/java/net/aufdemrand/denizen/nms/Handler_v1_13_R2.java
  27. +0 −11 v1_13_R2/src/main/java/net/aufdemrand/denizen/nms/helpers/EntityHelper_v1_13_R2.java
  28. +0 −34 v1_13_R2/src/main/java/net/aufdemrand/denizen/nms/helpers/ParticleHelper_v1_13_R2.java
  29. +1 −50 v1_13_R2/src/main/java/net/aufdemrand/denizen/nms/helpers/PlayerHelper_v1_13_R2.java
  30. +0 −10 v1_13_R2/src/main/java/net/aufdemrand/denizen/nms/helpers/SoundHelper_v1_13_R2.java
  31. +0 −54 v1_13_R2/src/main/java/net/aufdemrand/denizen/nms/impl/effects/Particle_v1_13_R2.java
@@ -28,8 +28,6 @@
* @author one4me
*/

import net.aufdemrand.denizen.nms.NMSHandler;
import net.aufdemrand.denizen.nms.NMSVersion;
import net.aufdemrand.denizen.nms.util.jnbt.CompoundTag;
import net.aufdemrand.denizen.nms.util.jnbt.DoubleTag;
import net.aufdemrand.denizen.nms.util.jnbt.FloatTag;
@@ -8,7 +8,33 @@
import java.util.List;
import java.util.Map;

public abstract class ParticleHelper {
public class ParticleHelper {

public ParticleHelper() {
for (org.bukkit.Particle particle : org.bukkit.Particle.values()) {
register(particle.name(), new Particle(particle));
}
register("SMOKE", new Particle(org.bukkit.Particle.SMOKE_NORMAL));
register("HUGE_EXPLOSION", new Particle(org.bukkit.Particle.EXPLOSION_HUGE));
register("LARGE_EXPLODE", new Particle(org.bukkit.Particle.EXPLOSION_LARGE));
register("BUBBLE", new Particle(org.bukkit.Particle.WATER_BUBBLE));
register("SUSPEND", new Particle(org.bukkit.Particle.SUSPENDED));
register("DEPTH_SUSPEND", new Particle(org.bukkit.Particle.SUSPENDED_DEPTH));
register("CRIT", new Particle(org.bukkit.Particle.CRIT));
register("MAGIC_CRIT", new Particle(org.bukkit.Particle.CRIT_MAGIC));
register("MOB_SPELL", new Particle(org.bukkit.Particle.SPELL_MOB));
register("MOB_SPELL_AMBIENT", new Particle(org.bukkit.Particle.SPELL_MOB_AMBIENT));
register("INSTANT_SPELL", new Particle(org.bukkit.Particle.SPELL_INSTANT));
register("WITCH_MAGIC", new Particle(org.bukkit.Particle.SPELL_WITCH));
register("STEP_SOUND", new Particle(org.bukkit.Particle.HEART));
register("EXPLODE", new Particle(org.bukkit.Particle.EXPLOSION_NORMAL));
register("SPLASH", new Particle(org.bukkit.Particle.WATER_SPLASH));
register("LARGE_SMOKE", new Particle(org.bukkit.Particle.SMOKE_LARGE));
register("RED_DUST", new Particle(org.bukkit.Particle.REDSTONE));
register("SNOWBALL_POOF", new Particle(org.bukkit.Particle.SNOWBALL));
register("ANGRY_VILLAGER", new Particle(org.bukkit.Particle.VILLAGER_ANGRY));
register("HAPPY_VILLAGER", new Particle(org.bukkit.Particle.VILLAGER_HAPPY));
}

public HashMap<String, Effect> effectRemap = new HashMap<>();
private final Map<String, Particle> particles = new HashMap<>();
@@ -306,7 +306,15 @@ public Location faceLocation(Location from, Location at) {
* @param from The Entity whose yaw and pitch you want to change.
* @param at The Location it should be looking at.
*/
public abstract void faceLocation(Entity from, Location at);
public void faceLocation(Entity from, Location at) {
if (from.getWorld() != at.getWorld()) {
return;
}
Location origin = from instanceof LivingEntity ? ((LivingEntity) from).getEyeLocation()
: from.getLocation().getBlock().getLocation().add(0.5, 0.5, 0.5);
Location rotated = faceLocation(origin, at);
rotate(from, rotated.getYaw(), rotated.getPitch());
}

/**
* Changes an entity's yaw and pitch to make it face another entity.
@@ -4,17 +4,36 @@
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;

public interface Particle {
public class Particle {

void playFor(Player player, Location location, int count, Vector offset, double extra);
public org.bukkit.Particle particle;

<T> void playFor(Player player, Location location, int count, Vector offset, double extra, T data);
public Particle(org.bukkit.Particle particle) {
this.particle = particle;
}

public void playFor(Player player, Location location, int count, Vector offset, double extra) {
player.spawnParticle(particle, location, count, offset.getX(), offset.getY(), offset.getZ(), extra);
}

boolean isVisible();
public <T> void playFor(Player player, Location location, int count, Vector offset, double extra, T data) {
player.spawnParticle(particle, location, count, offset.getX(), offset.getY(), offset.getZ(), extra, data);
}

String getName();
public boolean isVisible() {
return particle != org.bukkit.Particle.SUSPENDED && particle != org.bukkit.Particle.SUSPENDED_DEPTH
&& particle != org.bukkit.Particle.WATER_BUBBLE;
}

public String getName() {
return particle.name();
}

default Class neededData() {
return null;
public Class neededData() {
Class clazz = particle.getDataType();
if (clazz == Void.class) {
return null;
}
return clazz;
}
}
@@ -5,35 +5,31 @@
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;

import java.util.UUID;
import java.util.*;

public interface PlayerHelper {
public abstract class PlayerHelper {

float getAbsorption(Player player);
public abstract float getAbsorption(Player player);

void setAbsorption(Player player, float value);
public abstract void setAbsorption(Player player, float value);

int ticksPassedDuringCooldown(Player player);
public abstract int ticksPassedDuringCooldown(Player player);

float getMaxAttackCooldownTicks(Player player);
public abstract float getMaxAttackCooldownTicks(Player player);

float getAttackCooldownPercent(Player player);
public abstract float getAttackCooldownPercent(Player player);

void setAttackCooldown(Player player, int ticks);
public abstract void setAttackCooldown(Player player, int ticks);

boolean hasChunkLoaded(Player player, Chunk chunk);
public abstract boolean hasChunkLoaded(Player player, Chunk chunk);

int getPing(Player player);
public abstract int getPing(Player player);

void setTemporaryOp(Player player, boolean op);
public abstract void setTemporaryOp(Player player, boolean op);

void showEndCredits(Player player);
public abstract void showEndCredits(Player player);

ImprovedOfflinePlayer getOfflineData(UUID uuid);
public abstract ImprovedOfflinePlayer getOfflineData(UUID uuid);

ImprovedOfflinePlayer getOfflineData(OfflinePlayer offlinePlayer);

void showSimpleBossBar(Player player, String title, double progress);

void removeSimpleBossBar(Player player);
public abstract ImprovedOfflinePlayer getOfflineData(OfflinePlayer offlinePlayer);
}
@@ -49,10 +49,6 @@

Sound getDefaultMidiInstrument();

Sound getChestOpen();

Sound getChestClose();

default void playSound(Player player, Location location, String sound, float volume, float pitch, String category) {
if (player == null) {
location.getWorld().playSound(location, sound, volume, pitch);
@@ -14,6 +14,7 @@
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizen.utilities.depends.Depends;
import net.aufdemrand.denizen.utilities.entity.BossBarHelper;
import net.aufdemrand.denizen.utilities.packets.ItemChangeMessage;
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.tags.Attribute;
@@ -23,7 +24,6 @@
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.*;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.block.Block;
import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.Entity;
@@ -2921,14 +2921,14 @@ else if (split.length > 1 && new Element(split[1]).isBoolean()) {
if (!mechanism.getValue().asString().isEmpty()) {
String[] split = mechanism.getValue().asString().split("[\\|" + dList.internal_escape + "]", 2);
if (split.length == 2 && new Element(split[0]).isDouble()) {
NMSHandler.getInstance().getPlayerHelper().showSimpleBossBar(getPlayerEntity(), split[1], new Element(split[0]).asDouble() * (1.0 / 200.0));
BossBarHelper.showSimpleBossBar(getPlayerEntity(), split[1], new Element(split[0]).asDouble() * (1.0 / 200.0));
}
else {
NMSHandler.getInstance().getPlayerHelper().showSimpleBossBar(getPlayerEntity(), split[0], 1.0);
BossBarHelper.showSimpleBossBar(getPlayerEntity(), split[0], 1.0);
}
}
else {
NMSHandler.getInstance().getPlayerHelper().removeSimpleBossBar(getPlayerEntity());
BossBarHelper.removeSimpleBossBar(getPlayerEntity());
}
}

@@ -1,7 +1,5 @@
package net.aufdemrand.denizen.objects.properties.item;

import net.aufdemrand.denizen.nms.NMSHandler;
import net.aufdemrand.denizen.nms.NMSVersion;
import net.aufdemrand.denizen.objects.dColor;
import net.aufdemrand.denizen.objects.dItem;
import net.aufdemrand.denizencore.objects.Mechanism;
@@ -12,6 +12,7 @@
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.scripts.ScriptEntry;
import net.aufdemrand.denizencore.scripts.commands.AbstractCommand;
import org.bukkit.Sound;
import org.bukkit.entity.Player;

import java.util.Arrays;
@@ -96,7 +97,7 @@ public void execute(ScriptEntry scriptEntry) {
Player ent = player.getPlayerEntity();
if (sound.asBoolean()) {
NMSHandler.getInstance().getSoundHelper().playSound(ent, location,
NMSHandler.getInstance().getSoundHelper().getChestOpen(), 1, 1, "BLOCKS");
Sound.BLOCK_CHEST_OPEN, 1, 1, "BLOCKS");
}
packetHelper.showBlockAction(ent, location, 1, 1);
}
@@ -107,7 +108,7 @@ public void execute(ScriptEntry scriptEntry) {
Player ent = player.getPlayerEntity();
if (sound.asBoolean()) {
NMSHandler.getInstance().getSoundHelper().playSound(ent, location,
NMSHandler.getInstance().getSoundHelper().getChestClose(), 1, 1, "BLOCKS");
Sound.BLOCK_CHEST_CLOSE, 1, 1, "BLOCKS");
}
packetHelper.showBlockAction(ent, location, 1, 0);
}
@@ -0,0 +1,47 @@
package net.aufdemrand.denizen.utilities.entity;

import org.bukkit.Bukkit;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;

import java.util.*;

public class BossBarHelper {

private static final Map<UUID, List<BossBar>> bossBars = new HashMap<>();

public static void showSimpleBossBar(Player player, String title, double progress) {
UUID uuid = player.getUniqueId();
if (!bossBars.containsKey(uuid)) {
bossBars.put(uuid, new ArrayList<>());
}
List<BossBar> playerBars = bossBars.get(uuid);
if (!playerBars.isEmpty()) {
Iterator<BossBar> iterator = playerBars.iterator();
while (iterator.hasNext()) {
BossBar bossBar = iterator.next();
bossBar.removePlayer(player);
iterator.remove();
}
}
BossBar bossBar = Bukkit.createBossBar(title, BarColor.PURPLE, BarStyle.SOLID);
bossBar.setProgress(progress);
bossBar.addPlayer(player);
bossBar.setVisible(true);
playerBars.add(bossBar);
}

public static void removeSimpleBossBar(Player player) {
UUID uuid = player.getUniqueId();
if (bossBars.containsKey(uuid) && !bossBars.get(uuid).isEmpty()) {
Iterator<BossBar> iterator = bossBars.get(uuid).iterator();
while (iterator.hasNext()) {
BossBar bossBar = iterator.next();
bossBar.removePlayer(player);
iterator.remove();
}
}
}
}
@@ -483,17 +483,6 @@ public Location getImpactNormal(Location start, Vector direction, double range)
return null;
}

@Override
public void faceLocation(Entity from, Location at) {
if (from.getWorld() != at.getWorld()) {
return;
}
Location origin = from instanceof LivingEntity ? ((LivingEntity) from).getEyeLocation()
: from.getLocation().getBlock().getLocation().add(0.5, 0.5, 0.5);
Location rotated = faceLocation(origin, at);
rotate(from, rotated.getYaw(), rotated.getPitch());
}

@Override
public void move(Entity entity, Vector vector) {
((CraftEntity) entity).getHandle().move(vector.getX(), vector.getY(), vector.getZ());
@@ -1,37 +1,12 @@
package net.aufdemrand.denizen.nms.helpers;

import net.aufdemrand.denizen.nms.abstracts.ParticleHelper;
import net.aufdemrand.denizen.nms.impl.effects.Particle_v1_10_R1;
import org.bukkit.Effect;
import org.bukkit.Particle;

public class ParticleHelper_v1_10_R1 extends ParticleHelper {

public ParticleHelper_v1_10_R1() {
for (Particle particle : Particle.values()) {
register(particle.name(), new Particle_v1_10_R1(particle));
}
effectRemap.put("DRIP_WATER", Effect.WATERDRIP);
effectRemap.put("DRIP_LAVA", Effect.LAVADRIP);
register("SMOKE", new Particle_v1_10_R1(Particle.SMOKE_NORMAL));
register("HUGE_EXPLOSION", new Particle_v1_10_R1(Particle.EXPLOSION_HUGE));
register("LARGE_EXPLODE", new Particle_v1_10_R1(Particle.EXPLOSION_LARGE));
register("BUBBLE", new Particle_v1_10_R1(Particle.WATER_BUBBLE));
register("SUSPEND", new Particle_v1_10_R1(Particle.SUSPENDED));
register("DEPTH_SUSPEND", new Particle_v1_10_R1(Particle.SUSPENDED_DEPTH));
register("CRIT", new Particle_v1_10_R1(Particle.CRIT));
register("MAGIC_CRIT", new Particle_v1_10_R1(Particle.CRIT_MAGIC));
register("MOB_SPELL", new Particle_v1_10_R1(Particle.SPELL_MOB));
register("MOB_SPELL_AMBIENT", new Particle_v1_10_R1(Particle.SPELL_MOB_AMBIENT));
register("INSTANT_SPELL", new Particle_v1_10_R1(Particle.SPELL_INSTANT));
register("WITCH_MAGIC", new Particle_v1_10_R1(Particle.SPELL_WITCH));
register("STEP_SOUND", new Particle_v1_10_R1(Particle.HEART));
register("EXPLODE", new Particle_v1_10_R1(Particle.EXPLOSION_NORMAL));
register("SPLASH", new Particle_v1_10_R1(Particle.WATER_SPLASH));
register("LARGE_SMOKE", new Particle_v1_10_R1(Particle.SMOKE_LARGE));
register("RED_DUST", new Particle_v1_10_R1(Particle.REDSTONE));
register("SNOWBALL_POOF", new Particle_v1_10_R1(Particle.SNOWBALL));
register("ANGRY_VILLAGER", new Particle_v1_10_R1(Particle.VILLAGER_ANGRY));
register("HAPPY_VILLAGER", new Particle_v1_10_R1(Particle.VILLAGER_HAPPY));
}
}

0 comments on commit fbfe208

Please sign in to comment.
You can’t perform that action at this time.