New Shop Config Format With Help, Removed Useless Code FactionsBlockListener Block Break Revamp, F Wild Revamp (DroppingAnvil) & Alot I can't remember xD

This commit is contained in:
Driftay
2020-04-04 05:09:05 -04:00
parent 0aeadcf0d0
commit d79b93d6c5
90 changed files with 576 additions and 560 deletions

View File

@@ -0,0 +1,46 @@
package com.massivecraft.factions.util.wait;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.concurrent.ConcurrentHashMap;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/4/2020
*/
public class WaitExecutor {
private static boolean enabled = false;
public static ConcurrentHashMap<Player, WaitTask> taskMap = new ConcurrentHashMap<>();
public static void startTask() {
if (enabled) return;
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.instance, () ->
{
for (WaitTask task : taskMap.values()) {
int i = task.getWait() - 1;
if (i > 0) {
if (i != 1) {
task.getPlayer().sendMessage(task.getMessage().format((i + " Seconds")));
} else {
task.getPlayer().sendMessage(task.getMessage().format((i + " Second")));
}
task.setWait(i);
} else {
task.success();
taskMap.remove(task.getPlayer());
}
}
}, 0L, 20L);
enabled = true;
}
public static void handleAction(Player player) {
if (!taskMap.containsKey(player)) return;
taskMap.get(player).fail();
taskMap.remove(player);
}
}

View File

@@ -0,0 +1,47 @@
package com.massivecraft.factions.util.wait;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.entity.Player;
/**
* @author droppinganvil
*/
public class WaitTask {
private Integer wait;
private TL msg;
//Using player as to not have to convert every event
private Player player;
private WaitedTask origin;
public WaitTask(Integer wait, TL message, Player player, WaitedTask waitedTask) {
this.wait = wait;
this.msg = message;
this.player = player;
this.origin = waitedTask;
}
public Integer getWait() {
return wait;
}
public TL getMessage() {
return msg;
}
public Player getPlayer() {
return player;
}
public void setWait(Integer i) {
wait = i;
}
public void success() {
origin.handleSuccess(player);
}
public void fail() {
origin.handleFailure(player);
}
}

View File

@@ -0,0 +1,14 @@
package com.massivecraft.factions.util.wait;
import org.bukkit.entity.Player;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/4/2020
*/
public interface WaitedTask {
void handleSuccess(Player player);
void handleFailure(Player player);
}