-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a430e94
Showing
99 changed files
with
7,054 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/web/web/bundles/ | ||
/web/app/bootstrap* | ||
/web/app/cache/* | ||
/web/app/logs/* | ||
/web/vendor/ | ||
/web/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (C) 2013 Jonathan Devine | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Skynet-Minecraft | ||
================ | ||
|
||
TODO | ||
|
||
[SQLFiddle](http://sqlfiddle.com/#!2/32e4e9) | ||
```sql | ||
|
||
CREATE DATABASE IF NOT EXISTS `skynet`; | ||
USE `skynet`; | ||
|
||
CREATE TABLE IF NOT EXISTS `event_type` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`name` varchar(32) NOT NULL, | ||
PRIMARY KEY (`id`) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS `player` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`username` varchar(32) NOT NULL, | ||
`online` tinyint(1) NOT NULL DEFAULT '0', | ||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `username` (`username`) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS `event` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`event_type_id` int(4) NOT NULL, | ||
`player_id` int(32) NOT NULL, | ||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`id`), | ||
KEY `fk_event_type` (`event_type_id`), | ||
KEY `fk_event_player` (`player_id`) | ||
); | ||
|
||
ALTER TABLE `event` | ||
ADD CONSTRAINT `fk_event_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`), | ||
ADD CONSTRAINT `fk_event_type` FOREIGN KEY (`event_type_id`) REFERENCES `event_type` (`id`); | ||
|
||
CREATE TABLE IF NOT EXISTS `session` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`player_id` int(11) NOT NULL, | ||
`login` int(11) NOT NULL, | ||
`logout` int(11) DEFAULT NULL, | ||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`duration` int(50) NOT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `fk_login_event` (`login`), | ||
KEY `fk_logout_event` (`logout`), | ||
KEY `fk_session_player` (`player_id`) | ||
); | ||
|
||
ALTER TABLE `session` | ||
ADD CONSTRAINT `fk_login_event` FOREIGN KEY (`login`) REFERENCES `event` (`id`), | ||
ADD CONSTRAINT `fk_logout_event` FOREIGN KEY (`logout`) REFERENCES `event` (`id`), | ||
ADD CONSTRAINT `fk_session_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`); | ||
``` | ||
|
||
Made by [Jonathan Devine](http://jonnydevine.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
var assert = require('assert') | ||
, quoteMeta = require('quotemeta') | ||
, LEGAL_CHARS = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»§' | ||
, CHAT_LENGTH_LIMIT = 100 | ||
|
||
module.exports = inject; | ||
|
||
var quotedLegalChars = quoteMeta(LEGAL_CHARS); | ||
var incomingFilter = new RegExp("([^" + quotedLegalChars + "]|§.)", 'g'); | ||
var outgoingFilter = new RegExp("([^" + quotedLegalChars + "])", 'g'); | ||
|
||
function inject(bot) { | ||
bot.client.on(0x03, function(packet) { | ||
|
||
// used by minecraft <= 1.6.1 and craftbukkit >= 1.6.2 | ||
function parseOldMessage(message) { | ||
console.log("**************************** " + message); | ||
var legalContent = message.replace(incomingFilter, ''); | ||
var front = legalContent.substr(0, legalContent.indexOf(':')); | ||
var content = legalContent.substr(legalContent.indexOf(':')+1); | ||
var frontParts = front.split(' '); | ||
|
||
var frontPart1 = frontParts[0]; | ||
var frontPart2 = frontParts[1]; | ||
if (frontPart1) { | ||
if (typeof frontPart1 != 'undefined' && frontPart1 == 'From' && typeof frontPart2 != 'undefined' && content != 'undefined') { | ||
bot.emit('whisper', frontPart2, content, message); | ||
} else if (typeof frontPart1 != 'undefined' && typeof frontPart2 === 'undefined' && content != 'undefined') { | ||
bot.emit('chat', frontPart1, content, message); | ||
} | ||
} else { | ||
bot.emit('nonSpokenChat', legalContent); | ||
} | ||
} | ||
|
||
// used by minecraft >= 1.6.2 | ||
function parseJsonMessage(jsonMessage) { | ||
var username, content; | ||
if (typeof jsonMsg.translate === 'string' && jsonMsg.translate.match(/^chat\./)) { | ||
// spoken chat | ||
username = jsonMsg.using[0]; | ||
content = jsonMsg.using[1].replace(incomingFilter, ''); | ||
bot.emit('chat', username, content, jsonMsg.translate, jsonMsg); | ||
} else if (jsonMsg.translate === "commands.message.display.incoming") { | ||
// whispered chat | ||
username = jsonMsg.using[0]; | ||
content = jsonMsg.using[1].replace(incomingFilter, ''); | ||
bot.emit('whisper', username, content, jsonMsg.translate, jsonMsg); | ||
} else if (typeof jsonMsg.text === 'string') { | ||
// craftbukkit message format | ||
parseOldMessage(jsonMsg.text); | ||
} | ||
} | ||
|
||
var jsonMsg; | ||
try { | ||
jsonMsg = JSON.parse(packet.message); | ||
} catch (e) { | ||
// old message format | ||
bot.emit('message', packet.message); | ||
parseOldMessage(packet.message); | ||
return; | ||
} | ||
bot.emit('message', jsonMsg); | ||
parseJsonMessage(jsonMsg) | ||
}); | ||
|
||
function chatWithHeader(header, message) { | ||
message = message.replace(outgoingFilter, ''); | ||
var lengthLimit = CHAT_LENGTH_LIMIT - header.length; | ||
message.split("\n").forEach(function(subMessage) { | ||
if (! subMessage) return; | ||
var i, smallMsg; | ||
for (i = 0; i < subMessage.length; i += lengthLimit) { | ||
smallMsg = header + subMessage.substring(i, i + lengthLimit); | ||
bot.client.write(0x03, {message: smallMsg}); | ||
} | ||
}); | ||
} | ||
bot.whisper = function(username, message) { | ||
chatWithHeader("/tell " + username + " ", message); | ||
}; | ||
bot.chat = function(message) { | ||
chatWithHeader("", message); | ||
}; | ||
} |
Oops, something went wrong.