1
0
mirror of https://e.coding.net/circlecloud/ResFly.git synced 2024-11-21 10:48:48 +00:00

Optimization performance and fix perm error...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-06-14 13:53:15 +08:00
parent b06f262e24
commit 74ecd2e08e

View File

@ -26,38 +26,31 @@ public class PlayerListen implements Listener {
plugin = main;
}
@EventHandler(ignoreCancelled = true)
public void PlayerMove(ResidenceChangedEvent event) {
Player player = event.getPlayer();
ClaimedResidence resto = event.getTo();
if (permCheck(player)) {
if (!resPermCheck(resto, player)) {
ChangePlayerFly(player, false);
} else {
ChangePlayerFly(player, true);
void ChangePlayerFly(Player p, boolean fly) {
if (p.getAllowFlight() && !fly) {
if (p.isFlying()) {
fall.put(p, p);
}
p.setAllowFlight(false);
p.sendMessage(plugin.getfullmsg("Message.Not_Allow"));
}
if (!p.getAllowFlight() && fly) {
if (p == fall.get(p)) {
fall.remove(p);
}
p.setAllowFlight(true);
p.sendMessage(plugin.getfullmsg("Message.Allow"));
}
}
// ResidenceDeleteEvent.class
// ResidenceFlagChangeEvent.class
@EventHandler(ignoreCancelled = true)
public void ResDelete(ResidenceDeleteEvent e) {
ClaimedResidence res = e.getResidence();
for (Player p : res.getPlayersInResidence()) {
if (permCheck(p)) {
ChangePlayerFly(p, false);
}
}
}
@EventHandler(ignoreCancelled = true)
public void FlagChange(ResidenceFlagChangeEvent e) {
ClaimedResidence res = e.getResidence();
for (Player p : res.getPlayersInResidence()) {
if (permCheck(p)) {
if (permCheck(p)) {
if (!permCheck(p)) {
if (!resPermCheck(res, p)) {
ChangePlayerFly(p, false);
} else {
@ -66,7 +59,6 @@ public class PlayerListen implements Listener {
}
}
}
}
public void onFallDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
@ -81,37 +73,37 @@ public class PlayerListen implements Listener {
}
}
void ChangePlayerFly(Player p, boolean fly) {
if (p.getAllowFlight() && !fly) {
if (p.isFlying())
fall.put(p, p);
p.setAllowFlight(false);
p.sendMessage(plugin.getfullmsg("Message.Not_Allow"));
boolean permCheck(Player p) {
return p.hasPermission("resfly.ignore") || p.isOp() || p.getGameMode() == GameMode.CREATIVE;
}
@EventHandler(ignoreCancelled = true)
public void resChange(ResidenceChangedEvent event) {
Player player = event.getPlayer();
ClaimedResidence resto = event.getTo();
if (!permCheck(player)) {
if (!resPermCheck(resto, player)) {
ChangePlayerFly(player, false);
} else {
ChangePlayerFly(player, true);
}
if (!p.getAllowFlight() && fly) {
if (p == fall.get(p))
fall.remove(p);
p.setAllowFlight(true);
p.sendMessage(plugin.getfullmsg("Message.Allow"));
}
}
boolean permCheck(Player p) {
if (p.hasPermission("fcp.ignore.resfly") || p.isOp()
|| p.getGameMode() == GameMode.CREATIVE) {
return false;
@EventHandler(ignoreCancelled = true)
public void ResDelete(ResidenceDeleteEvent e) {
ClaimedResidence res = e.getResidence();
for (Player p : res.getPlayersInResidence()) {
if (!permCheck(p)) {
ChangePlayerFly(p, false);
}
}
return true;
}
boolean resPermCheck(ClaimedResidence res, Player p) {
if (res == null) {
if (res == null)
return false;
}
ResidencePermissions perms = res.getPermissions();
if (perms.playerHas(p.getName(), "fly", false)) {
return true;
}
return false;
return perms.playerHas(p.getName(), "fly", false);
}
}