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
@ -1,117 +1,109 @@
|
|||||||
package cn.citycraft.ResFly.listen;
|
package cn.citycraft.ResFly.listen;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
import cn.citycraft.ResFly.ResFly;
|
import cn.citycraft.ResFly.ResFly;
|
||||||
|
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceChangedEvent;
|
import com.bekvon.bukkit.residence.event.ResidenceChangedEvent;
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent;
|
import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent;
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceFlagChangeEvent;
|
import com.bekvon.bukkit.residence.event.ResidenceFlagChangeEvent;
|
||||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||||
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
|
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
|
||||||
|
|
||||||
public class PlayerListen implements Listener {
|
public class PlayerListen implements Listener {
|
||||||
|
|
||||||
HashMap<Player, Player> fall = new HashMap<Player, Player>();
|
HashMap<Player, Player> fall = new HashMap<Player, Player>();
|
||||||
ResFly plugin;
|
ResFly plugin;
|
||||||
|
|
||||||
public PlayerListen(ResFly main) {
|
public PlayerListen(ResFly main) {
|
||||||
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)) {
|
p.setAllowFlight(false);
|
||||||
ChangePlayerFly(player, false);
|
p.sendMessage(plugin.getfullmsg("Message.Not_Allow"));
|
||||||
} else {
|
}
|
||||||
ChangePlayerFly(player, true);
|
if (!p.getAllowFlight() && fly) {
|
||||||
}
|
if (p == fall.get(p)) {
|
||||||
}
|
fall.remove(p);
|
||||||
}
|
}
|
||||||
|
p.setAllowFlight(true);
|
||||||
// ResidenceDeleteEvent.class
|
p.sendMessage(plugin.getfullmsg("Message.Allow"));
|
||||||
// ResidenceFlagChangeEvent.class
|
}
|
||||||
|
}
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void ResDelete(ResidenceDeleteEvent e) {
|
// ResidenceDeleteEvent.class
|
||||||
ClaimedResidence res = e.getResidence();
|
// ResidenceFlagChangeEvent.class
|
||||||
for (Player p : res.getPlayersInResidence()) {
|
|
||||||
if (permCheck(p)) {
|
@EventHandler(ignoreCancelled = true)
|
||||||
ChangePlayerFly(p, false);
|
public void FlagChange(ResidenceFlagChangeEvent e) {
|
||||||
}
|
ClaimedResidence res = e.getResidence();
|
||||||
}
|
for (Player p : res.getPlayersInResidence()) {
|
||||||
}
|
if (!permCheck(p)) {
|
||||||
|
if (!resPermCheck(res, p)) {
|
||||||
@EventHandler(ignoreCancelled = true)
|
ChangePlayerFly(p, false);
|
||||||
public void FlagChange(ResidenceFlagChangeEvent e) {
|
} else {
|
||||||
ClaimedResidence res = e.getResidence();
|
ChangePlayerFly(p, true);
|
||||||
for (Player p : res.getPlayersInResidence()) {
|
}
|
||||||
if (permCheck(p)) {
|
}
|
||||||
if (permCheck(p)) {
|
}
|
||||||
if (!resPermCheck(res, p)) {
|
}
|
||||||
ChangePlayerFly(p, false);
|
|
||||||
} else {
|
public void onFallDamage(EntityDamageEvent e) {
|
||||||
ChangePlayerFly(p, true);
|
if (e.getEntity() instanceof Player) {
|
||||||
}
|
Player p = (Player) e.getEntity();
|
||||||
}
|
if (e.getCause() == DamageCause.FALL) {
|
||||||
}
|
if (p == fall.get(p)) {
|
||||||
}
|
fall.remove(p);
|
||||||
}
|
e.setCancelled(true);
|
||||||
|
p.sendMessage(plugin.getfullmsg("Message.Protect"));
|
||||||
public void onFallDamage(EntityDamageEvent e) {
|
}
|
||||||
if (e.getEntity() instanceof Player) {
|
}
|
||||||
Player p = (Player) e.getEntity();
|
}
|
||||||
if (e.getCause() == DamageCause.FALL) {
|
}
|
||||||
if (p == fall.get(p)) {
|
|
||||||
fall.remove(p);
|
boolean permCheck(Player p) {
|
||||||
e.setCancelled(true);
|
return p.hasPermission("resfly.ignore") || p.isOp() || p.getGameMode() == GameMode.CREATIVE;
|
||||||
p.sendMessage(plugin.getfullmsg("Message.Protect"));
|
}
|
||||||
}
|
|
||||||
}
|
@EventHandler(ignoreCancelled = true)
|
||||||
}
|
public void resChange(ResidenceChangedEvent event) {
|
||||||
}
|
Player player = event.getPlayer();
|
||||||
|
ClaimedResidence resto = event.getTo();
|
||||||
void ChangePlayerFly(Player p, boolean fly) {
|
if (!permCheck(player)) {
|
||||||
if (p.getAllowFlight() && !fly) {
|
if (!resPermCheck(resto, player)) {
|
||||||
if (p.isFlying())
|
ChangePlayerFly(player, false);
|
||||||
fall.put(p, p);
|
} else {
|
||||||
p.setAllowFlight(false);
|
ChangePlayerFly(player, true);
|
||||||
p.sendMessage(plugin.getfullmsg("Message.Not_Allow"));
|
}
|
||||||
}
|
}
|
||||||
if (!p.getAllowFlight() && fly) {
|
}
|
||||||
if (p == fall.get(p))
|
|
||||||
fall.remove(p);
|
@EventHandler(ignoreCancelled = true)
|
||||||
p.setAllowFlight(true);
|
public void ResDelete(ResidenceDeleteEvent e) {
|
||||||
p.sendMessage(plugin.getfullmsg("Message.Allow"));
|
ClaimedResidence res = e.getResidence();
|
||||||
}
|
for (Player p : res.getPlayersInResidence()) {
|
||||||
}
|
if (!permCheck(p)) {
|
||||||
|
ChangePlayerFly(p, false);
|
||||||
boolean permCheck(Player p) {
|
}
|
||||||
if (p.hasPermission("fcp.ignore.resfly") || p.isOp()
|
}
|
||||||
|| p.getGameMode() == GameMode.CREATIVE) {
|
}
|
||||||
return false;
|
|
||||||
}
|
boolean resPermCheck(ClaimedResidence res, Player p) {
|
||||||
return true;
|
if (res == null)
|
||||||
}
|
return false;
|
||||||
|
ResidencePermissions perms = res.getPermissions();
|
||||||
boolean resPermCheck(ClaimedResidence res, Player p) {
|
return perms.playerHas(p.getName(), "fly", false);
|
||||||
if (res == null) {
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ResidencePermissions perms = res.getPermissions();
|
|
||||||
if (perms.playerHas(p.getName(), "fly", false)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user