Browse Source

InGame command Whitelist

master
pintux98 6 years ago
parent
commit
028d922fef
  1. 4
      MultiArena-TheBridge/config.yml
  2. 153
      MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java

4
MultiArena-TheBridge/config.yml

@ -9,6 +9,10 @@ chat:
lobby: "&b[TheBridge] &e<player>: &7<msg>"
ingame: "<teamColor>[<teamName>] <player>: &7<msg>"
global: "&6[GLOBAL] <teamColor> <teamName> <player>: &7<msg>"
commands:
enabled: true
list:
- /myCommand
archievements:
disable: false
remove:

153
MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java

@ -2,6 +2,7 @@ package cx.sfy.TheBridge.listeners;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -26,6 +27,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
@ -73,6 +75,22 @@ public class PlayerListener implements Listener {
Utils.setPlayerExperience(p, PlayerStat.getPlayerStat(p).getXP());
}
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent e) {
if (plugin.getGM().getGameByPlayer(e.getPlayer()) != null
|| plugin.getGM().getGameFourByPlayer(e.getPlayer()) != null) {
final List<String> cmds = plugin.getConfig().getStringList("commands.list");
if (e.getMessage().contains("/bridges"))
return;
if (plugin.getConfig().getBoolean("commands.whitelist") == true) {
if (cmds.contains(e.getMessage()))
return;
} else if (plugin.getConfig().getBoolean("commands.whitelist") == false)
if (!cmds.contains(e.getMessage()))
e.setCancelled(true);
}
}
public void givePlayerItems(Player p) {
final ItemStack select = ItemBuilder.item(Material.valueOf(plugin.getConfig().getString("items.menu.material")),
plugin.getConfig().getInt("items.menu.amount"), (short) plugin.getConfig().getInt("items.menu.data"),
@ -201,7 +219,7 @@ public class PlayerListener implements Listener {
}
if (item.getType().equals(Material.REDSTONE_COMPARATOR)
|| item.getType().equals(Material.REDSTONE_COMPARATOR_OFF) && item.getItemMeta().getDisplayName()
.equals(plugin.getLang().get("items.config.nameItem"))) {
.equals(plugin.getLang().get("items.config.nameItem"))) {
e.setCancelled(true);
plugin.getSOM().openOptionsMenu(p);
}
@ -385,28 +403,28 @@ public class PlayerListener implements Listener {
if (!game.getTeams().get(ChatColor.RED).getDeath()
&& !game.getTeamPlayer(p).getColor().equals(ChatColor.RED)
&& game.getTeams().get(ChatColor.RED).getPortal()
.contains(p.getLocation().getBlock().getLocation())) {
.contains(p.getLocation().getBlock().getLocation())) {
game.celebrateGoal(game.getTeamPlayer(p), game.getTeams().get(ChatColor.RED), p);
return;
}
if (!game.getTeams().get(ChatColor.BLUE).getDeath()
&& !game.getTeamPlayer(p).getColor().equals(ChatColor.BLUE)
&& game.getTeams().get(ChatColor.BLUE).getPortal()
.contains(p.getLocation().getBlock().getLocation())) {
.contains(p.getLocation().getBlock().getLocation())) {
game.celebrateGoal(game.getTeamPlayer(p), game.getTeams().get(ChatColor.BLUE), p);
return;
}
if (!game.getTeams().get(ChatColor.YELLOW).getDeath()
&& !game.getTeamPlayer(p).getColor().equals(ChatColor.YELLOW)
&& game.getTeams().get(ChatColor.YELLOW).getPortal()
.contains(p.getLocation().getBlock().getLocation())) {
.contains(p.getLocation().getBlock().getLocation())) {
game.celebrateGoal(game.getTeamPlayer(p), game.getTeams().get(ChatColor.YELLOW), p);
return;
}
if (!game.getTeams().get(ChatColor.GREEN).getDeath()
&& !game.getTeamPlayer(p).getColor().equals(ChatColor.GREEN)
&& game.getTeams().get(ChatColor.GREEN).getPortal()
.contains(p.getLocation().getBlock().getLocation())) {
.contains(p.getLocation().getBlock().getLocation())) {
game.celebrateGoal(game.getTeamPlayer(p), game.getTeams().get(ChatColor.GREEN), p);
return;
}
@ -571,7 +589,7 @@ public class PlayerListener implements Listener {
e.setCancelled(true);
if (e.getClickedInventory().getTitle().equals(plugin.getLang().get("menus.hotbar.title")))
if (e.getSlot() == 53 || e.getSlot() == 52 || e.getSlot() == 51 || e.getSlot() == 48
|| e.getSlot() == 47 || e.getSlot() == 46 || e.getSlot() == 45)
|| e.getSlot() == 47 || e.getSlot() == 46 || e.getSlot() == 45)
e.setCancelled(true);
}
}
@ -670,7 +688,7 @@ public class PlayerListener implements Listener {
else if (cage.isBuy() && cage.getPrice() <= PlayerStat.getPlayerStat(p).getCoins()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
plugin.getConfig().getString("permFormat").replaceAll("<name>", p.getName())
.replaceAll("<permission>", cage.getPermission()));
.replaceAll("<permission>", cage.getPermission()));
PlayerStat.getPlayerStat(p).removeCoins(cage.getPrice());
p.getOpenInventory().close();
new BukkitRunnable() {
@ -865,11 +883,11 @@ public class PlayerListener implements Listener {
game.removeAllPlayerTeam(p);
if (game.getTeams().get(ChatColor.BLUE).getTeamSize() < game.getTeamSize()
&& game.getTeams().get(ChatColor.BLUE).getTeamSize() <= game.getTeams().get(ChatColor.RED)
.getTeamSize()
.getTeamSize()
&& game.getTeams().get(ChatColor.BLUE).getTeamSize() <= game.getTeams()
.get(ChatColor.YELLOW).getTeamSize()
.get(ChatColor.YELLOW).getTeamSize()
&& game.getTeams().get(ChatColor.BLUE).getTeamSize() <= game.getTeams().get(ChatColor.GREEN)
.getTeamSize()) {
.getTeamSize()) {
game.addPlayerTeam(p, game.getTeams().get(ChatColor.BLUE));
p.sendMessage(plugin.getLang().get("messages.joinedTeam").replaceAll("<team>",
"§9" + plugin.getConfig().getString("names.blue")));
@ -891,11 +909,11 @@ public class PlayerListener implements Listener {
game.removeAllPlayerTeam(p);
if (game.getTeams().get(ChatColor.RED).getTeamSize() < game.getTeamSize()
&& game.getTeams().get(ChatColor.RED).getTeamSize() <= game.getTeams().get(ChatColor.BLUE)
.getTeamSize()
.getTeamSize()
&& game.getTeams().get(ChatColor.RED).getTeamSize() <= game.getTeams().get(ChatColor.YELLOW)
.getTeamSize()
.getTeamSize()
&& game.getTeams().get(ChatColor.RED).getTeamSize() <= game.getTeams().get(ChatColor.GREEN)
.getTeamSize()) {
.getTeamSize()) {
game.addPlayerTeam(p, game.getTeams().get(ChatColor.RED));
p.sendMessage(plugin.getLang().get("messages.joinedTeam").replaceAll("<team>",
"§c" + plugin.getConfig().getString("names.red")));
@ -917,11 +935,11 @@ public class PlayerListener implements Listener {
game.removeAllPlayerTeam(p);
if (game.getTeams().get(ChatColor.GREEN).getTeamSize() < game.getTeamSize()
&& game.getTeams().get(ChatColor.GREEN).getTeamSize() <= game.getTeams().get(ChatColor.RED)
.getTeamSize()
.getTeamSize()
&& game.getTeams().get(ChatColor.GREEN).getTeamSize() <= game.getTeams()
.get(ChatColor.YELLOW).getTeamSize()
.get(ChatColor.YELLOW).getTeamSize()
&& game.getTeams().get(ChatColor.GREEN).getTeamSize() <= game.getTeams().get(ChatColor.BLUE)
.getTeamSize()) {
.getTeamSize()) {
game.addPlayerTeam(p, game.getTeams().get(ChatColor.GREEN));
p.sendMessage(plugin.getLang().get("messages.joinedTeam").replaceAll("<team>",
"§a" + plugin.getConfig().getString("names.green")));
@ -943,11 +961,11 @@ public class PlayerListener implements Listener {
game.removeAllPlayerTeam(p);
if (game.getTeams().get(ChatColor.YELLOW).getTeamSize() < game.getTeamSize()
&& game.getTeams().get(ChatColor.YELLOW).getTeamSize() <= game.getTeams().get(ChatColor.RED)
.getTeamSize()
.getTeamSize()
&& game.getTeams().get(ChatColor.YELLOW).getTeamSize() <= game.getTeams()
.get(ChatColor.BLUE).getTeamSize()
.get(ChatColor.BLUE).getTeamSize()
&& game.getTeams().get(ChatColor.YELLOW).getTeamSize() <= game.getTeams()
.get(ChatColor.GREEN).getTeamSize()) {
.get(ChatColor.GREEN).getTeamSize()) {
game.addPlayerTeam(p, game.getTeams().get(ChatColor.YELLOW));
p.sendMessage(plugin.getLang().get("messages.joinedTeam").replaceAll("<team>",
"§e" + plugin.getConfig().getString("names.yellow")));
@ -1094,36 +1112,36 @@ public class PlayerListener implements Listener {
p.setHealth(p.getMaxHealth());
if (plugin.getConfig().getBoolean("remove.absorption") == true)
new BukkitRunnable() {
@Override
public void run() {
p.removePotionEffect(PotionEffectType.ABSORPTION);
}
}.runTaskLater(plugin, 1);
@Override
public void run() {
p.removePotionEffect(PotionEffectType.ABSORPTION);
}
}.runTaskLater(plugin, 1);
if (plugin.getConfig().getBoolean("remove.regeneration") == true)
new BukkitRunnable() {
@Override
public void run() {
p.removePotionEffect(PotionEffectType.REGENERATION);
}
}.runTaskLater(plugin, 1);
@Override
public void run() {
p.removePotionEffect(PotionEffectType.REGENERATION);
}
}.runTaskLater(plugin, 1);
}
if (plugin.getGM().getGameFourByPlayer(p) != null)
if (e.getItem().getType().equals(Material.GOLDEN_APPLE)) {
p.setHealth(p.getMaxHealth());
if (plugin.getConfig().getBoolean("remove.absorption") == true)
new BukkitRunnable() {
@Override
public void run() {
p.removePotionEffect(PotionEffectType.ABSORPTION);
}
}.runTaskLater(plugin, 1);
@Override
public void run() {
p.removePotionEffect(PotionEffectType.ABSORPTION);
}
}.runTaskLater(plugin, 1);
if (plugin.getConfig().getBoolean("remove.regeneration") == true)
new BukkitRunnable() {
@Override
public void run() {
p.removePotionEffect(PotionEffectType.REGENERATION);
}
}.runTaskLater(plugin, 1);
@Override
public void run() {
p.removePotionEffect(PotionEffectType.REGENERATION);
}
}.runTaskLater(plugin, 1);
}
}
@ -1187,8 +1205,7 @@ public class PlayerListener implements Listener {
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
if (game.isState(State.WAITING) || game.isState(State.STARTING) || game.isState(State.PREGAME)
|| game.isState(State.PREGAME)
|| game.isState(State.FINISH) || game.isState(State.RESTARTING))
|| game.isState(State.PREGAME) || game.isState(State.FINISH) || game.isState(State.RESTARTING))
e.setCancelled(true);
if (game.isState(State.INGAME))
if (!game.getPlaced().contains(e.getBlock().getLocation())) {
@ -1201,8 +1218,7 @@ public class PlayerListener implements Listener {
if (plugin.getGM().getGameFourByPlayer(p) != null) {
final GameFour game = plugin.getGM().getGameFourByPlayer(p);
if (game.isState(FState.WAITING) || game.isState(FState.STARTING) || game.isState(FState.PREGAME)
|| game.isState(FState.PREGAME)
|| game.isState(FState.FINISH) || game.isState(FState.RESTARTING))
|| game.isState(FState.PREGAME) || game.isState(FState.FINISH) || game.isState(FState.RESTARTING))
e.setCancelled(true);
if (game.isState(FState.INGAME))
if (!game.getPlaced().contains(e.getBlock().getLocation())) {
@ -1235,8 +1251,7 @@ public class PlayerListener implements Listener {
if (plugin.getGM().getGameFourByPlayer(p) != null) {
final GameFour game = plugin.getGM().getGameFourByPlayer(p);
if (game.isState(FState.WAITING) || game.isState(FState.STARTING) || game.isState(FState.PREGAME)
|| game.isState(FState.PREGAME)
|| game.isState(FState.FINISH) || game.isState(FState.RESTARTING))
|| game.isState(FState.PREGAME) || game.isState(FState.FINISH) || game.isState(FState.RESTARTING))
e.setCancelled(true);
if (game.isState(FState.INGAME))
if (!game.getBuild().contains(e.getBlockPlaced().getLocation())) {
@ -1269,9 +1284,9 @@ public class PlayerListener implements Listener {
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName())
+ plugin.getLang().get("deathMessages.player")
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
else {
final DamageCause cause = d.getLastDamageCause().getCause();
if (cause.equals(DamageCause.VOID))
@ -1281,9 +1296,9 @@ public class PlayerListener implements Listener {
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName())
+ plugin.getLang().get("deathMessages.player")
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
else if (cause.equals(DamageCause.ENTITY_ATTACK))
for (final Player on : game.getGamePlayers())
on.sendMessage(plugin.getLang().get("deathMessages.damage")
@ -1291,9 +1306,9 @@ public class PlayerListener implements Listener {
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName())
+ plugin.getLang().get("deathMessages.player")
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
else
for (final Player on : game.getGamePlayers())
on.sendMessage(plugin.getLang().get("deathMessages.custom")
@ -1301,9 +1316,9 @@ public class PlayerListener implements Listener {
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName())
+ plugin.getLang().get("deathMessages.player")
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
}
} else {
final Game game = plugin.getGM().getGameByPlayer(d);
@ -1352,9 +1367,9 @@ public class PlayerListener implements Listener {
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName())
+ plugin.getLang().get("deathMessages.player")
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
else {
final DamageCause cause = d.getLastDamageCause().getCause();
if (cause.equals(DamageCause.VOID))
@ -1364,9 +1379,9 @@ public class PlayerListener implements Listener {
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName())
+ plugin.getLang().get("deathMessages.player")
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
else if (cause.equals(DamageCause.ENTITY_ATTACK))
for (final Player on : game.getPlayers())
on.sendMessage(plugin.getLang().get("deathMessages.damage")
@ -1374,9 +1389,9 @@ public class PlayerListener implements Listener {
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName())
+ plugin.getLang().get("deathMessages.player")
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
else
for (final Player on : game.getPlayers())
on.sendMessage(plugin.getLang().get("deathMessages.custom")
@ -1384,9 +1399,9 @@ public class PlayerListener implements Listener {
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName())
+ plugin.getLang().get("deathMessages.player")
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
.replaceAll("<TDColor>", game.getTeamPlayer(d).getColor() + "")
.replaceAll("<TKColor>", game.getTeamPlayer(k).getColor() + "")
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
}
} else {
final GameFour game = plugin.getGM().getGameFourByPlayer(d);

Loading…
Cancel
Save