use of net.sacredlabyrinth.phaed.simpleclans.ClanPlayer in project MyPet by xXKeyleXx.
the class SimpleClansHook method canHurt.
@Override
public boolean canHurt(Player attacker, Player defender) {
try {
if (simpleClans.getSettingsManager().isBlacklistedWorld(defender.getLocation().getWorld().getName())) {
return true;
}
ClanPlayer acp = simpleClans.getClanManager().getClanPlayer(attacker);
ClanPlayer vcp = simpleClans.getClanManager().getClanPlayer(defender);
Clan vclan = vcp == null ? null : vcp.getClan();
Clan aclan = acp == null ? null : acp.getClan();
if (simpleClans.getSettingsManager().isPvpOnlywhileInWar()) {
if ((aclan == null) || (vclan == null)) {
return false;
}
if (simpleClans.getPermissionsManager().has(defender, "simpleclans.mod.nopvpinwar")) {
return false;
}
if (!aclan.isWarring(vclan)) {
return false;
}
}
if (vclan != null) {
if (aclan != null) {
if (vcp.isFriendlyFire()) {
return true;
}
if (vclan.isFriendlyFire()) {
return true;
}
if (simpleClans.getSettingsManager().isGlobalff()) {
return true;
}
if (vclan.equals(aclan)) {
return false;
}
if (vclan.isAlly(aclan.getTag())) {
return false;
}
} else if (simpleClans.getSettingsManager().getSafeCivilians()) {
return false;
}
} else if (simpleClans.getSettingsManager().getSafeCivilians()) {
return false;
}
} catch (Throwable ignored) {
}
return true;
}
use of net.sacredlabyrinth.phaed.simpleclans.ClanPlayer in project RedProtect by FabioZumbi12.
the class RPGui method applyFlag.
private void applyFlag(String flag, ItemMeta itemMeta, InventoryClickEvent event) {
boolean flagv = false;
if (flag.equalsIgnoreCase("clan")) {
Player p = (Player) event.getInventory().getHolder();
ClanPlayer cp = RedProtect.get().clanManager.getClanPlayer(p);
if (this.region.getFlagString(flag).equals("")) {
this.region.setFlag(flag, cp.getTag());
flagv = true;
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.setclan").replace("{clan}", "'" + cp.getClan().getColorTag() + "'"));
} else {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.denyclan").replace("{clan}", "'" + this.region.getFlagString(flag) + "'"));
this.region.setFlag(flag, "");
flagv = false;
}
} else {
flagv = !this.region.getFlagBool(flag);
this.region.setFlag(flag, flagv);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + flagv);
}
if (allowEnchant) {
if (flagv) {
itemMeta.addEnchant(Enchantment.DURABILITY, 0, true);
} else {
itemMeta.removeEnchant(Enchantment.DURABILITY);
}
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.setLore(Arrays.asList(RPConfig.getGuiString("value") + RPConfig.getGuiString(String.valueOf(flagv)), "§0" + flag, RPConfig.getGuiFlagString(flag, "description"), RPConfig.getGuiFlagString(flag, "description1"), RPConfig.getGuiFlagString(flag, "description2")));
event.getCurrentItem().setItemMeta(itemMeta);
RedProtect.get().logger.addLog("(World " + this.region.getWorld() + ") Player " + player.getName() + " CHANGED flag " + flag + " of region " + this.region.getName() + " to " + String.valueOf(flagv));
}
use of net.sacredlabyrinth.phaed.simpleclans.ClanPlayer in project RedProtect by FabioZumbi12.
the class SCHook method inWar.
@SuppressWarnings("deprecation")
public static boolean inWar(Region r, Player attack, Player defend) {
if (!RPConfig.getBool("hooks.simpleclans.use-war")) {
return false;
}
if (!RPConfig.getBool("hooks.simpleclans.war-on-server-regions") && r.getLeaders().contains(RPConfig.getString("region-settings.default-leader"))) {
return false;
}
ClanPlayer atClan = RedProtect.get().clanManager.getClanPlayer(attack);
if (atClan == null) {
return false;
}
ClanPlayer defCclan = RedProtect.get().clanManager.getClanPlayer(defend);
return defCclan != null && atClan.getClan().isWarring(defCclan.getClan());
}
use of net.sacredlabyrinth.phaed.simpleclans.ClanPlayer in project UltimateChat by FabioZumbi12.
the class UCMessages method formatTags.
@SuppressWarnings("deprecation")
public static String formatTags(String tag, String text, Object cmdSender, Object receiver, String msg, UCChannel ch) {
if (receiver instanceof CommandSender && tag.equals("message")) {
text = text.replace("{message}", mention(cmdSender, (CommandSender) receiver, msg));
if (UChat.get().getUCConfig().getBoolean("general.item-hand.enable")) {
text = text.replace(UChat.get().getUCConfig().getString("general.item-hand.placeholder"), formatTags("", ChatColor.translateAlternateColorCodes('&', UChat.get().getUCConfig().getString("general.item-hand.format")), cmdSender, receiver, msg, ch));
}
} else {
text = text.replace("{message}", msg);
}
if (tag.equals("message") && !UChat.get().getUCConfig().getBoolean("general.enable-tags-on-messages")) {
return text;
}
text = text.replace("{ch-color}", ch.getColor()).replace("{ch-name}", ch.getName()).replace("{ch-alias}", ch.getAlias());
if (UChat.get().getUCConfig().getBoolean("jedis.enable") && ch.useJedis()) {
text = text.replace("{jedis-id}", UChat.get().getUCConfig().getString("jedis.server-id"));
}
if (ch.isBungee()) {
text = text.replace("{bungee-id}", UChat.get().getUCConfig().getString("bungee.server-id"));
}
if (cmdSender instanceof CommandSender) {
text = text.replace("{playername}", ((CommandSender) cmdSender).getName());
if (receiver instanceof CommandSender)
text = text.replace("{receivername}", ((CommandSender) receiver).getName());
if (receiver instanceof String)
text = text.replace("{receivername}", (String) receiver);
} else {
text = text.replace("{playername}", (String) cmdSender).replace("{receivername}", (String) receiver);
}
for (String repl : registeredReplacers.keySet()) {
if (registeredReplacers.get(repl).equals(repl)) {
text = text.replace(repl, "");
continue;
}
text = text.replace(repl, registeredReplacers.get(repl));
}
StringBuilder def = new StringBuilder();
for (int i = 0; i < defFormat.length; i++) {
text = text.replace("{default-format-" + i + "}", defFormat[i]);
def.append(" ").append(defFormat[i]);
}
if (def.length() > 0) {
text = text.replace("{default-format-full}", def.substring(1));
}
if (text.contains("{time-now}")) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
text = text.replace("{time-now}", sdf.format(cal.getTime()));
}
if (cmdSender instanceof Player) {
Player sender = (Player) cmdSender;
if (text.contains("{world}")) {
String world = UChat.get().getUCConfig().getString("general.world-names." + sender.getWorld().getName());
text = text.replace("{world}", world != null ? world : sender.getWorld().getName());
}
text = text.replace("{nickname}", sender.getDisplayName());
// replace item hand
text = text.replace(UChat.get().getUCConfig().getString("general.item-hand.placeholder"), ChatColor.translateAlternateColorCodes('&', UChat.get().getUCConfig().getString("general.item-hand.format")));
if (text.contains("{hand-") && !sender.getItemInHand().getType().equals(Material.AIR)) {
ItemStack item = sender.getItemInHand();
text = text.replace("{hand-durability}", String.valueOf(item.getDurability()));
if (item.hasItemMeta()) {
ItemMeta meta = item.getItemMeta();
if (UCUtil.getBukkitVersion() >= 1112 && meta.hasLocalizedName()) {
text = text.replace("{hand-name}", item.getItemMeta().getLocalizedName());
} else if (meta.hasDisplayName()) {
text = text.replace("{hand-name}", item.getItemMeta().getDisplayName());
} else {
text = text.replace("{hand-name}", UCUtil.capitalize(item.getType().toString()));
}
if (meta.hasLore()) {
StringBuilder lorestr = new StringBuilder();
for (String lore : meta.getLore()) {
lorestr.append("\n ").append(lore);
}
if (lorestr.length() >= 2) {
text = text.replace("{hand-lore}", lorestr.toString().substring(0, lorestr.length() - 1));
}
}
if (meta.hasEnchants()) {
StringBuilder str = new StringBuilder();
for (Entry<Enchantment, Integer> enchant : meta.getEnchants().entrySet()) {
str.append("\n ").append(enchant.getKey().getName()).append(": ").append(enchant.getValue());
}
if (str.length() >= 2) {
text = text.replace("{hand-enchants}", str.toString().substring(0, str.length() - 1));
}
}
}
text = text.replace("{hand-amount}", String.valueOf(item.getAmount()));
text = text.replace("{hand-name}", UCUtil.capitalize(item.getType().toString()));
text = text.replace("{hand-type}", UCUtil.capitalize(item.getType().toString()));
} else {
text = text.replace("{hand-name}", UChat.get().getLang().get("chat.emptyslot"));
text = text.replace("{hand-type}", "Air");
}
if (UChat.get().getVaultChat() != null && (text.contains("-prefix") || text.contains("-suffix"))) {
text = text.replace("{group-suffix}", UCVaultCache.getVaultChat(sender).getPlayerSuffix()).replace("{group-prefix}", UCVaultCache.getVaultChat(sender).getPlayerPrefix());
String[] pgs = UCVaultCache.getVaultPerms(sender).getPlayerGroups();
if (pgs.length > 0) {
text = text.replace("{player-groups-prefixes}", UCVaultCache.getVaultChat(sender).getGroupPrefixes()).replace("{player-groups-suffixes}", UCVaultCache.getVaultChat(sender).getGroupSuffixes());
}
}
if (UChat.get().getVaultEco() != null && text.contains("{balance}")) {
text = text.replace("{balance}", "" + UChat.get().getVaultEco().getBalance(sender, sender.getWorld().getName()));
}
if (UChat.get().getVaultPerms() != null && (text.contains("-group}") || text.contains("-groups}"))) {
String[] pgs = UCVaultCache.getVaultPerms(sender).getPlayerGroups();
if (pgs.length > 0) {
StringBuilder groups = new StringBuilder();
for (String g : pgs) {
groups.append(g).append(",");
}
text = text.replace("{player-groups}", groups.toString().substring(0, groups.length() - 1));
}
String primGroup = UCVaultCache.getVaultPerms(sender).getPrimaryGroup();
String group = UChat.get().getUCConfig().getString("general.group-names." + primGroup);
text = text.replace("{prim-group}", group == null ? primGroup : group);
}
if (text.contains("{clan-") && UChat.SClans) {
ClanPlayer cp = UChat.sc.getClanManager().getClanPlayer(sender.getUniqueId());
SettingsManager scm = UChat.sc.getSettingsManager();
if (cp != null) {
String fulltag = scm.getTagBracketColor() + scm.getTagBracketLeft() + scm.getTagDefaultColor() + cp.getClan().getColorTag() + scm.getTagBracketColor() + scm.getTagBracketRight() + scm.getTagSeparatorColor() + scm.getTagSeparator();
text = text.replace("{clan-tag}", cp.getTag()).replace("{clan-fulltag}", fulltag).replace("{clan-name}", checkEmpty(cp.getClan().getName())).replace("{clan-kdr}", "" + cp.getKDR()).replace("{clan-rank}", checkEmpty(cp.getRank())).replace("{clan-totalkdr}", "" + cp.getClan().getTotalKDR()).replace("{clan-deaths}", "" + cp.getDeaths()).replace("{clan-isleader}", "" + cp.isLeader()).replace("{clan-totalkdr}", "" + cp.getClan().getTotalKDR()).replace("{clan-ctag}", cp.getClan().getColorTag());
}
}
if (UChat.Factions) {
text = UCFactionsHook.formatFac(text, sender, receiver);
}
if (text.contains("{marry-")) {
if (UChat.MarryReloded && sender.hasMetadata("marriedTo")) {
String partner = sender.getMetadata("marriedTo").get(0).asString();
String prefix = UChat.mapi.getBukkitConfig("config.yml").getString("chat.status-format");
UChat.mapi.getMPlayer(sender.getUniqueId()).getGender().getChatPrefix();
prefix = prefix.replace("{icon:male}", "♂").replace("{icon:female}", "♀").replace("{icon:genderless}", "⚤").replace("{icon:heart}", "❤");
String gender = UChat.mapi.getMPlayer(sender.getUniqueId()).getGender().getChatPrefix();
gender = gender.replace("{icon:male}", "♂").replace("{icon:female}", "♀").replace("{icon:genderless}", "⚤").replace("{icon:heart}", "❤");
text = text.replace("{marry-partner}", partner).replace("{marry-prefix}", prefix).replace("{marry-suffix}", gender);
}
if (UChat.MarryMaster) {
if (UChat.mm.HasPartner(sender)) {
text = text.replace("{marry-partner}", UChat.mm.DB.GetPartner(sender)).replace("{marry-prefix}", UChat.mm.config.GetPrefix().replace("<heart>", ChatColor.RED + "❤" + ChatColor.WHITE)).replace("{marry-suffix}", UChat.mm.config.GetSuffix().replace("<heart>", ChatColor.RED + "❤" + ChatColor.WHITE));
}
}
}
if (UChat.PlaceHolderAPI) {
if (receiver instanceof Player && UChat.get().isRelation()) {
while (text.contains("%rel_")) {
text = PlaceholderAPI.setRelationalPlaceholders(sender, (Player) receiver, text);
}
}
text = PlaceholderAPI.setPlaceholders(sender, text);
if (tag.equals("message")) {
text = composeColor(sender, text);
}
}
}
if (cmdSender instanceof CommandSender) {
text = text.replace("{nickname}", UChat.get().getUCConfig().getString("general.console-tag").replace("{console}", ((CommandSender) cmdSender).getName()));
} else {
text = text.replace("{nickname}", UChat.get().getUCConfig().getString("general.console-tag").replace("{console}", (String) cmdSender));
}
// colorize tags (not message)
if (!tag.equals("message")) {
text = ChatColor.translateAlternateColorCodes('&', text);
}
// remove blank items
text = text.replaceAll("\\{.*\\}", "");
// remove remain PlaceholderAPI
if (UChat.get().getUCConfig().getBoolean("general.remove-unnused-placeholderapi")) {
text = text.replaceAll("\\%.*\\%", "");
}
if (!tag.equals("message")) {
for (String rpl : UChat.get().getUCConfig().getStringList("general.remove-from-chat")) {
text = text.replace(ChatColor.translateAlternateColorCodes('&', rpl), "");
}
}
if (text.equals(" ") || text.equals(" ")) {
text = "";
}
return text;
}
use of net.sacredlabyrinth.phaed.simpleclans.ClanPlayer in project RedProtect by FabioZumbi12.
the class RPCommands method handleFlag.
// TODO Flag Handler
private static void handleFlag(Player p, String flag, String value, Region r) {
if (flag.equalsIgnoreCase("?")) {
sendFlagHelp(p);
return;
}
if (r == null) {
sendNotInRegionMessage(p);
return;
}
Object objflag = RPUtil.parseObject(value);
if (RedProtect.get().ph.hasPerm(p, "redprotect.flag." + flag) || flag.equalsIgnoreCase("info")) {
if (r.isAdmin(p) || r.isLeader(p) || RedProtect.get().ph.hasRegionPermAdmin(p, "redprotect.admin.flag." + flag, r)) {
if (flag.equalsIgnoreCase("info") || flag.equalsIgnoreCase("i")) {
p.sendMessage(RPLang.get("general.color") + "------------[" + RPLang.get("cmdmanager.region.flag.values") + "]------------");
p.sendMessage(r.getFlagInfo());
p.sendMessage(RPLang.get("general.color") + "------------------------------------");
return;
}
if (value.equalsIgnoreCase("remove")) {
if (RPConfig.AdminFlags.contains(flag) && r.flags.containsKey(flag)) {
r.removeFlag(flag);
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.removed").replace("{flag}", flag).replace("{region}", r.getName()));
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " REMOVED FLAG " + flag + " of region " + r.getName());
return;
} else {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.notset").replace("{flag}", flag));
return;
}
}
if (r.flagExists("for-sale") && flag.equalsIgnoreCase("for-sale")) {
RPLang.sendMessage(p, "cmdmanager.eco.changeflag");
return;
}
/*
if (RPConfig.getDefFlagsValues().containsKey("clan") && !RedProtect.get().ph.hasPerm(p, "RedProtect.get().admin.flag.clan")){
RPLang.sendMessage(p,"cmdmanager.region.flag.clancommand");
return;
}
*/
if (!value.equals("")) {
if (RPConfig.getDefFlagsValues().containsKey(flag)) {
// flag clan
if (flag.equalsIgnoreCase("clan")) {
if (!RedProtect.get().SC || !RedProtect.get().ph.hasGenPerm(p, "redprotect.admin.flag.clan")) {
sendFlagHelp(p);
return;
}
if (!RedProtect.get().clanManager.isClan(value)) {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.invalidclan").replace("{tag}", value));
return;
}
Clan clan = RedProtect.get().clanManager.getClan(value);
if (!clan.isLeader(p)) {
RPLang.sendMessage(p, "cmdmanager.region.flag.clancommand");
return;
}
r.setFlag(flag, value);
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagString(flag));
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
return;
}
if (objflag instanceof Boolean) {
r.setFlag(flag, objflag);
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagBool(flag));
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
return;
} else {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.usage") + " <true/false>");
return;
}
}
if (RPConfig.AdminFlags.contains(flag)) {
if (!validate(flag, objflag)) {
SendFlagUsageMessage(p, flag);
return;
}
r.setFlag(flag, objflag);
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagString(flag));
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
return;
}
if (RPConfig.AdminFlags.contains(flag)) {
SendFlagUsageMessage(p, flag);
} else {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.usage") + " <true/false>");
}
sendFlagHelp(p);
} else {
// flag clan
if (flag.equalsIgnoreCase("clan")) {
if (RedProtect.get().SC) {
ClanPlayer clan = RedProtect.get().clanManager.getClanPlayer(p);
if (clan == null) {
RPLang.sendMessage(p, "cmdmanager.region.flag.haveclan");
return;
}
if (!clan.isLeader()) {
RPLang.sendMessage(p, "cmdmanager.region.flag.clancommand");
return;
}
if (r.getFlagString(flag).equalsIgnoreCase("")) {
r.setFlag(flag, clan.getTag());
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.setclan").replace("{clan}", "'" + clan.getClan().getColorTag() + "'"));
} else {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.denyclan").replace("{clan}", "'" + r.getFlagString(flag) + "'"));
r.setFlag(flag, "");
}
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
return;
} else {
sendFlagHelp(p);
return;
}
}
if (RPConfig.getDefFlagsValues().containsKey(flag)) {
r.setFlag(flag, !r.getFlagBool(flag));
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagBool(flag));
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + r.getFlagString(flag));
} else {
if (RPConfig.AdminFlags.contains(flag)) {
SendFlagUsageMessage(p, flag);
} else {
RPLang.sendMessage(p, RPLang.get("cmdmanager.region.flag.usage") + " <true/false>");
}
sendFlagHelp(p);
}
}
} else {
RPLang.sendMessage(p, "cmdmanager.region.flag.nopermregion");
}
} else {
RPLang.sendMessage(p, "cmdmanager.region.flag.noperm");
}
}
Aggregations