Skip to content

Commit

Permalink
1.9.10 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed Apr 20, 2020
1 parent be06040 commit 077b9e9
Show file tree
Hide file tree
Showing 18 changed files with 1,143 additions and 1,092 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<classpathentry kind="lib" path="D:/Users/LOOHP/Desktop 2/test/spigot/plugins/PlaceholderAPI-2.10.4.jar"/>
<classpathentry kind="lib" path="D:/Users/LOOHP/Desktop 2/test/spigot/plugins/LightAPI-fork-3.4.2.jar"/>
<classpathentry kind="lib" path="D:/Users/LOOHP/Desktop 2/test/spigot/1.8/spigot-1.15.2.jar"/>
<classpathentry kind="lib" path="D:/Users/LOOHP/Desktop 2/test/spigot/1.8/spigot-1.10-R0.1-SNAPSHOT-latest.jar"/>
<classpathentry kind="lib" path="D:/Users/LOOHP/Desktop 2/test/spigot/1.8/spigot-1.11.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
308 changes: 150 additions & 158 deletions src/com/loohp/interactionvisualizer/Blocks/BeaconDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;

Expand Down Expand Up @@ -82,191 +81,184 @@ public void onBreakBeacon(BlockBreakEvent event) {
}

public static int gc() {
return new BukkitRunnable() {
public void run() {
Iterator<Entry<Block, HashMap<String, Object>>> itr = beaconMap.entrySet().iterator();
int count = 0;
int maxper = (int) Math.ceil((double) beaconMap.size() / (double) 600);
int delay = 1;
while (itr.hasNext()) {
count++;
if (count > maxper) {
count = 0;
delay++;
return Bukkit.getScheduler().runTaskTimerAsynchronously(InteractionVisualizer.plugin, () -> {
Iterator<Entry<Block, HashMap<String, Object>>> itr = beaconMap.entrySet().iterator();
int count = 0;
int maxper = (int) Math.ceil((double) beaconMap.size() / (double) 600);
int delay = 1;
while (itr.hasNext()) {
count++;
if (count > maxper) {
count = 0;
delay++;
}
Entry<Block, HashMap<String, Object>> entry = itr.next();
Bukkit.getScheduler().runTaskLater(InteractionVisualizer.plugin, () -> {
Block block = entry.getKey();
boolean active = false;
if (isActive(block.getLocation())) {
active = true;
}
Entry<Block, HashMap<String, Object>> entry = itr.next();
new BukkitRunnable() {
public void run() {
Block block = entry.getKey();
boolean active = false;
if (isActive(block.getLocation())) {
active = true;
}
if (active == false) {
HashMap<String, Object> map = entry.getValue();
if (map.get("1") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("1");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
if (map.get("2") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("2");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
if (map.get("3") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("3");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
beaconMap.remove(block);
CustomBlockDataManager.removeBlock(CustomBlockDataManager.locKey(block.getLocation()));
return;
}
if (!block.getType().equals(Material.BEACON)) {
HashMap<String, Object> map = entry.getValue();
if (map.get("1") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("1");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
if (map.get("2") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("2");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
if (map.get("3") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("3");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
beaconMap.remove(block);
CustomBlockDataManager.removeBlock(CustomBlockDataManager.locKey(block.getLocation()));
return;
}
if (active == false) {
HashMap<String, Object> map = entry.getValue();
if (map.get("1") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("1");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
}.runTaskLater(InteractionVisualizer.plugin, delay);
}
if (map.get("2") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("2");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
if (map.get("3") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("3");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
beaconMap.remove(block);
return;
}
if (!block.getType().equals(Material.BEACON)) {
HashMap<String, Object> map = entry.getValue();
if (map.get("1") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("1");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
if (map.get("2") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("2");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
if (map.get("3") instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) map.get("3");
PacketManager.removeArmorStand(InteractionVisualizer.getOnlinePlayers(), stand);
stand.remove();
}
beaconMap.remove(block);
CustomBlockDataManager.removeBlock(CustomBlockDataManager.locKey(block.getLocation()));
return;
}
}, delay);
}
}.runTaskTimerAsynchronously(InteractionVisualizer.plugin, 0, 600).getTaskId();
}, 0, 600).getTaskId();
}

public static int run() {
return new BukkitRunnable() {
public void run() {
Bukkit.getScheduler().runTask(InteractionVisualizer.plugin, () -> {
List<Block> list = nearbyBeacon();
for (Block block : list) {
if (beaconMap.get(block) == null && isActive(block.getLocation())) {
if (block.getType().equals(Material.BEACON)) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("Item", "N/A");
boolean done = false;
HashMap<String, Object> datamap = CustomBlockDataManager.getBlock(CustomBlockDataManager.locKey(block.getLocation()));
if (datamap != null) {
try {
String data = (String) datamap.get("Directional");
BlockFace face = BlockFace.valueOf(data);
map.putAll(spawnArmorStands(block, face));
done = true;
} catch (Exception e) {
done = false;
}
}
if (!done) {
float[] dir = placemap.containsKey(block) ? placemap.remove(block) : new float[]{0.0F, 0.0F};
BlockFace face = getCardinalFacing(dir);
return Bukkit.getScheduler().runTaskTimerAsynchronously(InteractionVisualizer.plugin, () -> {
Bukkit.getScheduler().runTask(InteractionVisualizer.plugin, () -> {
List<Block> list = nearbyBeacon();
for (Block block : list) {
if (beaconMap.get(block) == null && isActive(block.getLocation())) {
if (block.getType().equals(Material.BEACON)) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("Item", "N/A");
boolean done = false;
HashMap<String, Object> datamap = CustomBlockDataManager.getBlock(CustomBlockDataManager.locKey(block.getLocation()));
if (datamap != null) {
try {
String data = (String) datamap.get("Directional");
BlockFace face = BlockFace.valueOf(data);
map.putAll(spawnArmorStands(block, face));
HashMap<String, Object> savemap = (datamap != null) ? datamap : new HashMap<String, Object>();
savemap.put("Directional", face.toString().toUpperCase());
savemap.put("BlockType", block.getType().toString().toUpperCase());
CustomBlockDataManager.setBlock(CustomBlockDataManager.locKey(block.getLocation()), savemap);
done = true;
} catch (Exception e) {
done = false;
}
beaconMap.put(block, map);
}
if (!done) {
float[] dir = placemap.containsKey(block) ? placemap.remove(block) : new float[]{0.0F, 0.0F};
BlockFace face = getCardinalFacing(dir);
map.putAll(spawnArmorStands(block, face));
HashMap<String, Object> savemap = (datamap != null) ? datamap : new HashMap<String, Object>();
savemap.put("Directional", face.toString().toUpperCase());
savemap.put("BlockType", block.getType().toString().toUpperCase());
CustomBlockDataManager.setBlock(CustomBlockDataManager.locKey(block.getLocation()), savemap);
}
beaconMap.put(block, map);
}
}
});
}
});

Iterator<Entry<Block, HashMap<String, Object>>> itr = beaconMap.entrySet().iterator();
int count = 0;
int maxper = (int) Math.ceil((double) beaconMap.size() / (double) 20);
int delay = 1;
while (itr.hasNext()) {
Entry<Block, HashMap<String, Object>> entry = itr.next();

Iterator<Entry<Block, HashMap<String, Object>>> itr = beaconMap.entrySet().iterator();
int count = 0;
int maxper = (int) Math.ceil((double) beaconMap.size() / (double) 20);
int delay = 1;
while (itr.hasNext()) {
Entry<Block, HashMap<String, Object>> entry = itr.next();
count++;
if (count > maxper) {
count = 0;
delay++;
}
Bukkit.getScheduler().runTaskLater(InteractionVisualizer.plugin, () -> {
Block block = entry.getKey();
if (!isActive(block.getLocation())) {
return;
}
if (!block.getType().equals(Material.BEACON)) {
return;
}
org.bukkit.block.Beacon beacon = (org.bukkit.block.Beacon) block.getState();

count++;
if (count > maxper) {
count = 0;
delay++;
String arrow = "\u27f9";
ChatColor color = getBeaconColor(block);
ArmorStand line1 = (ArmorStand) entry.getValue().get("1");
ArmorStand line2 = (ArmorStand) entry.getValue().get("2");
ArmorStand line3 = (ArmorStand) entry.getValue().get("3");

String one = color + "T" + beacon.getTier() + " " + arrow + " " + getRange(beacon.getTier()) + "m";
if (!line1.getCustomName().equals(one)) {
line1.setCustomName(one);
line1.setCustomNameVisible(true);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line1);
}
Bukkit.getScheduler().runTaskLater(InteractionVisualizer.plugin, () -> {
Block block = entry.getKey();
if (!isActive(block.getLocation())) {
return;
if (beacon.getTier() == 0) {
if (!line2.getCustomName().equals("")) {
line2.setCustomName("");
line2.setCustomNameVisible(false);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line2);
}
if (!block.getType().equals(Material.BEACON)) {
return;
if (!line3.getCustomName().equals("")) {
line3.setCustomName("");
line3.setCustomNameVisible(false);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line3);
}
org.bukkit.block.Beacon beacon = (org.bukkit.block.Beacon) block.getState();

String arrow = "\u27f9";
ChatColor color = getBeaconColor(block);
ArmorStand line1 = (ArmorStand) entry.getValue().get("1");
ArmorStand line2 = (ArmorStand) entry.getValue().get("2");
ArmorStand line3 = (ArmorStand) entry.getValue().get("3");

String one = color + "T" + beacon.getTier() + " " + arrow + " " + getRange(beacon.getTier()) + "m";
if (!line1.getCustomName().equals(one)) {
line1.setCustomName(one);
line1.setCustomNameVisible(true);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line1);
}
if (beacon.getTier() == 0) {
} else {
if (beacon.getPrimaryEffect() != null) {
String two = color + EffectManager.getEffectConfig().getString("Effects." + beacon.getPrimaryEffect().getType().getName().toUpperCase()) + " " + RomanNumberUtils.toRoman(beacon.getPrimaryEffect().getAmplifier() + 1);
if (!line2.getCustomName().equals(two)) {
line2.setCustomName(two);
line2.setCustomNameVisible(true);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line2);
}
} else {
if (!line2.getCustomName().equals("")) {
line2.setCustomName("");
line2.setCustomNameVisible(false);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line2);
}
}
if (beacon.getSecondaryEffect() != null) {
String three = color + EffectManager.getEffectConfig().getString("Effects." + beacon.getSecondaryEffect().getType().getName().toUpperCase()) + " " + RomanNumberUtils.toRoman(beacon.getSecondaryEffect().getAmplifier() + 1);
if (!line3.getCustomName().equals(three)) {
line3.setCustomName(three);
line3.setCustomNameVisible(true);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line3);
}
} else {
if (!line3.getCustomName().equals("")) {
line3.setCustomName("");
line3.setCustomNameVisible(false);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line3);
}
} else {
if (beacon.getPrimaryEffect() != null) {
String two = color + EffectManager.getEffectConfig().getString("Effects." + beacon.getPrimaryEffect().getType().getName().toUpperCase()) + " " + RomanNumberUtils.toRoman(beacon.getPrimaryEffect().getAmplifier() + 1);
if (!line2.getCustomName().equals(two)) {
line2.setCustomName(two);
line2.setCustomNameVisible(true);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line2);
}
} else {
if (!line2.getCustomName().equals("")) {
line2.setCustomName("");
line2.setCustomNameVisible(false);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line2);
}
}
if (beacon.getSecondaryEffect() != null) {
String three = color + EffectManager.getEffectConfig().getString("Effects." + beacon.getSecondaryEffect().getType().getName().toUpperCase()) + " " + RomanNumberUtils.toRoman(beacon.getSecondaryEffect().getAmplifier() + 1);
if (!line3.getCustomName().equals(three)) {
line3.setCustomName(three);
line3.setCustomNameVisible(true);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line3);
}
} else {
if (!line3.getCustomName().equals("")) {
line3.setCustomName("");
line3.setCustomNameVisible(false);
PacketManager.updateArmorStand(InteractionVisualizer.getOnlinePlayers(), line3);
}
}
}
}, delay);
}
}
}, delay);
}
}.runTaskTimerAsynchronously(InteractionVisualizer.plugin, 0, 20).getTaskId();
}, 0, 20).getTaskId();
}

public static List<Block> nearbyBeacon() {
Expand Down
Loading

0 comments on commit 077b9e9

Please sign in to comment.