BossMessage
#1
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 Cool

RedDragonNL
Reply
Thanks given by:
#2
Welcome to the forum Smile
Unfortunately, you can't send this type of messages via lua (I think), because of the line below the text.
Reply
Thanks given by:
#3
(07-23-2014, 05:03 AM)tonibm19 Wrote: Welcome to the forum Smile
Unfortunately, you can't send this type of messages via lua (I think), because of the line below the text.
I think it will be possible with an API?!
I will try it out, if it's not possible i let you know Wink

-RedDragonNL
Reply
Thanks given by:
#4
I'm curious how bukkit does it. Do they spawn an ender dragon with a custom name at like Y-1000?
Reply
Thanks given by:
#5
(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.
Reply
Thanks given by:
#6
(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.

:(
Reply
Thanks given by:
#7
Don't worry. I trained it
[Image: How_to_Train_Your_Dragon.jpg]
Never seen the movie though
Reply
Thanks given by:
#8
I'd guess that's the new Position param in the chat packet:
http://wiki.vg/Pre-release_protocol#Chat_Message
Reply
Thanks given by:
#9
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.
Reply
Thanks given by:
#10
I use this code in bukkit:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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));
        }
    }
     
}
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)