Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec769a56e4 | ||
|
|
1927f49221 | ||
|
|
9349a914ce | ||
|
|
f8e22896d5 |
@@ -4,6 +4,7 @@ import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.missions.Mission;
|
||||
import com.massivecraft.factions.shield.TimeFrame;
|
||||
import com.massivecraft.factions.struct.BanInfo;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
@@ -441,4 +442,10 @@ public interface Faction extends EconomyParticipator {
|
||||
|
||||
void paypalSet(String paypal);
|
||||
|
||||
|
||||
// shield
|
||||
|
||||
void setTimeFrame(TimeFrame timeFrame);
|
||||
TimeFrame getTimeFrame();
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.integration.dynmap.EngineDynmap;
|
||||
import com.massivecraft.factions.listeners.*;
|
||||
import com.massivecraft.factions.missions.MissionHandler;
|
||||
import com.massivecraft.factions.shield.TimeFrameTask;
|
||||
import com.massivecraft.factions.shop.ShopConfig;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
@@ -267,6 +268,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new CheckTask(this, 30), 0L, (long) (minute * 30));
|
||||
this.getServer().getScheduler().runTaskTimer(this, CheckTask::cleanupTask, 0L, 1200L);
|
||||
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new WeeWooTask(this), 600L, 600L);
|
||||
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new TimeFrameTask(), 1200, 1200); // every 1 minute...
|
||||
}
|
||||
if(Conf.useDiscordSystem && !Conf.discordBotToken.equals("<token here>")) {
|
||||
new FactionChatHandler(this);
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class CmdFly extends FCommand {
|
||||
|
||||
|
||||
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<String, Boolean>();
|
||||
public static int id = -1;
|
||||
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
|
||||
public static BukkitTask particleTask = null;
|
||||
public static BukkitTask flyTask = null;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class CmdFly extends FCommand {
|
||||
|
||||
public static void startParticles() {
|
||||
|
||||
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
||||
particleTask = Bukkit.getScheduler().runTaskTimerAsynchronously(FactionsPlugin.instance, () -> {
|
||||
for (String name : flyMap.keySet()) {
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (player == null) continue;
|
||||
@@ -49,11 +49,10 @@ public class CmdFly extends FCommand {
|
||||
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
||||
fplayer.isVanished();
|
||||
|
||||
}
|
||||
if (flyMap.keySet().size() == 0) {
|
||||
Bukkit.getScheduler().cancelTask(id);
|
||||
id = -1;
|
||||
if (flyMap.isEmpty()) {
|
||||
particleTask.cancel();
|
||||
particleTask = null;
|
||||
}
|
||||
}, 10L, 3L);
|
||||
}
|
||||
@@ -192,6 +191,10 @@ public class CmdFly extends FCommand {
|
||||
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
||||
fme.setFlying(true);
|
||||
flyMap.put(fme.getPlayer().getName(), true);
|
||||
if (particleTask == null) {
|
||||
startParticles();
|
||||
}
|
||||
|
||||
if (flyTask == null) {
|
||||
startFlyCheck();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CmdHome extends FCommand {
|
||||
public CmdHome() {
|
||||
super();
|
||||
this.aliases.add("home");
|
||||
this.optionalArgs.put("home", "faction-name");
|
||||
this.optionalArgs.put("faction", "yours");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.HOME)
|
||||
.playerOnly()
|
||||
|
||||
@@ -19,7 +19,6 @@ public class CmdLock extends FCommand {
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.LOCK)
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class CmdMoneyBalance extends FCommand {
|
||||
}
|
||||
|
||||
if (context.fPlayer != null) {
|
||||
Econ.sendBalanceInfo((CommandSender) context.fPlayer, faction);
|
||||
Econ.sendBalanceInfo(context.sender, faction);
|
||||
} else {
|
||||
Econ.sendBalanceInfo(context.sender, faction);
|
||||
}
|
||||
|
||||
@@ -581,15 +581,12 @@ public class FactionsPlayerListener implements Listener {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffly.AutoEnable")) {
|
||||
me.setFlying(true);
|
||||
CmdFly.flyMap.put(me.getName(), true);
|
||||
if (CmdFly.id == -1) {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffly.Particles.Enabled")) {
|
||||
if (CmdFly.particleTask == null)
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffly.Particles.Enabled"))
|
||||
CmdFly.startParticles();
|
||||
}
|
||||
}
|
||||
if (CmdFly.flyTask == null) CmdFly.startFlyCheck();
|
||||
CmdFly.startFlyCheck();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//inspect
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.massivecraft.factions.shield;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
|
||||
public class TimeFrame {
|
||||
|
||||
//each of these objs will be in 1 fac
|
||||
|
||||
private Faction faction;
|
||||
private Enum startingTime;
|
||||
private Enum endingTime;
|
||||
|
||||
private int currentMinutes; // this will be the variable for either the currentTime starting, or ending, or current in effect.
|
||||
|
||||
private boolean inEffect; // if the forcefield is in effect
|
||||
private boolean starting; // pending starting countdown
|
||||
private boolean ending; // pending ending countdown
|
||||
|
||||
private enum times {
|
||||
twelveAM, oneAM, twoAM, threeAM, fourAM, fiveAM, sixAM, sevenAM, eightAM, nineAM, tenAM, elevenAM, twelvePM,
|
||||
onePM, twoPM, threePM, fourPM, fivePM, sixPM, sevenPM, eightPM, ninePM, tenPM, elevenPM;
|
||||
}
|
||||
|
||||
|
||||
public TimeFrame(Faction faction, Enum startingTime, Enum endingTime, boolean starting, boolean ending, boolean inEffect, int currentMinutes){
|
||||
this.faction = faction;
|
||||
this.startingTime = startingTime;
|
||||
this.endingTime = endingTime;
|
||||
this.starting = starting;
|
||||
this.ending = ending;
|
||||
this.inEffect = inEffect;
|
||||
this.currentMinutes = currentMinutes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isEnding() {
|
||||
return ending;
|
||||
}
|
||||
|
||||
public boolean isInEffect() {
|
||||
return inEffect;
|
||||
}
|
||||
|
||||
public Enum getEndingTime() {
|
||||
return endingTime;
|
||||
}
|
||||
|
||||
public Enum getStartingTime() {
|
||||
return startingTime;
|
||||
}
|
||||
|
||||
public boolean isStarting() {
|
||||
return starting;
|
||||
}
|
||||
|
||||
public Faction getFaction() {
|
||||
return faction;
|
||||
}
|
||||
|
||||
public void setCurrentMinutes(int currentMinutes) {
|
||||
this.currentMinutes = currentMinutes;
|
||||
}
|
||||
|
||||
public int getCurrentMinutes() {
|
||||
return currentMinutes;
|
||||
}
|
||||
|
||||
public void setEnding(boolean ending) {
|
||||
this.ending = ending;
|
||||
}
|
||||
|
||||
public void setEndingTime(Enum endingTime) {
|
||||
this.endingTime = endingTime;
|
||||
}
|
||||
|
||||
public void setStartingTime(Enum startingTime) {
|
||||
this.startingTime = startingTime;
|
||||
}
|
||||
|
||||
public void setFaction(Faction faction) {
|
||||
this.faction = faction;
|
||||
}
|
||||
|
||||
public void setInEffect(boolean inEffect) {
|
||||
this.inEffect = inEffect;
|
||||
}
|
||||
|
||||
public void setStarting(boolean starting) {
|
||||
this.starting = starting;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.massivecraft.factions.shield;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
|
||||
public class TimeFrameTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//remove tiem from the timeFrame
|
||||
|
||||
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
||||
|
||||
if (faction.getTimeFrame() != null){
|
||||
TimeFrame timeFrame = faction.getTimeFrame();
|
||||
|
||||
if (timeFrame.isStarting() || timeFrame.isEnding() || timeFrame.isInEffect()){
|
||||
//either starting, ending, or in effect, so we have to remove 1 minute interval from the currentTime
|
||||
int newTime = Math.subtractExact(timeFrame.getCurrentMinutes(), 1);
|
||||
if (newTime == 0){
|
||||
//time is done, do functions...
|
||||
if (timeFrame.isStarting() || timeFrame.isInEffect()){
|
||||
if (timeFrame.isStarting()){
|
||||
//it was starting, now set to inEffect
|
||||
timeFrame.setStarting(false);
|
||||
timeFrame.setInEffect(true);
|
||||
}
|
||||
//we don't need to check for inEffect because if it is, it'll just set the time back anyways...
|
||||
timeFrame.setCurrentMinutes(720);
|
||||
continue; // continue to the next faction
|
||||
}else if (timeFrame.isEnding()){
|
||||
//it was ending, now set inEffect to false, basically remove from the faction obj
|
||||
timeFrame.setEnding(false);
|
||||
timeFrame.setInEffect(false);
|
||||
//remove from faction object
|
||||
faction.setTimeFrame(null);
|
||||
continue; // continue to the next faction
|
||||
}
|
||||
}
|
||||
timeFrame.setCurrentMinutes(newTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ public class PermissableRelationFrame {
|
||||
GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
|
||||
ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation");
|
||||
for (String key : sec.getConfigurationSection("slots").getKeys(false)) {
|
||||
if (key == null || sec.getInt("slots." + key) < 0) continue;
|
||||
GUIItems.set(sec.getInt("slots." + key), new GuiItem(buildAsset("fperm-gui.relation.materials." + key, key), e -> {
|
||||
e.setCancelled(true);
|
||||
// Closing and opening resets the cursor.
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.missions.Mission;
|
||||
import com.massivecraft.factions.scoreboards.FTeamWrapper;
|
||||
import com.massivecraft.factions.shield.TimeFrame;
|
||||
import com.massivecraft.factions.struct.BanInfo;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
@@ -29,6 +30,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -93,6 +95,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
private String weeWooFormat;
|
||||
private String guildId;
|
||||
private String memberRoleId;
|
||||
private TimeFrame timeFrame;
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
@@ -128,6 +131,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
this.notifyFormat = "@everyone, check %type%";
|
||||
this.weeWooFormat = "@everyone, we're being raided! Get online!";
|
||||
this.memberRoleId = null;
|
||||
this.timeFrame = null;
|
||||
resetPerms(); // Reset on new Faction so it has default values.
|
||||
}
|
||||
|
||||
@@ -160,7 +164,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
this.checks = new ConcurrentHashMap<>();
|
||||
this.playerWallCheckCount = new ConcurrentHashMap<>();
|
||||
this.playerBufferCheckCount = new ConcurrentHashMap<>();
|
||||
|
||||
this.timeFrame = null;
|
||||
resetPerms(); // Reset on new Faction so it has default values.
|
||||
}
|
||||
|
||||
@@ -1505,4 +1509,12 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
public Set<FLocation> getAllClaims() {
|
||||
return Board.getInstance().getAllClaims(this);
|
||||
}
|
||||
|
||||
public TimeFrame getTimeFrame(){
|
||||
return this.timeFrame;
|
||||
}
|
||||
|
||||
public void setTimeFrame(TimeFrame timeFrame){
|
||||
this.timeFrame = timeFrame;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user