style: formatting code

This commit is contained in:
MiaoWoo 2019-02-23 16:00:53 +00:00
parent c2c17a46d4
commit ccdbd8b683
2 changed files with 14 additions and 14 deletions

View File

@ -17,7 +17,7 @@ var itemConfig;
function load() { function load() {
var itemFile = self.file('item.yml'); var itemFile = self.file('item.yml');
task.async(function () { task.async(function() {
if (!itemFile.exists()) { if (!itemFile.exists()) {
fs.save(itemFile, http.get('https://data.yumc.pw/config/Item_zh_CN.yml')) fs.save(itemFile, http.get('https://data.yumc.pw/config/Item_zh_CN.yml'))
} }
@ -28,10 +28,10 @@ function load() {
function enable() { function enable() {
switch (DetectServerType) { switch (DetectServerType) {
case ServerType.Bukkit: case ServerType.Bukkit:
event.on(self, 'ItemMergeEvent', function (event) { event.on(self, 'ItemMergeEvent', function(event) {
bukkit(event.target, event.entity.itemStack.amount + event.target.itemStack.amount); bukkit(event.target, event.entity.itemStack.amount + event.target.itemStack.amount);
}); });
event.on(self, 'ItemSpawnEvent', function (event) { event.on(self, 'ItemSpawnEvent', function(event) {
if (event.entity.itemStack) { if (event.entity.itemStack) {
bukkit(event.entity, event.entity.itemStack.amount); bukkit(event.entity, event.entity.itemStack.amount);
} }
@ -39,11 +39,11 @@ function enable() {
break; break;
case ServerType.Sponge: case ServerType.Sponge:
Keys = Java.type('org.spongepowered.api.data.key.Keys'); Keys = Java.type('org.spongepowered.api.data.key.Keys');
event.on(self, 'ItemMergeItemEvent', function (event) { event.on(self, 'ItemMergeItemEvent', function(event) {
// Sponge 暂未实现当前事件 // Sponge 暂未实现当前事件
}); });
event.on(self, 'SpawnEntityEvent', function (event) { event.on(self, 'SpawnEntityEvent', function(event) {
event.entities.forEach(function (entity) { event.entities.forEach(function(entity) {
if (entity.type.name === "item") sponge(entity); if (entity.type.name === "item") sponge(entity);
}) })
}); });

View File

@ -59,12 +59,12 @@ function enable() {
return ['reload']; return ['reload'];
} }
}); });
bukkit.players(function (p) fakeTag.set(p)); bukkit.players(function(p) { fakeTag.set(p) });
event.on(self, 'PlayerJoin', function (event) fakeTag.set(event.player)); event.on(self, 'PlayerJoin', function(event) { fakeTag.set(event.player) });
var entityUpdate = function (event) { var entityUpdate = function(event) {
var player = event.entity || event.player; var player = event.entity || event.player;
if (player instanceof org.bukkit.entity.Player) { if (player instanceof org.bukkit.entity.Player) {
setTimeout(function () { setTimeout(function() {
fakeTag.update(player); fakeTag.update(player);
}, 1); }, 1);
} }
@ -108,18 +108,18 @@ function FakeTag(name) {
player.handle.playerConnection.sendPacket(p); player.handle.playerConnection.sendPacket(p);
} }
this.set = function (player) { this.set = function(player) {
sendPacket(player, cache.objective); sendPacket(player, cache.objective);
sendPacket(player, cache.display); sendPacket(player, cache.display);
this.update(player); this.update(player);
}; };
this.update = function (player) { this.update = function(player) {
var score = mainScoreboard.getPlayerScoreForObjective(player.name, objective); var score = mainScoreboard.getPlayerScoreForObjective(player.name, objective);
score.setScore(player.getHealth()); score.setScore(player.getHealth());
var scorePack = new PacketPlayOutScoreboardScore(score); var scorePack = new PacketPlayOutScoreboardScore(score);
//把其他玩家缓存的包发给这个玩家 //把其他玩家缓存的包发给这个玩家
bukkit.players(function (t) { bukkit.players(function(t) {
sendPacket(t, scorePack); sendPacket(t, scorePack);
if (t.name !== player.name) { if (t.name !== player.name) {
var outher = mainScoreboard.getPlayerScoreForObjective(t.name, objective); var outher = mainScoreboard.getPlayerScoreForObjective(t.name, objective);
@ -129,7 +129,7 @@ function FakeTag(name) {
}); });
}; };
this.disable = function () { this.disable = function() {
// 注销tag对象 // 注销tag对象
mainScoreboard.unregisterObjective(objective); mainScoreboard.unregisterObjective(objective);
} }