fix commands requiring trust
This commit is contained in:
parent
7f4fa390f2
commit
6d14031a02
|
|
@ -64,6 +64,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
|
|
@ -131,6 +132,44 @@ class PlayerEventHandler implements Listener
|
|||
bannedWordFinder = new WordFinder(instance.dataStore.loadBannedWords());
|
||||
}
|
||||
|
||||
//when a player uses a slash command...
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
synchronized void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
String message = event.getMessage();
|
||||
String[] args = message.split(" ");
|
||||
String command = args[0];
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerData playerData = this.dataStore.getPlayerData(event.getPlayer().getUniqueId());
|
||||
|
||||
//if the slash command used is in the list of monitored commands, treat it like a chat message (see above)
|
||||
boolean isMonitoredCommand = false;
|
||||
for (String monitoredCommand : instance.config_claims_commandsRequiringAccessTrust)
|
||||
{
|
||||
if (command.equalsIgnoreCase(monitoredCommand))
|
||||
{
|
||||
isMonitoredCommand = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isMonitoredCommand)
|
||||
{
|
||||
Claim claim = this.dataStore.getClaimAt(player.getLocation(), false, playerData.lastClaim);
|
||||
if (claim != null)
|
||||
{
|
||||
playerData.lastClaim = claim;
|
||||
Supplier<String> reason = claim.checkPermission(player, ClaimPermission.Access, event);
|
||||
if (reason != null)
|
||||
{
|
||||
GriefPrevention.sendMessage(player, TextMode.Err, reason.get());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int longestNameLength = 10;
|
||||
|
||||
static void makeSocialLogEntry(String name, String message)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user