mirror of
https://github.com/lax1dude/eaglercraft-motd.git
synced 2024-09-18 15:06:00 -07:00
Version 1.0.4 - updated to the latest EaglercraftBungee (0.2.0)
This commit is contained in:
parent
3aa3741fd5
commit
d827fbaab5
BIN
EaglerMOTD.jar
BIN
EaglerMOTD.jar
Binary file not shown.
|
@ -338,6 +338,9 @@ public class EaglerMOTD extends Plugin implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMOTD(WebsocketMOTDEvent evt) {
|
public void onMOTD(WebsocketMOTDEvent evt) {
|
||||||
|
if(!evt.getAccept().equalsIgnoreCase("motd") && !evt.getAccept().equalsIgnoreCase("motd.noicon")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
MOTDConnection con = new MOTDConnection(evt.getListener(), evt.getMOTD());
|
MOTDConnection con = new MOTDConnection(evt.getListener(), evt.getMOTD());
|
||||||
if(con.execute()) {
|
if(con.execute()) {
|
||||||
if(max_total_sockets > 0) {
|
if(max_total_sockets > 0) {
|
||||||
|
|
|
@ -235,106 +235,108 @@ public class MOTDConnection {
|
||||||
}
|
}
|
||||||
shouldPush = true;
|
shouldPush = true;
|
||||||
}
|
}
|
||||||
boolean shouldRenderIcon = false;
|
if(!this.motd.getAccept().equalsIgnoreCase("motd.noicon")) {
|
||||||
Object icon = frame.opt("icon");
|
boolean shouldRenderIcon = false;
|
||||||
if(icon != null) {
|
Object icon = frame.opt("icon");
|
||||||
String asString = (icon instanceof String) ? (String)icon : null;
|
if(icon != null) {
|
||||||
shouldRenderIcon = true;
|
String asString = (icon instanceof String) ? (String)icon : null;
|
||||||
if(icon == JSONObject.NULL || asString == null || asString.equalsIgnoreCase("none") || asString.equalsIgnoreCase("default")
|
shouldRenderIcon = true;
|
||||||
|| asString.equalsIgnoreCase("null") || asString.equalsIgnoreCase("color")) {
|
if(icon == JSONObject.NULL || asString == null || asString.equalsIgnoreCase("none") || asString.equalsIgnoreCase("default")
|
||||||
bitmap = null;
|
|| asString.equalsIgnoreCase("null") || asString.equalsIgnoreCase("color")) {
|
||||||
}else {
|
bitmap = null;
|
||||||
bitmap = BitmapFile.getCachedIcon(asString);
|
}else {
|
||||||
}
|
bitmap = BitmapFile.getCachedIcon(asString);
|
||||||
spriteX = spriteY = rotate = 0;
|
|
||||||
flipX = flipY = false;
|
|
||||||
color = new float[] { 0.0f, 0.0f, 0.0f, 0.0f };
|
|
||||||
tint = new float[] { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
||||||
}
|
|
||||||
int sprtX = frame.optInt("icon_spriteX", -1) * 64;
|
|
||||||
if(sprtX >= 0 && sprtX != spriteX) {
|
|
||||||
shouldRenderIcon = true;
|
|
||||||
spriteX = sprtX;
|
|
||||||
}
|
|
||||||
int sprtY = frame.optInt("icon_spriteY", -1) * 64;
|
|
||||||
if(sprtY >= 0 && sprtY != spriteY) {
|
|
||||||
shouldRenderIcon = true;
|
|
||||||
spriteY = sprtY;
|
|
||||||
}
|
|
||||||
sprtX = frame.optInt("icon_pixelX", -1);
|
|
||||||
if(sprtX >= 0 && sprtX != spriteX) {
|
|
||||||
shouldRenderIcon = true;
|
|
||||||
spriteX = sprtX;
|
|
||||||
}
|
|
||||||
sprtY = frame.optInt("icon_pixelY", -1);
|
|
||||||
if(sprtY >= 0 && sprtY != spriteY) {
|
|
||||||
shouldRenderIcon = true;
|
|
||||||
spriteY = sprtY;
|
|
||||||
}
|
|
||||||
Object flip = frame.opt("icon_flipX");
|
|
||||||
if(flip != null) {
|
|
||||||
shouldRenderIcon = true;
|
|
||||||
if(flip instanceof Boolean) {
|
|
||||||
flipX = ((Boolean)flip).booleanValue();
|
|
||||||
}else {
|
|
||||||
flipX = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
flip = frame.opt("icon_flipY");
|
|
||||||
if(flip != null) {
|
|
||||||
shouldRenderIcon = true;
|
|
||||||
if(flip instanceof Boolean) {
|
|
||||||
flipY = ((Boolean)flip).booleanValue();
|
|
||||||
}else {
|
|
||||||
flipY = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int rot = frame.optInt("icon_rotate", -1);
|
|
||||||
if(rot >= 0) {
|
|
||||||
shouldRenderIcon = true;
|
|
||||||
rotate = rot % 4;
|
|
||||||
}
|
|
||||||
JSONArray colorF = frame.optJSONArray("icon_color");
|
|
||||||
if(colorF != null && colorF.length() > 0) {
|
|
||||||
shouldRenderIcon = true;
|
|
||||||
color[0] = colorF.getFloat(0);
|
|
||||||
color[1] = colorF.length() > 1 ? colorF.getFloat(1) : color[1];
|
|
||||||
color[2] = colorF.length() > 2 ? colorF.getFloat(2) : color[2];
|
|
||||||
color[3] = colorF.length() > 3 ? colorF.getFloat(3) : 1.0f;
|
|
||||||
}
|
|
||||||
colorF = frame.optJSONArray("icon_tint");
|
|
||||||
if(colorF != null && colorF.length() > 0) {
|
|
||||||
shouldRenderIcon = true;
|
|
||||||
tint[0] = colorF.getFloat(0);
|
|
||||||
tint[1] = colorF.length() > 1 ? colorF.getFloat(1) : tint[1];
|
|
||||||
tint[2] = colorF.length() > 2 ? colorF.getFloat(2) : tint[2];
|
|
||||||
tint[3] = colorF.length() > 3 ? colorF.getFloat(3) : 1.0f;
|
|
||||||
}
|
|
||||||
if(shouldRenderIcon) {
|
|
||||||
int[] newIcon = null;
|
|
||||||
if(bitmap != null) {
|
|
||||||
newIcon = bitmap.getSprite(spriteX, spriteY);
|
|
||||||
}
|
|
||||||
if(newIcon == null) {
|
|
||||||
newIcon = new int[64*64];
|
|
||||||
}
|
|
||||||
newIcon = BitmapFile.applyTint(newIcon, tint[0], tint[1], tint[2], tint[3]);
|
|
||||||
if(color[3] > 0.0f) {
|
|
||||||
newIcon = BitmapFile.applyColor(newIcon, color[0], color[1], color[2], color[3]);
|
|
||||||
}
|
|
||||||
if(bitmap != null) {
|
|
||||||
if(flipX) {
|
|
||||||
newIcon = BitmapFile.flipX(newIcon);
|
|
||||||
}
|
}
|
||||||
if(flipY) {
|
spriteX = spriteY = rotate = 0;
|
||||||
newIcon = BitmapFile.flipY(newIcon);
|
flipX = flipY = false;
|
||||||
}
|
color = new float[] { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
if(rotate != 0) {
|
tint = new float[] { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
newIcon = BitmapFile.rotate(newIcon, rotate);
|
}
|
||||||
|
int sprtX = frame.optInt("icon_spriteX", -1) * 64;
|
||||||
|
if(sprtX >= 0 && sprtX != spriteX) {
|
||||||
|
shouldRenderIcon = true;
|
||||||
|
spriteX = sprtX;
|
||||||
|
}
|
||||||
|
int sprtY = frame.optInt("icon_spriteY", -1) * 64;
|
||||||
|
if(sprtY >= 0 && sprtY != spriteY) {
|
||||||
|
shouldRenderIcon = true;
|
||||||
|
spriteY = sprtY;
|
||||||
|
}
|
||||||
|
sprtX = frame.optInt("icon_pixelX", -1);
|
||||||
|
if(sprtX >= 0 && sprtX != spriteX) {
|
||||||
|
shouldRenderIcon = true;
|
||||||
|
spriteX = sprtX;
|
||||||
|
}
|
||||||
|
sprtY = frame.optInt("icon_pixelY", -1);
|
||||||
|
if(sprtY >= 0 && sprtY != spriteY) {
|
||||||
|
shouldRenderIcon = true;
|
||||||
|
spriteY = sprtY;
|
||||||
|
}
|
||||||
|
Object flip = frame.opt("icon_flipX");
|
||||||
|
if(flip != null) {
|
||||||
|
shouldRenderIcon = true;
|
||||||
|
if(flip instanceof Boolean) {
|
||||||
|
flipX = ((Boolean)flip).booleanValue();
|
||||||
|
}else {
|
||||||
|
flipX = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
motd.setBitmap(newIcon);
|
flip = frame.opt("icon_flipY");
|
||||||
shouldPush = true;
|
if(flip != null) {
|
||||||
|
shouldRenderIcon = true;
|
||||||
|
if(flip instanceof Boolean) {
|
||||||
|
flipY = ((Boolean)flip).booleanValue();
|
||||||
|
}else {
|
||||||
|
flipY = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int rot = frame.optInt("icon_rotate", -1);
|
||||||
|
if(rot >= 0) {
|
||||||
|
shouldRenderIcon = true;
|
||||||
|
rotate = rot % 4;
|
||||||
|
}
|
||||||
|
JSONArray colorF = frame.optJSONArray("icon_color");
|
||||||
|
if(colorF != null && colorF.length() > 0) {
|
||||||
|
shouldRenderIcon = true;
|
||||||
|
color[0] = colorF.getFloat(0);
|
||||||
|
color[1] = colorF.length() > 1 ? colorF.getFloat(1) : color[1];
|
||||||
|
color[2] = colorF.length() > 2 ? colorF.getFloat(2) : color[2];
|
||||||
|
color[3] = colorF.length() > 3 ? colorF.getFloat(3) : 1.0f;
|
||||||
|
}
|
||||||
|
colorF = frame.optJSONArray("icon_tint");
|
||||||
|
if(colorF != null && colorF.length() > 0) {
|
||||||
|
shouldRenderIcon = true;
|
||||||
|
tint[0] = colorF.getFloat(0);
|
||||||
|
tint[1] = colorF.length() > 1 ? colorF.getFloat(1) : tint[1];
|
||||||
|
tint[2] = colorF.length() > 2 ? colorF.getFloat(2) : tint[2];
|
||||||
|
tint[3] = colorF.length() > 3 ? colorF.getFloat(3) : 1.0f;
|
||||||
|
}
|
||||||
|
if(shouldRenderIcon) {
|
||||||
|
int[] newIcon = null;
|
||||||
|
if(bitmap != null) {
|
||||||
|
newIcon = bitmap.getSprite(spriteX, spriteY);
|
||||||
|
}
|
||||||
|
if(newIcon == null) {
|
||||||
|
newIcon = new int[64*64];
|
||||||
|
}
|
||||||
|
newIcon = BitmapFile.applyTint(newIcon, tint[0], tint[1], tint[2], tint[3]);
|
||||||
|
if(color[3] > 0.0f) {
|
||||||
|
newIcon = BitmapFile.applyColor(newIcon, color[0], color[1], color[2], color[3]);
|
||||||
|
}
|
||||||
|
if(bitmap != null) {
|
||||||
|
if(flipX) {
|
||||||
|
newIcon = BitmapFile.flipX(newIcon);
|
||||||
|
}
|
||||||
|
if(flipY) {
|
||||||
|
newIcon = BitmapFile.flipY(newIcon);
|
||||||
|
}
|
||||||
|
if(rotate != 0) {
|
||||||
|
newIcon = BitmapFile.rotate(newIcon, rotate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
motd.setBitmap(newIcon);
|
||||||
|
shouldPush = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(shouldPush) {
|
if(shouldPush) {
|
||||||
motd.sendToUser();
|
motd.sendToUser();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name: EaglerMOTD
|
name: EaglerMOTD
|
||||||
main: net.lax1dude.eaglercraft.eaglermotd.EaglerMOTD
|
main: net.lax1dude.eaglercraft.eaglermotd.EaglerMOTD
|
||||||
version: 1.0.3
|
version: 1.0.4
|
||||||
author: LAX1DUDE
|
author: LAX1DUDE
|
Loading…
Reference in New Issue
Block a user