PowerRegenEvent and optimization
- Add power regeneration event - Change getNone(), a deprecated method, to getWilderness() - Optimization
This commit is contained in:
parent
ff6a3b2b1a
commit
5f8ea0bd19
4
pom.xml
4
pom.xml
@ -28,8 +28,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -446,7 +446,6 @@ class MassiveStatsDataRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ("unused")
|
|
||||||
final class MassiveStatsDataResponse {
|
final class MassiveStatsDataResponse {
|
||||||
|
|
||||||
private final boolean isUpToDate;
|
private final boolean isUpToDate;
|
||||||
|
@ -39,11 +39,13 @@ public class CmdChat extends FCommand {
|
|||||||
if (modeString != null) {
|
if (modeString != null) {
|
||||||
modeString = modeString.toLowerCase();
|
modeString = modeString.toLowerCase();
|
||||||
// Only allow Mods and higher rank to switch to this channel.
|
// Only allow Mods and higher rank to switch to this channel.
|
||||||
if (modeString.startsWith("m") && fme.getRole().isAtLeast(Role.MODERATOR)) {
|
if (modeString.startsWith("m")) {
|
||||||
modeTarget = ChatMode.MOD;
|
if (!fme.getRole().isAtLeast(Role.MODERATOR))
|
||||||
} else if (modeString.startsWith("m") && !fme.getRole().isAtLeast(Role.MODERATOR)) {
|
{
|
||||||
msg(TL.COMMAND_CHAT_MOD_ONLY);
|
msg(TL.COMMAND_CHAT_MOD_ONLY);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
else modeTarget = ChatMode.MOD;
|
||||||
} else if (modeString.startsWith("p")) {
|
} else if (modeString.startsWith("p")) {
|
||||||
modeTarget = ChatMode.PUBLIC;
|
modeTarget = ChatMode.PUBLIC;
|
||||||
} else if (modeString.startsWith("a")) {
|
} else if (modeString.startsWith("a")) {
|
||||||
@ -60,16 +62,13 @@ public class CmdChat extends FCommand {
|
|||||||
|
|
||||||
fme.setChatMode(modeTarget);
|
fme.setChatMode(modeTarget);
|
||||||
|
|
||||||
if (fme.getChatMode() == ChatMode.MOD) {
|
switch (fme.getChatMode())
|
||||||
msg(TL.COMMAND_CHAT_MODE_MOD);
|
{
|
||||||
} else if (fme.getChatMode() == ChatMode.PUBLIC) {
|
case MOD: msg(TL.COMMAND_CHAT_MODE_MOD); break;
|
||||||
msg(TL.COMMAND_CHAT_MODE_PUBLIC);
|
case PUBLIC: msg(TL.COMMAND_CHAT_MODE_PUBLIC); break;
|
||||||
} else if (fme.getChatMode() == ChatMode.ALLIANCE) {
|
case ALLIANCE: msg(TL.COMMAND_CHAT_MODE_ALLIANCE); break;
|
||||||
msg(TL.COMMAND_CHAT_MODE_ALLIANCE);
|
case TRUCE: msg(TL.COMMAND_CHAT_MODE_TRUCE); break;
|
||||||
} else if (fme.getChatMode() == ChatMode.TRUCE) {
|
default: msg(TL.COMMAND_CHAT_MODE_FACTION); break;
|
||||||
msg(TL.COMMAND_CHAT_MODE_TRUCE);
|
|
||||||
} else {
|
|
||||||
msg(TL.COMMAND_CHAT_MODE_FACTION);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class CmdList extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Faction> factionList = Factions.getInstance().getAllFactions();
|
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().getSafeZone());
|
||||||
factionList.remove(Factions.getInstance().getWarZone());
|
factionList.remove(Factions.getInstance().getWarZone());
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public class CmdList extends FCommand {
|
|||||||
|
|
||||||
ArrayList<String> lines = new ArrayList<>();
|
ArrayList<String> lines = new ArrayList<>();
|
||||||
|
|
||||||
factionList.add(0, Factions.getInstance().getNone());
|
factionList.add(0, Factions.getInstance().getWilderness());
|
||||||
|
|
||||||
final int pageheight = 9;
|
final int pageheight = 9;
|
||||||
int pagenumber = this.argAsInt(0, 1);
|
int pagenumber = this.argAsInt(0, 1);
|
||||||
|
@ -24,7 +24,6 @@ public class CmdPaypalSee extends FCommand {
|
|||||||
fme.msg(TL.GENERIC_DISABLED);
|
fme.msg(TL.GENERIC_DISABLED);
|
||||||
} else {
|
} else {
|
||||||
Faction faction = argAsFaction(0);
|
Faction faction = argAsFaction(0);
|
||||||
String paypal = argAsString(1);
|
|
||||||
|
|
||||||
if (faction != null) {
|
if (faction != null) {
|
||||||
if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) {
|
if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) {
|
||||||
|
@ -76,7 +76,7 @@ public class CmdSeeChunk extends FCommand {
|
|||||||
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Iterator itr = seeChunkMap.keySet().iterator();
|
Iterator<String> itr = seeChunkMap.keySet().iterator();
|
||||||
while (itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
Object nameObject = itr.next();
|
Object nameObject = itr.next();
|
||||||
String name = nameObject + "";
|
String name = nameObject + "";
|
||||||
|
@ -46,9 +46,8 @@ public class CmdTnt extends FCommand {
|
|||||||
|
|
||||||
if (args.size() == 2) {
|
if (args.size() == 2) {
|
||||||
if (args.get(0).equalsIgnoreCase("add") || args.get(0).equalsIgnoreCase("a")) {
|
if (args.get(0).equalsIgnoreCase("add") || args.get(0).equalsIgnoreCase("a")) {
|
||||||
int testNumber = - 1;
|
|
||||||
try {
|
try {
|
||||||
testNumber = Integer.parseInt(args.get(1));
|
Integer.parseInt(args.get(1));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
||||||
return;
|
return;
|
||||||
@ -87,9 +86,8 @@ public class CmdTnt extends FCommand {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (args.get(0).equalsIgnoreCase("take") || args.get(0).equalsIgnoreCase("t")) {
|
if (args.get(0).equalsIgnoreCase("take") || args.get(0).equalsIgnoreCase("t")) {
|
||||||
int testNumber = - 1;
|
|
||||||
try {
|
try {
|
||||||
testNumber = Integer.parseInt(args.get(1));
|
Integer.parseInt(args.get(1));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
||||||
return;
|
return;
|
||||||
|
@ -54,9 +54,9 @@ public class CmdTntFill extends FCommand {
|
|||||||
msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", SavageFactions.plugin.getConfig().getInt("Tntfill.max-amount") + ""));
|
msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", SavageFactions.plugin.getConfig().getInt("Tntfill.max-amount") + ""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int testNumber = - 1;
|
|
||||||
try {
|
try {
|
||||||
testNumber = Integer.parseInt(args.get(1));
|
Integer.parseInt(args.get(1));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
||||||
return;
|
return;
|
||||||
@ -124,9 +124,8 @@ public class CmdTntFill extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeFromBank(int amount) {
|
private void removeFromBank(int amount) {
|
||||||
int testNumber = - 1;
|
|
||||||
try {
|
try {
|
||||||
testNumber = Integer.parseInt(args.get(1));
|
Integer.parseInt(args.get(1));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
||||||
return;
|
return;
|
||||||
|
@ -29,7 +29,6 @@ public class CmdTpBanner extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final FactionsPlayerListener fpl = new FactionsPlayerListener(SavageFactions.plugin);
|
final FactionsPlayerListener fpl = new FactionsPlayerListener(SavageFactions.plugin);
|
||||||
|
|
||||||
if (FactionsBlockListener.bannerLocations.containsKey(fme.getTag())) {
|
if (FactionsBlockListener.bannerLocations.containsKey(fme.getTag())) {
|
||||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public abstract class FCommand extends MCommand<SavageFactions> {
|
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;
|
public boolean disableOnLock;
|
||||||
|
|
||||||
|
@ -69,11 +69,6 @@ public class FPromoteCommand extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (promotion == null) {
|
|
||||||
fme.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't allow people to promote people to their same or higher rnak.
|
// Don't allow people to promote people to their same or higher rnak.
|
||||||
if (fme.getRole().value <= promotion.value) {
|
if (fme.getRole().value <= promotion.value) {
|
||||||
fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
|
fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
|
||||||
|
@ -8,7 +8,7 @@ import com.massivecraft.factions.Faction;
|
|||||||
*/
|
*/
|
||||||
public class FactionPlayerEvent extends FactionEvent {
|
public class FactionPlayerEvent extends FactionEvent {
|
||||||
|
|
||||||
private final FPlayer fPlayer;
|
protected final FPlayer fPlayer;
|
||||||
|
|
||||||
public FactionPlayerEvent(Faction faction, FPlayer fPlayer) {
|
public FactionPlayerEvent(Faction faction, FPlayer fPlayer) {
|
||||||
super(faction);
|
super(faction);
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,13 +1,18 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
import com.earth2me.essentials.IEssentials;
|
|
||||||
import com.earth2me.essentials.Teleport;
|
import com.earth2me.essentials.Teleport;
|
||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
|
|
||||||
|
import net.ess3.api.IEssentials;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class Essentials {
|
public class Essentials {
|
||||||
@ -28,9 +33,9 @@ public class Essentials {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Teleport teleport = essentials.getUser(player).getTeleport();
|
Teleport teleport = essentials.getUser(player).getTeleport();
|
||||||
Trade trade = new Trade(Conf.econCostHome, essentials);
|
Trade trade = new Trade(new BigDecimal(Conf.econCostHome), essentials);
|
||||||
try {
|
try {
|
||||||
teleport.teleport(loc, trade);
|
teleport.teleport(loc, trade, TeleportCause.PLUGIN);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
player.sendMessage(ChatColor.RED.toString() + e.getMessage());
|
player.sendMessage(ChatColor.RED.toString() + e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,8 @@ public class Worldguard {
|
|||||||
// Returns:
|
// Returns:
|
||||||
// True: PVP is allowed
|
// True: PVP is allowed
|
||||||
// False: PVP is disallowed
|
// False: PVP is disallowed
|
||||||
public static boolean isPVP(Player player) {
|
@SuppressWarnings("deprecation")
|
||||||
|
public static boolean isPVP(Player player) {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
// No WG hooks so we'll always bypass this check.
|
// No WG hooks so we'll always bypass this check.
|
||||||
return true;
|
return true;
|
||||||
|
@ -40,13 +40,12 @@ public class EngineDynmap {
|
|||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static EngineDynmap i = new EngineDynmap();
|
private static final EngineDynmap i = new EngineDynmap();
|
||||||
public DynmapAPI dynmapApi;
|
public DynmapAPI dynmapApi;
|
||||||
public MarkerAPI markerApi;
|
public MarkerAPI markerApi;
|
||||||
public MarkerSet markerset;
|
public MarkerSet markerset;
|
||||||
|
|
||||||
private EngineDynmap() {
|
private EngineDynmap() {}
|
||||||
}
|
|
||||||
|
|
||||||
public static EngineDynmap getInstance() {
|
public static EngineDynmap getInstance() {
|
||||||
return i;
|
return i;
|
||||||
@ -64,10 +63,7 @@ public class EngineDynmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getHtmlPlayerName(FPlayer fplayer) {
|
public static String getHtmlPlayerName(FPlayer fplayer) {
|
||||||
if (fplayer == null) {
|
return fplayer != null ? escapeHtml(fplayer.getName()):"none";
|
||||||
return "none";
|
|
||||||
}
|
|
||||||
return escapeHtml(fplayer.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String escapeHtml(String string) {
|
public static String escapeHtml(String string) {
|
||||||
@ -75,9 +71,9 @@ public class EngineDynmap {
|
|||||||
for (int i = 0; i < string.length(); i++) {
|
for (int i = 0; i < string.length(); i++) {
|
||||||
char c = string.charAt(i);
|
char c = string.charAt(i);
|
||||||
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
|
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
|
||||||
out.append("&#");
|
out.append("&#")
|
||||||
out.append((int) c);
|
.append((int) c)
|
||||||
out.append(';');
|
.append(';');
|
||||||
} else {
|
} else {
|
||||||
out.append(c);
|
out.append(c);
|
||||||
}
|
}
|
||||||
@ -87,8 +83,7 @@ public class EngineDynmap {
|
|||||||
|
|
||||||
// Thread Safe / Asynchronous: Yes
|
// Thread Safe / Asynchronous: Yes
|
||||||
public static void info(String msg) {
|
public static void info(String msg) {
|
||||||
String message = DYNMAP_INTEGRATION + msg;
|
System.out.println(DYNMAP_INTEGRATION + msg);
|
||||||
System.out.println(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -97,8 +92,7 @@ public class EngineDynmap {
|
|||||||
|
|
||||||
// Thread Safe / Asynchronous: Yes
|
// Thread Safe / Asynchronous: Yes
|
||||||
public static void severe(String msg) {
|
public static void severe(String msg) {
|
||||||
String message = DYNMAP_INTEGRATION + ChatColor.RED.toString() + msg;
|
System.out.println(DYNMAP_INTEGRATION + ChatColor.RED.toString() + msg);
|
||||||
System.out.println(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -163,6 +163,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) {
|
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) {
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) {
|
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) {
|
||||||
return true;
|
return true;
|
||||||
@ -180,7 +181,6 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
Relation rel = myFaction.getRelationTo(otherFaction);
|
Relation rel = myFaction.getRelationTo(otherFaction);
|
||||||
|
|
||||||
|
|
||||||
// no door/chest/whatever protection in wilderness, war zones, or safe zones
|
// no door/chest/whatever protection in wilderness, war zones, or safe zones
|
||||||
if (!otherFaction.isNormal()) {
|
if (!otherFaction.isNormal()) {
|
||||||
return true;
|
return true;
|
||||||
@ -915,13 +915,13 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
// returns the current attempt count
|
// returns the current attempt count
|
||||||
public int increment() {
|
public int increment() {
|
||||||
long Now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (Now > lastAttempt + 2000) {
|
if (now > lastAttempt + 2000) {
|
||||||
attempts = 1;
|
attempts = 1;
|
||||||
} else {
|
} else {
|
||||||
attempts++;
|
attempts++;
|
||||||
}
|
}
|
||||||
lastAttempt = Now;
|
lastAttempt = now;
|
||||||
return attempts;
|
return attempts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,17 +95,15 @@ public enum Relation implements Permissable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor() {
|
public ChatColor getColor() {
|
||||||
if (this == MEMBER) {
|
|
||||||
return Conf.colorMember;
|
switch (this)
|
||||||
} else if (this == ALLY) {
|
{
|
||||||
return Conf.colorAlly;
|
case MEMBER: return Conf.colorMember;
|
||||||
} else if (this == NEUTRAL) {
|
case ALLY: return Conf.colorAlly;
|
||||||
return Conf.colorNeutral;
|
case NEUTRAL: return Conf.colorNeutral;
|
||||||
} else if (this == TRUCE) {
|
case TRUCE: return Conf.colorTruce;
|
||||||
return Conf.colorTruce;
|
default: return Conf.colorEnemy;
|
||||||
} else {
|
}
|
||||||
return Conf.colorEnemy;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
||||||
|
@ -92,23 +92,15 @@ public enum Role implements Permissable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix() {
|
public String getPrefix() {
|
||||||
if (this == Role.LEADER) {
|
|
||||||
return Conf.prefixLeader;
|
switch (this)
|
||||||
}
|
{
|
||||||
if (this == Role.COLEADER) {
|
case LEADER: return Conf.prefixLeader;
|
||||||
return Conf.prefixCoLeader;
|
case COLEADER: return Conf.prefixCoLeader;
|
||||||
}
|
case MODERATOR: return Conf.prefixMod;
|
||||||
if (this == Role.MODERATOR) {
|
case NORMAL: return Conf.prefixNormal;
|
||||||
return Conf.prefixMod;
|
case RECRUIT: return Conf.prefixRecruit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this == Role.NORMAL) {
|
|
||||||
return Conf.prefixNormal;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this == Role.RECRUIT) {
|
|
||||||
return Conf.prefixRecruit;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -107,18 +107,15 @@ public enum PermissableAction {
|
|||||||
ItemStack item = new ItemStack(material);
|
ItemStack item = new ItemStack(material);
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
|
||||||
|
|
||||||
String accessValue = null;
|
String accessValue = null;
|
||||||
|
|
||||||
if (access.equals(Access.ALLOW)) {
|
switch (access)
|
||||||
accessValue = "allow";
|
{
|
||||||
} else if (access.equals(Access.DENY)) {
|
case ALLOW: accessValue = "allow"; break;
|
||||||
accessValue = "deny";
|
case DENY: accessValue = "deny"; break;
|
||||||
} else if (access.equals(Access.UNDEFINED)) {
|
case UNDEFINED: accessValue = "undefined"; break;
|
||||||
accessValue = "undefined";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If under the 1.13 version we will use the colorable option.
|
// If under the 1.13 version we will use the colorable option.
|
||||||
if (!SavageFactions.plugin.mc113) {
|
if (!SavageFactions.plugin.mc113) {
|
||||||
DyeColor dyeColor = null;
|
DyeColor dyeColor = null;
|
||||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.zcore.fupgrades;
|
|||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.*;
|
||||||
import org.bukkit.CropState;
|
import org.bukkit.CropState;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockGrowEvent;
|
import org.bukkit.event.block.BlockGrowEvent;
|
||||||
@ -46,9 +47,6 @@ public class CropUpgrades implements Listener {
|
|||||||
|
|
||||||
private void growCrop(BlockGrowEvent e) {
|
private void growCrop(BlockGrowEvent e) {
|
||||||
|
|
||||||
Material CROPS;
|
|
||||||
|
|
||||||
|
|
||||||
if (e.getBlock().getType().equals(SavageFactions.plugin.CROPS)) {
|
if (e.getBlock().getType().equals(SavageFactions.plugin.CROPS)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
Crops c = new Crops(CropState.RIPE);
|
Crops c = new Crops(CropState.RIPE);
|
||||||
@ -56,21 +54,18 @@ public class CropUpgrades implements Listener {
|
|||||||
bs.setData(c);
|
bs.setData(c);
|
||||||
bs.update();
|
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) {
|
if (below.getType() == SavageFactions.plugin.SUGAR_CANE_BLOCK) {
|
||||||
|
Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
|
||||||
org.bukkit.block.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) {
|
if (above.getType() == Material.AIR && above.getLocation().add(0, - 2, 0).getBlock().getType() != Material.AIR) {
|
||||||
above.setType(SavageFactions.plugin.SUGAR_CANE_BLOCK);
|
above.setType(SavageFactions.plugin.SUGAR_CANE_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (below.getType() == Material.CACTUS) {
|
if (below.getType() == Material.CACTUS) {
|
||||||
|
Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
|
||||||
|
|
||||||
org.bukkit.block.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) {
|
if (above.getType() == Material.AIR && above.getLocation().add(0, - 2, 0).getBlock().getType() != Material.AIR) {
|
||||||
above.setType(Material.CACTUS);
|
above.setType(Material.CACTUS);
|
||||||
|
@ -12,14 +12,15 @@ public class EXPUpgrade implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDeath(EntityDeathEvent e) {
|
public void onDeath(EntityDeathEvent e) {
|
||||||
Entity killer = e.getEntity().getKiller();
|
Entity killer = e.getEntity().getKiller();
|
||||||
Player player = (Player) killer;
|
|
||||||
if (player == null) {
|
if (killer == null || !(killer instanceof Player))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
Location loc = e.getEntity().getLocation();
|
Location loc = e.getEntity().getLocation();
|
||||||
Faction wild = Factions.getInstance().getWilderness();
|
Faction wild = Factions.getInstance().getWilderness();
|
||||||
FLocation floc = new FLocation(loc);
|
FLocation floc = new FLocation(loc);
|
||||||
Faction faction = Board.getInstance().getFactionAt(floc);
|
Faction faction = Board.getInstance().getFactionAt(floc);
|
||||||
|
|
||||||
if (faction != wild) {
|
if (faction != wild) {
|
||||||
int level = faction.getUpgrade("Exp");
|
int level = faction.getUpgrade("Exp");
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
@ -41,7 +42,6 @@ public class EXPUpgrade implements Listener {
|
|||||||
|
|
||||||
private void spawnMoreExp(EntityDeathEvent e, double multiplier) {
|
private void spawnMoreExp(EntityDeathEvent e, double multiplier) {
|
||||||
double newExp = e.getDroppedExp() * multiplier;
|
double newExp = e.getDroppedExp() * multiplier;
|
||||||
int newExpInt = (int) newExp;
|
e.setDroppedExp((int) newExp);
|
||||||
e.setDroppedExp(newExpInt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,40 +31,37 @@ public class FUpgradesGUI implements Listener {
|
|||||||
dummyData,
|
dummyData,
|
||||||
SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.DummyItem.Name")),
|
SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.DummyItem.Name")),
|
||||||
SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.DummyItem.Lore")));
|
SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.DummyItem.Lore")));
|
||||||
|
|
||||||
for (int i = 0; i <= dummySlots.size() - 1; i++) {
|
for (int i = 0; i <= dummySlots.size() - 1; i++) {
|
||||||
inventory.setItem(dummySlots.get(i), dummyItem);
|
inventory.setItem(dummySlots.get(i), dummyItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack[] items = buildItems(fme);
|
ItemStack[] items = buildItems(fme);
|
||||||
List<Integer> cropSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Crops.CropItem.slots");
|
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> spawnerSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Spawners.SpawnerItem.slots");
|
||||||
List<Integer> expSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.EXP.EXPItem.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");
|
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]);
|
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]);
|
inventory.setItem(spawnerSlots.get(i), items[1]);
|
||||||
}
|
|
||||||
|
|
||||||
|
for (int i = 0; i < expSlots.size(); i++)
|
||||||
for (int i = 0; i <= expSlots.size() - 1; i++) {
|
|
||||||
inventory.setItem(expSlots.get(i), items[0]);
|
inventory.setItem(expSlots.get(i), items[0]);
|
||||||
}
|
|
||||||
|
|
||||||
|
for (int i = 0; i < chestSlots.size(); i++)
|
||||||
for (int i = 0; i <= chestSlots.size() - 1; i++) {
|
|
||||||
inventory.setItem(chestSlots.get(i), items[3]);
|
inventory.setItem(chestSlots.get(i), items[3]);
|
||||||
}
|
|
||||||
|
|
||||||
fme.getPlayer().openInventory(inventory);
|
fme.getPlayer().openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(InventoryClickEvent e) {
|
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;
|
return;
|
||||||
}
|
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
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())))) {
|
if (e.getClickedInventory().getTitle().equalsIgnoreCase(SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", fme.getFaction().getTag())))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -73,170 +70,88 @@ public class FUpgradesGUI implements Listener {
|
|||||||
ItemStack expItem = items[0];
|
ItemStack expItem = items[0];
|
||||||
ItemStack chestitem = items[3];
|
ItemStack chestitem = items[3];
|
||||||
ItemStack spawnerItem = items[1];
|
ItemStack spawnerItem = items[1];
|
||||||
int cropLevel = fme.getFaction().getUpgrade("Crop");
|
|
||||||
if (e.getCurrentItem().equals(cropItem)) {
|
if (e.getCurrentItem().equals(cropItem)) {
|
||||||
if (cropLevel == 3) {
|
int cropLevel = fme.getFaction().getUpgrade("Crop");
|
||||||
return;
|
|
||||||
}
|
switch (cropLevel)
|
||||||
if (cropLevel == 2) {
|
{
|
||||||
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3");
|
case 3: return;
|
||||||
|
case 2: upgradeItem(fme, "Crop", 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3")); break;
|
||||||
if (hasMoney(fme, cost)) {
|
case 1: upgradeItem(fme, "Crop", 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-2")); break;
|
||||||
fme.getFaction().setUpgrades("Crop", 3);
|
case 0: upgradeItem(fme, "Crop", 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-1")); break;
|
||||||
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 spawnerLevel = fme.getFaction().getUpgrade("Spawner");
|
else if (e.getCurrentItem().equals(spawnerItem)) {
|
||||||
if (e.getCurrentItem().equals(spawnerItem)) {
|
int spawnerLevel = fme.getFaction().getUpgrade("Spawner");
|
||||||
if (spawnerLevel == 3) {
|
|
||||||
return;
|
switch(spawnerLevel)
|
||||||
}
|
{
|
||||||
if (spawnerLevel == 2) {
|
case 3: return;
|
||||||
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3");
|
case 2: upgradeItem(fme, "Spawner", 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3")); break;
|
||||||
if (!hasMoney(fme, cost)) {
|
case 1: upgradeItem(fme, "Spawner", 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-2")); break;
|
||||||
return;
|
case 0: upgradeItem(fme, "Spawner", 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-1")); break;
|
||||||
}
|
}
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int expLevel = fme.getFaction().getUpgrade("Exp");
|
else if (e.getCurrentItem().equals(expItem)) {
|
||||||
if (e.getCurrentItem().equals(expItem)) {
|
int expLevel = fme.getFaction().getUpgrade("Exp");
|
||||||
if (expLevel == 3) {
|
|
||||||
return;
|
switch (expLevel)
|
||||||
}
|
{
|
||||||
if (expLevel == 2) {
|
case 3: return;
|
||||||
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3");
|
case 2: upgradeItem(fme, "Exp", 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3")); break;
|
||||||
if (!hasMoney(fme, cost)) {
|
case 1: upgradeItem(fme, "Exp", 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-2")); break;
|
||||||
return;
|
case 0: upgradeItem(fme, "Exp", 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-1")); break;
|
||||||
}
|
}
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int chestLevel = fme.getFaction().getUpgrade("Chest");
|
else if (e.getCurrentItem().equals(chestitem)) {
|
||||||
if (e.getCurrentItem().equals(chestitem)) {
|
int chestLevel = fme.getFaction().getUpgrade("Chest");
|
||||||
if (chestLevel == 3) {
|
|
||||||
return;
|
switch (chestLevel)
|
||||||
}
|
{
|
||||||
if (chestLevel == 2) {
|
case 3: return;
|
||||||
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3");
|
case 2:
|
||||||
if (!hasMoney(fme, cost)) {
|
{
|
||||||
return;
|
if (upgradeItem(fme, "Chest", 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3")))
|
||||||
}
|
updateChests(fme.getFaction());
|
||||||
takeMoney(fme, cost);
|
break;
|
||||||
fme.getFaction().setUpgrades("Chest", 3);
|
}
|
||||||
updateChests(fme.getFaction());
|
case 1:
|
||||||
fme.getPlayer().closeInventory();
|
{
|
||||||
}
|
if (upgradeItem(fme, "Chest", 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2")))
|
||||||
if (chestLevel == 1) {
|
updateChests(fme.getFaction());
|
||||||
int cost = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2");
|
break;
|
||||||
if (!hasMoney(fme, cost)) {
|
}
|
||||||
return;
|
case 0:
|
||||||
}
|
{
|
||||||
takeMoney(fme, cost);
|
if (upgradeItem(fme, "Chest", 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-1")))
|
||||||
fme.getFaction().setUpgrades("Chest", 2);
|
updateChests(fme.getFaction());
|
||||||
updateChests(fme.getFaction());
|
break;
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateChests(Faction faction) {
|
private void updateChests(Faction faction) {
|
||||||
|
String invName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fchest.Inventory-Title"));
|
||||||
|
|
||||||
for (Player player : faction.getOnlinePlayers()) {
|
for (Player player : faction.getOnlinePlayers()) {
|
||||||
if (player.getInventory().getTitle() == null) {
|
if (player.getInventory().getTitle() != null && player.getInventory().getTitle().equalsIgnoreCase(invName))
|
||||||
return;
|
player.closeInventory();
|
||||||
}
|
|
||||||
String invName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fchest.Inventory-Title"));
|
|
||||||
if (player.getInventory().getTitle().equalsIgnoreCase(invName)) {
|
|
||||||
player.closeInventory();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int level = faction.getUpgrade("Chest");
|
int level = faction.getUpgrade("Chest");
|
||||||
int size = 9;
|
int size = 1;
|
||||||
if (level == 1) {
|
|
||||||
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1") * 9;
|
switch (level)
|
||||||
} else if (level == 2) {
|
{
|
||||||
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2") * 9;
|
case 1: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1"); break;
|
||||||
} else if (level == 3) {
|
case 2: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2"); break;
|
||||||
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3") * 9;
|
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) {
|
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"));
|
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"));
|
List<String> expLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.EXP.EXPItem.Lore"));
|
||||||
int expLevel = fme.getFaction().getUpgrade("Exp");
|
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 + ""));
|
expLore.set(i, expLore.get(i).replace("{level}", expLevel + ""));
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ItemStack expItem = SavageFactions.plugin.createItem(expMaterial, expAmt, expData, expName, expLore);
|
ItemStack expItem = SavageFactions.plugin.createItem(expMaterial, expAmt, expData, expName, expLore);
|
||||||
|
|
||||||
if (expLevel >= 1) {
|
if (expLevel >= 1) {
|
||||||
ItemMeta itemMeta = expItem.getItemMeta();
|
ItemMeta itemMeta = expItem.getItemMeta();
|
||||||
if (!SavageFactions.plugin.mc17) {
|
if (!SavageFactions.plugin.mc17) {
|
||||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
}
|
}
|
||||||
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
||||||
|
|
||||||
expItem.setItemMeta(itemMeta);
|
expItem.setItemMeta(itemMeta);
|
||||||
|
expItem.setAmount(expLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
Material spawnerMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Type"));
|
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++) {
|
for (int i = 0; i <= spawnerLore.size() - 1; i++) {
|
||||||
spawnerLore.set(i, spawnerLore.get(i).replace("{level}", spawnerLevel + ""));
|
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"));
|
Material cropMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Type"));
|
||||||
int cropAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Amount");
|
int cropAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Amount");
|
||||||
short cropData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Damage") + "");
|
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"));
|
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"));
|
List<String> cropLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Crops.CropItem.Lore"));
|
||||||
int cropLevel = fme.getFaction().getUpgrade("Crop");
|
int cropLevel = fme.getFaction().getUpgrade("Crop");
|
||||||
|
|
||||||
for (int i = 0; i <= cropLore.size() - 1; i++) {
|
for (int i = 0; i <= cropLore.size() - 1; i++) {
|
||||||
String line = cropLore.get(i);
|
String line = cropLore.get(i);
|
||||||
line = line.replace("{level}", cropLevel + "");
|
line = line.replace("{level}", cropLevel + "");
|
||||||
cropLore.set(i, line);
|
cropLore.set(i, line);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack cropItem = SavageFactions.plugin.createItem(cropMaterial, cropAmt, cropData, cropName, cropLore);
|
ItemStack cropItem = SavageFactions.plugin.createItem(cropMaterial, cropAmt, cropData, cropName, cropLore);
|
||||||
cropItem.getItemMeta().setLore(cropLore);
|
cropItem.getItemMeta().setLore(cropLore);
|
||||||
|
|
||||||
if (cropLevel >= 1) {
|
if (cropLevel >= 1) {
|
||||||
ItemMeta itemMeta = cropItem.getItemMeta();
|
ItemMeta itemMeta = cropItem.getItemMeta();
|
||||||
if (!SavageFactions.plugin.mc17) {
|
if (!SavageFactions.plugin.mc17) {
|
||||||
@ -299,12 +214,10 @@ public class FUpgradesGUI implements Listener {
|
|||||||
}
|
}
|
||||||
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
||||||
cropItem.setItemMeta(itemMeta);
|
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);
|
ItemStack spawnerItem = SavageFactions.plugin.createItem(spawnerMaterial, spawnerAmt, spawnerData, spawnerName, spawnerLore);
|
||||||
spawnerItem.getItemMeta().setLore(spawnerLore);
|
spawnerItem.getItemMeta().setLore(spawnerLore);
|
||||||
if (spawnerLevel >= 1) {
|
if (spawnerLevel >= 1) {
|
||||||
@ -313,24 +226,22 @@ public class FUpgradesGUI implements Listener {
|
|||||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
}
|
}
|
||||||
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
||||||
|
|
||||||
spawnerItem.setItemMeta(itemMeta);
|
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"));
|
Material chestMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Type"));
|
||||||
int chesttAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Amount");
|
int chesttAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Amount");
|
||||||
short chestData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Damage") + "");
|
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"));
|
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"));
|
List<String> chestLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Chest.ChestItem.Lore"));
|
||||||
int chestlevel = fme.getFaction().getUpgrade("Chest");
|
int chestlevel = fme.getFaction().getUpgrade("Chest");
|
||||||
|
|
||||||
for (int i = 0; i <= chestLore.size() - 1; i++) {
|
for (int i = 0; i <= chestLore.size() - 1; i++) {
|
||||||
String line = chestLore.get(i);
|
String line = chestLore.get(i);
|
||||||
line = line.replace("{level}", chestlevel + "");
|
line = line.replace("{level}", chestlevel + "");
|
||||||
chestLore.set(i, line);
|
chestLore.set(i, line);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack chestItem = SavageFactions.plugin.createItem(chestMaterial, chesttAmt, chestData, chestName, chestLore);
|
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.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
}
|
}
|
||||||
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
|
||||||
|
|
||||||
chestItem.setItemMeta(itemMeta);
|
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};
|
ItemStack[] items = {expItem, spawnerItem, cropItem, chestItem};
|
||||||
return items;
|
return items;
|
||||||
@ -361,4 +268,15 @@ public class FUpgradesGUI implements Listener {
|
|||||||
private void takeMoney(FPlayer fme, int amt) {
|
private void takeMoney(FPlayer fme, int amt) {
|
||||||
fme.takeMoney(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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.massivecraft.factions.zcore.fupgrades;
|
package com.massivecraft.factions.zcore.fupgrades;
|
||||||
|
|
||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.*;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||||
@ -10,22 +11,16 @@ public class SpawnerUpgrades implements Listener {
|
|||||||
public void onSpawn(SpawnerSpawnEvent e) {
|
public void onSpawn(SpawnerSpawnEvent e) {
|
||||||
FLocation floc = new FLocation(e.getLocation());
|
FLocation floc = new FLocation(e.getLocation());
|
||||||
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
|
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
|
||||||
if (factionAtLoc != Factions.getInstance().getWilderness()) {
|
|
||||||
|
if (!factionAtLoc.isWilderness()) {
|
||||||
int level = factionAtLoc.getUpgrade("Spawner");
|
int level = factionAtLoc.getUpgrade("Spawner");
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
if (level == 1) {
|
switch (level)
|
||||||
int rate = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-1");
|
{
|
||||||
lowerSpawnerDelay(e, rate);
|
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;
|
||||||
if (level == 2) {
|
case 3: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-3")); break;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@ public class NBTList {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ("unchecked")
|
|
||||||
public void addString(String s) {
|
public void addString(String s) {
|
||||||
if (type != NBTType.NBTTagString) {
|
if (type != NBTType.NBTTagString) {
|
||||||
new Throwable("Using String method on a non String list!").printStackTrace();
|
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) {
|
public void setString(int i, String s) {
|
||||||
if (type != NBTType.NBTTagString) {
|
if (type != NBTType.NBTTagString) {
|
||||||
new Throwable("Using String method on a non String list!").printStackTrace();
|
new Throwable("Using String method on a non String list!").printStackTrace();
|
||||||
|
@ -21,11 +21,10 @@ public class NBTReflectionUtil {
|
|||||||
|
|
||||||
private static final String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
private static final String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
|
|
||||||
@SuppressWarnings ("rawtypes")
|
private static Class<?> getCraftItemStack() {
|
||||||
private static Class getCraftItemStack() {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class clazz = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
|
Class<?> clazz = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
|
||||||
return clazz;
|
return clazz;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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 {
|
try {
|
||||||
Class clazz = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftEntity");
|
Class<?> clazz = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftEntity");
|
||||||
return clazz;
|
return clazz;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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 {
|
try {
|
||||||
Class clazz = Class.forName("net.minecraft.server." + version + ".NBTBase");
|
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".NBTBase");
|
||||||
return clazz;
|
return clazz;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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 {
|
try {
|
||||||
Class clazz = Class.forName("net.minecraft.server." + version + ".NBTTagString");
|
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".NBTTagString");
|
||||||
return clazz;
|
return clazz;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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 {
|
try {
|
||||||
Class clazz = Class.forName("net.minecraft.server." + version + ".ItemStack");
|
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".ItemStack");
|
||||||
return clazz;
|
return clazz;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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 {
|
try {
|
||||||
Class clazz = Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
|
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
|
||||||
return clazz;
|
return clazz;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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 {
|
try {
|
||||||
Class clazz = Class.forName("net.minecraft.server." + version + ".NBTCompressedStreamTools");
|
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".NBTCompressedStreamTools");
|
||||||
return clazz;
|
return clazz;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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 {
|
try {
|
||||||
Class c = Class.forName("net.minecraft.server." + version + ".MojangsonParser");
|
Class<?> c = Class.forName("net.minecraft.server." + version + ".MojangsonParser");
|
||||||
return c;
|
return c;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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 {
|
try {
|
||||||
Class clazz = Class.forName("net.minecraft.server." + version + ".TileEntity");
|
Class<?> clazz = Class.forName("net.minecraft.server." + version + ".TileEntity");
|
||||||
return clazz;
|
return clazz;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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 {
|
try {
|
||||||
Class clazz = Class.forName("org.bukkit.craftbukkit." + version + ".CraftWorld");
|
Class<?> clazz = Class.forName("org.bukkit.craftbukkit." + version + ".CraftWorld");
|
||||||
return clazz;
|
return clazz;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
||||||
@ -145,8 +135,7 @@ public class NBTReflectionUtil {
|
|||||||
public static Object getNewNBTTag() {
|
public static Object getNewNBTTag() {
|
||||||
String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> c = Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
|
||||||
Class c = Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
|
|
||||||
return c.newInstance();
|
return c.newInstance();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
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) {
|
private static Object getNewBlockPosition(int x, int y, int z) {
|
||||||
String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
try {
|
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);
|
return clazz.getConstructor(int.class, int.class, int.class).newInstance(x, y, z);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
System.out.println("Error in ItemNBTAPI!(Outdated plugin?)");
|
||||||
@ -180,10 +168,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ("unchecked")
|
|
||||||
public static Object getNMSItemStack(ItemStack item) {
|
public static Object getNMSItemStack(ItemStack item) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> clazz = getCraftItemStack();
|
||||||
Class clazz = getCraftItemStack();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = clazz.getMethod("asNMSCopy", ItemStack.class);
|
method = clazz.getMethod("asNMSCopy", ItemStack.class);
|
||||||
@ -195,10 +181,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ("unchecked")
|
|
||||||
public static Object getNMSEntity(Entity entity) {
|
public static Object getNMSEntity(Entity entity) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> clazz = getCraftEntity();
|
||||||
Class clazz = getCraftEntity();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = clazz.getMethod("getHandle");
|
method = clazz.getMethod("getHandle");
|
||||||
@ -209,10 +193,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ({"unchecked"})
|
|
||||||
public static Object parseNBT(String json) {
|
public static Object parseNBT(String json) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> cis = getMojangsonParser();
|
||||||
Class cis = getMojangsonParser();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = cis.getMethod("parse", String.class);
|
method = cis.getMethod("parse", String.class);
|
||||||
@ -223,10 +205,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ({"unchecked"})
|
|
||||||
public static Object readNBTFile(FileInputStream stream) {
|
public static Object readNBTFile(FileInputStream stream) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> clazz = getNBTCompressedStreamTools();
|
||||||
Class clazz = getNBTCompressedStreamTools();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = clazz.getMethod("a", InputStream.class);
|
method = clazz.getMethod("a", InputStream.class);
|
||||||
@ -237,10 +217,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ({"unchecked"})
|
|
||||||
public static Object saveNBTFile(Object nbt, FileOutputStream stream) {
|
public static Object saveNBTFile(Object nbt, FileOutputStream stream) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> clazz = getNBTCompressedStreamTools();
|
||||||
Class clazz = getNBTCompressedStreamTools();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = clazz.getMethod("a", getNBTTagCompound(), OutputStream.class);
|
method = clazz.getMethod("a", getNBTTagCompound(), OutputStream.class);
|
||||||
@ -251,10 +229,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ({"unchecked"})
|
|
||||||
public static ItemStack getBukkitItemStack(Object item) {
|
public static ItemStack getBukkitItemStack(Object item) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> clazz = getCraftItemStack();
|
||||||
Class clazz = getCraftItemStack();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = clazz.getMethod("asCraftMirror", item.getClass());
|
method = clazz.getMethod("asCraftMirror", item.getClass());
|
||||||
@ -266,10 +242,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ({"unchecked"})
|
|
||||||
public static Object getItemRootNBTTagCompound(Object nmsitem) {
|
public static Object getItemRootNBTTagCompound(Object nmsitem) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> clazz = nmsitem.getClass();
|
||||||
Class clazz = nmsitem.getClass();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = clazz.getMethod("getTag");
|
method = clazz.getMethod("getTag");
|
||||||
@ -281,10 +255,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ({"unchecked"})
|
|
||||||
public static Object convertNBTCompoundtoNMSItem(NBTCompound nbtcompound) {
|
public static Object convertNBTCompoundtoNMSItem(NBTCompound nbtcompound) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> clazz = getNMSItemStack();
|
||||||
Class clazz = getNMSItemStack();
|
|
||||||
try {
|
try {
|
||||||
Object nmsstack = clazz.getConstructor(getNBTTagCompound()).newInstance(gettoCompount(nbtcompound.getCompound(), nbtcompound));
|
Object nmsstack = clazz.getConstructor(getNBTTagCompound()).newInstance(gettoCompount(nbtcompound.getCompound(), nbtcompound));
|
||||||
return nmsstack;
|
return nmsstack;
|
||||||
@ -294,10 +266,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ({"unchecked"})
|
|
||||||
public static NBTContainer convertNMSItemtoNBTCompound(Object nmsitem) {
|
public static NBTContainer convertNMSItemtoNBTCompound(Object nmsitem) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> clazz = nmsitem.getClass();
|
||||||
Class clazz = nmsitem.getClass();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = clazz.getMethod("save", getNBTTagCompound());
|
method = clazz.getMethod("save", getNBTTagCompound());
|
||||||
@ -309,10 +279,8 @@ public class NBTReflectionUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ({"unchecked"})
|
|
||||||
public static Object getEntityNBTTagCompound(Object nmsitem) {
|
public static Object getEntityNBTTagCompound(Object nmsitem) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> c = nmsitem.getClass();
|
||||||
Class c = nmsitem.getClass();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = c.getMethod(MethodNames.getEntityNbtGetterMethodName(), getNBTTagCompound());
|
method = c.getMethod(MethodNames.getEntityNbtGetterMethodName(), getNBTTagCompound());
|
||||||
@ -372,11 +340,8 @@ public class NBTReflectionUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings ("unchecked")
|
|
||||||
public static Object getSubNBTTagCompound(Object compound, String name) {
|
public static Object getSubNBTTagCompound(Object compound, String name) {
|
||||||
@SuppressWarnings ("rawtypes")
|
Class<?> c = compound.getClass();
|
||||||
Class c = compound.getClass();
|
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
method = c.getMethod("getCompound", String.class);
|
method = c.getMethod("getCompound", String.class);
|
||||||
|
@ -5,6 +5,7 @@ import com.massivecraft.factions.cmd.CmdFly;
|
|||||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||||
import com.massivecraft.factions.event.FPlayerStoppedFlying;
|
import com.massivecraft.factions.event.FPlayerStoppedFlying;
|
||||||
import com.massivecraft.factions.event.LandClaimEvent;
|
import com.massivecraft.factions.event.LandClaimEvent;
|
||||||
|
import com.massivecraft.factions.event.PowerRegenEvent;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.iface.RelationParticipator;
|
import com.massivecraft.factions.iface.RelationParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
@ -557,8 +558,14 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
return; // don't let dead players regain power until they respawn
|
return; // don't let dead players regain power until they respawn
|
||||||
}
|
}
|
||||||
|
|
||||||
int millisPerMinute = 60 * 1000;
|
PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this);
|
||||||
this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute);
|
Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent);
|
||||||
|
|
||||||
|
if (!powerRegenEvent.isCancelled())
|
||||||
|
{
|
||||||
|
int millisPerMinute = 60 * 1000;
|
||||||
|
this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void losePowerFromBeingOffline() {
|
public void losePowerFromBeingOffline() {
|
||||||
@ -1126,7 +1133,6 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
|
|
||||||
|
|
||||||
if (!this.canClaimForFactionAtLocation(forFaction, flocation, notifyFailure)) {
|
if (!this.canClaimForFactionAtLocation(forFaction, flocation, notifyFailure)) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1191,21 +1197,16 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRolePrefix() {
|
public String getRolePrefix() {
|
||||||
if (getRole() == Role.RECRUIT) {
|
|
||||||
return Conf.prefixRecruit;
|
switch (getRole())
|
||||||
}
|
{
|
||||||
if (getRole() == Role.NORMAL) {
|
case RECRUIT: return Conf.prefixRecruit;
|
||||||
return Conf.prefixNormal;
|
case NORMAL: return Conf.prefixNormal;
|
||||||
}
|
case MODERATOR: return Conf.prefixMod;
|
||||||
if (getRole() == Role.MODERATOR) {
|
case COLEADER: return Conf.prefixCoLeader;
|
||||||
return Conf.prefixMod;
|
case LEADER: return Conf.prefixLeader;
|
||||||
}
|
}
|
||||||
if (getRole() == Role.COLEADER) {
|
|
||||||
return Conf.prefixCoLeader;
|
|
||||||
}
|
|
||||||
if (getRole() == Role.LEADER) {
|
|
||||||
return Conf.prefixLeader;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public enum TagReplacer {
|
|||||||
case TOTAL_ONLINE:
|
case TOTAL_ONLINE:
|
||||||
return String.valueOf(Bukkit.getOnlinePlayers().size());
|
return String.valueOf(Bukkit.getOnlinePlayers().size());
|
||||||
case FACTIONLESS:
|
case FACTIONLESS:
|
||||||
return String.valueOf(Factions.getInstance().getNone().getFPlayersWhereOnline(true).size());
|
return String.valueOf(Factions.getInstance().getWilderness().getFPlayersWhereOnline(true).size());
|
||||||
case MAX_ALLIES:
|
case MAX_ALLIES:
|
||||||
if (SavageFactions.plugin.getConfig().getBoolean("max-relations.enabled", true)) {
|
if (SavageFactions.plugin.getConfig().getBoolean("max-relations.enabled", true)) {
|
||||||
return String.valueOf(SavageFactions.plugin.getConfig().getInt("max-relations.ally", 10));
|
return String.valueOf(SavageFactions.plugin.getConfig().getInt("max-relations.ally", 10));
|
||||||
@ -139,6 +139,7 @@ public enum TagReplacer {
|
|||||||
return TL.GENERIC_INFINITY.toString();
|
return TL.GENERIC_INFINITY.toString();
|
||||||
case MAX_WARPS:
|
case MAX_WARPS:
|
||||||
return String.valueOf(SavageFactions.plugin.getConfig().getInt("max-warps", 5));
|
return String.valueOf(SavageFactions.plugin.getConfig().getInt("max-warps", 5));
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -180,6 +181,7 @@ public enum TagReplacer {
|
|||||||
return String.valueOf(fp.getKills());
|
return String.valueOf(fp.getKills());
|
||||||
case PLAYER_DEATHS:
|
case PLAYER_DEATHS:
|
||||||
return String.valueOf(fp.getDeaths());
|
return String.valueOf(fp.getDeaths());
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (this) {
|
switch (this) {
|
||||||
@ -252,6 +254,7 @@ public enum TagReplacer {
|
|||||||
return String.valueOf(fac.getDeaths());
|
return String.valueOf(fac.getDeaths());
|
||||||
case FACTION_BANCOUNT:
|
case FACTION_BANCOUNT:
|
||||||
return String.valueOf(fac.getBannedPlayers().size());
|
return String.valueOf(fac.getBannedPlayers().size());
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -232,6 +232,7 @@ public class TagUtil {
|
|||||||
}
|
}
|
||||||
fancyMessages.add(currentOffline);
|
fancyMessages.add(currentOffline);
|
||||||
return firstOffline && minimal ? null : fancyMessages; // we must return here and not outside the switch
|
return firstOffline && minimal ? null : fancyMessages; // we must return here and not outside the switch
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user