Created
January 10, 2017 00:07
-
-
Save ticklemynausea/7bd37fb0f59f85517201538c0a89fa4d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (function() { | |
| var data = {} | |
| data.regions = { | |
| 'test-1' : { | |
| title: 'Welcome to the Test Area!', | |
| description: 'This area tests better than 99% of other areas', | |
| }, | |
| 'test-2' : { | |
| title: 'Welcome to HELL!', | |
| description: 'This area SUCKS', | |
| }, | |
| 'limbo-minigame-1' : { | |
| title: 'here pig piggy', | |
| description: 'pig pig pig', | |
| }, | |
| 'limbo-arena' : { | |
| title: '§4Arena PVP§r', | |
| description: 'Aqui dás e aqui levas!' | |
| }, | |
| 'limbo-rg-casadocomercio' : { | |
| title: '§7Casa do Comércio§r', | |
| description: 'Melhor que o OLX.' | |
| }, | |
| 'limbo-rg-campofutebol' : { | |
| title: '§7Campo do Ilha Morena FC§r', | |
| description: 'Presença nos oitavos da Taça de Portugal de 1968' | |
| }, | |
| 'limbo-rg-feiradaladra' : { | |
| title: '§7Feira da Ladra§r', | |
| description: 'Pague 10, leve 2!' | |
| }, | |
| 'limbo-rg-igreja' : { | |
| title: '§7Igreja§r', | |
| description: 'As aventuras começam aqui!' | |
| }, | |
| 'limbo-rg-casino' : { | |
| title: '§7Casino Underground§r', | |
| description: 'Nem todos passam pelo Mário!' | |
| }, | |
| 'limbo-rg-hof-entrada' : { | |
| title: '§4aaah wtf omg§r', | |
| description: '§4a cair, a cair, a cair!!!§r', | |
| tFadeIn: 0, tFadeOut: 0, | |
| sPlayIn: 'GHAST_SCREAM', sVolume: 1, sPitch: 1.1 | |
| }, | |
| 'limbo-rg-hof-donors' : { | |
| title: '§6Hall of Fame§r', | |
| description: '§oVIP donors - Suportam a nossa existência!§r', | |
| }, | |
| 'limbo-rg-hof-admin' : { | |
| title: '§6Hall of Fame§r', | |
| description: '§6STAFF§r', | |
| }, | |
| 'limbo-rg-hof-welcome' : { | |
| title: '§6Hall of Fame§r', | |
| description: '§oHomenagens e fantasmas do passado...§r', | |
| tStay: 100, | |
| stay: true, | |
| }, | |
| } | |
| data.automessages = { | |
| } | |
| module.exports = data; | |
| })(); |
This file contains hidden or 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
| /* For some weird reason every event captured by events.on() here turns out to be every subclass of RegionEvent. | |
| * Even if I register the listener with RegionEnterEvent or RegionLeftEvent or whatever, it will trigger for every | |
| * sub event. WTF?? | |
| * As such we need some trickery to distinguish between region events. */ | |
| var data = require('./data.js') | |
| var sounds = require('sounds'); | |
| var TitleAnnouncer = (function() { | |
| var module = {}; | |
| module.evRegionEnterEvent = null, | |
| module.hndRegionEnterEvent = function(e, c) { | |
| var realEventName = e.toString().split('@')[0].split('com.mewin.WGRegionEvents.events.')[1]; | |
| var rId = e.getRegion().getId(); | |
| if (!(rId in data.regions)) { | |
| return; | |
| } | |
| var d = data.regions[rId]; | |
| switch (realEventName) { | |
| case 'RegionEnteredEvent': { | |
| module.sendMessage(e.getPlayer(), d); | |
| module.playSound(e.getPlayer(), d); | |
| break; | |
| } | |
| case 'RegionLeftEvent': { | |
| if (!d.stay) module.sendMessage(e.getPlayer(), { | |
| title: '', | |
| description: '', | |
| tStay: 0, | |
| tFadeIn: 0, | |
| tFadeOut : 0, | |
| }); | |
| break; | |
| } | |
| } | |
| }; | |
| module.sendMessage = function(player, data) { | |
| var title = data.title; | |
| var description = data.description; | |
| var tStay = !!data.tStay ? data.tStay : 50; | |
| var tFadeIn = !!data.tFadeIn ? data.tFadeIn : 10; | |
| var tFadeOut = !!data.tFadeOut ? data.tFadeOut : 10; | |
| var ttObj = new Packages.io.puharesource.mc.titlemanager.api.TitleObject(title, description); | |
| ttObj.setFadeIn(tFadeIn).setFadeOut(tFadeOut).setStay(tStay).send(player); | |
| }; | |
| module.playSound = function(player, data) { | |
| var sVolume = !!data.sVolume ? data.sVolume : 1; | |
| var sPitch = !!data.sPitch ? data.sPitch : 0; | |
| if (!!data.sPlayIn) { | |
| sounds.play(Packages.org.bukkit.Sound[data.sPlayIn], player, data.sVolume, data.sPitch); | |
| } | |
| }; | |
| module.load = function() { | |
| module.evRegionEnterEvent = events.on( | |
| Packages.com.mewin.WGRegionEvents.events.RegionEnterEvent, | |
| module.hndRegionEnterEvent | |
| ); | |
| addUnloadHandler(module.unload) | |
| }; | |
| module.unload = function() { | |
| module.evRegionEnterEvent.unregister() | |
| }; | |
| return module; | |
| })(); | |
| TitleAnnouncer.load(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment