Added alot

This commit is contained in:
Driftay 2019-05-14 22:07:59 -04:00
parent a25ba5e71c
commit 26a9e4eba8
12 changed files with 735 additions and 474 deletions

View File

@ -81,6 +81,7 @@ public class Conf {
public static String truceChatFormat = ChatColor.DARK_PURPLE + "%s:" + ChatColor.WHITE + " %s";
public static String modChatFormat = ChatColor.RED + "%s:" + ChatColor.WHITE + " %s";
public static int stealthFlyCheckRadius = 32;
public static boolean gracePeriod = false;
public static boolean noEnderpearlsInFly = false;
public static boolean broadcastDescriptionChanges = false;
public static boolean broadcastTagChanges = false;

View File

@ -73,6 +73,10 @@ public interface Faction extends EconomyParticipator {
void ban(FPlayer target, FPlayer banner);
int getStrikes();
void setStrikes(int strikes);
void unban(FPlayer player);
boolean isBanned(FPlayer player);

View File

@ -0,0 +1,83 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdSetStrikes extends FCommand {
public CmdSetStrikes() {
super();
this.aliases.add("setstrikes");
this.aliases.add("setstrike");
this.requiredArgs.add("set,give,remove");
this.requiredArgs.add("faction");
this.requiredArgs.add("# of strikes");
this.requiredArgs.add("reason");
this.errorOnToManyArgs = false;
//this.optionalArgs
this.permission = Permission.SETSTRIKES.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
Faction faction = Factions.getInstance().getByTag(args.get(1));
boolean success = false;
if (faction == null) {
fme.msg(TL.COMMAND_SETSTRIKES_FAILURE.toString().replace("{faction}", args.get(1)));
}
if (args.get(0).equalsIgnoreCase("set")) {
faction.setStrikes(argAsInt(2));
success = true;
} else if (args.get(0).equalsIgnoreCase("give")) {
faction.setStrikes(faction.getStrikes() + argAsInt(2));
success = true;
} else if (args.get(0).equalsIgnoreCase("take")) {
faction.setStrikes(faction.getStrikes() - argAsInt(2));
success = true;
}
if (success) {
for (FPlayer fPlayer : FPlayers.getInstance().getOnlinePlayers()) {
fPlayer.msg(TL.COMMAND_SETSTRIKES_BROADCAST.toString()
.replace("{faction}", faction.getTag())
.replace("{reason}", getReason()));
}
fme.msg(TL.COMMAND_SETSTRIKES_SUCCESS.toString()
.replace("{faction}", faction.getTag())
.replace("{strikes}", faction.getStrikes() + ""));
}
}
private String getReason() {
String reason = "";
for (int i = 3; i < args.size(); i++) {
reason += args.get(i) + " ";
}
return reason;
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_SETSTRIKES_DESCRIPTION;
}
}

View File

@ -25,6 +25,7 @@ public class CmdShow extends FCommand {
defaults.add("<a>Description: <i>{description}");
defaults.add("<a>Joining: <i>{joining} {peaceful}");
defaults.add("<a>Land / Power / Maxpower: <i> {chunks} / {power} / {maxPower}");
defaults.add("<a>Faction Strikes: {strikes}");
defaults.add("<a>Founded: <i>{create-date}");
defaults.add("<a>This faction is permanent, remaining even with no members.");
defaults.add("<a>Land value: <i>{land-value} {land-refund}");

View File

@ -0,0 +1,52 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.zcore.util.TL;
public class CmdStrike extends FCommand {
public CmdStrike() {
super();
this.aliases.add("strike");
this.aliases.add("strikes");
this.optionalArgs.put("faction", "tag");
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
if (args.size() == 0) {
if (myFaction.isWilderness()) {
fme.msg(TL.COMMAND_STRIKE_NEEDFACTION);
return;
}
fme.msg(TL.COMMAND_STRIKE_MESSAGE.toString().replace("{faction}", fme.getFaction().getTag()).replace("{strikes}", fme.getFaction().getStrikes() + ""));
return;
}
Faction faction = Factions.getInstance().getByTag(args.get(0));
if (faction != null) {
fme.msg(TL.COMMAND_STRIKE_MESSAGE.toString().replace("{faction}", faction.getTag()).replace("{strikes}", faction.getStrikes() + ""));
} else {
fme.msg(TL.COMMAND_STRIKE_NOTFOUND.toString().replace("{faction}", args.get(0)));
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_STUCK_DESCRIPTION;
}
}

View File

@ -23,6 +23,7 @@ public class FCmdRoot extends FCommand {
public CmdDescription cmdDescription = new CmdDescription();
public CmdDisband cmdDisband = new CmdDisband();
public CmdFocus cmdFocus = new CmdFocus();
public CmdGrace cmdGrace = new CmdGrace();
public CmdHelp cmdHelp = new CmdHelp();
public CmdHome cmdHome = new CmdHome();
public CmdInvite cmdInvite = new CmdInvite();
@ -104,6 +105,8 @@ public class FCmdRoot extends FCommand {
public CmdTntFill cmdTntFill = new CmdTntFill();
public CmdChest cmdChest = new CmdChest();
public CmdSetBanner cmdSetBanner = new CmdSetBanner();
public CmdStrike cmdStrike = new CmdStrike();
public CmdSetStrikes cmdSetStrikes = new CmdSetStrikes();
public FCmdRoot() {
@ -140,7 +143,8 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdDeinvite);
this.addSubCommand(this.cmdDescription);
this.addSubCommand(this.cmdDisband);
this.addSubCommand(this.cmdStrike);
this.addSubCommand(this.cmdSetStrikes);
this.addSubCommand(this.cmdHelp);
this.addSubCommand(this.cmdHome);
this.addSubCommand(this.cmdInvite);
@ -217,6 +221,10 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdChest);
this.addSubCommand(this.cmdSetBanner);
if (SavageFactions.plugin.getConfig().getBoolean("f-grace.Enabled")) {
this.addSubCommand(this.cmdGrace);
}
if (Bukkit.getServer().getPluginManager().getPlugin("CoreProtect") != null) {
SavageFactions.plugin.log("Found CoreProtect, enabling Inspect");

View File

@ -22,6 +22,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
@ -164,7 +166,7 @@ public class FactionsBlockListener implements Listener {
/*
* note that I originally was testing the territory of each affected block, but since I found that pistons can only push
* up to 12 blocks and the width of any territory is 16 blocks, it should be safe (and much more lightweight) to test
* only the final target block as done above
* only the target block as done above
*/
}
@ -323,24 +325,24 @@ public class FactionsBlockListener implements Listener {
bannerCooldownMap.put(fme.getTag(), true);
bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation());
final int bannerCooldown = SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Place-Cooldown");
final ArmorStand as = (ArmorStand) e.getBlockPlaced().getLocation().add(0.5, 1, 0.5).getWorld().spawnEntity(e.getBlockPlaced().getLocation().add(0.5, 1, 0.5), EntityType.ARMOR_STAND); //Spawn the ArmorStand
int bannerCooldown = SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Place-Cooldown");
ArmorStand as = (ArmorStand) e.getBlockPlaced().getLocation().add(0.5, 1, 0.5).getWorld().spawnEntity(e.getBlockPlaced().getLocation().add(0.5, 1, 0.5), EntityType.ARMOR_STAND); //Spawn the ArmorStand
as.setVisible(false); //Makes the ArmorStand invisible
as.setGravity(false); //Make sure it doesn't fall
as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it
as.setCustomName(SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fbanners.BannerHolo").replace("{Faction}", fme.getTag()))); //Set this to the text you want
as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not
final ArmorStand armorStand = as;
final String tag = fme.getTag();
ArmorStand armorStand = as;
String tag = fme.getTag();
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, () -> bannerCooldownMap.remove(tag), Long.parseLong(bannerCooldown + ""));
final Block banner = e.getBlockPlaced();
final Material bannerType = banner.getType();
final Faction bannerFaction = fme.getFaction();
Block banner = e.getBlockPlaced();
Material bannerType = banner.getType();
Faction bannerFaction = fme.getFaction();
banner.getWorld().strikeLightningEffect(banner.getLocation());
// e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.ENTITY_LIGHTNING_IMPACT,2.0F,0.5F);
final int radius = SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Effect-Radius");
final List<String> effects = SavageFactions.plugin.getConfig().getStringList("fbanners.Effects");
final int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
int radius = SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Effect-Radius");
List<String> effects = SavageFactions.plugin.getConfig().getStringList("fbanners.Effects");
int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
for (Entity e1 : banner.getLocation().getWorld().getNearbyEntities(banner.getLocation(), radius, 255, radius)) {
if (e1 instanceof Player) {
@ -398,6 +400,63 @@ public class FactionsBlockListener implements Listener {
}
}
@EventHandler
public void onFallingBlock(EntityChangeBlockEvent event) {
if(!SavageFactions.plugin.getConfig().getBoolean("Falling-Block-Fix.Enabled"))
return;
Faction faction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
if (faction.isWarZone() || faction.isSafeZone()) {
event.getBlock().setType(Material.AIR);
event.setCancelled(true);
}
}
//Grace
@EventHandler
public void onBreak(EntityExplodeEvent e) {
if (!SavageFactions.plugin.getConfig().getBoolean("f-grace.Enabled"))
return;
if (!graceisEnabled()) {
e.setCancelled(true);
}
}
@EventHandler
public void entityDamage(EntityDamageEvent e) {
if (!SavageFactions.plugin.getConfig().getBoolean("f-grace.Enabled"))
return;
if (!graceisEnabled()) {
if (e.getEntity() instanceof com.sk89q.worldedit.entity.Player) {
if (e.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
e.setCancelled(true);
}
}
}
}
@EventHandler
public void onTNTPlace(BlockPlaceEvent e1) {
FPlayer fp = FPlayers.getInstance().getByPlayer(e1.getPlayer());
if (!SavageFactions.plugin.getConfig().getBoolean("f-grace.Enabled"))
return;
if (!graceisEnabled() && !fp.isAdminBypassing()) {
if (e1.getBlock().getType().equals(Material.TNT)) {
e1.setCancelled(true);
fp.msg(TL.COMMAND_GRACE_ENABLED, e1.getBlockPlaced().getType().toString());
}
}
}
public static boolean graceisEnabled() {
return Conf.gracePeriod;
}
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
@ -474,7 +533,8 @@ public class FactionsBlockListener implements Listener {
/// <param name="shouldHurt">Determine whether we should hurt the player when access is denied</param>
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) {
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) return true;
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
return true;
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
if (shouldHurt) {
@ -497,7 +557,8 @@ public class FactionsBlockListener implements Listener {
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain) {
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
// If pain should be applied
if (pain && Conf.ownedAreaPainBuild) me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location)));
if (pain && Conf.ownedAreaPainBuild)
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location)));
if (Conf.ownedAreaDenyBuild && pain) return false;
else if (Conf.ownedAreaDenyBuild) {
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString()));

View File

@ -31,6 +31,7 @@ public enum Permission {
DISBAND_ANY("disband.any"),
FLY("fly"),
FOCUS("focus"),
GRACE("grace"),
HELP("help"),
HOME("home"),
INVITE("invite"),
@ -77,6 +78,7 @@ public enum Permission {
SAVE("save"),
SETHOME("sethome"),
SETHOME_ANY("sethome.any"),
SETSTRIKES("setstrikes"),
SHOW("show"),
STATUS("status"),
STEALTH("stealth"),

View File

@ -68,6 +68,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
Inventory chest;
Map<String, Object> bannerSerialized;
private long lastDeath;
private int strikes = 0;
// -------------------------------------------- //
// Construct
@ -117,6 +118,14 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
resetPerms(); // Reset on new Faction so it has default values.
}
public int getStrikes() {
return strikes;
}
public void setStrikes(int strikes) {
this.strikes = strikes;
}
public HashMap<String, List<String>> getAnnouncements() {
return this.announcements;
}

View File

@ -317,6 +317,10 @@ public enum TL {
COMMAND_FWARP_PASSWORD_REQUIRED("&c&l[!]&c Warp Password:"),
COMMAND_FWARP_PASSWORD_TIMEOUT("&c&l[!]&7 Warp password &ccanceled"),
COMMAND_GRACE_DESCRIPTION("Toggles Grace Period on/off"),
COMMAND_GRACE_ENABLED("&cYou cannot place &e%s &cwhile grace period is active!"),
COMMAND_GRACE_TOGGLE("&8» &7Grace period is now &c%1$s"),
COMMAND_HINT_PERMISSION("&aYou can manage your factions permissions using &7/f perms"),
COMMAND_HOME_DISABLED("&c&l[!]&7 Sorry, Faction homes are &cdisabled on this server."),
@ -605,6 +609,16 @@ public enum TL {
COMMAND_SETMAXVAULTS_DESCRIPTION("Set max vaults for a Faction."),
COMMAND_SETMAXVAULTS_SUCCESS("&aSet max vaults for &e%s &ato &b%d"),
COMMAND_SETSTRIKES_FAILURE("&c&l[!]&7 &c{faction} does not exist."),
COMMAND_SETSTRIKES_BROADCAST("&c&l[!]&7 &c{faction} has received a strike for {reason}"),
COMMAND_SETSTRIKES_SUCCESS("&c&l[!]&7 &c{faction}'s&7 new strikes are &c{strikes}"),
COMMAND_SETSTRIKES_DESCRIPTION("Set a faction's points"),
COMMAND_STRIKE_MESSAGE("&c&l[!] &7{faction} has {strikes} strikes."),
COMMAND_STRIKE_NOTFOUND("&c&l[!] &7{faction} does not exist."),
COMMAND_STRIKE_NEEDFACTION("&c&l[!] &7&cYou need to join a faction to view your own!"),
COMMAND_STRIKE_DESCRIPTION("Give a faction strikes."),
COMMAND_VAULT_DESCRIPTION("Open your placed faction vault!"),
COMMAND_VAULT_INVALID("&c&l[!]&7 Your vault was either&c claimed&7, &cbroken&7, or has&c not been&7 placed yet."),
COMMAND_VAULT_OPENING("&c&l[!]&7 Opening faction vault."),

View File

@ -6,6 +6,7 @@ import com.massivecraft.factions.struct.Relation;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.dynmap.snakeyaml.nodes.Tag;
import java.util.ArrayList;
import java.util.List;
@ -72,6 +73,7 @@ public enum TagReplacer {
FACTION_KILLS(TagType.FACTION, "{faction-kills}"),
FACTION_DEATHS(TagType.FACTION, "{faction-deaths}"),
FACTION_BANCOUNT(TagType.FACTION, "{faction-bancount}"),
FACTION_STRIKES(TagType.FACTION, "{strikes}"),
/**
* General variables, require no faction or player
@ -255,6 +257,9 @@ public enum TagReplacer {
return String.valueOf(fac.getDeaths());
case FACTION_BANCOUNT:
return String.valueOf(fac.getBannedPlayers().size());
case FACTION_STRIKES:
return String.valueOf(fac.getStrikes());
default:
}
return null;

View File

@ -280,6 +280,7 @@ show:
- '&6 * &eOwner &7{leader}'
- '&6 * &eDescription &7{description}'
- '&6 * &eLand / Power / Max Power: &7{chunks} &8/ &7{power} &8/ &7{maxPower}'
- '&6 * &eFaction Strikes: &7{strikes}'
- '&6 * &eFounded &7{create-date}'
- '&6 * &eBalance &f{faction-balance}'
- '&6 * &eAllies &c{allies-list}'
@ -753,6 +754,26 @@ fnear:
Enabled: true
Radius: 50
############################################################
# +------------------------------------------------------+ #
# | Falling Block Fix | #
# +------------------------------------------------------+ #
############################################################
#Enabling this will disallow falling blocks to be in spawn.
#Meaning people cannot shoot cannons into spawn and stack sand
#Recommended: true
Falling-Block-Fix:
enabled: true
############################################################
# +------------------------------------------------------+ #
# | Faction GracePeriod | #
# +------------------------------------------------------+ #
############################################################
f-grace:
Enabled: true
############################################################
# +------------------------------------------------------+ #
# | Faction Focus | #