Merge pull request #60 from GenialJerome/1.6.x

PowerRegenEvent and optimization
This commit is contained in:
Naman 2018-11-21 03:22:41 -06:00 committed by GitHub
commit eee6a014e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 281 additions and 401 deletions

View File

@ -28,8 +28,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>

View File

@ -446,7 +446,6 @@ class MassiveStatsDataRequest {
}
@SuppressWarnings ("unused")
final class MassiveStatsDataResponse {
private final boolean isUpToDate;

View File

@ -39,11 +39,13 @@ public class CmdChat extends FCommand {
if (modeString != null) {
modeString = modeString.toLowerCase();
// Only allow Mods and higher rank to switch to this channel.
if (modeString.startsWith("m") && fme.getRole().isAtLeast(Role.MODERATOR)) {
modeTarget = ChatMode.MOD;
} else if (modeString.startsWith("m") && !fme.getRole().isAtLeast(Role.MODERATOR)) {
msg(TL.COMMAND_CHAT_MOD_ONLY);
return;
if (modeString.startsWith("m")) {
if (!fme.getRole().isAtLeast(Role.MODERATOR))
{
msg(TL.COMMAND_CHAT_MOD_ONLY);
return;
}
else modeTarget = ChatMode.MOD;
} else if (modeString.startsWith("p")) {
modeTarget = ChatMode.PUBLIC;
} else if (modeString.startsWith("a")) {
@ -60,16 +62,13 @@ public class CmdChat extends FCommand {
fme.setChatMode(modeTarget);
if (fme.getChatMode() == ChatMode.MOD) {
msg(TL.COMMAND_CHAT_MODE_MOD);
} else if (fme.getChatMode() == ChatMode.PUBLIC) {
msg(TL.COMMAND_CHAT_MODE_PUBLIC);
} else if (fme.getChatMode() == ChatMode.ALLIANCE) {
msg(TL.COMMAND_CHAT_MODE_ALLIANCE);
} else if (fme.getChatMode() == ChatMode.TRUCE) {
msg(TL.COMMAND_CHAT_MODE_TRUCE);
} else {
msg(TL.COMMAND_CHAT_MODE_FACTION);
switch (fme.getChatMode())
{
case MOD: msg(TL.COMMAND_CHAT_MODE_MOD); break;
case PUBLIC: msg(TL.COMMAND_CHAT_MODE_PUBLIC); break;
case ALLIANCE: msg(TL.COMMAND_CHAT_MODE_ALLIANCE); break;
case TRUCE: msg(TL.COMMAND_CHAT_MODE_TRUCE); break;
default: msg(TL.COMMAND_CHAT_MODE_FACTION); break;
}
}

View File

@ -46,7 +46,7 @@ public class CmdList extends FCommand {
}
ArrayList<Faction> factionList = Factions.getInstance().getAllFactions();
factionList.remove(Factions.getInstance().getNone());
factionList.remove(Factions.getInstance().getWilderness());
factionList.remove(Factions.getInstance().getSafeZone());
factionList.remove(Factions.getInstance().getWarZone());
@ -94,7 +94,7 @@ public class CmdList extends FCommand {
ArrayList<String> lines = new ArrayList<>();
factionList.add(0, Factions.getInstance().getNone());
factionList.add(0, Factions.getInstance().getWilderness());
final int pageheight = 9;
int pagenumber = this.argAsInt(0, 1);

View File

@ -24,7 +24,6 @@ public class CmdPaypalSee extends FCommand {
fme.msg(TL.GENERIC_DISABLED);
} else {
Faction faction = argAsFaction(0);
String paypal = argAsString(1);
if (faction != null) {
if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) {

View File

@ -76,7 +76,7 @@ public class CmdSeeChunk extends FCommand {
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
@Override
public void run() {
Iterator itr = seeChunkMap.keySet().iterator();
Iterator<String> itr = seeChunkMap.keySet().iterator();
while (itr.hasNext()) {
Object nameObject = itr.next();
String name = nameObject + "";

View File

@ -46,9 +46,8 @@ public class CmdTnt extends FCommand {
if (args.size() == 2) {
if (args.get(0).equalsIgnoreCase("add") || args.get(0).equalsIgnoreCase("a")) {
int testNumber = - 1;
try {
testNumber = Integer.parseInt(args.get(1));
Integer.parseInt(args.get(1));
} catch (NumberFormatException e) {
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
return;
@ -87,9 +86,8 @@ public class CmdTnt extends FCommand {
}
if (args.get(0).equalsIgnoreCase("take") || args.get(0).equalsIgnoreCase("t")) {
int testNumber = - 1;
try {
testNumber = Integer.parseInt(args.get(1));
Integer.parseInt(args.get(1));
} catch (NumberFormatException e) {
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
return;

View File

@ -54,9 +54,9 @@ public class CmdTntFill extends FCommand {
msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", SavageFactions.plugin.getConfig().getInt("Tntfill.max-amount") + ""));
return;
}
int testNumber = - 1;
try {
testNumber = Integer.parseInt(args.get(1));
Integer.parseInt(args.get(1));
} catch (NumberFormatException e) {
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
return;
@ -124,9 +124,8 @@ public class CmdTntFill extends FCommand {
}
private void removeFromBank(int amount) {
int testNumber = - 1;
try {
testNumber = Integer.parseInt(args.get(1));
Integer.parseInt(args.get(1));
} catch (NumberFormatException e) {
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
return;

View File

@ -29,7 +29,6 @@ public class CmdTpBanner extends FCommand {
return;
}
final FactionsPlayerListener fpl = new FactionsPlayerListener(SavageFactions.plugin);
if (FactionsBlockListener.bannerLocations.containsKey(fme.getTag())) {

View File

@ -15,7 +15,7 @@ import java.util.List;
public abstract class FCommand extends MCommand<SavageFactions> {
public SimpleDateFormat sdf = new SimpleDateFormat(TL.DATE_FORMAT.toString());
public static final SimpleDateFormat sdf = new SimpleDateFormat(TL.DATE_FORMAT.toString());
public boolean disableOnLock;

View File

@ -69,11 +69,6 @@ public class FPromoteCommand extends FCommand {
return;
}
if (promotion == null) {
fme.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER);
return;
}
// Don't allow people to promote people to their same or higher rnak.
if (fme.getRole().value <= promotion.value) {
fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);

View File

@ -8,7 +8,7 @@ import com.massivecraft.factions.Faction;
*/
public class FactionPlayerEvent extends FactionEvent {
private final FPlayer fPlayer;
protected final FPlayer fPlayer;
public FactionPlayerEvent(Faction faction, FPlayer fPlayer) {
super(faction);

View File

@ -0,0 +1,29 @@
package com.massivecraft.factions.event;
import org.bukkit.event.Cancellable;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
/**
* Event called when a player regenerate power.
*/
public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable {
private boolean cancelled = false;
public PowerRegenEvent(Faction f, FPlayer p) {
super(f, p);
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean c) {
this.cancelled = c;
}
}

View File

@ -1,13 +1,18 @@
package com.massivecraft.factions.integration;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Teleport;
import com.earth2me.essentials.Trade;
import com.massivecraft.factions.Conf;
import net.ess3.api.IEssentials;
import java.math.BigDecimal;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.plugin.Plugin;
public class Essentials {
@ -28,9 +33,9 @@ public class Essentials {
}
Teleport teleport = essentials.getUser(player).getTeleport();
Trade trade = new Trade(Conf.econCostHome, essentials);
Trade trade = new Trade(new BigDecimal(Conf.econCostHome), essentials);
try {
teleport.teleport(loc, trade);
teleport.teleport(loc, trade, TeleportCause.PLUGIN);
} catch (Exception e) {
player.sendMessage(ChatColor.RED.toString() + e.getMessage());
}

View File

@ -54,7 +54,8 @@ public class Worldguard {
// Returns:
// True: PVP is allowed
// False: PVP is disallowed
public static boolean isPVP(Player player) {
@SuppressWarnings("deprecation")
public static boolean isPVP(Player player) {
if (!enabled) {
// No WG hooks so we'll always bypass this check.
return true;

View File

@ -40,13 +40,12 @@ public class EngineDynmap {
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static EngineDynmap i = new EngineDynmap();
private static final EngineDynmap i = new EngineDynmap();
public DynmapAPI dynmapApi;
public MarkerAPI markerApi;
public MarkerSet markerset;
private EngineDynmap() {
}
private EngineDynmap() {}
public static EngineDynmap getInstance() {
return i;
@ -64,10 +63,7 @@ public class EngineDynmap {
}
public static String getHtmlPlayerName(FPlayer fplayer) {
if (fplayer == null) {
return "none";
}
return escapeHtml(fplayer.getName());
return fplayer != null ? escapeHtml(fplayer.getName()):"none";
}
public static String escapeHtml(String string) {
@ -75,9 +71,9 @@ public class EngineDynmap {
for (int i = 0; i < string.length(); i++) {
char c = string.charAt(i);
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
out.append("&#");
out.append((int) c);
out.append(';');
out.append("&#")
.append((int) c)
.append(';');
} else {
out.append(c);
}
@ -87,8 +83,7 @@ public class EngineDynmap {
// Thread Safe / Asynchronous: Yes
public static void info(String msg) {
String message = DYNMAP_INTEGRATION + msg;
System.out.println(message);
System.out.println(DYNMAP_INTEGRATION + msg);
}
// -------------------------------------------- //
@ -97,8 +92,7 @@ public class EngineDynmap {
// Thread Safe / Asynchronous: Yes
public static void severe(String msg) {
String message = DYNMAP_INTEGRATION + ChatColor.RED.toString() + msg;
System.out.println(message);
System.out.println(DYNMAP_INTEGRATION + ChatColor.RED.toString() + msg);
}
public void init() {

View File

@ -163,6 +163,7 @@ public class FactionsPlayerListener implements Listener {
return true;
}
@SuppressWarnings("deprecation")
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) {
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) {
return true;
@ -180,7 +181,6 @@ public class FactionsPlayerListener implements Listener {
Faction myFaction = me.getFaction();
Relation rel = myFaction.getRelationTo(otherFaction);
// no door/chest/whatever protection in wilderness, war zones, or safe zones
if (!otherFaction.isNormal()) {
return true;
@ -915,13 +915,13 @@ public class FactionsPlayerListener implements Listener {
// returns the current attempt count
public int increment() {
long Now = System.currentTimeMillis();
if (Now > lastAttempt + 2000) {
long now = System.currentTimeMillis();
if (now > lastAttempt + 2000) {
attempts = 1;
} else {
attempts++;
}
lastAttempt = Now;
lastAttempt = now;
return attempts;
}
}

View File

@ -95,17 +95,15 @@ public enum Relation implements Permissable {
}
public ChatColor getColor() {
if (this == MEMBER) {
return Conf.colorMember;
} else if (this == ALLY) {
return Conf.colorAlly;
} else if (this == NEUTRAL) {
return Conf.colorNeutral;
} else if (this == TRUCE) {
return Conf.colorTruce;
} else {
return Conf.colorEnemy;
}
switch (this)
{
case MEMBER: return Conf.colorMember;
case ALLY: return Conf.colorAlly;
case NEUTRAL: return Conf.colorNeutral;
case TRUCE: return Conf.colorTruce;
default: return Conf.colorEnemy;
}
}
// return appropriate Conf setting for DenyBuild based on this relation and their online status

View File

@ -92,23 +92,15 @@ public enum Role implements Permissable {
}
public String getPrefix() {
if (this == Role.LEADER) {
return Conf.prefixLeader;
}
if (this == Role.COLEADER) {
return Conf.prefixCoLeader;
}
if (this == Role.MODERATOR) {
return Conf.prefixMod;
}
if (this == Role.NORMAL) {
return Conf.prefixNormal;
}
if (this == Role.RECRUIT) {
return Conf.prefixRecruit;
}
switch (this)
{
case LEADER: return Conf.prefixLeader;
case COLEADER: return Conf.prefixCoLeader;
case MODERATOR: return Conf.prefixMod;
case NORMAL: return Conf.prefixNormal;
case RECRUIT: return Conf.prefixRecruit;
}
return "";
}

View File

@ -107,18 +107,15 @@ public enum PermissableAction {
ItemStack item = new ItemStack(material);
ItemMeta itemMeta = item.getItemMeta();
String accessValue = null;
if (access.equals(Access.ALLOW)) {
accessValue = "allow";
} else if (access.equals(Access.DENY)) {
accessValue = "deny";
} else if (access.equals(Access.UNDEFINED)) {
accessValue = "undefined";
switch (access)
{
case ALLOW: accessValue = "allow"; break;
case DENY: accessValue = "deny"; break;
case UNDEFINED: accessValue = "undefined"; break;
}
// If under the 1.13 version we will use the colorable option.
if (!SavageFactions.plugin.mc113) {
DyeColor dyeColor = null;

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.*;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockGrowEvent;
@ -46,9 +47,6 @@ public class CropUpgrades implements Listener {
private void growCrop(BlockGrowEvent e) {
Material CROPS;
if (e.getBlock().getType().equals(SavageFactions.plugin.CROPS)) {
e.setCancelled(true);
Crops c = new Crops(CropState.RIPE);
@ -56,21 +54,18 @@ public class CropUpgrades implements Listener {
bs.setData(c);
bs.update();
}
org.bukkit.block.Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock();
Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock();
if (below.getType() == SavageFactions.plugin.SUGAR_CANE_BLOCK) {
org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
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(SavageFactions.plugin.SUGAR_CANE_BLOCK);
}
}
if (below.getType() == Material.CACTUS) {
org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
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);

View File

@ -12,14 +12,15 @@ public class EXPUpgrade implements Listener {
@EventHandler
public void onDeath(EntityDeathEvent e) {
Entity killer = e.getEntity().getKiller();
Player player = (Player) killer;
if (player == null) {
if (killer == null || !(killer instanceof Player))
return;
}
Location loc = e.getEntity().getLocation();
Faction wild = Factions.getInstance().getWilderness();
FLocation floc = new FLocation(loc);
Faction faction = Board.getInstance().getFactionAt(floc);
if (faction != wild) {
int level = faction.getUpgrade("Exp");
if (level != 0) {
@ -41,7 +42,6 @@ public class EXPUpgrade implements Listener {
private void spawnMoreExp(EntityDeathEvent e, double multiplier) {
double newExp = e.getDroppedExp() * multiplier;
int newExpInt = (int) newExp;
e.setDroppedExp(newExpInt);
e.setDroppedExp((int) newExp);
}
}

View File

@ -31,40 +31,37 @@ public class FUpgradesGUI implements Listener {
dummyData,
SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.DummyItem.Name")),
SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.DummyItem.Lore")));
for (int i = 0; i <= dummySlots.size() - 1; i++) {
inventory.setItem(dummySlots.get(i), dummyItem);
}
ItemStack[] items = buildItems(fme);
List<Integer> cropSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Crops.CropItem.slots");
List<Integer> spawnerSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Spawners.SpawnerItem.slots");
List<Integer> expSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.EXP.EXPItem.slots");
List<Integer> chestSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Chest.ChestItem.slots");
for (int i = 0; i <= cropSlots.size() - 1; i++) {
for (int i = 0; i < cropSlots.size(); i++)
inventory.setItem(cropSlots.get(i), items[2]);
}
for (int i = 0; i <= spawnerSlots.size() - 1; i++) {
for (int i = 0; i < spawnerSlots.size(); i++)
inventory.setItem(spawnerSlots.get(i), items[1]);
}
for (int i = 0; i <= expSlots.size() - 1; i++) {
for (int i = 0; i < expSlots.size(); i++)
inventory.setItem(expSlots.get(i), items[0]);
}
for (int i = 0; i <= chestSlots.size() - 1; i++) {
for (int i = 0; i < chestSlots.size(); i++)
inventory.setItem(chestSlots.get(i), items[3]);
}
fme.getPlayer().openInventory(inventory);
}
@EventHandler
public void onClick(InventoryClickEvent e) {
if (e.getClickedInventory() == null || e.getCurrentItem() == null || e.getCurrentItem().getItemMeta() == null || e.getCursor() == null) {
if (e.getClickedInventory() == null || e.getCurrentItem() == null || e.getCurrentItem().getItemMeta() == null || e.getCursor() == null)
return;
}
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (e.getClickedInventory().getTitle().equalsIgnoreCase(SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", fme.getFaction().getTag())))) {
e.setCancelled(true);
@ -73,170 +70,88 @@ public class FUpgradesGUI implements Listener {
ItemStack expItem = items[0];
ItemStack chestitem = items[3];
ItemStack spawnerItem = items[1];
int cropLevel = fme.getFaction().getUpgrade("Crop");
if (e.getCurrentItem().equals(cropItem)) {
if (cropLevel == 3) {
return;
}
if (cropLevel == 2) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3");
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrades("Crop", 3);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
}
}
if (cropLevel == 1) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-2");
if (hasMoney(fme, cost)) {
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Crop", 2);
fme.getPlayer().closeInventory();
}
}
if (cropLevel == 0) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-1");
if (hasMoney(fme, cost)) {
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Crop", 1);
fme.getPlayer().closeInventory();
}
}
int cropLevel = fme.getFaction().getUpgrade("Crop");
switch (cropLevel)
{
case 3: return;
case 2: upgradeItem(fme, "Crop", 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3")); break;
case 1: upgradeItem(fme, "Crop", 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-2")); break;
case 0: upgradeItem(fme, "Crop", 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-1")); break;
}
}
int spawnerLevel = fme.getFaction().getUpgrade("Spawner");
if (e.getCurrentItem().equals(spawnerItem)) {
if (spawnerLevel == 3) {
return;
}
if (spawnerLevel == 2) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3");
if (!hasMoney(fme, cost)) {
return;
}
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Spawner", 3);
fme.getPlayer().closeInventory();
}
if (spawnerLevel == 1) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-2");
if (!hasMoney(fme, cost)) {
return;
}
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Spawner", 2);
fme.getPlayer().closeInventory();
}
if (spawnerLevel == 0) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-1");
if (!hasMoney(fme, cost)) {
return;
}
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Spawner", 1);
fme.getPlayer().closeInventory();
}
else if (e.getCurrentItem().equals(spawnerItem)) {
int spawnerLevel = fme.getFaction().getUpgrade("Spawner");
switch(spawnerLevel)
{
case 3: return;
case 2: upgradeItem(fme, "Spawner", 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3")); break;
case 1: upgradeItem(fme, "Spawner", 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-2")); break;
case 0: upgradeItem(fme, "Spawner", 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-1")); break;
}
}
int expLevel = fme.getFaction().getUpgrade("Exp");
if (e.getCurrentItem().equals(expItem)) {
if (expLevel == 3) {
return;
}
if (expLevel == 2) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3");
if (!hasMoney(fme, cost)) {
return;
}
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Exp", 3);
fme.getPlayer().closeInventory();
}
if (expLevel == 1) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-2");
if (!hasMoney(fme, cost)) {
return;
}
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Exp", 2);
fme.getPlayer().closeInventory();
}
if (expLevel == 0) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-1");
if (!hasMoney(fme, cost)) {
return;
}
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Exp", 1);
fme.getPlayer().closeInventory();
}
else if (e.getCurrentItem().equals(expItem)) {
int expLevel = fme.getFaction().getUpgrade("Exp");
switch (expLevel)
{
case 3: return;
case 2: upgradeItem(fme, "Exp", 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3")); break;
case 1: upgradeItem(fme, "Exp", 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-2")); break;
case 0: upgradeItem(fme, "Exp", 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-1")); break;
}
}
int chestLevel = fme.getFaction().getUpgrade("Chest");
if (e.getCurrentItem().equals(chestitem)) {
if (chestLevel == 3) {
return;
}
if (chestLevel == 2) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3");
if (!hasMoney(fme, cost)) {
return;
}
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Chest", 3);
updateChests(fme.getFaction());
fme.getPlayer().closeInventory();
}
if (chestLevel == 1) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2");
if (!hasMoney(fme, cost)) {
return;
}
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Chest", 2);
updateChests(fme.getFaction());
fme.getPlayer().closeInventory();
}
if (chestLevel == 0) {
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-1");
if (!hasMoney(fme, cost)) {
return;
}
takeMoney(fme, cost);
fme.getFaction().setUpgrades("Chest", 1);
updateChests(fme.getFaction());
fme.getPlayer().closeInventory();
}
else if (e.getCurrentItem().equals(chestitem)) {
int chestLevel = fme.getFaction().getUpgrade("Chest");
switch (chestLevel)
{
case 3: return;
case 2:
{
if (upgradeItem(fme, "Chest", 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3")))
updateChests(fme.getFaction());
break;
}
case 1:
{
if (upgradeItem(fme, "Chest", 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2")))
updateChests(fme.getFaction());
break;
}
case 0:
{
if (upgradeItem(fme, "Chest", 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-1")))
updateChests(fme.getFaction());
break;
}
}
}
}
}
private void updateChests(Faction faction) {
String invName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fchest.Inventory-Title"));
for (Player player : faction.getOnlinePlayers()) {
if (player.getInventory().getTitle() == null) {
return;
}
String invName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fchest.Inventory-Title"));
if (player.getInventory().getTitle().equalsIgnoreCase(invName)) {
player.closeInventory();
}
if (player.getInventory().getTitle() != null && player.getInventory().getTitle().equalsIgnoreCase(invName))
player.closeInventory();
}
int level = faction.getUpgrade("Chest");
int size = 9;
if (level == 1) {
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1") * 9;
} else if (level == 2) {
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2") * 9;
} else if (level == 3) {
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3") * 9;
int size = 1;
switch (level)
{
case 1: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1"); break;
case 2: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2"); break;
case 3: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3"); break;
}
faction.setChestSize(size);
faction.setChestSize(size * 9);
}
private ItemStack[] buildItems(FPlayer fme) {
@ -246,19 +161,21 @@ public class FUpgradesGUI implements Listener {
String expName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Name"));
List<String> expLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.EXP.EXPItem.Lore"));
int expLevel = fme.getFaction().getUpgrade("Exp");
for (int i = 0; i <= expLore.size() - 1; i++) {
for (int i = 0; i <= expLore.size() - 1; i++)
expLore.set(i, expLore.get(i).replace("{level}", expLevel + ""));
}
ItemStack expItem = SavageFactions.plugin.createItem(expMaterial, expAmt, expData, expName, expLore);
if (expLevel >= 1) {
ItemMeta itemMeta = expItem.getItemMeta();
if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
expItem.setItemMeta(itemMeta);
expItem.setAmount(expLevel);
}
Material spawnerMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Type"));
@ -273,25 +190,23 @@ public class FUpgradesGUI implements Listener {
for (int i = 0; i <= spawnerLore.size() - 1; i++) {
spawnerLore.set(i, spawnerLore.get(i).replace("{level}", spawnerLevel + ""));
}
if (expLevel == 2) {
expItem.setAmount(2);
} else if (expLevel == 3) {
expItem.setAmount(3);
}
Material cropMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Type"));
int cropAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Amount");
short cropData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Damage") + "");
String cropName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Name"));
List<String> cropLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Crops.CropItem.Lore"));
int cropLevel = fme.getFaction().getUpgrade("Crop");
for (int i = 0; i <= cropLore.size() - 1; i++) {
String line = cropLore.get(i);
line = line.replace("{level}", cropLevel + "");
cropLore.set(i, line);
}
ItemStack cropItem = SavageFactions.plugin.createItem(cropMaterial, cropAmt, cropData, cropName, cropLore);
cropItem.getItemMeta().setLore(cropLore);
if (cropLevel >= 1) {
ItemMeta itemMeta = cropItem.getItemMeta();
if (!SavageFactions.plugin.mc17) {
@ -299,12 +214,10 @@ public class FUpgradesGUI implements Listener {
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
cropItem.setItemMeta(itemMeta);
cropItem.setAmount(cropLevel);
}
if (cropLevel == 2) {
cropItem.setAmount(2);
} else if (cropLevel == 3) {
cropItem.setAmount(3);
}
ItemStack spawnerItem = SavageFactions.plugin.createItem(spawnerMaterial, spawnerAmt, spawnerData, spawnerName, spawnerLore);
spawnerItem.getItemMeta().setLore(spawnerLore);
if (spawnerLevel >= 1) {
@ -313,24 +226,22 @@ public class FUpgradesGUI implements Listener {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
spawnerItem.setItemMeta(itemMeta);
spawnerItem.setAmount(spawnerLevel);
}
if (spawnerLevel == 2) {
spawnerItem.setAmount(2);
} else if (spawnerLevel == 3) {
spawnerItem.setAmount(3);
}
Material chestMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Type"));
int chesttAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Amount");
short chestData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Damage") + "");
String chestName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Name", "&e&lUpgrade Chest Size"));
List<String> chestLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Chest.ChestItem.Lore"));
int chestlevel = fme.getFaction().getUpgrade("Chest");
for (int i = 0; i <= chestLore.size() - 1; i++) {
String line = chestLore.get(i);
line = line.replace("{level}", chestlevel + "");
chestLore.set(i, line);
}
ItemStack chestItem = SavageFactions.plugin.createItem(chestMaterial, chesttAmt, chestData, chestName, chestLore);
@ -341,14 +252,10 @@ public class FUpgradesGUI implements Listener {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
chestItem.setItemMeta(itemMeta);
chestItem.setAmount(chestlevel);
}
if (chestlevel == 2) {
chestItem.setAmount(2);
} else if (chestlevel == 3) {
chestItem.setAmount(3);
}
ItemStack[] items = {expItem, spawnerItem, cropItem, chestItem};
return items;
@ -361,4 +268,15 @@ public class FUpgradesGUI implements Listener {
private void takeMoney(FPlayer fme, int amt) {
fme.takeMoney(amt);
}
private boolean upgradeItem(FPlayer fme, String upgrade, int level, int cost)
{
if (hasMoney(fme, cost)) {
takeMoney(fme, cost);
fme.getFaction().setUpgrades(upgrade, level);
fme.getPlayer().closeInventory();
return true;
}
return false;
}
}

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.SpawnerSpawnEvent;
@ -10,22 +11,16 @@ public class SpawnerUpgrades implements Listener {
public void onSpawn(SpawnerSpawnEvent e) {
FLocation floc = new FLocation(e.getLocation());
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
if (factionAtLoc != Factions.getInstance().getWilderness()) {
if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade("Spawner");
if (level != 0) {
if (level == 1) {
int rate = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-1");
lowerSpawnerDelay(e, rate);
}
if (level == 2) {
int rate = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-2");
lowerSpawnerDelay(e, rate);
}
if (level == 3) {
int rate = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-3");
lowerSpawnerDelay(e, rate);
}
switch (level)
{
case 1: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-1")); break;
case 2: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-2")); break;
case 3: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-3")); break;
}
}
}
}

View File

@ -70,7 +70,6 @@ public class NBTList {
return null;
}
@SuppressWarnings ("unchecked")
public void addString(String s) {
if (type != NBTType.NBTTagString) {
new Throwable("Using String method on a non String list!").printStackTrace();
@ -85,7 +84,6 @@ public class NBTList {
}
}
@SuppressWarnings ("unchecked")
public void setString(int i, String s) {
if (type != NBTType.NBTTagString) {
new Throwable("Using String method on a non String list!").printStackTrace();

View File

@ -21,11 +21,10 @@ public class NBTReflectionUtil {
private static final String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
@SuppressWarnings ("rawtypes")
private static Class getCraftItemStack() {
private static Class<?> getCraftItemStack() {
try {
Class clazz = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
Class<?> clazz = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
return clazz;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -34,10 +33,9 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("rawtypes")
private static Class getCraftEntity() {
private static Class<?> getCraftEntity() {
try {
Class clazz = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftEntity");
Class<?> clazz = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftEntity");
return clazz;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -46,10 +44,9 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("rawtypes")
protected static Class getNBTBase() {
protected static Class<?> getNBTBase() {
try {
Class clazz = Class.forName("net.minecraft.server." + version + ".NBTBase");
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".NBTBase");
return clazz;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -58,10 +55,9 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("rawtypes")
protected static Class getNBTTagString() {
protected static Class<?> getNBTTagString() {
try {
Class clazz = Class.forName("net.minecraft.server." + version + ".NBTTagString");
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".NBTTagString");
return clazz;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -70,10 +66,9 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("rawtypes")
protected static Class getNMSItemStack() {
protected static Class<?> getNMSItemStack() {
try {
Class clazz = Class.forName("net.minecraft.server." + version + ".ItemStack");
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".ItemStack");
return clazz;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -82,10 +77,9 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("rawtypes")
protected static Class getNBTTagCompound() {
protected static Class<?> getNBTTagCompound() {
try {
Class clazz = Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
return clazz;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -94,10 +88,9 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("rawtypes")
protected static Class getNBTCompressedStreamTools() {
protected static Class<?> getNBTCompressedStreamTools() {
try {
Class clazz = Class.forName("net.minecraft.server." + version + ".NBTCompressedStreamTools");
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".NBTCompressedStreamTools");
return clazz;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -106,10 +99,9 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("rawtypes")
protected static Class getMojangsonParser() {
protected static Class<?> getMojangsonParser() {
try {
Class c = Class.forName("net.minecraft.server." + version + ".MojangsonParser");
Class<?> c = Class.forName("net.minecraft.server." + version + ".MojangsonParser");
return c;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -118,10 +110,9 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("rawtypes")
protected static Class getTileEntity() {
protected static Class<?> getTileEntity() {
try {
Class clazz = Class.forName("net.minecraft.server." + version + ".TileEntity");
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".TileEntity");
return clazz;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -130,10 +121,9 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("rawtypes")
protected static Class getCraftWorld() {
protected static Class<?> getCraftWorld() {
try {
Class clazz = Class.forName("org.bukkit.craftbukkit." + version + ".CraftWorld");
Class<?> clazz = Class.forName("org.bukkit.craftbukkit." + version + ".CraftWorld");
return clazz;
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -145,8 +135,7 @@ public class NBTReflectionUtil {
public static Object getNewNBTTag() {
String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
try {
@SuppressWarnings ("rawtypes")
Class c = Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
Class<?> c = Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
return c.newInstance();
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -158,8 +147,7 @@ public class NBTReflectionUtil {
private static Object getNewBlockPosition(int x, int y, int z) {
String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
try {
@SuppressWarnings ("rawtypes")
Class clazz = Class.forName("net.minecraft.server." + version + ".BlockPosition");
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".BlockPosition");
return clazz.getConstructor(int.class, int.class, int.class).newInstance(x, y, z);
} catch (Exception ex) {
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
@ -180,10 +168,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ("unchecked")
public static Object getNMSItemStack(ItemStack item) {
@SuppressWarnings ("rawtypes")
Class clazz = getCraftItemStack();
Class<?> clazz = getCraftItemStack();
Method method;
try {
method = clazz.getMethod("asNMSCopy", ItemStack.class);
@ -195,10 +181,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ("unchecked")
public static Object getNMSEntity(Entity entity) {
@SuppressWarnings ("rawtypes")
Class clazz = getCraftEntity();
Class<?> clazz = getCraftEntity();
Method method;
try {
method = clazz.getMethod("getHandle");
@ -209,10 +193,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ({"unchecked"})
public static Object parseNBT(String json) {
@SuppressWarnings ("rawtypes")
Class cis = getMojangsonParser();
Class<?> cis = getMojangsonParser();
Method method;
try {
method = cis.getMethod("parse", String.class);
@ -223,10 +205,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ({"unchecked"})
public static Object readNBTFile(FileInputStream stream) {
@SuppressWarnings ("rawtypes")
Class clazz = getNBTCompressedStreamTools();
Class<?> clazz = getNBTCompressedStreamTools();
Method method;
try {
method = clazz.getMethod("a", InputStream.class);
@ -237,10 +217,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ({"unchecked"})
public static Object saveNBTFile(Object nbt, FileOutputStream stream) {
@SuppressWarnings ("rawtypes")
Class clazz = getNBTCompressedStreamTools();
Class<?> clazz = getNBTCompressedStreamTools();
Method method;
try {
method = clazz.getMethod("a", getNBTTagCompound(), OutputStream.class);
@ -251,10 +229,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ({"unchecked"})
public static ItemStack getBukkitItemStack(Object item) {
@SuppressWarnings ("rawtypes")
Class clazz = getCraftItemStack();
Class<?> clazz = getCraftItemStack();
Method method;
try {
method = clazz.getMethod("asCraftMirror", item.getClass());
@ -266,10 +242,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ({"unchecked"})
public static Object getItemRootNBTTagCompound(Object nmsitem) {
@SuppressWarnings ("rawtypes")
Class clazz = nmsitem.getClass();
Class<?> clazz = nmsitem.getClass();
Method method;
try {
method = clazz.getMethod("getTag");
@ -281,10 +255,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ({"unchecked"})
public static Object convertNBTCompoundtoNMSItem(NBTCompound nbtcompound) {
@SuppressWarnings ("rawtypes")
Class clazz = getNMSItemStack();
Class<?> clazz = getNMSItemStack();
try {
Object nmsstack = clazz.getConstructor(getNBTTagCompound()).newInstance(gettoCompount(nbtcompound.getCompound(), nbtcompound));
return nmsstack;
@ -294,10 +266,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ({"unchecked"})
public static NBTContainer convertNMSItemtoNBTCompound(Object nmsitem) {
@SuppressWarnings ("rawtypes")
Class clazz = nmsitem.getClass();
Class<?> clazz = nmsitem.getClass();
Method method;
try {
method = clazz.getMethod("save", getNBTTagCompound());
@ -309,10 +279,8 @@ public class NBTReflectionUtil {
return null;
}
@SuppressWarnings ({"unchecked"})
public static Object getEntityNBTTagCompound(Object nmsitem) {
@SuppressWarnings ("rawtypes")
Class c = nmsitem.getClass();
Class<?> c = nmsitem.getClass();
Method method;
try {
method = c.getMethod(MethodNames.getEntityNbtGetterMethodName(), getNBTTagCompound());
@ -372,11 +340,8 @@ public class NBTReflectionUtil {
}
}
@SuppressWarnings ("unchecked")
public static Object getSubNBTTagCompound(Object compound, String name) {
@SuppressWarnings ("rawtypes")
Class c = compound.getClass();
Class<?> c = compound.getClass();
Method method;
try {
method = c.getMethod("getCompound", String.class);

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.event.FPlayerStoppedFlying;
import com.massivecraft.factions.event.LandClaimEvent;
import com.massivecraft.factions.event.PowerRegenEvent;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.integration.Econ;
@ -555,8 +556,14 @@ public abstract class MemoryFPlayer implements FPlayer {
return; // don't let dead players regain power until they respawn
}
int millisPerMinute = 60 * 1000;
this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute);
PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this);
Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent);
if (!powerRegenEvent.isCancelled())
{
int millisPerMinute = 60 * 1000;
this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute);
}
}
public void losePowerFromBeingOffline() {
@ -1124,7 +1131,6 @@ public abstract class MemoryFPlayer implements FPlayer {
if (!this.canClaimForFactionAtLocation(forFaction, flocation, notifyFailure)) {
return false;
}
@ -1189,21 +1195,16 @@ public abstract class MemoryFPlayer implements FPlayer {
@Override
public String getRolePrefix() {
if (getRole() == Role.RECRUIT) {
return Conf.prefixRecruit;
}
if (getRole() == Role.NORMAL) {
return Conf.prefixNormal;
}
if (getRole() == Role.MODERATOR) {
return Conf.prefixMod;
}
if (getRole() == Role.COLEADER) {
return Conf.prefixCoLeader;
}
if (getRole() == Role.LEADER) {
return Conf.prefixLeader;
}
switch (getRole())
{
case RECRUIT: return Conf.prefixRecruit;
case NORMAL: return Conf.prefixNormal;
case MODERATOR: return Conf.prefixMod;
case COLEADER: return Conf.prefixCoLeader;
case LEADER: return Conf.prefixLeader;
}
return null;
}

View File

@ -121,7 +121,7 @@ public enum TagReplacer {
case TOTAL_ONLINE:
return String.valueOf(Bukkit.getOnlinePlayers().size());
case FACTIONLESS:
return String.valueOf(Factions.getInstance().getNone().getFPlayersWhereOnline(true).size());
return String.valueOf(Factions.getInstance().getWilderness().getFPlayersWhereOnline(true).size());
case MAX_ALLIES:
if (SavageFactions.plugin.getConfig().getBoolean("max-relations.enabled", true)) {
return String.valueOf(SavageFactions.plugin.getConfig().getInt("max-relations.ally", 10));
@ -139,6 +139,7 @@ public enum TagReplacer {
return TL.GENERIC_INFINITY.toString();
case MAX_WARPS:
return String.valueOf(SavageFactions.plugin.getConfig().getInt("max-warps", 5));
default:
}
return null;
}
@ -180,6 +181,7 @@ public enum TagReplacer {
return String.valueOf(fp.getKills());
case PLAYER_DEATHS:
return String.valueOf(fp.getDeaths());
default:
}
}
switch (this) {
@ -252,6 +254,7 @@ public enum TagReplacer {
return String.valueOf(fac.getDeaths());
case FACTION_BANCOUNT:
return String.valueOf(fac.getBannedPlayers().size());
default:
}
return null;
}

View File

@ -232,6 +232,7 @@ public class TagUtil {
}
fancyMessages.add(currentOffline);
return firstOffline && minimal ? null : fancyMessages; // we must return here and not outside the switch
default:
}
return null;
}