<1.1.0> Add protocol V4 support to EaglerXVelocity

This commit is contained in:
lax1dude
2024-09-21 12:03:57 -07:00
parent 1cf3a85c2a
commit 173727c8c4
87 changed files with 11988 additions and 1102 deletions

View File

@ -1,11 +1,11 @@
voice_stun_servers:
voice_servers_no_passwd:
- 'stun:stun.l.google.com:19302'
- 'stun:stun1.l.google.com:19302'
- 'stun:stun2.l.google.com:19302'
- 'stun:stun3.l.google.com:19302'
- 'stun:stun4.l.google.com:19302'
- 'stun:openrelay.metered.ca:80'
voice_turn_servers:
voice_servers_passwd:
openrelay1:
url: 'turn:openrelay.metered.ca:80'
username: 'openrelayproject'

View File

@ -10,6 +10,10 @@ listener_01:
- '&6An EaglercraftX server'
allow_motd: true
allow_query: true
allow_protocol_v3: true
allow_protocol_v4: true
protocol_v4_defrag_send_delay: 10
allow_cookie_revoke_query: true
request_motd_cache:
cache_ttl: 7200
online_server_list_animation: false

View File

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Eaglercraft Server</title>
<style type="text/css">
body {
margin: 16px;
font-family: sans-serif;
}
</style>
</head>
<script type="text/javascript">
{% embed text `message_api_v1.js` %}
</script>
<script type="text/javascript">
// Open the channel, this can be any string
serverMessageAPI.openChannel("com.example.test_channel");
// Set the callback for when messages are recieved
serverMessageAPI.addEventListener("message", function(msg) {
var newElement = document.createElement("li");
if(msg.type === "binary") {
newElement.innerText = "[" + msg.channel + "][binary] ArrayBuffer(" + msg.data.byteLength + ")";
}else if(msg.type === "string") {
newElement.innerText = "[" + msg.channel + "][string] \"" + msg.data + "\"";
}
document.getElementById("messages_recieved").appendChild(newElement);
});
window.addEventListener("load", function() {
document.getElementById("message_send").addEventListener("click", function() {
var el = document.getElementById("message_contents");
var toSend = el.value.trim();
if(toSend.length > 0) {
// Send the message, can be a string, ArrayBuffer, Int8Array, or Uint8Array
serverMessageAPI.send("com.example.test_channel", toSend);
el.value = "";
}
});
});
/*
* // Add this event listener to your velocity plugin:
*
* @Subscribe
* public void testWebViewMessageAPI(EaglercraftWebViewMessageEvent event) {
* if(event.getType() == MessageType.STRING && event.getChannelName().equals("com.example.test_channel")) {
* event.sendResponse(event.getAsString());
* }
* }
*
*/
</script>
<body>
<h1>Message API Test</h1>
<h4>Server Version: {% global `plugin_name` %} {% global `plugin_version` %}</h4>
<h4>Make sure you enable javascript in "pause_menu.yml"</h4>
<p>Message: <input type="text" id="message_contents" placeholder="eagler"> <button id="message_send">Send</button></p>
<p>Recieved from server:</p>
<ul id="messages_recieved"></ul>
</body>
</html>

View File

@ -0,0 +1,63 @@
"use strict";
window.serverMessageAPI = (function() {
var channelOpen = null;
var messageHandlers = [];
window.addEventListener("message", function(evt) {
var dat = evt.data;
if((typeof dat === "object") && dat.ver === 1 && (typeof dat.type === "string") && (typeof dat.channel === "string") && dat.channel.length > 0) {
for(var i = 0; i < messageHandlers.length; ++i) {
messageHandlers[i](dat);
}
}
});
var ServerMessageAPIError = function(message) {
this.name = "ServerMessageAPIError";
this.message = message;
};
ServerMessageAPIError.prototype = Error.prototype;
var openCh = function(chName) {
if(channelOpen !== null) throw new ServerMessageAPIError("Cannot open multiple channels, this feature is not supported!");
channelOpen = chName;
window.parent.postMessage({ver:1,channel:chName,open:true}, "*");
};
var closeCh = function(chName) {
if(channelOpen !== chName) throw new ServerMessageAPIError("Cannot close channel \"" + chName + "\", that channel is not open!");
channelOpen = null;
window.parent.postMessage({ver:1,channel:chName,open:false}, "*");
};
var addListener = function(name, handler) {
if(name === "message") messageHandlers.push(handler);
};
var remListener = function(name, handler) {
if(name === "message") messageHandlers = messageHandlers.filter(function(o) { return o !== handler; });
};
var fixTypedArray = function(arr) {
if(arr.length === arr.buffer.byteLength) {
return arr.buffer;
}else {
var toSend = (data instanceof Uint8Array) ? new Uint8Array(arr.length) : new Int8Array(arr.length);
toSend.set(arr);
return toSend.buffer;
}
};
var send = function(chName, data) {
if(channelOpen !== chName) throw new ServerMessageAPIError("Cannot send message on channel \"" + chName + "\", that channel is not open!");
if(typeof data === "string") {
window.parent.postMessage({ver:1,channel:chName,data:data}, "*");
}else if(data instanceof ArrayBuffer) {
window.parent.postMessage({ver:1,channel:chName,data:data}, "*");
}else if((data instanceof Uint8Array) || (data instanceof Int8Array)) {
window.parent.postMessage({ver:1,channel:chName,data:fixTypedArray(data)}, "*");
}else {
throw new ServerMessageAPIError("Only strings, ArrayBuffers, Uint8Arrays, and Int8Arrays can be sent with this function!");
}
};
return {
ServerMessageAPIError: ServerMessageAPIError,
openChannel: openCh,
closeChannel: closeCh,
addEventListener: addListener,
removeEventListener: remListener,
send: send
};
})();

View File

@ -0,0 +1,43 @@
enable_custom_pause_menu: false
server_info_button:
enable_button: true
button_text: 'Server Info'
button_mode_open_new_tab: false
server_info_embed_url: ''
button_mode_embed_file: true
server_info_embed_file: 'server_info.html'
server_info_embed_screen_title: 'Server Info'
server_info_embed_send_chunk_rate: 1
server_info_embed_send_chunk_size: 24576
enable_template_macros: true
server_info_embed_template_globals:
example_global: 'eagler'
allow_embed_template_eval_macro: false
enable_webview_javascript: false
enable_webview_message_api: false
enable_webview_strict_csp: true
discord_button:
enable_button: true
button_text: 'Discord'
button_url: 'https://invite url here'
custom_images:
icon_title_L: ''
icon_title_R: ''
icon_backToGame_L: ''
icon_backToGame_R: ''
icon_achievements_L: ''
icon_achievements_R: ''
icon_statistics_L: ''
icon_statistics_R: ''
icon_serverInfo_L: ''
icon_serverInfo_R: ''
icon_options_L: ''
icon_options_R: ''
icon_discord_L: ''
icon_discord_R: ''
icon_disconnect_L: ''
icon_disconnect_R: ''
icon_background_pause: 'test_image.png'
icon_background_all: 'test_image.png'
icon_watermark_pause: ''
icon_watermark_all: ''

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Eaglercraft Server</title>
<style type="text/css">
body {
margin: 16px;
font-family: sans-serif;
}
</style>
</head>
<body>
<h1>Hello World</h1>
{% htmlescape on %}
<p>Server Name: {% global `server_name` %}</p>
<p>Using: {% global `plugin_name` %} {% global `plugin_version` %}</p>
<p>JVM: {% property `java.vm.name` `(unknown)` %} ({% property `java.vm.info` `null` %}) {% property `java.vm.vendor` `(unknown)` %}</p>
{% htmlescape off %}
<p><img src="data:image/png;base64,{% embed base64 `test_image.png` %}" /></p>
<!-- Note: JPEGs are recommended for larger images to reduce their size -->
<!-- <p><img src="data:image/jpeg;base64,(% embed base64 `large_image.jpg` %)" /></p> -->
</body>
</html>

View File

@ -23,4 +23,5 @@ eagler_players_vanilla_skin: ''
enable_is_eagler_player_property: true
disable_voice_chat_on_servers: []
disable_fnaw_skins_everywhere: false
disable_fnaw_skins_on_servers: []
disable_fnaw_skins_on_servers: []
enable_backend_rpc_api: false

View File

@ -1 +1 @@
{"id":"eaglerxvelocity","name":"EaglercraftXVelocity","version":"1.0.6","description":"Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks","authors":["lax1dude", "ayunami2000"],"dependencies":[],"main":"net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity"}
{"id":"eaglerxvelocity","name":"EaglercraftXVelocity","version":"1.1.0","description":"Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks","authors":["lax1dude", "ayunami2000"],"dependencies":[],"main":"net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity"}