Merge branch 'LAX1DUDE-main'

This commit is contained in:
ayunami2000 2022-04-16 11:25:49 -04:00
commit ae0ff1579d
37 changed files with 25360 additions and 23995 deletions

View File

@ -60,6 +60,7 @@ import net.md_5.bungee.command.CommandSend;
import net.md_5.bungee.command.CommandPerms;
import net.md_5.bungee.command.CommandBungee;
import net.md_5.bungee.command.CommandClearRatelimit;
import net.md_5.bungee.command.CommandConfirmCode;
import net.md_5.bungee.command.CommandAlert;
import net.md_5.bungee.command.CommandIP;
import net.md_5.bungee.command.CommandServer;
@ -154,6 +155,7 @@ public class BungeeCord extends ProxyServer {
this.getPluginManager().registerCommand(null, new CommandSend());
this.getPluginManager().registerCommand(null, new CommandFind());
this.getPluginManager().registerCommand(null, new CommandClearRatelimit());
this.getPluginManager().registerCommand(null, new CommandConfirmCode());
this.registerChannel("BungeeCord");
Log.setOutput(new PrintStream(ByteStreams.nullOutputStream()));
AnsiConsole.systemInstall();

View File

@ -12,7 +12,7 @@ public enum ChatColor {
BLACK('0'), DARK_BLUE('1'), DARK_GREEN('2'), DARK_AQUA('3'), DARK_RED('4'), DARK_PURPLE('5'), GOLD('6'), GRAY('7'), DARK_GRAY('8'), BLUE('9'), GREEN('a'), AQUA('b'), RED('c'), LIGHT_PURPLE('d'), YELLOW('e'), WHITE('f'), MAGIC('k'),
BOLD('l'), STRIKETHROUGH('m'), UNDERLINE('n'), ITALIC('o'), RESET('r');
public static final char COLOR_CHAR = '§';
public static final char COLOR_CHAR = '\u00A7';
private static final Pattern STRIP_COLOR_PATTERN;
private static final Map<Character, ChatColor> BY_CHAR;
private final char code;
@ -20,7 +20,7 @@ public enum ChatColor {
private ChatColor(final char code) {
this.code = code;
this.toString = new String(new char[] { '§', code });
this.toString = new String(new char[] { '\u00A7', code });
}
@Override
@ -39,7 +39,7 @@ public enum ChatColor {
final char[] b = textToTranslate.toCharArray();
for (int i = 0; i < b.length - 1; ++i) {
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
b[i] = '§';
b[i] = '\u00A7';
b[i + 1] = Character.toLowerCase(b[i + 1]);
}
}
@ -51,7 +51,7 @@ public enum ChatColor {
}
static {
STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('\u00A7') + "[0-9A-FK-OR]");
BY_CHAR = new HashMap<Character, ChatColor>();
for (final ChatColor colour : values()) {
ChatColor.BY_CHAR.put(colour.code, colour);

View File

@ -0,0 +1,33 @@
package net.md_5.bungee.command;
import java.nio.charset.StandardCharsets;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.eaglercraft.QueryConnectionImpl;
import net.md_5.bungee.eaglercraft.SHA1Digest;
public class CommandConfirmCode extends Command {
public CommandConfirmCode() {
super("confirm-code", "bungeecord.command.eag.confirmcode", "confirmcode");
}
@Override
public void execute(CommandSender p0, String[] p1) {
if(p1.length != 1) {
p0.sendMessage(ChatColor.RED + "How to use: " + ChatColor.WHITE + "/confirm-code <code>");
}else {
p0.sendMessage(ChatColor.YELLOW + "Server list 2FA code has been set to: " + ChatColor.GREEN + p1[0]);
p0.sendMessage(ChatColor.YELLOW + "You can now return to the server list site and continue");
byte[] bts = p1[0].getBytes(StandardCharsets.US_ASCII);
SHA1Digest dg = new SHA1Digest();
dg.update(bts, 0, bts.length);
byte[] f = new byte[20];
dg.doFinal(f, 0);
QueryConnectionImpl.confirmHash = SHA1Digest.hash2string(f);
}
}
}

View File

@ -0,0 +1,124 @@
package net.md_5.bungee.eaglercraft;
/**
* base implementation of MD4 family style digest as outlined in
* "Handbook of Applied Cryptography", pages 344 - 347.
*/
public abstract class GeneralDigest {
private byte[] xBuf;
private int xBufOff;
private long byteCount;
/**
* Standard constructor
*/
protected GeneralDigest()
{
xBuf = new byte[4];
xBufOff = 0;
}
/**
* Copy constructor. We are using copy constructors in place
* of the Object.clone() interface as this interface is not
* supported by J2ME.
*/
protected GeneralDigest(GeneralDigest t)
{
xBuf = new byte[t.xBuf.length];
System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length);
xBufOff = t.xBufOff;
byteCount = t.byteCount;
}
public void update(
byte in)
{
xBuf[xBufOff++] = in;
if (xBufOff == xBuf.length)
{
processWord(xBuf, 0);
xBufOff = 0;
}
byteCount++;
}
public void update(
byte[] in,
int inOff,
int len)
{
//
// fill the current word
//
while ((xBufOff != 0) && (len > 0))
{
update(in[inOff]);
inOff++;
len--;
}
//
// process whole words.
//
while (len > xBuf.length)
{
processWord(in, inOff);
inOff += xBuf.length;
len -= xBuf.length;
byteCount += xBuf.length;
}
//
// load in the remainder.
//
while (len > 0)
{
update(in[inOff]);
inOff++;
len--;
}
}
public void finish()
{
long bitLength = (byteCount << 3);
//
// add the pad bytes.
//
update((byte)128);
while (xBufOff != 0)
{
update((byte)0);
}
processLength(bitLength);
processBlock();
}
public void reset()
{
byteCount = 0;
xBufOff = 0;
for ( int i = 0; i < xBuf.length; i++ ) {
xBuf[i] = 0;
}
}
protected abstract void processWord(byte[] in, int inOff);
protected abstract void processLength(long bitLength);
protected abstract void processBlock();
}

View File

@ -19,6 +19,8 @@ public class QueryConnectionImpl implements QueryConnection {
protected List<String> packetBuffer = new LinkedList();
protected long creationTime;
protected boolean keepAlive = false;
public static String confirmHash = null;
public QueryConnectionImpl(ListenerInfo listener, InetAddress addr, WebSocket socket, String accept) {
this.listener = listener;

View File

@ -0,0 +1,270 @@
package net.md_5.bungee.eaglercraft;
/**
* implementation of SHA-1 as outlined in "Handbook of Applied Cryptography", pages 346 - 349.
*
* It is interesting to ponder why the, apart from the extra IV, the other difference here from MD5
* is the "endienness" of the word processing!
*/
public class SHA1Digest
extends GeneralDigest
{
private static final int DIGEST_LENGTH = 20;
private int H1, H2, H3, H4, H5;
private int[] X = new int[80];
private int xOff;
/**
* Standard constructor
*/
public SHA1Digest()
{
reset();
}
/**
* Copy constructor. This will copy the state of the provided
* message digest.
*/
public SHA1Digest(SHA1Digest t)
{
super(t);
H1 = t.H1;
H2 = t.H2;
H3 = t.H3;
H4 = t.H4;
H5 = t.H5;
System.arraycopy(t.X, 0, X, 0, t.X.length);
xOff = t.xOff;
}
public String getAlgorithmName()
{
return "SHA-1";
}
public int getDigestSize()
{
return DIGEST_LENGTH;
}
protected void processWord(
byte[] in,
int inOff)
{
X[xOff++] = ((in[inOff] & 0xff) << 24) | ((in[inOff + 1] & 0xff) << 16)
| ((in[inOff + 2] & 0xff) << 8) | ((in[inOff + 3] & 0xff));
if (xOff == 16)
{
processBlock();
}
}
private void unpackWord(
int word,
byte[] out,
int outOff)
{
out[outOff] = (byte)(word >>> 24);
out[outOff + 1] = (byte)(word >>> 16);
out[outOff + 2] = (byte)(word >>> 8);
out[outOff + 3] = (byte)word;
}
protected void processLength(
long bitLength)
{
if (xOff > 14)
{
processBlock();
}
X[14] = (int)(bitLength >>> 32);
X[15] = (int)(bitLength & 0xffffffff);
}
public int doFinal(
byte[] out,
int outOff)
{
finish();
unpackWord(H1, out, outOff);
unpackWord(H2, out, outOff + 4);
unpackWord(H3, out, outOff + 8);
unpackWord(H4, out, outOff + 12);
unpackWord(H5, out, outOff + 16);
reset();
return DIGEST_LENGTH;
}
/**
* reset the chaining variables
*/
public void reset()
{
super.reset();
H1 = 0x67452301;
H2 = 0xefcdab89;
H3 = 0x98badcfe;
H4 = 0x10325476;
H5 = 0xc3d2e1f0;
xOff = 0;
for (int i = 0; i != X.length; i++)
{
X[i] = 0;
}
}
//
// Additive constants
//
private static final int Y1 = 0x5a827999;
private static final int Y2 = 0x6ed9eba1;
private static final int Y3 = 0x8f1bbcdc;
private static final int Y4 = 0xca62c1d6;
private int f(
int u,
int v,
int w)
{
return ((u & v) | ((~u) & w));
}
private int h(
int u,
int v,
int w)
{
return (u ^ v ^ w);
}
private int g(
int u,
int v,
int w)
{
return ((u & v) | (u & w) | (v & w));
}
private int rotateLeft(
int x,
int n)
{
return (x << n) | (x >>> (32 - n));
}
protected void processBlock()
{
//
// expand 16 word block into 80 word block.
//
for (int i = 16; i <= 79; i++)
{
X[i] = rotateLeft((X[i - 3] ^ X[i - 8] ^ X[i - 14] ^ X[i - 16]), 1);
}
//
// set up working variables.
//
int A = H1;
int B = H2;
int C = H3;
int D = H4;
int E = H5;
//
// round 1
//
for (int j = 0; j <= 19; j++)
{
int t = rotateLeft(A, 5) + f(B, C, D) + E + X[j] + Y1;
E = D;
D = C;
C = rotateLeft(B, 30);
B = A;
A = t;
}
//
// round 2
//
for (int j = 20; j <= 39; j++)
{
int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y2;
E = D;
D = C;
C = rotateLeft(B, 30);
B = A;
A = t;
}
//
// round 3
//
for (int j = 40; j <= 59; j++)
{
int t = rotateLeft(A, 5) + g(B, C, D) + E + X[j] + Y3;
E = D;
D = C;
C = rotateLeft(B, 30);
B = A;
A = t;
}
//
// round 4
//
for (int j = 60; j <= 79; j++)
{
int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y4;
E = D;
D = C;
C = rotateLeft(B, 30);
B = A;
A = t;
}
H1 += A;
H2 += B;
H3 += C;
H4 += D;
H5 += E;
//
// reset the offset and clean out the word buffer.
//
xOff = 0;
for (int i = 0; i != X.length; i++)
{
X[i] = 0;
}
}
private static final String hex = "0123456789abcdef";
public static String hash2string(byte[] b) {
char[] ret = new char[b.length * 2];
for(int i = 0; i < b.length; ++i) {
int bb = (int)b[i] & 0xFF;
ret[i * 2] = hex.charAt((bb >> 4) & 0xF);
ret[i * 2 + 1] = hex.charAt(bb & 0xF);
}
return new String(ret);
}
}

View File

@ -95,9 +95,9 @@ public class WebSocketListener extends WebSocketServer {
if(o instanceof PendingSocket) {
InetAddress realAddr = ((PendingSocket)o).realAddress;
arg1 = arg1.trim().toLowerCase();
QueryConnectionImpl con;
if(arg1.startsWith("accept:")) {
arg1 = arg1.substring(7).trim();
QueryConnectionImpl con;
WebsocketQueryEvent evt;
if(arg1.startsWith("motd")) {
if(info.isAllowMOTD()) {
@ -121,7 +121,12 @@ public class WebSocketListener extends WebSocketServer {
return;
}
}else {
if(info.isAllowQuery()) {
if(QueryConnectionImpl.confirmHash != null && arg1.equalsIgnoreCase(QueryConnectionImpl.confirmHash)) {
QueryConnectionImpl.confirmHash = null;
arg0.send("OK");
arg0.close();
return;
}else if(info.isAllowQuery()) {
if(ratelimitQuery != null && !BanList.isBlockedBan(realAddr)) {
RateLimit l = ratelimitQuery.rateLimit(realAddr);
if(l.blocked()) {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,232 @@
package ayunami2000;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;
public class MapPacketCodec {
public interface FragmentHandler {
void sendFragment(byte[] data, boolean isLastFragment);
}
public enum PixelFormat {
R5_G6_B5, R8_G8_B8
}
public final int mapId;
private Deflater deflate = null;
private PixelFormat pixelFormat = PixelFormat.R5_G6_B5;
private int[] pixels = null;
private int[] pallete = null;
private boolean palleteIsSet = false;
private boolean palleteIsDirty = false;
/**
* @param mapId the ID of the map item to write to
*/
public MapPacketCodec(int mapId) {
this.mapId = mapId;
}
/**
* @param enable enables java.util.zip deflate on packets encoded by this class
*/
public MapPacketCodec deflate(boolean enable) {
deflate(enable ? 5 : 0);
return this;
}
/**
* @param level sets or disables compression level (0-9)
*/
public MapPacketCodec deflate(int level) {
deflate = level > 0 ? new Deflater(level) : null;
return this;
}
/**
* @param pix sets if pixels should be encoded as 16 bits per pixel or 24 bits per pixel
*/
public MapPacketCodec pixelFormat(PixelFormat pix) {
pixelFormat = pix == null ? PixelFormat.R5_G6_B5 : pix;
return this;
}
/**
* @param pixels If pallete is disabled, array of 16384 integers each containing the RGB of a pixel. If
* pallete is enabled, array of 16384 integers each containing an index in the current pallete between 0 and 255
*/
public MapPacketCodec setPixels(int[] pixels) {
if(pixels != null && pixels.length != 16384) {
throw new IllegalArgumentException("Pixel array must be 16384 pixels long");
}
this.pixels = pixels;
return this;
}
/**
* @param pixels a 128x128 RGB java.awt.image.BufferedImage, this will disable the pallete
*/
public MapPacketCodec setPixels(BufferedImage pixels) {
if(pixels.getWidth() != 128 || pixels.getHeight() != 128) {
throw new IllegalArgumentException("BufferedImage must be 128x128 pixels");
}
palleteIsSet = false;
this.pallete = null;
palleteIsDirty = false;
int[] pxls = new int[16384];
pixels.getRGB(0, 0, 128, 128, pxls, 0, 128);
setPixels(pxls);
return this;
}
/**
* sets and enables the pallete, or disables it if 'pallete' is null
*
* @param pallete an array of any size between 1 and 256 containing integers each representing a single RGB color
*/
public MapPacketCodec setPallete(int[] pallete) {
boolean b = pallete != null;
if(b) {
palleteIsSet = true;
this.pallete = pallete;
palleteIsDirty = true;
}else {
if(pixels != null && this.pallete != null) {
int[] px = pixels;
pixels = new int[16384];
for(int i = 0; i < 16384; ++i) {
int j = px[i];
pixels[i] = this.pallete[j >= this.pallete.length ? 0 : j];
}
}
this.pallete = null;
palleteIsSet = false;
palleteIsDirty = false;
}
return this;
}
/**
* Disables the pallete
*/
public MapPacketCodec clearPallete() {
setPallete(null);
return this;
}
/*
* Operations:
*
* - 0: disable engine
* - 1: compressed data
*
* - 2: set pixels R8_G8_B8
* - 3: set pixels R5_G6_B5
* - 4: set pallete R8_G8_B8
* - 5: set pallete R5_G6_B5
* - 6: set pixels via pallete
* - 7: set pallete and pixels R8_G8_B8
* - 8: set pallete and pixels R5_G6_B5
*
*/
/**
* takes the current pixels array and writes it to a packet and returns it, or returns null if the current pixels array has not changed
*/
public byte[] getNextPacket() {
if(pixels == null) {
return null;
}
try {
ByteArrayOutputStream o = new ByteArrayOutputStream();
DataOutputStream s;
if(deflate != null) {
o.write(1);
s = new DataOutputStream(new DeflaterOutputStream(o, deflate));
}else {
s = new DataOutputStream(o);
}
if(!palleteIsSet || pallete == null) {
palleteIsSet = false;
if(pixelFormat == PixelFormat.R5_G6_B5) {
s.write(3);
for(int i = 0; i < 16384; ++i) {
int j = pixels[i];
int r = (j >> 19) & 0x1F;
int g = (j >> 10) & 0x3F;
int b = (j >> 3) & 0x1F;
s.writeShort((r << 11) | (g << 5) | b);
}
}else if(pixelFormat == PixelFormat.R8_G8_B8) {
s.write(2);
for(int i = 0; i < 16384; ++i) {
int j = pixels[i];
s.write((j >> 16) & 0xFF);
s.write((j >> 8) & 0xFF);
s.write(j & 0xFF);
}
}else {
return null; // ?
}
}else {
if(palleteIsDirty) {
if(pixelFormat == PixelFormat.R5_G6_B5) {
s.write(8);
s.write(pallete.length);
for(int i = 0; i < pallete.length; ++i) {
int j = pallete[i];
int r = (j >> 19) & 0x1F;
int g = (j >> 10) & 0x3F;
int b = (j >> 3) & 0x1F;
s.writeShort((r << 11) | (g << 5) | b);
}
}else if(pixelFormat == PixelFormat.R8_G8_B8) {
s.write(7);
s.write(pallete.length);
for(int i = 0; i < pallete.length; ++i) {
int j = pallete[i];
s.write((j >> 16) & 0xFF);
s.write((j >> 8) & 0xFF);
s.write(j & 0xFF);
}
}else {
return null; // ?
}
palleteIsDirty = false;
}else {
s.write(6);
}
for(int i = 0; i < 16384; ++i) {
s.write(pixels[i]);
}
}
pixels = null;
s.close();
return o.toByteArray();
}catch(IOException e) {
throw new RuntimeException("Failed to write ayunami map packet");
}
}
public byte[] getDisablePacket() {
try {
palleteIsSet = false;
palleteIsDirty = false;
pallete = null;
pixels = null;
ByteArrayOutputStream o = new ByteArrayOutputStream();
DataOutputStream s = new DataOutputStream(o);
s.writeShort(mapId);
s.write(0);
return o.toByteArray();
}catch(IOException e) {
throw new RuntimeException("Failed to write ayunami map packet");
}
}
}

View File

@ -0,0 +1,76 @@
package ayunami2000;
import java.util.List;
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_5_R3.Packet;
import net.minecraft.server.v1_5_R3.Packet131ItemData;
public class MapPacketCodecBukkit extends MapPacketCodec {
public MapPacketCodecBukkit(int mapId) {
super(mapId);
}
public Object getNextBukkitPacket() {
byte[] pkt = getNextPacket();
if(pkt == null) {
return null;
}
return new Packet131ItemData((short)103, (short)mapId, pkt);
}
public Object getDisableBukkitPacket() {
byte[] pkt = getDisablePacket();
if(pkt == null) {
return null;
}
return new Packet131ItemData((short)103, (short)mapId, pkt);
}
public void sendNextPacketToPlayer(Player p) {
nativeSendPacketToPlayer(p, getNextBukkitPacket());
}
public void sendDisablePacketToPlayer(Player p) {
nativeSendPacketToPlayer(p, getDisableBukkitPacket());
}
public void sendNextPacketToPlayers(Player... p) {
Object pkt = getNextBukkitPacket();
for(Player pl : p) {
nativeSendPacketToPlayer(pl, pkt);
}
}
public void sendDisablePacketToPlayers(Player... p) {
Object pkt = getDisableBukkitPacket();
for(Player pl : p) {
nativeSendPacketToPlayer(pl, pkt);
}
}
public void sendNextPacketToPlayers(List<Player> p) {
Object pkt = getNextBukkitPacket();
for(Player pl : p) {
nativeSendPacketToPlayer(pl, pkt);
}
}
public void sendDisablePacketToPlayers(List<Player> p) {
Object pkt = getDisableBukkitPacket();
for(Player pl : p) {
nativeSendPacketToPlayer(pl, pkt);
}
}
public static void nativeSendPacketToPlayer(Player player, Object obj) {
if(obj == null) {
return;
}
((CraftPlayer)player).getHandle().playerConnection.sendPacket((Packet)obj);
}
}

11
samples/plugin.yml Normal file
View File

@ -0,0 +1,11 @@
name: EaglerSamplesPlugin
main: plugin.EaglerSamplesPlugin
version: 1.0
author: lax1dude
description: eagler
depend: []
commands:
samplemap:
description: test ayunami map system
usage: /samplemap <get|disable|set> [mapid] [image file] [16bpp|24bpp] [compress]
permission: eaglersamples.samplemap

View File

@ -0,0 +1,116 @@
package plugin;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import ayunami2000.MapPacketCodec.PixelFormat;
import ayunami2000.MapPacketCodecBukkit;
public class CommandSampleMap implements CommandExecutor {
public final EaglerSamplesPlugin plugin;
public CommandSampleMap(EaglerSamplesPlugin plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender arg0, Command arg01, String arg1, String[] arg2) {
if(!(arg0 instanceof Player)) {
arg0.sendMessage(ChatColor.RED + "Internal Error: " + ChatColor.WHITE + "CommmandSender must be a Player");
return false;
}
arg0.sendMessage(ChatColor.YELLOW + "Note: test packets are only sent to the player running this command");
Player p = (Player)arg0;
try {
int mapId = -1;
if(arg2.length >= 2) {
mapId = Integer.parseInt(arg2[1]);
}else {
ItemStack i = p.getInventory().getItemInHand();
if(i.getType() == Material.MAP) {
mapId = (int)i.getDurability() & 0xFFFF;
}
}
if(mapId != -1) {
if(arg2.length == 1) {
if(arg2[0].equalsIgnoreCase("get")) {
arg0.sendMessage(ChatColor.GREEN + "Current map ID: " + ChatColor.WHITE + mapId);
return true;
}else if(arg2[0].equalsIgnoreCase("disable")) {
MapPacketCodecBukkit pkt = new MapPacketCodecBukkit(mapId);
pkt.sendDisablePacketToPlayer(p);
arg0.sendMessage(ChatColor.GREEN + "Reset map: " + ChatColor.WHITE + mapId);
return true;
}else if(arg2[0].equalsIgnoreCase("set")) {
arg0.sendMessage(ChatColor.RED + "Use: " + ChatColor.WHITE + "/samplemap set <file> [compress]");
return true;
}else {
MapPacketCodecBukkit pkt = new MapPacketCodecBukkit(mapId);
BufferedImage img = ImageIO.read(new File(arg2[0]));
pkt.setPixels(img);
pkt.sendNextPacketToPlayer(p);
arg0.sendMessage(ChatColor.GREEN + "Wrote image " + ChatColor.WHITE + arg2[0] + ChatColor.GREEN + " to map " + ChatColor.WHITE + mapId);
return true;
}
}else if(arg2.length == 2) {
int j = Integer.parseInt(arg2[1]);
if(arg2[0].equalsIgnoreCase("disable")) {
MapPacketCodecBukkit pkt = new MapPacketCodecBukkit(j);
pkt.sendDisablePacketToPlayer(p);
arg0.sendMessage(ChatColor.GREEN + "Reset map: " + ChatColor.WHITE + j);
return true;
}
}else if(arg2.length >= 3) {
int j = Integer.parseInt(arg2[1]);
MapPacketCodecBukkit pkt = new MapPacketCodecBukkit(j);
BufferedImage img = ImageIO.read(new File(arg2[2]));
if(arg2.length == 4 || arg2.length == 5) {
if(arg2[3].equalsIgnoreCase("16bpp")) {
pkt.pixelFormat(PixelFormat.R5_G6_B5);
if(arg2.length == 5) {
if(arg2[4].equalsIgnoreCase("true")) {
pkt.deflate(true);
}else {
pkt.deflate(Integer.parseInt(arg2[4]));
}
}
}else if(arg2[3].equalsIgnoreCase("24bpp")) {
pkt.pixelFormat(PixelFormat.R8_G8_B8);
if(arg2.length == 5) {
if(arg2[4].equalsIgnoreCase("true")) {
pkt.deflate(true);
}else {
pkt.deflate(Integer.parseInt(arg2[4]));
}
}
}else if(arg2[3].equalsIgnoreCase("true")) {
pkt.deflate(true);
}else {
pkt.deflate(Integer.parseInt(arg2[3]));
}
}
pkt.setPixels(img);
pkt.sendNextPacketToPlayer(p);
arg0.sendMessage(ChatColor.GREEN + "Wrote image " + ChatColor.WHITE + arg2[2] + ChatColor.GREEN + " to map " + ChatColor.WHITE + mapId);
return true;
}
}
}catch(Throwable t) {
arg0.sendMessage(ChatColor.RED + "Internal Error: " + ChatColor.WHITE + t.toString());
t.printStackTrace();
}
return false;
}
}

View File

@ -0,0 +1,14 @@
package plugin;
import org.bukkit.plugin.java.JavaPlugin;
public class EaglerSamplesPlugin extends JavaPlugin {
public void onEnable() {
getCommand("samplemap").setExecutor(new CommandSampleMap(this));
}
public void onDisable() {
}
}

1
samples/readme.txt Normal file
View File

@ -0,0 +1 @@
These are sample source files to assist the process of integrating Eaglercraft into other projects, or to assist the process of integrating other projects into Eaglercraft

View File

@ -213,7 +213,7 @@ public class EaglerAdapterImpl2 {
public static final int _wGL_SRC_COLOR = GL11.GL_SRC_COLOR;
public static final int _wGL_ONE = GL11.GL_ONE;
public static final int _wGL_NEAREST = GL11.GL_NEAREST;
public static final int _wGL_CLAMP = GL11.GL_REPEAT;
public static final int _wGL_CLAMP = GL12.GL_CLAMP_TO_EDGE;
public static final int _wGL_TEXTURE_WRAP_S = GL11.GL_TEXTURE_WRAP_S;
public static final int _wGL_TEXTURE_WRAP_T = GL11.GL_TEXTURE_WRAP_T;
public static final int _wGL_TEXTURE_MAX_LEVEL = GL12.GL_TEXTURE_MAX_LEVEL;
@ -936,7 +936,7 @@ public class EaglerAdapterImpl2 {
}else {
rateLimitStatus = RateLimit.FAILED;
}
}else if(!socketIsAlive) {
}else if(!socketIsAlive && (blockedAddresses.contains(serverUriString) || rateLimitedAddresses.contains(serverUriString))) {
rateLimitStatus = RateLimit.LOCKED;
}
}

View File

@ -6,7 +6,7 @@ public class ConfigConstants {
public static boolean profanity = false;
public static final String version = "22w14b";
public static final String version = "22w15d";
public static final String mainMenuString = "ayuncraft " + version;
public static final String forkMe = "https://github.com/ayunami2000/ayuncraft";

View File

@ -54,10 +54,10 @@ public class TextureTerrainMap implements IconRegister {
this.maxV = (float)(originY + 48) / (float)map.height;
this.originX_center = originX + 16;
this.originY_center = originY + 16;
this.minU_center = (float)originX_center / (float)map.width;
this.minV_center = (float)originY_center / (float)map.height;
this.maxU_center = (float)(originX_center + 16) / (float)map.width;
this.maxV_center = (float)(originY_center + 16) / (float)map.height;
this.minU_center = (float)(originX_center + 0.1f) / (float)map.width;
this.minV_center = (float)(originY_center + 0.1f) / (float)map.height;
this.maxU_center = (float)(originX_center + 16 - 0.1f) / (float)map.width;
this.maxV_center = (float)(originY_center + 16 - 0.1f) / (float)map.height;
}
@Override

View File

@ -249,7 +249,7 @@ public class Minecraft implements Runnable {
String s = EaglerAdapter.getServerToJoinOnLaunch();
if(s != null) {
this.displayGuiScreen(new GuiScreenEditProfile(new GuiConnecting(new GuiMainMenu(), this, new ServerData("Eaglercraft Server", s))));
this.displayGuiScreen(new GuiScreenEditProfile(new GuiConnecting(new GuiMainMenu(), this, new ServerData("Eaglercraft Server", s, false))));
}else {
this.displayGuiScreen(new GuiScreenEditProfile(new GuiMainMenu()));
}

View File

@ -142,10 +142,11 @@ public class EntityFX extends Entity {
}
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {
float var8 = (float) this.particleTextureIndexX / 16.0F;
float var9 = var8 + 0.0624375F;
float var10 = (float) this.particleTextureIndexY / 16.0F;
float var11 = var10 + 0.0624375F;
float fix = 0.001f;
float var8 = (float) this.particleTextureIndexX / 16.0F + fix;
float var9 = var8 + 0.0624375F - fix;
float var10 = (float) this.particleTextureIndexY / 16.0F + fix;
float var11 = var10 + 0.0624375F - fix;
float var12 = 0.1F * this.particleScale;
if (this.particleIcon != null) {

View File

@ -191,12 +191,12 @@ public class FontRenderer {
float var3 = (float) (par1 % 16 * 8);
float var4 = (float) (par1 / 16 * 8);
float var5 = par2 ? 1.0F : 0.0F;
float var6 = (float) this.charWidth[par1] - 0.02F;
float var6 = (float) this.charWidth[par1] - 0.2F;
Tessellator t = Tessellator.instance;
t.addVertexWithUV(this.posX + 0.02F + var5, this.posY + 0.02F, 0.0F, (var3 + 0.02F) / 128.0F, (var4 + 0.02F) / 128.0F);
t.addVertexWithUV(this.posX + 0.02F - var5, this.posY + 7.98F, 0.0F, (var3 + 0.02F) / 128.0F, (var4 + 7.98F) / 128.0F);
t.addVertexWithUV(this.posX + var6 - var5, this.posY + 7.98F, 0.0F, (var3 + var6) / 128.0F, (var4 + 7.98F) / 128.0F);
t.addVertexWithUV(this.posX + var6 + var5, this.posY + 0.02F, 0.0F, (var3 + var6) / 128.0F, (var4 + 0.02F) / 128.0F);
t.addVertexWithUV(this.posX + 0.05F + var5, this.posY + 0.05F, 0.0F, (var3 + 0.1F) / 128.0F, (var4 + 0.1F) / 128.0F);
t.addVertexWithUV(this.posX + 0.05F - var5, this.posY + 7.95F, 0.0F, (var3 + 0.1F) / 128.0F, (var4 + 7.8F) / 128.0F);
t.addVertexWithUV(this.posX + var6 - var5, this.posY + 7.95F, 0.0F, (var3 + var6) / 128.0F, (var4 + 7.8F) / 128.0F);
t.addVertexWithUV(this.posX + var6 + var5, this.posY + 0.05F, 0.0F, (var3 + var6) / 128.0F, (var4 + 0.1F) / 128.0F);
return (float) this.charWidth[par1];
}

View File

@ -174,14 +174,14 @@ public class GuiMultiplayer extends GuiScreen {
this.joinServer(this.selectedServer);
} else if (par1GuiButton.id == 4) {
this.directClicked = true;
this.mc.displayGuiScreen(new GuiScreenServerList(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "")));
this.mc.displayGuiScreen(new GuiScreenServerList(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false)));
} else if (par1GuiButton.id == 3) {
this.addClicked = true;
this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "")));
this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false)));
} else if (par1GuiButton.id == 7) {
this.editClicked = true;
ServerData var9 = this.internetServerList.getServerData(this.selectedServer);
this.theServerData = new ServerData(var9.serverName, var9.serverIP);
this.theServerData = new ServerData(var9.serverName, var9.serverIP, false);
this.theServerData.setHideAddress(var9.isHidingAddress());
this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData));
} else if (par1GuiButton.id == 0) {
@ -255,7 +255,7 @@ public class GuiMultiplayer extends GuiScreen {
this.mc.gameSettings.saveOptions();
} else {
if (isShiftKeyDown() && par2 == 200) {
if (var3 > 0 && var3 < this.internetServerList.countServers()) {
if (var3 > ServerList.forcedServers.size() && var3 < this.internetServerList.countServers()) {
this.internetServerList.swapServers(var3, var3 - 1);
--this.selectedServer;
@ -361,6 +361,10 @@ public class GuiMultiplayer extends GuiScreen {
}
static int getSelectedServer(GuiMultiplayer par0GuiMultiplayer) {
int i = internetServerList.countServers();
if(par0GuiMultiplayer.selectedServer >= i && par0GuiMultiplayer.selectedServer > 0) {
par0GuiMultiplayer.selectedServer = i - 1;
}
return par0GuiMultiplayer.selectedServer;
}

View File

@ -41,7 +41,7 @@ class GuiSlotServer extends GuiSlot {
if (par2 && var5) {
GuiMultiplayer.func_74008_b(this.parentGui, par1);
} else if (var6 && GuiScreen.isShiftKeyDown() && var3 >= 0 && var3 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) {
} else if (var6 && GuiScreen.isShiftKeyDown() && var3 > ServerList.forcedServers.size() && var3 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) {
GuiMultiplayer.getInternetServerList(this.parentGui).swapServers(var3, GuiMultiplayer.getSelectedServer(this.parentGui));
}
}

View File

@ -1,9 +1,9 @@
package net.minecraft.src;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.List;
public class ItemMap extends ItemMapBase {
protected ItemMap(int par1) {
super(par1);
@ -256,4 +256,21 @@ public class ItemMap extends ItemMapBase {
}
}
}
public static void readAyunamiMapPacket(WorldClient theWorld, short mapId, byte[] data) {
try {
String var2 = "map_" + mapId;
MapData var3 = (MapData) theWorld.loadItemData(MapData.class, var2);
if (var3 == null) {
var3 = new MapData(var2);
theWorld.setItemData(var2, var3);
}
var3.readAyunamiMapPacket(new ByteArrayInputStream(data));
}catch(IOException e) {
System.err.println("Failed to read AyunamiMap packet! " + e.toString());
e.printStackTrace();
}
}
}

View File

@ -108,9 +108,9 @@ public class ItemRenderer {
}
EaglerAdapter.glDisable(EaglerAdapter.GL_RESCALE_NORMAL);
EaglerAdapter.flipLightMatrix();
}
EaglerAdapter.flipLightMatrix();
EaglerAdapter.glPopMatrix();
}