/**
* Prevents teleporting when falling based on setting by stopping commands
*
* @param e
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onPlayerTeleport(final PlayerCommandPreprocessEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (Settings.allowTeleportWhenFalling || e.getPlayer().isOp() || !e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)) {
return;
}
if (!inASkyGridWorld(e.getPlayer().getWorld())) {
return;
}
// Check commands
// plugin.getLogger().info("DEBUG: falling command: '" +
// e.getMessage().substring(1).toLowerCase() + "'");
if (isFalling(e.getPlayer().getUniqueId()) && Settings.fallingCommandBlockList.contains(e.getMessage().substring(1).toLowerCase())) {
// Sorry you are going to die
e.getPlayer().sendMessage(plugin.myLocale(e.getPlayer().getUniqueId()).gridcannotTeleport);
e.setCancelled(true);
}
}
java类org.bukkit.event.player.PlayerCommandPreprocessEvent的实例源码
PlayerEvents.java 文件源码
项目:askygrid
阅读 28
收藏 0
点赞 0
评论 0
PlayerEvents.java 文件源码
项目:askygrid
阅读 24
收藏 0
点赞 0
评论 0
/**
* Prevents players from using commands like /spawner
* @param e
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onPlayerCommand(final PlayerCommandPreprocessEvent e) {
if (DEBUG) {
plugin.getLogger().info("Player command " + e.getEventName() + ": " + e.getMessage());
}
if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bannedcommands")) {
return;
}
// Check world
if (!inASkyGridWorld(e.getPlayer().getWorld())) {
return;
}
// Check banned commands
//plugin.getLogger().info(Settings.visitorCommandBlockList.toString());
String[] args = e.getMessage().substring(1).toLowerCase().split(" ");
if (Settings.bannedCommandList.contains(args[0])) {
e.getPlayer().sendMessage(ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).errorNoPermission);
e.setCancelled(true);
}
}
Events.java 文件源码
项目:GameDispenser
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (GameManager.getGameManager().getGameForPlayer(event.getPlayer()) == null) {
return;
}
String command = event.getMessage()
.replaceAll("^/*", "") // Remove forward slash if exists
.replaceAll(" .*", ""); // Remove anything after first word
for (String s : GameDispenser.getInstance().getBlacklistedCommands()) {
if (s.equalsIgnoreCase(command)) {
event.getPlayer().sendMessage(FormatUtil.format("&4Cannot use that command while playing a game."));
event.setCancelled(true);
return;
}
}
}
Main.java 文件源码
项目:defend-the-village
阅读 19
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onCommandPre(PlayerCommandPreprocessEvent ev) {
if (this.am.isInGame(ev.getPlayer())) {
// Only if the player is in game
boolean c = true;
// Is it allowed?
for (String com : this.allowedCommands) {
if (ev.getMessage().toLowerCase().startsWith("/" + com)) {
c = false;
}
}
if (c)
// If the command is not allowed, notify the user
s(ev.getPlayer(), this.config.get("no_command_in_game"));
ev.setCancelled(c);
}
}
ChatListener.java 文件源码
项目:ProSpam
阅读 31
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
String txt = event.getMessage();
for(String cmd: settings.filter_commands)
{
String cmdStr[] = txt.split(" ");
if(cmdStr.length >= 1 && cmdStr[0].equalsIgnoreCase(cmd))
{
String filtered = filterText(event.getPlayer(), txt.substring(cmd.length()));
if(filtered != null)
{
event.setMessage(cmd + filtered);
}
else
{
event.setCancelled(true);
}
return;
}
}
}
PlayerEvents.java 文件源码
项目:acidisland
阅读 25
收藏 0
点赞 0
评论 0
/**
* Prevents teleporting when falling based on setting by stopping commands
*
* @param e
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerCommandPreprocessEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!IslandGuard.inWorld(e.getPlayer()) || Settings.allowTeleportWhenFalling || e.getPlayer().isOp()
|| !e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)
|| plugin.getPlayers().isInTeleport(e.getPlayer().getUniqueId())) {
return;
}
// Check commands
// plugin.getLogger().info("DEBUG: falling command: '" +
// e.getMessage().substring(1).toLowerCase() + "'");
if (isFalling(e.getPlayer().getUniqueId()) && (Settings.fallingCommandBlockList.contains("*") || Settings.fallingCommandBlockList.contains(e.getMessage().substring(1).toLowerCase()))) {
// Sorry you are going to die
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).errorNoPermission);
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).islandcannotTeleport);
e.setCancelled(true);
}
}
PlayerEvents.java 文件源码
项目:acidisland
阅读 31
收藏 0
点赞 0
评论 0
/**
* Prevents visitors from using commands on islands, like /spawner
* @param e
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onVisitorCommand(final PlayerCommandPreprocessEvent e) {
if (DEBUG) {
plugin.getLogger().info("Visitor command " + e.getEventName() + ": " + e.getMessage());
}
if (!IslandGuard.inWorld(e.getPlayer()) || e.getPlayer().isOp()
|| VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
|| plugin.getGrid().locationIsOnIsland(e.getPlayer(), e.getPlayer().getLocation())) {
//plugin.getLogger().info("player is not in world or op etc.");
return;
}
// Check banned commands
//plugin.getLogger().info(Settings.visitorCommandBlockList.toString());
String[] args = e.getMessage().substring(1).toLowerCase().split(" ");
if (Settings.visitorCommandBlockList.contains(args[0])) {
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
e.setCancelled(true);
}
}
PreprocessableCommand.java 文件源码
项目:BukkitLib
阅读 18
收藏 0
点赞 0
评论 0
/**
* Checks for this command as the preprocessed command.
* @param event The command preprocessing event.
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event){
if(getExecutor() == null){
return;
}
String[] cmdAndArgs = event.getMessage().split(" ", 2);
cmdAndArgs[0] = cmdAndArgs[0].toLowerCase().trim();
for(String alias : _aliases){
if(alias.equals(cmdAndArgs[0])){
event.setCancelled(getExecutor().onCommand(event.getPlayer(), this, alias, cmdAndArgs.length == 1 ? new String[0] : cmdAndArgs[1].split(" ")));
break;
}
}
}
PlayerListener.java 文件源码
项目:UltimateSurvivalGames
阅读 29
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
Player p = event.getPlayer();
if(um.isPlaying(p.getName()) || um.isSpectator(p.getName())) {
String message = event.getMessage().toLowerCase();
for(String cmd : allowedCmds) {
if(message.startsWith(cmd))
return;
}
if(message.startsWith("/list")) {
UserState u = um.getUser(p.getName());
if(u == null)
u = um.getSpectator(p.getName());
Game g = u.getGame();
p.sendMessage(MessageHandler.getMessage("game-player-list").replace("%0%", Integer.valueOf(g.getPlayingUsers()).toString()).replace("%1%", g.getAlivePlayers()));
event.setCancelled(true);
} else if(message.startsWith("/vote")) {
p.chat("/sg " + message.replace("/", ""));
event.setCancelled(true);
} else {
event.setCancelled(true);
p.sendMessage(MessageHandler.getMessage("forbidden-command"));
}
}
}
PlayerEvents.java 文件源码
项目:askyblock
阅读 21
收藏 0
点赞 0
评论 0
/**
* Prevents teleporting when falling based on setting by stopping commands
*
* @param e
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerCommandPreprocessEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!IslandGuard.inWorld(e.getPlayer()) || Settings.allowTeleportWhenFalling || e.getPlayer().isOp()
|| !e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)
|| plugin.getPlayers().isInTeleport(e.getPlayer().getUniqueId())) {
return;
}
// Check commands
// plugin.getLogger().info("DEBUG: falling command: '" +
// e.getMessage().substring(1).toLowerCase() + "'");
if (isFalling(e.getPlayer().getUniqueId()) && (Settings.fallingCommandBlockList.contains("*") || Settings.fallingCommandBlockList.contains(e.getMessage().substring(1).toLowerCase()))) {
// Sorry you are going to die
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).errorNoPermission);
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).islandcannotTeleport);
e.setCancelled(true);
}
}