Version 1.0.4 - updated to the latest EaglercraftBungee (0.2.0)

This commit is contained in:
LAX1DUDE 2022-04-08 01:56:03 -07:00
parent 3aa3741fd5
commit d827fbaab5
4 changed files with 103 additions and 98 deletions

Binary file not shown.

View File

@ -338,6 +338,9 @@ public class EaglerMOTD extends Plugin implements Listener {
@EventHandler
public void onMOTD(WebsocketMOTDEvent evt) {
if(!evt.getAccept().equalsIgnoreCase("motd") && !evt.getAccept().equalsIgnoreCase("motd.noicon")) {
return;
}
MOTDConnection con = new MOTDConnection(evt.getListener(), evt.getMOTD());
if(con.execute()) {
if(max_total_sockets > 0) {

View File

@ -235,106 +235,108 @@ public class MOTDConnection {
}
shouldPush = true;
}
boolean shouldRenderIcon = false;
Object icon = frame.opt("icon");
if(icon != null) {
String asString = (icon instanceof String) ? (String)icon : null;
shouldRenderIcon = true;
if(icon == JSONObject.NULL || asString == null || asString.equalsIgnoreCase("none") || asString.equalsIgnoreCase("default")
|| asString.equalsIgnoreCase("null") || asString.equalsIgnoreCase("color")) {
bitmap = null;
}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(!this.motd.getAccept().equalsIgnoreCase("motd.noicon")) {
boolean shouldRenderIcon = false;
Object icon = frame.opt("icon");
if(icon != null) {
String asString = (icon instanceof String) ? (String)icon : null;
shouldRenderIcon = true;
if(icon == JSONObject.NULL || asString == null || asString.equalsIgnoreCase("none") || asString.equalsIgnoreCase("default")
|| asString.equalsIgnoreCase("null") || asString.equalsIgnoreCase("color")) {
bitmap = null;
}else {
bitmap = BitmapFile.getCachedIcon(asString);
}
if(flipY) {
newIcon = BitmapFile.flipY(newIcon);
}
if(rotate != 0) {
newIcon = BitmapFile.rotate(newIcon, rotate);
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;
}
}
motd.setBitmap(newIcon);
shouldPush = true;
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) {
newIcon = BitmapFile.flipY(newIcon);
}
if(rotate != 0) {
newIcon = BitmapFile.rotate(newIcon, rotate);
}
}
motd.setBitmap(newIcon);
shouldPush = true;
}
}
if(shouldPush) {
motd.sendToUser();

View File

@ -1,4 +1,4 @@
name: EaglerMOTD
main: net.lax1dude.eaglercraft.eaglermotd.EaglerMOTD
version: 1.0.3
version: 1.0.4
author: LAX1DUDE