mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 13:26:56 +00:00
Compare commits
15 Commits
v1.9.0-pre1
..
1.x
| Author | SHA1 | Date | |
|---|---|---|---|
| eb657798e4 | |||
| d15ccbef20 | |||
| 8ae6e9212c | |||
| fec1dd2ab6 | |||
| fba2f03aab | |||
| e30437694c | |||
| 8fcf34e310 | |||
| aac1f99374 | |||
| 7f1da79444 | |||
| 244ceb4dcc | |||
| ac1cafe0d9 | |||
| b3ce1913fd | |||
| 9a707b34a3 | |||
| d52648b4ff | |||
| 7d2c41646e |
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.youhavetrouble</groupId>
|
||||
<artifactId>PreventStabby</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<version>1.11.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>PreventStabby</name>
|
||||
@@ -100,7 +100,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
<version>1.18.26</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -76,18 +76,23 @@ public final class PreventStabby extends JavaPlugin {
|
||||
pvpCommand.setExecutor(mainCommand);
|
||||
pvpCommand.setTabCompleter(mainCommand);
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new PlacoholderApiHook(this).register();
|
||||
}
|
||||
|
||||
Metrics metrics = new Metrics(this, 14074);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
try {
|
||||
WorldGuardHook.init();
|
||||
worldGuardHook = true;
|
||||
} catch (NoClassDefFoundError e) {
|
||||
worldGuardHook = false;
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new PlacoholderApiHook(this).register();
|
||||
}
|
||||
|
||||
Metrics metrics = new Metrics(this, 14074);
|
||||
}
|
||||
|
||||
public static boolean worldGuardHookEnabled() {
|
||||
|
||||
@@ -45,4 +45,9 @@ public class PlayerEnterCombatEvent extends Event implements Cancellable {
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,9 @@ public class PlayerLeaveCombatEvent extends Event implements Cancellable {
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,9 @@ public class PlayerTogglePvpEvent extends Event {
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ public class ConfigCache {
|
||||
cannot_attack_pets_victim, cannot_attack_pets_attacker, no_permission, no_such_command, pvp_enabled_other,
|
||||
pvp_disabled_other, punish_for_combat_logout_message, entering_combat, leaving_combat,
|
||||
cant_do_that_during_combat, cannot_attack_mounts_attacker, cannot_attack_mounts_victim, force_pvp_on,
|
||||
force_pvp_off, force_pvp_none, placeholder_combat_time, placeholder_not_in_combat, cannot_attack_pvp_force_off;
|
||||
force_pvp_off, force_pvp_none, placeholder_combat_time, placeholder_not_in_combat, cannot_attack_pvp_force_off,
|
||||
placeholder_pvp_forced_true, placeholder_pvp_forced_false, placeholder_pvp_forced_none;
|
||||
@Getter private final double lava_and_fire_stopper_radius;
|
||||
@Getter private final long cache_time, combat_time, login_protection_time, teleport_protection_time;
|
||||
@Getter private final Set<String> combatBlockedCommands = new HashSet<>();
|
||||
@@ -91,6 +92,9 @@ public class ConfigCache {
|
||||
addDefault("messages.force_pvp_none", "PvP state is not forced now");
|
||||
addDefault("placeholder.placeholder_combat_time", "Combat time: %time%");
|
||||
addDefault("placeholder.not_in_combat", "Not in combat");
|
||||
addDefault("placeholder.pvp_forced_true", "PvP is forced on");
|
||||
addDefault("placeholder.pvp_forced_false", "PvP is forced off");
|
||||
addDefault("placeholder.pvp_forced_none", "PvP is not forced");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -152,6 +156,10 @@ public class ConfigCache {
|
||||
|
||||
this.placeholder_combat_time = config.getString("placeholder.placeholder_combat_time", "Combat time: %time%");
|
||||
this.placeholder_not_in_combat = config.getString("placeholder.not_in_combat", "Not in combat");
|
||||
|
||||
this.placeholder_pvp_forced_true = config.getString("placeholder.pvp_forced_true", "PvP is forced on");
|
||||
this.placeholder_pvp_forced_false = config.getString("placeholder.pvp_forced_false", "PvP is forced off");
|
||||
this.placeholder_pvp_forced_none = config.getString("placeholder.pvp_forced_none", "PvP is not forced");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.youhavetrouble.preventstabby.hooks;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import me.youhavetrouble.preventstabby.util.PluginMessages;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -46,6 +47,15 @@ public class PlacoholderApiHook extends PlaceholderExpansion {
|
||||
case "in_combat":
|
||||
if (!player.isOnline()) return String.valueOf(false);
|
||||
return String.valueOf(plugin.getPlayerManager().getPlayer(player.getUniqueId()).isInCombat());
|
||||
case "pvp_forced":
|
||||
switch (PreventStabby.getPlugin().getPlayerManager().getForcedPvpState()) {
|
||||
case NONE:
|
||||
return legacyComponentSerializer.serialize(PluginMessages.parseMessage(plugin.getConfigCache().getPlaceholder_pvp_forced_none()));
|
||||
case ENABLED:
|
||||
return legacyComponentSerializer.serialize(PluginMessages.parseMessage(plugin.getConfigCache().getPlaceholder_pvp_forced_true()));
|
||||
case DISABLED:
|
||||
return legacyComponentSerializer.serialize(PluginMessages.parseMessage(plugin.getConfigCache().getPlaceholder_pvp_forced_false()));
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,8 @@ import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class WorldGuardHook {
|
||||
|
||||
@@ -22,19 +21,18 @@ public class WorldGuardHook {
|
||||
public static StateFlag FORCE_PVP_FLAG;
|
||||
|
||||
public static void init() {
|
||||
PreventStabby plugin = PreventStabby.getPlugin();
|
||||
try {
|
||||
Class.forName("com.sk89q.worldguard.protection.flags.registry.FlagRegistry");
|
||||
WorldGuardPlugin worldGuardPlugin = WorldGuardPlugin.inst();
|
||||
if (WorldGuard.getInstance() == null || worldGuardPlugin == null) return;
|
||||
plugin.getLogger().info("Hooking into WorldGuard");
|
||||
Bukkit.getLogger().info("[PreventStabby] Hooking into WorldGuard");
|
||||
flagRegistry = WorldGuard.getInstance().getFlagRegistry();
|
||||
createForcePvpFlag(plugin);
|
||||
createForcePvpFlag();
|
||||
} catch (NoClassDefFoundError | ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void createForcePvpFlag(Plugin plugin) {
|
||||
private static void createForcePvpFlag() {
|
||||
if (flagRegistry == null) return;
|
||||
String flagName = "preventstabby-force-pvp";
|
||||
try {
|
||||
@@ -46,7 +44,7 @@ public class WorldGuardHook {
|
||||
if (existing instanceof StateFlag) {
|
||||
FORCE_PVP_FLAG = (StateFlag) existing;
|
||||
} else {
|
||||
plugin.getLogger().severe("There is a conflict between flag names!");
|
||||
Bukkit.getLogger().severe("[PreventStabby] There is a conflict between flag names!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -3,6 +3,7 @@ package me.youhavetrouble.preventstabby.listeners.pets;
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import me.youhavetrouble.preventstabby.players.SmartCache;
|
||||
import me.youhavetrouble.preventstabby.util.PreventStabbyListener;
|
||||
import me.youhavetrouble.preventstabby.util.PvpState;
|
||||
import me.youhavetrouble.preventstabby.util.Util;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Tameable;
|
||||
@@ -14,8 +15,12 @@ import org.bukkit.event.Listener;
|
||||
@PreventStabbyListener
|
||||
public class PetTargettingMountListener implements Listener {
|
||||
|
||||
/**
|
||||
* TODO - this needs to pass canDamage() in the future, for now it just checks forced pvp state directly
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onWolfAttackMount(org.bukkit.event.entity.EntityDamageByEntityEvent event) {
|
||||
if (PreventStabby.getPlugin().getPlayerManager().getForcedPvpState() == PvpState.ENABLED) return;
|
||||
if (!(event.getDamager() instanceof Tameable) || event.getEntity().getPassengers().isEmpty()) return;
|
||||
Tameable damager = (Tameable) event.getDamager();
|
||||
Entity victim = event.getEntity();
|
||||
|
||||
+12
-12
@@ -1,7 +1,9 @@
|
||||
package me.youhavetrouble.preventstabby.listeners.pets;
|
||||
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import me.youhavetrouble.preventstabby.config.ConfigCache;
|
||||
import me.youhavetrouble.preventstabby.players.SmartCache;
|
||||
import me.youhavetrouble.preventstabby.util.CombatTimer;
|
||||
import me.youhavetrouble.preventstabby.util.PreventStabbyListener;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wolf;
|
||||
@@ -14,23 +16,21 @@ public class PetTargettingPetListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onWolfAttackWolf(org.bukkit.event.entity.EntityDamageByEntityEvent event) {
|
||||
if (event.getDamager() instanceof Tameable && event.getEntity() instanceof Tameable) {
|
||||
if (!(event.getDamager() instanceof Tameable) || !(event.getEntity() instanceof Tameable)) return;
|
||||
Tameable damager = (Tameable) event.getDamager();
|
||||
Tameable victim = (Tameable) event.getEntity();
|
||||
if (damager.getOwner() == null || victim.getOwner() == null) return;
|
||||
|
||||
SmartCache smartCache = PreventStabby.getPlugin().getSmartCache();
|
||||
boolean damagerPvpEnabled = smartCache.getPlayerData(damager.getOwner().getUniqueId()).isPvpEnabled();
|
||||
boolean victimPvpEnabled = smartCache.getPlayerData(victim.getOwner().getUniqueId()).isPvpEnabled();
|
||||
|
||||
if (!victimPvpEnabled || !damagerPvpEnabled) {
|
||||
if (damager instanceof Wolf) {
|
||||
Wolf wolf = (Wolf) damager;
|
||||
wolf.setAngry(false);
|
||||
}
|
||||
if (!PreventStabby.getPlugin().getPlayerManager()
|
||||
.canDamage(
|
||||
damager.getUniqueId(),
|
||||
victim.getUniqueId(),
|
||||
false,
|
||||
false
|
||||
))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-2
@@ -8,6 +8,7 @@ import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -17,7 +18,7 @@ public class PetTargettingPlayerListener implements Listener {
|
||||
* Stops pets with owners targetting players with pvp off
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPetTargetPlayer(org.bukkit.event.entity.EntityTargetEvent event) {
|
||||
public void onPetTargetPlayer(EntityTargetEvent event) {
|
||||
if (!(event.getEntity() instanceof Tameable)) return;
|
||||
Tameable entity = (Tameable) event.getEntity();
|
||||
if (!(entity.getOwner() instanceof Player)) return;
|
||||
@@ -26,8 +27,15 @@ public class PetTargettingPlayerListener implements Listener {
|
||||
UUID damager = entity.getOwner().getUniqueId();
|
||||
UUID victim = event.getTarget().getUniqueId();
|
||||
|
||||
if (PreventStabby.getPlugin().getPlayerManager().canDamage(damager, victim, true, false))
|
||||
boolean tempting = event.getReason().equals(EntityTargetEvent.TargetReason.TEMPT);
|
||||
|
||||
if (PreventStabby.getPlugin().getPlayerManager().canDamage(damager, victim, !tempting, false)) {
|
||||
if (tempting) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
CombatTimer.refreshPlayersCombatTime(damager, victim);
|
||||
}
|
||||
else
|
||||
event.setCancelled(true);
|
||||
|
||||
|
||||
+15
-17
@@ -2,15 +2,14 @@ package me.youhavetrouble.preventstabby.listeners.pets;
|
||||
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import me.youhavetrouble.preventstabby.config.ConfigCache;
|
||||
import me.youhavetrouble.preventstabby.players.SmartCache;
|
||||
import me.youhavetrouble.preventstabby.util.CombatTimer;
|
||||
import me.youhavetrouble.preventstabby.util.PluginMessages;
|
||||
import me.youhavetrouble.preventstabby.util.PreventStabbyListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -18,10 +17,10 @@ import java.util.UUID;
|
||||
public class PlayerAttackPetListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerAttackPet(org.bukkit.event.entity.EntityDamageByEntityEvent event) {
|
||||
public void onPlayerAttackPet(EntityDamageByEntityEvent event) {
|
||||
|
||||
if (!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Tameable)) return;
|
||||
|
||||
if (event.getDamager() instanceof Player && event.getEntity() instanceof Tameable) {
|
||||
SmartCache smartCache = PreventStabby.getPlugin().getSmartCache();
|
||||
Tameable tameable = (Tameable) event.getEntity();
|
||||
if (tameable.getOwner() == null) return;
|
||||
|
||||
@@ -31,19 +30,18 @@ public class PlayerAttackPetListener implements Listener {
|
||||
if (damager.equals(victim)) return;
|
||||
|
||||
ConfigCache config = PreventStabby.getPlugin().getConfigCache();
|
||||
boolean damagerPvpState = PreventStabby.getPlugin().getPlayerManager().getPlayerPvPState(damager);
|
||||
if (!damagerPvpState) {
|
||||
PluginMessages.sendActionBar(damager, config.getCannot_attack_pets_attacker());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!smartCache.getPlayerData(victim).isPvpEnabled()) {
|
||||
PluginMessages.sendActionBar(damager, config.getCannot_attack_pets_victim());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PreventStabby.getPlugin().getPlayerManager()
|
||||
.canDamage(
|
||||
damager,
|
||||
victim,
|
||||
config.getCannot_attack_pets_attacker(),
|
||||
config.getCannot_attack_pets_victim(),
|
||||
false
|
||||
))
|
||||
CombatTimer.refreshPlayersCombatTime(damager);
|
||||
else
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-13
@@ -23,7 +23,7 @@ public class PlayerHitPetWithProjectileListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerHitPetWithProjectile(org.bukkit.event.entity.EntityDamageByEntityEvent event) {
|
||||
if (event.getEntity() instanceof Tameable && event.getDamager() instanceof Projectile) {
|
||||
if (!(event.getEntity() instanceof Tameable) || !(event.getDamager() instanceof Projectile)) return;
|
||||
Projectile projectile = (Projectile) event.getDamager();
|
||||
if (!(projectile.getShooter() instanceof Player)) return;
|
||||
Tameable tameable = (Tameable) event.getEntity();
|
||||
@@ -35,20 +35,19 @@ public class PlayerHitPetWithProjectileListener implements Listener {
|
||||
if (damager.equals(victim)) return;
|
||||
|
||||
ConfigCache config = PreventStabby.getPlugin().getConfigCache();
|
||||
SmartCache smartCache = PreventStabby.getPlugin().getSmartCache();
|
||||
|
||||
if (!smartCache.getPlayerData(damager).isPvpEnabled()) {
|
||||
PluginMessages.sendActionBar(damager, config.getCannot_attack_pets_attacker());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!smartCache.getPlayerData(victim).isPvpEnabled()) {
|
||||
PluginMessages.sendActionBar(damager, config.getCannot_attack_pets_victim());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (PreventStabby.getPlugin().getPlayerManager()
|
||||
.canDamage(
|
||||
damager,
|
||||
victim,
|
||||
config.getCannot_attack_pets_attacker(),
|
||||
config.getCannot_attack_pets_victim(),
|
||||
false
|
||||
))
|
||||
CombatTimer.refreshPlayersCombatTime(damager);
|
||||
else
|
||||
event.setCancelled(true);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -142,6 +143,22 @@ public class PlayerManager {
|
||||
* @return Whenever attacker can harm the victim.
|
||||
*/
|
||||
public boolean canDamage(UUID attacker, UUID victim, boolean sendDenyMessage, boolean checkVictimSpawnProtection) {
|
||||
ConfigCache config = PreventStabby.getPlugin().getConfigCache();
|
||||
String attackerMessage = sendDenyMessage ? config.getCannot_attack_attacker() : null;
|
||||
String victimMessage = sendDenyMessage ? config.getCannot_attack_victim() : null;
|
||||
return canDamage(attacker, victim, attackerMessage, victimMessage, checkVictimSpawnProtection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if attacker can harm the victim.
|
||||
* @param attacker Atacker's UUID.
|
||||
* @param victim Victim's UUID.
|
||||
* @param attackerDenyMessage Message that action was denied to the attacker.
|
||||
* @param victimDenyMessage Message that action was denied to the victim.
|
||||
* @param checkVictimSpawnProtection Should teleport and spawn protections be taken into account?
|
||||
* @return Whenever attacker can harm the victim.
|
||||
*/
|
||||
public boolean canDamage(UUID attacker, UUID victim, @Nullable String attackerDenyMessage, @Nullable String victimDenyMessage, boolean checkVictimSpawnProtection) {
|
||||
|
||||
if (hasLoginProtection(attacker) || hasTeleportProtection(attacker)) return false;
|
||||
if (checkVictimSpawnProtection && hasLoginProtection(victim)) return false;
|
||||
@@ -165,9 +182,8 @@ public class PlayerManager {
|
||||
if (PreventStabby.worldGuardHookEnabled() && attackerPlayer != null && WorldGuardHook.isPlayerForcedToPvp(attackerPlayer))
|
||||
return true;
|
||||
|
||||
if (sendDenyMessage) {
|
||||
ConfigCache config = PreventStabby.getPlugin().getConfigCache();
|
||||
PluginMessages.sendActionBar(attacker, config.getCannot_attack_attacker());
|
||||
if (attackerDenyMessage != null) {
|
||||
PluginMessages.sendActionBar(attacker, attackerDenyMessage);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -176,7 +192,7 @@ public class PlayerManager {
|
||||
if (PreventStabby.worldGuardHookEnabled() && victimPlayer != null && WorldGuardHook.isPlayerForcedToPvp(victimPlayer))
|
||||
return true;
|
||||
|
||||
if (sendDenyMessage) {
|
||||
if (victimDenyMessage != null) {
|
||||
ConfigCache config = PreventStabby.getPlugin().getConfigCache();
|
||||
PluginMessages.sendActionBar(attacker, config.getCannot_attack_victim());
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ public class PluginMessages {
|
||||
}
|
||||
|
||||
public static Component parseMessage(CommandSender sender,String message) {
|
||||
|
||||
if (sender instanceof Player && isPlaceholderApiEnabled()) {
|
||||
Player player = (Player) sender;
|
||||
message = PlaceholderAPI.setPlaceholders(player, message);
|
||||
@@ -37,15 +36,18 @@ public class PluginMessages {
|
||||
}
|
||||
|
||||
public static void sendMessage(CommandSender sender, String message) {
|
||||
if ("".equals(message)) return;
|
||||
audiences.sender(sender).sendMessage(parseMessage(sender, message));
|
||||
}
|
||||
|
||||
public static void sendActionBar(Player player, String message) {
|
||||
if ("".equals(message)) return;
|
||||
Component parsedMessage = parseMessage(player, message);
|
||||
audiences.player(player).sendActionBar(parsedMessage);
|
||||
}
|
||||
|
||||
public static void sendActionBar(UUID uuid, String message) {
|
||||
if ("".equals(message)) return;
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null) return;
|
||||
sendActionBar(player, message);
|
||||
@@ -57,6 +59,7 @@ public class PluginMessages {
|
||||
}
|
||||
|
||||
public static void broadcastMessage(Player player, String message) {
|
||||
if ("".equals(message)) return;
|
||||
message = parsePlayerName(player, message);
|
||||
if (PreventStabby.getPlugin().getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
message = PlaceholderAPI.setPlaceholders(player, message);
|
||||
@@ -65,6 +68,7 @@ public class PluginMessages {
|
||||
}
|
||||
|
||||
public static void broadcastMessage(String message) {
|
||||
if ("".equals(message)) return;
|
||||
audiences.all().sendMessage(parseMessage(message));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user