style: code format
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
2dff086a01
commit
2013b3b07c
@ -74,6 +74,10 @@ function getItemCount(amount) {
|
||||
return amount === 1 ? "" : "*" + amount;
|
||||
}
|
||||
|
||||
function disable() {
|
||||
console.log('卸载', description.name, '插件!');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
description: description,
|
||||
load: load,
|
||||
|
@ -84,9 +84,7 @@ function enable() {
|
||||
registerCommand();
|
||||
registerEvent();
|
||||
registerTask();
|
||||
server.players(function (player) {
|
||||
boards[player.name] = new MiaoBoard(player);
|
||||
})
|
||||
updatePlayers()
|
||||
}
|
||||
|
||||
function registerCommand() {
|
||||
@ -110,7 +108,7 @@ function mainCommand(sender, command, args) {
|
||||
function registerEvent() {
|
||||
switch (DetectServerType) {
|
||||
case ServerType.Bukkit:
|
||||
event.on(self, 'PlayerLoginEvent', handlerPlayerJoin);
|
||||
//event.on(self, 'PlayerLoginEvent', handlerPlayerJoin);
|
||||
break;
|
||||
case ServerType.Sponge:
|
||||
Player = org.spongepowered.api.entity.living.player.Player;
|
||||
@ -120,6 +118,19 @@ function registerEvent() {
|
||||
}
|
||||
}
|
||||
|
||||
function updatePlayers() {
|
||||
switch (DetectServerType) {
|
||||
case ServerType.Bukkit:
|
||||
//event.on(self, 'PlayerLoginEvent', handlerPlayerJoin);
|
||||
break;
|
||||
case ServerType.Sponge:
|
||||
server.players(function(player) {
|
||||
boards[player.name] = new MiaoBoard(player);
|
||||
})
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function handlerPlayerJoin(event) {
|
||||
var player = event.player || event.targetEntity;
|
||||
boards[player.name] = new MiaoBoard(player);
|
||||
@ -180,11 +191,11 @@ function MiaoBoard(player) {
|
||||
scoreboard.addObjective(sidebar);
|
||||
player.setScoreboard(scoreboard);
|
||||
|
||||
this.update = function (title, lines) {
|
||||
this.update = function(title, lines) {
|
||||
this.updateBuffer(title, lines);
|
||||
}
|
||||
|
||||
this.updateBuffer = function (title, lines) {
|
||||
this.updateBuffer = function(title, lines) {
|
||||
sidebar.scores.values().forEach(function removeScore(score) {
|
||||
sidebar.removeScore(score);
|
||||
})
|
||||
@ -196,7 +207,7 @@ function MiaoBoard(player) {
|
||||
scoreboard.updateDisplaySlot(sidebar, DisplaySlots.SIDEBAR);
|
||||
}
|
||||
|
||||
this.clear = function () {
|
||||
this.clear = function() {
|
||||
player.setScoreboard(Scoreboard.builder().build());
|
||||
}
|
||||
}
|
||||
|
@ -41,14 +41,14 @@ var description = {
|
||||
"index": 50,
|
||||
"permission": "MiaoChat.default",
|
||||
"range": 0,
|
||||
"format": "[world][player]: ",
|
||||
"format": "[world][player]&7: ",
|
||||
"item": true,
|
||||
"itemformat": "&6[&b%s&6]&r"
|
||||
},
|
||||
"admin": {
|
||||
"index": 49,
|
||||
"permission": "MiaoChat.admin",
|
||||
"format": "[admin][world][player][help]: ",
|
||||
"format": "[admin][world][player][help]&7: ",
|
||||
"range": 0,
|
||||
"item": true,
|
||||
"itemformat": "&6[&b%s&6]&r"
|
||||
@ -116,7 +116,7 @@ function load() {
|
||||
var FORMAT_PATTERN = /[\[]([^\[\]]+)[\]]/ig;
|
||||
|
||||
function initFormat(chat_formats) {
|
||||
chat_formats.forEach(function (chat_format) {
|
||||
chat_formats.forEach(function(chat_format) {
|
||||
var chat_format_str = chat_format.format;
|
||||
var temp = [];
|
||||
var r;
|
||||
@ -168,7 +168,7 @@ function registerEvent() {
|
||||
}
|
||||
|
||||
function handlerBukkitChat(event) {
|
||||
sendChat(event.player, event.message, function () {
|
||||
sendChat(event.player, event.message, function() {
|
||||
event.setCancelled(true);
|
||||
});
|
||||
}
|
||||
@ -182,7 +182,7 @@ function handlerSpongeChat(event) {
|
||||
if (plain.startsWith(tellraw.duplicateChar)) {
|
||||
return;
|
||||
}
|
||||
sendChat(player, plain, function () {
|
||||
sendChat(player, plain, function() {
|
||||
event.setMessageCancelled(true)
|
||||
});
|
||||
}
|
||||
|
@ -10,11 +10,13 @@ var bukkit = require('api/server');
|
||||
var item = require('api/item');
|
||||
|
||||
var Arrays = Java.type('java.util.Arrays');
|
||||
var Material = Java.type('org.bukkit.Material');
|
||||
var ItemStackArray = Java.type('org.bukkit.inventory.ItemStack[]');
|
||||
|
||||
var description = {
|
||||
name: 'Lottery',
|
||||
version: '1.0',
|
||||
author: 'MiaoWoo',
|
||||
commands: {
|
||||
'lottery': {
|
||||
description: 'Lottery主命令'
|
||||
@ -22,11 +24,15 @@ var description = {
|
||||
},
|
||||
config: {
|
||||
title: '§m§s§a幸运抽奖',
|
||||
panel: '160:13',
|
||||
control: {
|
||||
panel: 'GLASS_PANE:13',
|
||||
ok: 'GLASS_PANE:14',
|
||||
no: 'GLASS_PANE:15',
|
||||
},
|
||||
list: [
|
||||
{
|
||||
box: {
|
||||
id: 160,
|
||||
id: 'GLASS_PANE',
|
||||
damage: 1,
|
||||
name: '§a箱子',
|
||||
lore: [
|
||||
@ -34,7 +40,7 @@ var description = {
|
||||
]
|
||||
},
|
||||
key: {
|
||||
id: 160,
|
||||
id: 'GLASS_PANE',
|
||||
damage: 2,
|
||||
name: '§b钥匙',
|
||||
lore: [
|
||||
@ -46,7 +52,7 @@ var description = {
|
||||
percent: 10,
|
||||
command: 'money give %player% 100',
|
||||
item: {
|
||||
id: 160,
|
||||
id: 'GLASS_PANE',
|
||||
damage: 3,
|
||||
name: '§c奖品1',
|
||||
lore: [
|
||||
@ -58,7 +64,7 @@ var description = {
|
||||
percent: 20,
|
||||
command: 'money give %player% 200',
|
||||
item: {
|
||||
id: 160,
|
||||
id: 'GLASS_PANE',
|
||||
damage: 4,
|
||||
name: '§c奖品2',
|
||||
lore: [
|
||||
@ -72,25 +78,19 @@ var description = {
|
||||
}
|
||||
};
|
||||
|
||||
var panel = item.create(160, 1, 13);
|
||||
var panel;
|
||||
var config;
|
||||
var items;
|
||||
|
||||
function load() {
|
||||
panel = item.create('GLASS_PANE', 1, 13);
|
||||
config = this.config;
|
||||
if (config.panel) {
|
||||
var arr = config.panel.split(':');
|
||||
if (arr.length === 2) {
|
||||
panel = newItem(arr[0], arr[1]);
|
||||
} else {
|
||||
panel = newItem(arr[0]);
|
||||
}
|
||||
}
|
||||
panel = newItemFromString(config.control.panel || 'GLASS_PANE:13')
|
||||
items = new ItemStackArray(54);
|
||||
item.setName(panel, '');
|
||||
var ok = newItem(160, 14);
|
||||
var ok = newItemFromString(config.control.ok || 'GLASS_PANE:14')
|
||||
item.setName(ok, '§a确定抽奖');
|
||||
var no = newItem(160, 15);
|
||||
var no = newItemFromString(config.control.no || 'GLASS_PANE:15')
|
||||
item.setName(no, '§c取消抽奖');
|
||||
Arrays.fill(items, 0, 10, panel);
|
||||
Arrays.fill(items, 11, 16, panel);
|
||||
@ -113,6 +113,15 @@ function newItem(name, sub) {
|
||||
return item.create(name, 1, sub || 0);
|
||||
}
|
||||
|
||||
function newItemFromString(str) {
|
||||
var arr = str.split(':');
|
||||
if (arr.length === 2) {
|
||||
return newItem(arr[0], arr[1]);
|
||||
} else {
|
||||
return newItem(arr[0]);
|
||||
}
|
||||
}
|
||||
|
||||
function newItemFromConfig(config) {
|
||||
var i = newItem(config.id, config.damage);
|
||||
if (config.name) item.setName(i, config.name);
|
||||
@ -123,7 +132,7 @@ function newItemFromConfig(config) {
|
||||
function enable() {
|
||||
// noinspection JSUnusedLocalSymbols
|
||||
command.on(this, 'l', {
|
||||
cmd: function (sender, command, args) {
|
||||
cmd: function(sender, command, args) {
|
||||
if (!sender.openInventory) {
|
||||
console.sender(sender, "§4当前用户无法使用该命令!");
|
||||
}
|
||||
@ -180,7 +189,7 @@ function enable() {
|
||||
return;
|
||||
}
|
||||
var resultList = [];
|
||||
litem.result.forEach(function (t) {
|
||||
litem.result.forEach(function(t) {
|
||||
for (var i = 0; i < t.percent; i++) {
|
||||
resultList.push(t);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user