![]() |
|
BossMessage - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: BossMessage (/thread-1535.html) Pages:
1
2
|
BossMessage - RedDragonNL - 07-23-2014 Hi guys! I'm new at this community, so first i am gonna tell something about me. I'm Corné, and i make custom plugins for Spigot and BungeeCord. My lastest project is a perms plugin voor BungeeCord. But enough about Spigot and BungeeCord. Lua is completly new for me, but i'm gonna try it. BossMessage helps you to broadcast a message to all players. I have here an example (I use this for my server) : Screenshot You can use it for: You are playing on {server} or for example a welcome message. I hope it's ready next week, i first need to open my server at the 27th of July. I will give you some updates, Cya ![]() RedDragonNL RE: BossMessage - tonibm19 - 07-23-2014 Welcome to the forum ![]() Unfortunately, you can't send this type of messages via lua (I think), because of the line below the text. RE: BossMessage - RedDragonNL - 07-23-2014 (07-23-2014, 05:03 AM)tonibm19 Wrote: Welcome to the forumI think it will be possible with an API?! I will try it out, if it's not possible i let you know ![]() -RedDragonNL RE: BossMessage - NiLSPACE - 07-23-2014 I'm curious how bukkit does it. Do they spawn an ender dragon with a custom name at like Y-1000? RE: BossMessage - archshift - 07-23-2014 (07-23-2014, 05:13 AM)STR_Warrior Wrote: I'm curious how bukkit does it. Do they spawn an ender dragon with a custom name at like Y-1000? I don't know if *bukkit* does it that way, but I've played on servers that do that. RE: BossMessage - tigerw - 07-23-2014 (07-23-2014, 05:13 AM)STR_Warrior Wrote: I'm curious how bukkit does it. Do they spawn an ender dragon with a custom name at like Y-1000? WHAT. That's DRAGON ABUSE. :( RE: BossMessage - NiLSPACE - 07-23-2014 Don't worry. I trained it ![]() Never seen the movie though RE: BossMessage - xoft - 07-23-2014 I'd guess that's the new Position param in the chat packet: http://wiki.vg/Pre-release_protocol#Chat_Message RE: BossMessage - NiLSPACE - 07-23-2014 I don't think it's that because it works in 1.7 and maybe even lower MC versions. The position param might be for the new "Titles" (/title command). I'm not sure though because I remember seeing a new Title packet. RE: BossMessage - Howaner - 07-23-2014 I use this code in bukkit:
package de.howaner.OITC.util;
import de.howaner.OITC.OITCPlugin;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.server.v1_7_R3.DataWatcher;
import net.minecraft.server.v1_7_R3.EntityPlayer;
import net.minecraft.server.v1_7_R3.EnumClientCommand;
import net.minecraft.server.v1_7_R3.Packet;
import net.minecraft.server.v1_7_R3.PacketPlayInClientCommand;
import net.minecraft.server.v1_7_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_7_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class StatusBar {
public static final int ENTITY_ID = 1234;
public static List<String> hasHealthBar = new ArrayList<String>();
public static Map<String, Integer> schedulers = new HashMap<String, Integer>();
/* Set Variable with Reflections */
public static void setVar(String key, Object value, Object c) {
try {
Field f = c.getClass().getDeclaredField(key);
f.setAccessible(true);
f.set(c, value);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void sendPacket(Player player, Packet packet) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
entityPlayer.playerConnection.sendPacket(packet);
}
//Accessing packets
public static PacketPlayOutSpawnEntityLiving getMobPacket(String text, Location loc, int health) {
PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
setVar("a", (int) ENTITY_ID, mobPacket);
setVar("b", (byte) EntityType.ENDER_DRAGON.getTypeId(), mobPacket);
setVar("c", (int) Math.floor(loc.getBlockX() * 32.0D), mobPacket);
setVar("d", (int) Math.floor(loc.getBlockY() * 32.0D), mobPacket);
setVar("e", (int) Math.floor(loc.getBlockZ() * 32.0D), mobPacket);
setVar("f", (int) 0, mobPacket);
setVar("g", (byte) 0, mobPacket);
setVar("h", (byte) 0, mobPacket);
setVar("i", (byte) 0, mobPacket);
setVar("j", (byte) 0, mobPacket);
setVar("k", (byte) 0, mobPacket);
setVar("l", getWatcher(text, health), mobPacket);
return mobPacket;
}
public static PacketPlayOutEntityDestroy getDestroyEntityPacket() {
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy();
setVar("a", new int[]{ENTITY_ID}, packet);
return packet;
}
public static PacketPlayOutEntityMetadata getMetadataPacket(DataWatcher watcher) {
PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata();
setVar("a", (int) ENTITY_ID, metaPacket);
setVar("b", watcher.c(), metaPacket);
return metaPacket;
}
public static PacketPlayOutEntityTeleport getTeleportPacket(Location loc) {
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport();
setVar("a", (int) ENTITY_ID, packet);
setVar("b", (int) Math.floor(loc.getX() * 32.0D), packet);
setVar("c", (int) Math.floor(loc.getY() * 32.0D), packet);
setVar("d", (int) Math.floor(loc.getZ() * 32.0D), packet);
setVar("e", (byte) ((int) (loc.getYaw() * 256.0F / 360.F)), packet);
setVar("f", (byte) ((int) (loc.getPitch() * 256.0F / 360.0F)), packet);
return packet;
}
public static PacketPlayInClientCommand getRespawnPacket() {
PacketPlayInClientCommand packet = new PacketPlayInClientCommand();
setVar("a", EnumClientCommand.PERFORM_RESPAWN, packet);
return packet;
}
public static DataWatcher getWatcher(String text, int health) {
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (Byte) (byte) 0x20); //Flags, 0x20 = invisible
watcher.a(6, (Float) (float) health);
watcher.a(10, (String) text); //Entity name
watcher.a(11, (Byte) (byte) 1); //Show name, 1 = show, 0 = don't show
watcher.a(16, (Integer) (int) health); //Wither health, 300 = full health
return watcher;
}
public static void displayTextBar(String text, final Player player) {
displayTextBar(text, player, 200, -1);
}
public static void displayTextBar(String text, final Player player, int health, int time) {
if (hasHealthBar.contains(player.getName())) {
if (schedulers.containsKey(player.getName()))
Bukkit.getScheduler().cancelTask(schedulers.get(player.getName()));
schedulers.remove(player.getName());
sendPacket(player, getMetadataPacket(getWatcher(text, health)));
if (time != -1) {
schedulers.put(player.getName(), Bukkit.getScheduler().scheduleSyncDelayedTask(OITCPlugin.getPlugin(), new Runnable() {
@Override
public void run(){
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, destroyEntityPacket);
hasHealthBar.remove(player.getName());
schedulers.remove(player.getName());
}
}, 20L * time));
}
return;
}
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, player.getLocation().clone().add(0, -200, 0), health);
sendPacket(player, mobPacket);
hasHealthBar.add(player.getName());
if (time != -1) {
schedulers.put(player.getName(), Bukkit.getScheduler().scheduleSyncDelayedTask(OITCPlugin.getPlugin(), new Runnable() {
@Override
public void run(){
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, destroyEntityPacket);
hasHealthBar.remove(player.getName());
schedulers.remove(player.getName());
}
}, 20L * time));
}
}
}
|