Merge from Driftay/1.6.x
This commit is contained in:
commit
f78290b63d
@ -23,6 +23,13 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public interface Faction extends EconomyParticipator {
|
||||
|
||||
int getWarpsLimit();
|
||||
|
||||
void setWarpsLimit(int limit);
|
||||
|
||||
int getTntBankLimit();
|
||||
|
||||
void setTntBankLimit(int limit);
|
||||
|
||||
int getWallCheckMinutes();
|
||||
|
||||
|
@ -267,13 +267,10 @@ public class FactionsPlugin extends MPlugin {
|
||||
new FactionsExploitListener(),
|
||||
new FactionsBlockListener(),
|
||||
new FUpgradesGUI(),
|
||||
new EXPUpgrade(),
|
||||
new CropUpgrades(),
|
||||
new RedstoneUpgrade(),
|
||||
new ShopClickPersistence(),
|
||||
new UpgradesListener(),
|
||||
new MissionHandler(this),
|
||||
new ChestLogsHandler(),
|
||||
new SpawnerUpgrades()
|
||||
new ChestLogsHandler()
|
||||
};
|
||||
|
||||
for (Listener eventListener : eventsListener)
|
||||
|
@ -6,15 +6,12 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CmdBanner extends FCommand {
|
||||
public CmdBanner() {
|
||||
this.aliases.add("banner");
|
||||
|
@ -9,57 +9,42 @@ import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdSetFWarp extends FCommand {
|
||||
|
||||
public CmdSetFWarp() {
|
||||
super();
|
||||
|
||||
this.aliases.add("setwarp");
|
||||
this.aliases.add("sw");
|
||||
this.requiredArgs.add("warp name");
|
||||
this.optionalArgs.put("password", "password");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.SETWARP)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.SETWARP)
|
||||
.build();
|
||||
this.requirements = new CommandRequirements.Builder(Permission.SETWARP).playerOnly().memberOnly().withAction(PermissableAction.SETWARP).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!(context.fPlayer.getRelationToLocation() == Relation.MEMBER)) {
|
||||
if (context.fPlayer.getRelationToLocation() != Relation.MEMBER) {
|
||||
context.msg(TL.COMMAND_SETFWARP_NOTCLAIMED);
|
||||
return;
|
||||
}
|
||||
|
||||
String warp = context.argAsString(0);
|
||||
|
||||
// Checks if warp with same name already exists and ignores maxWarp check if it does.
|
||||
boolean warpExists = context.faction.isWarp(warp);
|
||||
|
||||
int maxWarps = FactionsPlugin.getInstance().getConfig().getInt("max-warps", 5);
|
||||
int maxWarps = context.faction.getWarpsLimit();
|
||||
boolean tooManyWarps = maxWarps <= context.faction.getWarps().size();
|
||||
if (tooManyWarps && !warpExists) {
|
||||
context.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!transact(context.fPlayer, context)) {
|
||||
if (!this.transact(context.fPlayer, context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String password = context.argAsString(1);
|
||||
|
||||
LazyLocation loc = new LazyLocation(context.player.getLocation());
|
||||
context.faction.setWarp(warp, loc);
|
||||
if (password != null) {
|
||||
context.faction.setWarpPassword(warp, password);
|
||||
}
|
||||
context.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : "");
|
||||
context.msg(TL.COMMAND_SETFWARP_SET, warp, (password != null) ? password : "");
|
||||
}
|
||||
|
||||
private boolean transact(FPlayer player, CommandContext context) {
|
||||
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.setwarp", 5), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString());
|
||||
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.setwarp", 5.0), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,20 +23,25 @@ public class ConvertConfigHandler {
|
||||
static FileConfiguration sv = YamlConfiguration.loadConfiguration(savageConfigFile);
|
||||
static File configFile = new File("plugins/Factions/config.yml");
|
||||
static FileConfiguration sb = YamlConfiguration.loadConfiguration(configFile);
|
||||
public static void setString(String s){
|
||||
static JavaPlugin plugin = JavaPlugin.getProvidingPlugin(FactionsPlugin.class);
|
||||
|
||||
public static void setString(String s) {
|
||||
sb.set(s, sv.getString(s));
|
||||
}
|
||||
public static void setInt(String s){
|
||||
|
||||
public static void setInt(String s) {
|
||||
sb.set(s, sv.getInt(s));
|
||||
}
|
||||
public static void setConfigSec(String s){
|
||||
|
||||
public static void setConfigSec(String s) {
|
||||
ConfigurationSection cs = sv.getConfigurationSection(s);
|
||||
sb.set(s, cs);
|
||||
}
|
||||
static JavaPlugin plugin = JavaPlugin.getProvidingPlugin(FactionsPlugin.class);
|
||||
public static void setBoolean(String s){
|
||||
|
||||
public static void setBoolean(String s) {
|
||||
sb.set(s, sv.getBoolean(s));
|
||||
}
|
||||
|
||||
public static void convertconfig(Player player) {
|
||||
if (new File("plugins/Factions/SavageFactions/config.yml").exists()) {
|
||||
BukkitScheduler scheduler = plugin.getServer().getScheduler();
|
||||
|
@ -115,7 +115,7 @@ public class CmdTnt extends FCommand {
|
||||
context.msg(TL.GENERIC_ARGS_TOOFEW);
|
||||
context.msg(context.args.get(0).equalsIgnoreCase("take") || context.args.get(0).equalsIgnoreCase("t") ? TL.COMMAND_TNT_TAKE_DESCRIPTION : TL.COMMAND_TNT_ADD_DESCRIPTION);
|
||||
}
|
||||
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + ""));
|
||||
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{bankSize}", context.faction.getTntBankLimit() + ""));
|
||||
}
|
||||
|
||||
|
||||
|
@ -328,14 +328,14 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBannerBreak(BlockBreakEvent e){
|
||||
public void onBannerBreak(BlockBreakEvent e) {
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||
if (FactionsPlugin.getInstance().mc17) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(bannerLocations.containsValue(e.getBlock().getLocation())){
|
||||
if(e.getBlock().getType().name().contains("BANNER")) {
|
||||
if (bannerLocations.containsValue(e.getBlock().getLocation())) {
|
||||
if (e.getBlock().getType().name().contains("BANNER")) {
|
||||
e.setCancelled(true);
|
||||
fme.msg(TL.BANNER_CANNOT_BREAK);
|
||||
}
|
||||
@ -562,4 +562,4 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -736,7 +736,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
if (me.getAutoClaimFor() != null) {
|
||||
me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true);
|
||||
if (Conf.disableFlightOnFactionClaimChange && event.getPlayer().getGameMode() != GameMode.CREATIVE) CmdFly.disableFlight(me);
|
||||
if (Conf.disableFlightOnFactionClaimChange && event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||
CmdFly.disableFlight(me);
|
||||
} else if (me.isAutoSafeClaimEnabled()) {
|
||||
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
||||
me.setIsAutoSafeClaimEnabled(false);
|
||||
@ -805,7 +806,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
// Check if the material is bypassing protection
|
||||
if (block == null) return; // clicked in air, apparently
|
||||
if(event.getItem() != null) {
|
||||
if (event.getItem() != null) {
|
||||
if (Conf.territoryBypassProtectedMaterials.contains(event.getItem().getType())) return;
|
||||
}
|
||||
if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) {
|
||||
|
@ -4,16 +4,13 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityBreedEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityTameEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
@ -29,6 +26,26 @@ public class MissionHandler implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerTame(EntityTameEvent event) {
|
||||
if (!(event.getOwner() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player) event.getOwner());
|
||||
if (fPlayer == null) {
|
||||
return;
|
||||
}
|
||||
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("tame")).collect(Collectors.toList());
|
||||
for (Mission mission2 : missions) {
|
||||
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
|
||||
if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType")) && !section.getConfigurationSection("Mission").getString("EntityType").equalsIgnoreCase("ALL")) {
|
||||
continue;
|
||||
}
|
||||
mission2.incrementProgress();
|
||||
checkIfDone(fPlayer, mission2, section);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
if (event.getEntity() == null || event.getEntity().getKiller() == null) {
|
||||
@ -41,7 +58,7 @@ public class MissionHandler implements Listener {
|
||||
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("kill")).collect(Collectors.toList());
|
||||
for (Mission mission2 : missions) {
|
||||
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
|
||||
if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType")) && !section.getConfigurationSection("Mission").getString("EntityType").equalsIgnoreCase("ALL")) {
|
||||
if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType"))) {
|
||||
continue;
|
||||
}
|
||||
mission2.incrementProgress();
|
||||
@ -58,7 +75,7 @@ public class MissionHandler implements Listener {
|
||||
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("mine")).collect(Collectors.toList());
|
||||
for (Mission mission2 : missions) {
|
||||
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
|
||||
if (!event.getBlock().getType().toString().equals(section.getConfigurationSection("Mission").getString("Material")) && !section.getConfigurationSection("Mission").getString("Material").equalsIgnoreCase("ALL")) {
|
||||
if (!event.getBlock().getType().toString().equals(section.getConfigurationSection("Mission").getString("Material"))) {
|
||||
continue;
|
||||
}
|
||||
mission2.incrementProgress();
|
||||
@ -75,7 +92,7 @@ public class MissionHandler implements Listener {
|
||||
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("place")).collect(Collectors.toList());
|
||||
for (Mission mission2 : missions) {
|
||||
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
|
||||
if (!event.getBlock().getType().toString().equals(section.getConfigurationSection("Mission").getString("Material")) && !section.getConfigurationSection("Mission").getString("Material").equalsIgnoreCase("ALL")) {
|
||||
if (!event.getBlock().getType().toString().equals(section.getConfigurationSection("Mission").getString("Material"))) {
|
||||
continue;
|
||||
}
|
||||
mission2.incrementProgress();
|
||||
@ -100,26 +117,6 @@ public class MissionHandler implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerTame(EntityTameEvent event) {
|
||||
if (!(event.getOwner() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player)event.getOwner());
|
||||
if (fPlayer == null) {
|
||||
return;
|
||||
}
|
||||
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("tame")).collect(Collectors.toList());
|
||||
for (Mission mission2 : missions) {
|
||||
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
|
||||
if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType")) && !section.getConfigurationSection("Mission").getString("EntityType").equalsIgnoreCase("ALL")) {
|
||||
continue;
|
||||
}
|
||||
mission2.incrementProgress();
|
||||
checkIfDone(fPlayer, mission2, section);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkIfDone(FPlayer fPlayer, Mission mission, ConfigurationSection section) {
|
||||
if (mission.getProgress() < section.getConfigurationSection("Mission").getLong("Amount")) {
|
||||
return;
|
||||
|
@ -34,7 +34,8 @@ public class PermissableActionFrame {
|
||||
List<GuiItem> GUIItems = new ArrayList<>();
|
||||
ItemStack dumby = buildDummyItem();
|
||||
// Fill background of GUI with dumbyitem & replace GUI assets after
|
||||
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
|
||||
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++)
|
||||
GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
|
||||
for (PermissableAction action : PermissableAction.values()) {
|
||||
if (action.getSlot() == -1) continue;
|
||||
GUIItems.set(action.getSlot(), new GuiItem(action.buildAsset(fplayer, perm), e -> {
|
||||
|
@ -33,7 +33,8 @@ public class PermissableRelationFrame {
|
||||
List<GuiItem> GUIItems = new ArrayList<>();
|
||||
ItemStack dumby = buildDummyItem();
|
||||
// Fill background of GUI with dumbyitem & replace GUI assets after
|
||||
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
|
||||
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++)
|
||||
GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
|
||||
ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation");
|
||||
for (String key : sec.getConfigurationSection("slots").getKeys(false)) {
|
||||
GUIItems.set(sec.getInt("slots." + key), new GuiItem(buildAsset("fperm-gui.relation.materials." + key, key), e -> {
|
||||
|
@ -1,79 +0,0 @@
|
||||
package com.massivecraft.factions.zcore.fupgrades;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.material.Crops;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class CropUpgrades implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onCropGrow(BlockGrowEvent e) {
|
||||
FLocation floc = new FLocation(e.getBlock().getLocation());
|
||||
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
|
||||
|
||||
if (!factionAtLoc.isWilderness()) {
|
||||
int level = factionAtLoc.getUpgrade(UpgradeType.CROP);
|
||||
if (level != 0) {
|
||||
int chance = -1;
|
||||
|
||||
switch (level) {
|
||||
case 1:
|
||||
chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-1");
|
||||
break;
|
||||
case 2:
|
||||
chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-2");
|
||||
break;
|
||||
case 3:
|
||||
chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-3");
|
||||
break;
|
||||
}
|
||||
|
||||
if (chance >= 0) {
|
||||
int randomNum = ThreadLocalRandom.current().nextInt(1, 100 + 1);
|
||||
if (randomNum <= chance)
|
||||
growCrop(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void growCrop(BlockGrowEvent e) {
|
||||
|
||||
if (e.getBlock().getType().equals(XMaterial.WHEAT.parseMaterial())) {
|
||||
e.setCancelled(true);
|
||||
Crops c = new Crops(CropState.RIPE);
|
||||
BlockState bs = e.getBlock().getState();
|
||||
bs.setData(c);
|
||||
bs.update();
|
||||
}
|
||||
|
||||
Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock();
|
||||
|
||||
if (below.getType() == XMaterial.SUGAR_CANE.parseMaterial()) {
|
||||
Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
|
||||
|
||||
if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) {
|
||||
above.setType(XMaterial.SUGAR_CANE.parseMaterial());
|
||||
}
|
||||
|
||||
} else if (below.getType() == Material.CACTUS) {
|
||||
Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
|
||||
|
||||
if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) {
|
||||
above.setType(Material.CACTUS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.massivecraft.factions.zcore.fupgrades;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
public class EXPUpgrade implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(EntityDeathEvent e) {
|
||||
Entity killer = e.getEntity().getKiller();
|
||||
|
||||
if (killer == null)
|
||||
return;
|
||||
|
||||
FLocation floc = new FLocation(e.getEntity().getLocation());
|
||||
Faction faction = Board.getInstance().getFactionAt(floc);
|
||||
|
||||
if (!faction.isWilderness()) {
|
||||
int level = faction.getUpgrade(UpgradeType.EXP);
|
||||
if (level != 0) {
|
||||
|
||||
double multiplier = -1;
|
||||
|
||||
switch (level) {
|
||||
case 1:
|
||||
multiplier = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-1");
|
||||
break;
|
||||
case 2:
|
||||
multiplier = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-2");
|
||||
break;
|
||||
case 3:
|
||||
multiplier = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-3");
|
||||
break;
|
||||
}
|
||||
|
||||
if (multiplier >= 0)
|
||||
spawnMoreExp(e, multiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnMoreExp(EntityDeathEvent e, double multiplier) {
|
||||
double newExp = e.getDroppedExp() * multiplier;
|
||||
e.setDroppedExp((int) newExp);
|
||||
}
|
||||
}
|
@ -41,6 +41,10 @@ public class FUpgradesGUI implements Listener {
|
||||
List<Integer> powerSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Power.PowerItem.slots");
|
||||
List<Integer> redSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Redstone.RedstoneItem.slots");
|
||||
List<Integer> memberSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Members.MembersItem.slots");
|
||||
List<Integer> reductSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.DamageReduct.ReduceItem.slots");
|
||||
List<Integer> increaseSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.DamageIncrease.IncreaseItem.slots");
|
||||
List<Integer> tntSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.TNT.TntItem.slots");
|
||||
List<Integer> warpSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Warps.WarpItem.slots");
|
||||
|
||||
for (Integer cropSlot : cropSlots) if (cropSlot != -1) inventory.setItem(cropSlot, items[2]);
|
||||
|
||||
@ -56,6 +60,14 @@ public class FUpgradesGUI implements Listener {
|
||||
|
||||
for (Integer memberSlot : memberSlots) if (memberSlot != -1) inventory.setItem(memberSlot, items[6]);
|
||||
|
||||
for (Integer reduceSlot : reductSlots) if (reduceSlot != -1) inventory.setItem(reduceSlot, items[7]);
|
||||
|
||||
for (Integer increaseSlot : increaseSlots) if (increaseSlot != -1) inventory.setItem(increaseSlot, items[8]);
|
||||
|
||||
for(Integer tntSlot : tntSlots) if(tntSlot != -1) inventory.setItem(tntSlot, items[9]);
|
||||
|
||||
for(Integer warpSlot : warpSlots) if(warpSlot != -1) inventory.setItem(warpSlot, items[10]);
|
||||
|
||||
fme.getPlayer().openInventory(inventory);
|
||||
}
|
||||
|
||||
@ -75,6 +87,10 @@ public class FUpgradesGUI implements Listener {
|
||||
ItemStack powerItem = items[4];
|
||||
ItemStack redItem = items[5];
|
||||
ItemStack memberItem = items[6];
|
||||
ItemStack reduceItem = items[7];
|
||||
ItemStack increaseItem = items[8];
|
||||
ItemStack tntItem = items[9];
|
||||
ItemStack warpItem = items[10];
|
||||
|
||||
if (e.getCurrentItem().equals(cropItem)) {
|
||||
int cropLevel = fme.getFaction().getUpgrade(UpgradeType.CROP);
|
||||
@ -181,6 +197,52 @@ public class FUpgradesGUI implements Listener {
|
||||
fme.getPlayer().closeInventory();
|
||||
takeMoney(fme, cost);
|
||||
}
|
||||
} else if (e.getCurrentItem().equals(reduceItem)) {
|
||||
int reduceLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE) + 1;
|
||||
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.DamageReduct.Cost.level-" + reduceLevel)) {
|
||||
return;
|
||||
}
|
||||
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.Cost.level-" + reduceLevel);
|
||||
if (hasMoney(fme, cost)) {
|
||||
fme.getFaction().setUpgrade(UpgradeType.DAMAGEDECREASE, reduceLevel);
|
||||
fme.getPlayer().closeInventory();
|
||||
takeMoney(fme, cost);
|
||||
}
|
||||
} else if (e.getCurrentItem().equals(increaseItem)) {
|
||||
int increaseLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEINCREASE) + 1;
|
||||
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.DamageIncrease.Cost.level-" + increaseLevel)) {
|
||||
return;
|
||||
}
|
||||
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.Cost.level-" + increaseLevel);
|
||||
if (hasMoney(fme, cost)) {
|
||||
fme.getFaction().setUpgrade(UpgradeType.DAMAGEINCREASE, increaseLevel);
|
||||
fme.getPlayer().closeInventory();
|
||||
takeMoney(fme, cost);
|
||||
}
|
||||
} else if(e.getCurrentItem().equals(tntItem)){
|
||||
int tntLevel = fme.getFaction().getUpgrade(UpgradeType.TNT) + 1;
|
||||
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.TNT.Cost.level-" + tntLevel)) {
|
||||
return;
|
||||
}
|
||||
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.Cost.level-" + tntLevel);
|
||||
if (hasMoney(fme, cost)) {
|
||||
fme.getFaction().setUpgrade(UpgradeType.TNT, tntLevel);
|
||||
fme.getPlayer().closeInventory();
|
||||
takeMoney(fme, cost);
|
||||
updateTntBanks(fme.getFaction());
|
||||
}
|
||||
} else if(e.getCurrentItem().equals(warpItem)){
|
||||
int warpLevel = fme.getFaction().getUpgrade(UpgradeType.WARP) + 1;
|
||||
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.Warps.Cost.level-" + warpLevel)) {
|
||||
return;
|
||||
}
|
||||
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.Cost.level-" + warpLevel);
|
||||
if (hasMoney(fme, cost)) {
|
||||
fme.getFaction().setUpgrade(UpgradeType.WARP, warpLevel);
|
||||
fme.getPlayer().closeInventory();
|
||||
takeMoney(fme, cost);
|
||||
setWarpLimit(fme.getFaction());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -407,11 +469,130 @@ public class FUpgradesGUI implements Listener {
|
||||
}
|
||||
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
||||
redItem.setItemMeta(itemMeta);
|
||||
|
||||
redItem.setAmount(redLevel);
|
||||
}
|
||||
|
||||
return new ItemStack[]{expItem, spawnerItem, cropItem, chestItem, powerItem, redItem, memberItem};
|
||||
Material reduceMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageReduct.ReduceItem.Type"));
|
||||
int reduceAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.ReduceItem.Amount");
|
||||
short reduceData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.ReduceItem.Damage") + "");
|
||||
String reduceName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageReduct.ReduceItem.Name"));
|
||||
List<String> reduceLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.DamageReduct.ReduceItem.Lore"));
|
||||
int reduceLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE);
|
||||
|
||||
for (int i = 0; i <= reduceLore.size() - 1; i++) {
|
||||
String line = reduceLore.get(i);
|
||||
line = line.replace("{level}", reduceLevel + "");
|
||||
reduceLore.set(i, line);
|
||||
}
|
||||
|
||||
ItemStack reduceItem = FactionsPlugin.getInstance().createItem(reduceMaterial, reduceAmt, reduceData, reduceName, reduceLore);
|
||||
reduceItem.getItemMeta().setLore(reduceLore);
|
||||
|
||||
if (reduceLevel >= 1) {
|
||||
ItemMeta itemMeta = reduceItem.getItemMeta();
|
||||
if (!FactionsPlugin.getInstance().mc17) {
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
}
|
||||
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
||||
reduceItem.setItemMeta(itemMeta);
|
||||
|
||||
reduceItem.setAmount(reduceLevel);
|
||||
}
|
||||
|
||||
Material increaseMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Type"));
|
||||
int increaseAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Amount");
|
||||
short increaseData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Damage") + "");
|
||||
String increaseName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Name"));
|
||||
List<String> increaseLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Lore"));
|
||||
int increaseLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEINCREASE);
|
||||
|
||||
for (int i = 0; i <= increaseLore.size() - 1; i++) {
|
||||
String line = increaseLore.get(i);
|
||||
line = line.replace("{level}", increaseLevel + "");
|
||||
increaseLore.set(i, line);
|
||||
}
|
||||
|
||||
ItemStack increaseItem = FactionsPlugin.getInstance().createItem(increaseMaterial, increaseAmt, increaseData, increaseName, increaseLore);
|
||||
increaseItem.getItemMeta().setLore(increaseLore);
|
||||
|
||||
if (increaseLevel >= 1) {
|
||||
ItemMeta itemMeta = increaseItem.getItemMeta();
|
||||
if (!FactionsPlugin.getInstance().mc17) {
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
}
|
||||
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
||||
increaseItem.setItemMeta(itemMeta);
|
||||
|
||||
increaseItem.setAmount(increaseLevel);
|
||||
}
|
||||
|
||||
Material tntMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.TNT.TntItem.Type"));
|
||||
int tntAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.TntItem.Amount");
|
||||
short tntData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.TntItem.Damage") + "");
|
||||
String tntName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.TNT.TntItem.Name"));
|
||||
List<String> tntLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.TNT.TntItem.Lore"));
|
||||
int tntLevel = fme.getFaction().getUpgrade(UpgradeType.TNT);
|
||||
|
||||
for (int i = 0; i <= tntLore.size() - 1; i++) {
|
||||
String line = tntLore.get(i);
|
||||
line = line.replace("{level}", tntLevel + "");
|
||||
tntLore.set(i, line);
|
||||
}
|
||||
|
||||
ItemStack tntItem = FactionsPlugin.getInstance().createItem(tntMaterial, tntAmt, tntData, tntName, tntLore);
|
||||
tntItem.getItemMeta().setLore(tntLore);
|
||||
|
||||
if (tntLevel >= 1) {
|
||||
ItemMeta itemMeta = tntItem.getItemMeta();
|
||||
if (!FactionsPlugin.getInstance().mc17) {
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
}
|
||||
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
||||
tntItem.setItemMeta(itemMeta);
|
||||
|
||||
tntItem.setAmount(tntLevel);
|
||||
}
|
||||
|
||||
Material warpMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Warps.WarpItem.Type"));
|
||||
int warpAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.WarpItem.Amount");
|
||||
short warpData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.WarpItem.Damage") + "");
|
||||
String warpName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Warps.WarpItem.Name"));
|
||||
List<String> warpLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Warps.WarpItem.Lore"));
|
||||
int warpLevel = fme.getFaction().getUpgrade(UpgradeType.WARP);
|
||||
|
||||
for (int i = 0; i <= warpLore.size() - 1; i++) {
|
||||
String line = warpLore.get(i);
|
||||
line = line.replace("{level}", warpLevel + "");
|
||||
warpLore.set(i, line);
|
||||
}
|
||||
|
||||
ItemStack warpItem = FactionsPlugin.getInstance().createItem(warpMaterial, warpAmt, warpData, warpName, warpLore);
|
||||
warpItem.getItemMeta().setLore(warpLore);
|
||||
|
||||
if (warpLevel >= 1) {
|
||||
ItemMeta itemMeta = warpItem.getItemMeta();
|
||||
if (!FactionsPlugin.getInstance().mc17) {
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
}
|
||||
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
||||
warpItem.setItemMeta(itemMeta);
|
||||
|
||||
warpItem.setAmount(warpLevel);
|
||||
}
|
||||
|
||||
return new ItemStack[]{expItem, spawnerItem, cropItem, chestItem, powerItem, redItem, memberItem, reduceItem, increaseItem, tntItem, warpItem};
|
||||
}
|
||||
|
||||
private void updateTntBanks(Faction faction) {
|
||||
int level = faction.getUpgrade(UpgradeType.TNT);
|
||||
int size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.tnt-limit.level-" + (level));
|
||||
faction.setTntBankLimit(size);
|
||||
}
|
||||
|
||||
private void setWarpLimit(Faction faction) {
|
||||
int level = faction.getUpgrade(UpgradeType.WARP);
|
||||
int size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.warp-limit.level-" + (level));
|
||||
faction.setWarpsLimit(size);
|
||||
}
|
||||
|
||||
private boolean hasMoney(FPlayer fme, int amt) {
|
||||
|
@ -1,34 +0,0 @@
|
||||
package com.massivecraft.factions.zcore.fupgrades;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RedstoneUpgrade implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onWaterRedstone(BlockFromToEvent e) {
|
||||
List<String> unbreakable = FactionsPlugin.getInstance().getConfig().getStringList("no-water-destroy.Item-List");
|
||||
String block = e.getToBlock().getType().toString();
|
||||
FLocation floc = new FLocation(e.getToBlock().getLocation());
|
||||
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
|
||||
|
||||
if (!factionAtLoc.isWilderness()) {
|
||||
int level = factionAtLoc.getUpgrade(UpgradeType.REDSTONE);
|
||||
if (level != 0) {
|
||||
if (level == 1) {
|
||||
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Cost");
|
||||
}
|
||||
if (unbreakable.contains(block)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.massivecraft.factions.zcore.fupgrades;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
|
||||
public class SpawnerUpgrades implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onSpawn(SpawnerSpawnEvent e) {
|
||||
FLocation floc = new FLocation(e.getLocation());
|
||||
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
|
||||
|
||||
if (!factionAtLoc.isWilderness()) {
|
||||
int level = factionAtLoc.getUpgrade(UpgradeType.SPAWNER);
|
||||
if (level != 0) {
|
||||
switch (level) {
|
||||
case 1:
|
||||
lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-1"));
|
||||
break;
|
||||
case 2:
|
||||
lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-2"));
|
||||
break;
|
||||
case 3:
|
||||
lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-3"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void lowerSpawnerDelay(SpawnerSpawnEvent e, double multiplier) {
|
||||
int lowerby = (int) Math.round(e.getSpawner().getDelay() * multiplier);
|
||||
e.getSpawner().setDelay(e.getSpawner().getDelay() - lowerby);
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,17 @@ package com.massivecraft.factions.zcore.fupgrades;
|
||||
|
||||
public enum UpgradeType {
|
||||
|
||||
CHEST("Chest"), SPAWNER("Spawner"), EXP("Exp"), CROP("Crop"), POWER("Power"), REDSTONE("Redstone"), MEMBERS("Members");
|
||||
CHEST("Chest"),
|
||||
SPAWNER("Spawner"),
|
||||
EXP("Exp"),
|
||||
CROP("Crop"),
|
||||
POWER("Power"),
|
||||
REDSTONE("Redstone"),
|
||||
MEMBERS("Members"),
|
||||
TNT("TNT"),
|
||||
WARP("Warps"),
|
||||
DAMAGEINCREASE("DamageIncrease"),
|
||||
DAMAGEDECREASE("DamageDecrease");
|
||||
|
||||
private String id;
|
||||
|
||||
|
@ -0,0 +1,174 @@
|
||||
package com.massivecraft.factions.zcore.fupgrades;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
import org.bukkit.material.Crops;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class UpgradesListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(EntityDeathEvent e) {
|
||||
Entity killer = e.getEntity().getKiller();
|
||||
if (killer == null || !(killer instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
FLocation floc = new FLocation(e.getEntity().getLocation());
|
||||
Faction faction = Board.getInstance().getFactionAt(floc);
|
||||
if (!faction.isWilderness()) {
|
||||
int level = faction.getUpgrade(UpgradeType.EXP);
|
||||
double multiplier = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-" + level);
|
||||
if (level != 0 && multiplier > 0.0) {
|
||||
this.spawnMoreExp(e, multiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnMoreExp(EntityDeathEvent e, double multiplier) {
|
||||
double newExp = e.getDroppedExp() * multiplier;
|
||||
e.setDroppedExp((int) newExp);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpawn(SpawnerSpawnEvent e) {
|
||||
FLocation floc = new FLocation(e.getLocation());
|
||||
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
|
||||
if (!factionAtLoc.isWilderness()) {
|
||||
int level = factionAtLoc.getUpgrade(UpgradeType.SPAWNER);
|
||||
if (level == 0) {
|
||||
return;
|
||||
}
|
||||
this.lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Spawners.Spawner-Boost.level-" + level));
|
||||
}
|
||||
}
|
||||
|
||||
private void lowerSpawnerDelay(SpawnerSpawnEvent e, double multiplier) {
|
||||
int lowerby = (int) Math.round(e.getSpawner().getDelay() * multiplier);
|
||||
e.getSpawner().setDelay(e.getSpawner().getDelay() - lowerby);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCropGrow( BlockGrowEvent e) {
|
||||
FLocation floc = new FLocation(e.getBlock().getLocation());
|
||||
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
|
||||
if (!factionAtLoc.isWilderness()) {
|
||||
int level = factionAtLoc.getUpgrade(UpgradeType.CROP);
|
||||
int chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-" + level);
|
||||
if (level == 0 || chance == 0) {
|
||||
return;
|
||||
}
|
||||
int randomNum = ThreadLocalRandom.current().nextInt(1, 101);
|
||||
if (randomNum <= chance) {
|
||||
this.growCrop(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void growCrop( BlockGrowEvent e) {
|
||||
if (e.getBlock().getType().equals(XMaterial.WHEAT.parseMaterial())) {
|
||||
e.setCancelled(true);
|
||||
Crops c = new Crops(CropState.RIPE);
|
||||
BlockState bs = e.getBlock().getState();
|
||||
bs.setData(c);
|
||||
bs.update();
|
||||
}
|
||||
Block below = e.getBlock().getLocation().subtract(0.0, 1.0, 0.0).getBlock();
|
||||
if (below.getType() == XMaterial.SUGAR_CANE.parseMaterial()) {
|
||||
Block above = e.getBlock().getLocation().add(0.0, 1.0, 0.0).getBlock();
|
||||
if (above.getType() == Material.AIR && above.getLocation().add(0.0, -2.0, 0.0).getBlock().getType() != Material.AIR) {
|
||||
above.setType(XMaterial.SUGAR_CANE.parseMaterial());
|
||||
}
|
||||
}
|
||||
else if (below.getType() == Material.CACTUS) {
|
||||
Block above = e.getBlock().getLocation().add(0.0, 1.0, 0.0).getBlock();
|
||||
if (above.getType() == Material.AIR && above.getLocation().add(0.0, -2.0, 0.0).getBlock().getType() != Material.AIR) {
|
||||
above.setType(Material.CACTUS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public static void onDamageReduction(EntityDamageByEntityEvent e) {
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity());
|
||||
FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager());
|
||||
if (fme == null || dame == null) {
|
||||
return;
|
||||
}
|
||||
FLocation floc = new FLocation(fme.getPlayer().getLocation());
|
||||
if (Board.getInstance().getFactionAt(floc) == fme.getFaction()) {
|
||||
if (dame.getFaction() == fme.getFaction()) {
|
||||
return;
|
||||
}
|
||||
double damage = e.getDamage();
|
||||
int level = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE);
|
||||
double increase = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.DamageReduction.DamageReductionPercent.level-" + level);
|
||||
e.setDamage(damage - damage / 100.0 * increase);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWaterRedstone(BlockFromToEvent e) {
|
||||
List<String> unbreakable = FactionsPlugin.getInstance().getConfig().getStringList("no-water-destroy.Item-List");
|
||||
String block = e.getToBlock().getType().toString();
|
||||
FLocation floc = new FLocation(e.getToBlock().getLocation());
|
||||
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
|
||||
|
||||
if (!factionAtLoc.isWilderness()) {
|
||||
int level = factionAtLoc.getUpgrade(UpgradeType.REDSTONE);
|
||||
if (level != 0) {
|
||||
if (level == 1) {
|
||||
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Cost");
|
||||
}
|
||||
if (unbreakable.contains(block)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public static void onDamageIncrease(EntityDamageByEntityEvent e) {
|
||||
if (e == null) {
|
||||
return;
|
||||
}
|
||||
if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity());
|
||||
FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager());
|
||||
if (fme == null || dame == null) {
|
||||
return;
|
||||
}
|
||||
FLocation floc = new FLocation(fme.getPlayer().getLocation());
|
||||
if (Board.getInstance().getFactionAt(floc) == fme.getFaction()) {
|
||||
if (dame.getFaction() == fme.getFaction()) {
|
||||
return;
|
||||
}
|
||||
double damage = e.getDamage();
|
||||
int level = fme.getFaction().getUpgrade(UpgradeType.DAMAGEINCREASE);
|
||||
double increase = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.DamageIncrease.DamageIncreasePercent.level-" + level);
|
||||
e.setDamage(damage + damage / 100.0 * increase);
|
||||
}
|
||||
}
|
||||
}
|
@ -80,6 +80,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
private Map<UUID, Integer> playerWallCheckCount;
|
||||
private Map<UUID, Integer> playerBufferCheckCount;
|
||||
private boolean weeWoo;
|
||||
private int tntBankSize;
|
||||
private int warpLimit;
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -452,6 +454,33 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
bannerSerialized = banner.serialize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getWarpsLimit() {
|
||||
if (warpLimit == 0) {
|
||||
return FactionsPlugin.getInstance().getConfig().getInt("max-warps");
|
||||
}
|
||||
return warpLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarpsLimit(int warpLimit) {
|
||||
this.warpLimit = warpLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTntBankLimit() {
|
||||
if (tntBankSize == 0) {
|
||||
return FactionsPlugin.getInstance().getConfig().getInt("ftnt.Bank-Limit");
|
||||
}
|
||||
return tntBankSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTntBankLimit(int newLimit) {
|
||||
tntBankSize = newLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getBanner() {
|
||||
if (bannerSerialized == null) {
|
||||
|
@ -844,7 +844,7 @@ public enum TL {
|
||||
COMMAND_TNT_WIDTHDRAW_SUCCESS("&cSuccessfully withdrew tnt."),
|
||||
COMMAND_TNT_WIDTHDRAW_NOTENOUGH("&cNot enough tnt in bank."),
|
||||
COMMAND_TNT_DEPOSIT_NOTENOUGH("&cNot enough tnt in tnt inventory."),
|
||||
COMMAND_TNT_AMOUNT("&cYour faction has {amount} tnt in the tnt bank."),
|
||||
COMMAND_TNT_AMOUNT("&cYour faction has {amount} tnt out of {bankSize} in the tnt bank."),
|
||||
COMMAND_TNT_POSITIVE("&cPlease use positive numbers!"),
|
||||
COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"),
|
||||
COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE("&cNot enough space in your inventory."),
|
||||
|
@ -918,7 +918,7 @@ fupgrades:
|
||||
level-3: 3000000
|
||||
PowerItem:
|
||||
Name: '&c&lFaction Power'
|
||||
Type: DIAMOND_SWORD
|
||||
Type: NETHER_STAR
|
||||
Amount: 1
|
||||
Damage: 0
|
||||
Lore:
|
||||
@ -942,7 +942,7 @@ fupgrades:
|
||||
Redstone:
|
||||
Cost: 1000000
|
||||
RedstoneItem:
|
||||
Name: '&c&lUnbreakable Redstone'
|
||||
Name: '&c&lUnbreakable Redstone'
|
||||
Type: REDSTONE
|
||||
Amount: 1
|
||||
Damage: 0
|
||||
@ -988,6 +988,134 @@ fupgrades:
|
||||
- '&e&lClick to &nUnlock'
|
||||
slots:
|
||||
- 24
|
||||
DamageReduct:
|
||||
DamageReductPercent:
|
||||
level-1: 3
|
||||
level-2: 5
|
||||
level-3: 7
|
||||
Cost:
|
||||
level-1: 2000000
|
||||
level-2: 4000000
|
||||
level-3: 6000000
|
||||
ReduceItem:
|
||||
Name: '&c&lDamage Reduction Upgrade'
|
||||
Type: DIAMOND_CHESTPLATE
|
||||
Amount: 1
|
||||
Damage: 0
|
||||
Lore:
|
||||
- '&7Reduce the amount of damage taken'
|
||||
- '&7in your faction claims.'
|
||||
- ''
|
||||
- '&c&lTier'
|
||||
- '&f&l* &7Current Level: &3{level}/3'
|
||||
- ''
|
||||
- '&c&lPerks'
|
||||
- '&f&l* &7Level 1 - &7((&f-3% Damage Per Hit&7))'
|
||||
- '&7 - Cost: $2,000,000'
|
||||
- '&f&l* &7Level 2 - &7((&f-5% Damage Per Hit&7))'
|
||||
- '&7 - Cost: $4,000,000'
|
||||
- '&f&l* &7Level 3 - &7((&f-7% Damage Per Hit&7))'
|
||||
- '&7 - Cost: $6,000,000'
|
||||
- ''
|
||||
- '&e&lClick to &nUnlock'
|
||||
slots:
|
||||
- 0
|
||||
DamageIncrease:
|
||||
DamageIncreasePercent:
|
||||
level-1: 3
|
||||
level-2: 5
|
||||
level-3: 7
|
||||
Cost:
|
||||
level-1: 2000000
|
||||
level-2: 4000000
|
||||
level-3: 6000000
|
||||
IncreaseItem:
|
||||
Name: '&c&lDamage Increase Upgrade'
|
||||
Type: DIAMOND_SWORD
|
||||
Amount: 1
|
||||
Damage: 0
|
||||
Lore:
|
||||
- '&7Increase the amount of damage given'
|
||||
- '&7in your faction claims.'
|
||||
- ''
|
||||
- '&c&lTier'
|
||||
- '&f&l* &7Current Level: &3{level}/3'
|
||||
- ''
|
||||
- '&c&lPerks'
|
||||
- '&f&l* &7Level 1 - &7((&f+3% Damage Per Hit&7))'
|
||||
- '&7 - Cost: $2,000,000'
|
||||
- '&f&l* &7Level 2 - &7((&f+5% Damage Per Hit&7))'
|
||||
- '&7 - Cost: $4,000,000'
|
||||
- '&f&l* &7Level 3 - &7((&f+7% Damage Per Hit&7))'
|
||||
- '&7 - Cost: $6,000,000'
|
||||
- ''
|
||||
- '&e&lClick to &nUnlock'
|
||||
slots:
|
||||
- 8
|
||||
TNT:
|
||||
tnt-limit:
|
||||
level-1: 500000
|
||||
level-2: 1000000
|
||||
level-3: 2000000
|
||||
Cost:
|
||||
level-1: 2000000
|
||||
level-2: 4000000
|
||||
level-3: 6000000
|
||||
TntItem:
|
||||
Name: '&c&lTNT Bank Upgrade'
|
||||
Type: TNT
|
||||
Amount: 1
|
||||
Damage: 0
|
||||
Lore:
|
||||
- '&7Upgrade Your tnt bank limit,'
|
||||
- '&7to be eligible to store more tnt.'
|
||||
- ''
|
||||
- '&c&lTier'
|
||||
- '&f&l* &7Current Level: &3{level}/3'
|
||||
- ''
|
||||
- '&c&lPerks'
|
||||
- '&f&l* &7Level 1 - &f500,000 TNT'
|
||||
- '&7 - Cost: $2,000,000'
|
||||
- '&f&l* &7Level 2 - &f1,000,000 TNT'
|
||||
- '&7 - Cost: $4,000,000'
|
||||
- '&f&l* &7Level 3 - &f2,000,000 TNT'
|
||||
- '&7 - Cost: $6,000,000'
|
||||
- ''
|
||||
- '&e&lClick to &nUnlock'
|
||||
slots:
|
||||
- 36
|
||||
Warps:
|
||||
warp-limit:
|
||||
level-1: 3
|
||||
level-2: 4
|
||||
level-3: 5
|
||||
Cost:
|
||||
level-1: 1000000
|
||||
level-2: 2000000
|
||||
level-3: 3000000
|
||||
WarpItem:
|
||||
Name: '&c&lWarp Upgrade'
|
||||
Type: EYE_OF_ENDER
|
||||
Amount: 1
|
||||
Damage: 0
|
||||
Lore:
|
||||
- '&7Upgrade Your warp limit,'
|
||||
- '&7to be able to set more warps.'
|
||||
- ''
|
||||
- '&c&lTier'
|
||||
- '&f&l* &7Current Level: &3{level}/3'
|
||||
- ''
|
||||
- '&c&lPerks'
|
||||
- '&f&l* &7Level 1 - &f3 Warps'
|
||||
- '&7 - Cost: $1,000,000'
|
||||
- '&f&l* &7Level 2 - &f4 Warps'
|
||||
- '&7 - Cost: $2,000,000'
|
||||
- '&f&l* &7Level 3 - &f5 Warps'
|
||||
- '&7 - Cost: $3,000,000'
|
||||
- ''
|
||||
- '&e&lClick to &nUnlock'
|
||||
slots:
|
||||
- 44
|
||||
Chest:
|
||||
Chest-Size:
|
||||
# This is rows
|
||||
|
Loading…
Reference in New Issue
Block a user