Browse Source

Fixed Trails and (Maybe) bungeecord

master
pintux98 6 years ago
parent
commit
915ea1a370
  1. 2
      MultiArena-TheBridge/config.yml
  2. 1
      MultiArena-TheBridge/src/cx/sfy/TheBridge/Main.java
  3. 61
      MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java
  4. 2
      MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java
  5. 39
      MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/Reflection.java

2
MultiArena-TheBridge/config.yml

@ -110,7 +110,7 @@ items:
&7to lobby.
archievements:
enabled: false
material: NOTEBLOCK
material: ARROW
data: 0
amount: 1
slot: 7

1
MultiArena-TheBridge/src/cx/sfy/TheBridge/Main.java

@ -154,6 +154,7 @@ public class Main extends JavaPlugin {
refl = new PacketMain(this);
instance = this;
stop = false;
getServer().getMessenger().registerOutgoingPluginChannel(Main.get(), "BungeeCord");
getConfig().options().copyDefaults(true);
saveConfig();
File s = new File(getDataFolder() + "/cages");

61
MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java

@ -1,5 +1,7 @@
package cx.sfy.TheBridge.listeners;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -9,9 +11,9 @@ import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Sign;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
@ -43,11 +45,8 @@ import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import org.bukkit.scheduler.BukkitTask;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.cosmetics.Cage;
@ -75,35 +74,26 @@ public class PlayerListener implements Listener {
this.plugin = plugin;
}
public void runTask() {
Bukkit.getScheduler().runTaskTimer(this.plugin, () -> {
for (GameDuo gd : plugin.getGm().getGames()) {
for (Location loc : gd.getBuild()) {
World world = loc.getWorld();
if (world == null) {
continue;
}
for (Projectile proj : world.getEntitiesByClass(Projectile.class)) {
ProjectileSource p = proj.getShooter();
if (!(p instanceof Player)) {
continue;
}
private BukkitTask task;
createTrail(proj.getLocation(),
plugin.getArm().getArrowByName(PlayerStat.getPlayerStat((Player) p).getArrow()));
}
}
public void runTask(Player p, Entity e) {
task = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, () -> {
Location loc = e.getLocation();
if (e.isOnGround()) {
task.cancel();
}
}, 5, 5);
createTrail(loc, plugin.getArm().getArrowByName(PlayerStat.getPlayerStat(p).getArrow()));
}, 0, 1);
}
@EventHandler
public void onShoot(ProjectileLaunchEvent e) {
if (e.getEntity() instanceof Arrow) {
runTask();
if (e.getEntity().getShooter() instanceof Player) {
if (e.getEntity() instanceof Arrow) {
Player p = (Player) e.getEntity().getShooter();
if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null)
runTask(p, e.getEntity());
}
}
}
@ -424,13 +414,18 @@ public class PlayerListener implements Listener {
plugin.getConfig().getString("items.lobby.nameItem").replaceAll("&", "§"),
plugin.getConfig().getString("items.lobby.loreItem").replaceAll("&", "§"));
if (item.equals(random)) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(plugin.getConfig().getString("items.lobby.server"));
String broadcastMessage = "Yolo";
ByteArrayOutputStream bo = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(bo);
byte[] data = broadcastMessage.getBytes();
try {
p.sendPluginMessage(Main.get(), "BungeeCord", out.toByteArray());
out.writeUTF("Forward");
out.writeUTF(plugin.getConfig().getString("items.lobby.server"));
out.writeShort(data.length);
out.write(data);
p.sendPluginMessage(Main.get(), "BungeeCord", bo.toByteArray());
} catch (Exception ex) {
e.setCancelled(true);
ex.printStackTrace();
plugin.getServer().getConsoleSender()
.sendMessage(ChatColor.RED + "Server " + ChatColor.YELLOW
+ plugin.getConfig().getString("items.lobby.server") + ChatColor.RED

2
MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java

@ -104,7 +104,7 @@ public class GenericNMS implements NMS {
@Override
public void sendParticle(Location loc, Arrow particle) {
Reflection.sendParticle(loc, particle.getTrail(), 50, 0.3);
Reflection.sendParticle(loc, particle.getTrail(), 50, 0.2);
}
}

39
MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/Reflection.java

@ -22,7 +22,6 @@ import org.bukkit.plugin.SimplePluginManager;
import org.bukkit.scoreboard.Scoreboard;
import org.json.simple.JSONObject;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.utils.V1_8;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.ComponentBuilder;
@ -117,32 +116,28 @@ public class Reflection {
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void sendParticle(Location loc, String particle, int radius, double offset) {
int[] in = new int[1];
SplittableRandom sr = new SplittableRandom();
loc.add(sr.nextDouble(-offset, offset), sr.nextDouble(-offset, offset), sr.nextDouble(-offset, offset));
Collection<Entity> ents = loc.getWorld().getNearbyEntities(loc, radius, radius, radius);
Bukkit.getScheduler().runTaskAsynchronously(Main.get(), () -> {
try {
Class enumParticles = Classes.EnumParticle.getType();
Object packet = Classes.PacketPlayOutWorldParticles.getType()
.getConstructor(
new Class[] { enumParticles, boolean.class, float.class, float.class, float.class,
float.class, float.class, float.class, float.class, int.class, int[].class })
.newInstance(Enum.valueOf(enumParticles, (particle != null ? particle.toUpperCase() : "FLAME")),
true, (float) loc.getX(), (float) loc.getY(), (float) loc.getZ(), 0F, 0F, 0F, 2F, 20,
in);
for (Entity p : ents) {
if (!(p instanceof Player)) {
continue;
}
sendPlayerPacket((Player) p, packet);
try {
Class enumParticles = Classes.EnumParticle.getType();
Object packet = Classes.PacketPlayOutWorldParticles.getType()
.getConstructor(new Class[] { enumParticles, boolean.class, float.class, float.class, float.class,
float.class, float.class, float.class, float.class, int.class, int[].class })
.newInstance(Enum.valueOf(enumParticles, (particle != null ? particle.toUpperCase() : "FLAME")),
true, (float) loc.getX(), (float) loc.getY(), (float) loc.getZ(), 0F, 0F, 0F, 1F, 15, in);
for (Entity p : ents) {
if (!(p instanceof Player)) {
continue;
}
} catch (Exception e) {
e.printStackTrace();
sendPlayerPacket((Player) p, packet);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}

Loading…
Cancel
Save