Fixes quite a lot of warnings
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package net.knarcraft.factions.task;
|
||||
|
||||
import net.knarcraft.factions.entity.MFlag;
|
||||
import net.knarcraft.factions.entity.MPerm;
|
||||
import com.massivecraft.massivecore.ModuloRepeatTask;
|
||||
import com.massivecraft.massivecore.util.TimeUnit;
|
||||
import net.knarcraft.factions.entity.MFlag;
|
||||
import net.knarcraft.factions.entity.MPerm;
|
||||
|
||||
public class TaskFlagPermCreate extends ModuloRepeatTask {
|
||||
// -------------------------------------------- //
|
||||
@@ -16,7 +16,7 @@ public class TaskFlagPermCreate extends ModuloRepeatTask {
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static TaskFlagPermCreate i = new TaskFlagPermCreate();
|
||||
private static final TaskFlagPermCreate i = new TaskFlagPermCreate();
|
||||
|
||||
public static TaskFlagPermCreate get() {
|
||||
return i;
|
||||
|
@@ -1,15 +1,15 @@
|
||||
package net.knarcraft.factions.task;
|
||||
|
||||
import com.massivecraft.massivecore.ModuloRepeatTask;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.util.TimeUnit;
|
||||
import net.knarcraft.factions.entity.BoardColl;
|
||||
import net.knarcraft.factions.entity.Faction;
|
||||
import net.knarcraft.factions.entity.MConf;
|
||||
import net.knarcraft.factions.entity.MFlag;
|
||||
import net.knarcraft.factions.entity.MPlayer;
|
||||
import net.knarcraft.factions.event.EventFactionsPowerChange;
|
||||
import com.massivecraft.massivecore.ModuloRepeatTask;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.util.TimeUnit;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -18,7 +18,7 @@ public class TaskPlayerPowerUpdate extends ModuloRepeatTask {
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static TaskPlayerPowerUpdate i = new TaskPlayerPowerUpdate();
|
||||
private static final TaskPlayerPowerUpdate i = new TaskPlayerPowerUpdate();
|
||||
|
||||
public static TaskPlayerPowerUpdate get() {
|
||||
return i;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
package net.knarcraft.factions.task;
|
||||
|
||||
import com.massivecraft.massivecore.Couple;
|
||||
import com.massivecraft.massivecore.Task;
|
||||
import com.massivecraft.massivecore.collections.MassiveMap;
|
||||
import com.massivecraft.massivecore.mixin.MixinMessage;
|
||||
import com.massivecraft.massivecore.money.Money;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.TimeUnit;
|
||||
import net.knarcraft.factions.Factions;
|
||||
import net.knarcraft.factions.entity.Faction;
|
||||
import net.knarcraft.factions.entity.FactionColl;
|
||||
@@ -9,13 +16,6 @@ import net.knarcraft.factions.entity.MPlayer;
|
||||
import net.knarcraft.factions.entity.MPlayerColl;
|
||||
import net.knarcraft.factions.event.EventFactionsMembershipChange;
|
||||
import net.knarcraft.factions.integration.Econ;
|
||||
import com.massivecraft.massivecore.Couple;
|
||||
import com.massivecraft.massivecore.Task;
|
||||
import com.massivecraft.massivecore.collections.MassiveMap;
|
||||
import com.massivecraft.massivecore.mixin.MixinMessage;
|
||||
import com.massivecraft.massivecore.money.Money;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.TimeUnit;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -27,7 +27,7 @@ public class TaskTax extends Task {
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static TaskTax i = new TaskTax();
|
||||
private static final TaskTax i = new TaskTax();
|
||||
|
||||
public static TaskTax get() {
|
||||
return i;
|
||||
@@ -105,9 +105,9 @@ public class TaskTax extends Task {
|
||||
|
||||
for (Couple<MPlayer, Double> couple : taxes) {
|
||||
double tax = doTaxPlayer(couple);
|
||||
if (tax == 0D) {
|
||||
continue;
|
||||
}
|
||||
if (tax == 0D) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Log data
|
||||
Faction faction = couple.getFirst().getFaction();
|
||||
@@ -142,11 +142,11 @@ public class TaskTax extends Task {
|
||||
if (success) {
|
||||
// Inform player
|
||||
if (mplayer.isOnline()) {
|
||||
if (tax > 0) {
|
||||
mplayer.msg("<i>You were just taxed <reset>%s <i> by your faction.", Money.format(tax)); // Tax
|
||||
} else {
|
||||
mplayer.msg("<i>You were just paid <reset>%s <i> by your faction.", Money.format(-tax)); // Salary
|
||||
}
|
||||
if (tax > 0) {
|
||||
mplayer.msg("<i>You were just taxed <reset>%s <i> by your faction.", Money.format(tax)); // Tax
|
||||
} else {
|
||||
mplayer.msg("<i>You were just paid <reset>%s <i> by your faction.", Money.format(-tax)); // Salary
|
||||
}
|
||||
}
|
||||
|
||||
return tax;
|
||||
@@ -154,9 +154,9 @@ public class TaskTax extends Task {
|
||||
{
|
||||
faction.msg("%s<i> couldn't afford tax!", mplayer.describeTo(faction));
|
||||
boolean kicked = tryKickPlayer(mplayer);
|
||||
if (!kicked) {
|
||||
faction.msg("%s <i>could not afford tax.", mplayer.describeTo(faction));
|
||||
}
|
||||
if (!kicked) {
|
||||
faction.msg("%s <i>could not afford tax.", mplayer.describeTo(faction));
|
||||
}
|
||||
return 0D;
|
||||
} else // If a salary
|
||||
{
|
||||
@@ -167,40 +167,36 @@ public class TaskTax extends Task {
|
||||
|
||||
private boolean shouldBeTaxed(long now, MPlayer mplayer) {
|
||||
// Must have faction
|
||||
if (!mplayer.hasFaction()) {
|
||||
return false;
|
||||
}
|
||||
if (!mplayer.hasFaction()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Must have been online recently
|
||||
long offlinePeriod;
|
||||
if (mplayer.isOnline()) {
|
||||
offlinePeriod = 0;
|
||||
} else {
|
||||
offlinePeriod = now - mplayer.getLastActivityMillis();
|
||||
}
|
||||
if (mplayer.isOnline()) {
|
||||
offlinePeriod = 0;
|
||||
} else {
|
||||
offlinePeriod = now - mplayer.getLastActivityMillis();
|
||||
}
|
||||
|
||||
int inactiveDays = MConf.get().taxInactiveDays;
|
||||
if (inactiveDays > 0 && offlinePeriod > inactiveDays * TimeUnit.MILLIS_PER_DAY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return inactiveDays <= 0 || offlinePeriod <= inactiveDays * TimeUnit.MILLIS_PER_DAY;
|
||||
}
|
||||
|
||||
private boolean tryKickPlayer(MPlayer mplayer) {
|
||||
Faction faction = mplayer.getFaction();
|
||||
if (mplayer.getRank().isLeader()) {
|
||||
return false;
|
||||
}
|
||||
if (!faction.getFlag(MFlag.getFlagTaxKick())) {
|
||||
return false;
|
||||
}
|
||||
if (mplayer.getRank().isLeader()) {
|
||||
return false;
|
||||
}
|
||||
if (!faction.getFlag(MFlag.getFlagTaxKick())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EventFactionsMembershipChange event = new EventFactionsMembershipChange(null, mplayer, FactionColl.get().getNone(), EventFactionsMembershipChange.MembershipChangeReason.KICK);
|
||||
event.run();
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
faction.msg("%s <i>could not afford tax and was kicked from your faction.", mplayer.describeTo(faction));
|
||||
|
||||
|
Reference in New Issue
Block a user