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:
parent
b06f262e24
commit
74ecd2e08e
@ -26,43 +26,35 @@ public class PlayerListen implements Listener {
|
|||||||
plugin = main;
|
plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
void ChangePlayerFly(Player p, boolean fly) {
|
||||||
public void PlayerMove(ResidenceChangedEvent event) {
|
if (p.getAllowFlight() && !fly) {
|
||||||
Player player = event.getPlayer();
|
if (p.isFlying()) {
|
||||||
ClaimedResidence resto = event.getTo();
|
fall.put(p, p);
|
||||||
if (permCheck(player)) {
|
|
||||||
if (!resPermCheck(resto, player)) {
|
|
||||||
ChangePlayerFly(player, false);
|
|
||||||
} else {
|
|
||||||
ChangePlayerFly(player, true);
|
|
||||||
}
|
}
|
||||||
|
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
|
// ResidenceDeleteEvent.class
|
||||||
// ResidenceFlagChangeEvent.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)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void FlagChange(ResidenceFlagChangeEvent e) {
|
public void FlagChange(ResidenceFlagChangeEvent e) {
|
||||||
ClaimedResidence res = e.getResidence();
|
ClaimedResidence res = e.getResidence();
|
||||||
for (Player p : res.getPlayersInResidence()) {
|
for (Player p : res.getPlayersInResidence()) {
|
||||||
if (permCheck(p)) {
|
if (!permCheck(p)) {
|
||||||
if (permCheck(p)) {
|
if (!resPermCheck(res, p)) {
|
||||||
if (!resPermCheck(res, p)) {
|
ChangePlayerFly(p, false);
|
||||||
ChangePlayerFly(p, false);
|
} else {
|
||||||
} else {
|
ChangePlayerFly(p, true);
|
||||||
ChangePlayerFly(p, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,37 +73,37 @@ public class PlayerListen implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangePlayerFly(Player p, boolean fly) {
|
boolean permCheck(Player p) {
|
||||||
if (p.getAllowFlight() && !fly) {
|
return p.hasPermission("resfly.ignore") || p.isOp() || p.getGameMode() == GameMode.CREATIVE;
|
||||||
if (p.isFlying())
|
}
|
||||||
fall.put(p, p);
|
|
||||||
p.setAllowFlight(false);
|
@EventHandler(ignoreCancelled = true)
|
||||||
p.sendMessage(plugin.getfullmsg("Message.Not_Allow"));
|
public void resChange(ResidenceChangedEvent event) {
|
||||||
}
|
Player player = event.getPlayer();
|
||||||
if (!p.getAllowFlight() && fly) {
|
ClaimedResidence resto = event.getTo();
|
||||||
if (p == fall.get(p))
|
if (!permCheck(player)) {
|
||||||
fall.remove(p);
|
if (!resPermCheck(resto, player)) {
|
||||||
p.setAllowFlight(true);
|
ChangePlayerFly(player, false);
|
||||||
p.sendMessage(plugin.getfullmsg("Message.Allow"));
|
} else {
|
||||||
|
ChangePlayerFly(player, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean permCheck(Player p) {
|
@EventHandler(ignoreCancelled = true)
|
||||||
if (p.hasPermission("fcp.ignore.resfly") || p.isOp()
|
public void ResDelete(ResidenceDeleteEvent e) {
|
||||||
|| p.getGameMode() == GameMode.CREATIVE) {
|
ClaimedResidence res = e.getResidence();
|
||||||
return false;
|
for (Player p : res.getPlayersInResidence()) {
|
||||||
|
if (!permCheck(p)) {
|
||||||
|
ChangePlayerFly(p, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean resPermCheck(ClaimedResidence res, Player p) {
|
boolean resPermCheck(ClaimedResidence res, Player p) {
|
||||||
if (res == null) {
|
if (res == null)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
ResidencePermissions perms = res.getPermissions();
|
ResidencePermissions perms = res.getPermissions();
|
||||||
if (perms.playerHas(p.getName(), "fly", false)) {
|
return perms.playerHas(p.getName(), "fly", false);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user