mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-03 21:15:28 +02:00
Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into tridentsxbows
This commit is contained in:
@@ -14,7 +14,7 @@ public class CheckDateTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
// Set up jokes
|
||||
new AprilTask().runTaskTimer(mcMMO.p, 1L * 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR);
|
||||
new AprilTask().runTaskTimer(mcMMO.p, 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR);
|
||||
mcMMO.getHolidayManager().registerAprilCommand();
|
||||
|
||||
// Jokes deployed.
|
||||
|
@@ -5,7 +5,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
|
||||
private LivingEntity target;
|
||||
private final LivingEntity target;
|
||||
|
||||
public MobHealthDisplayUpdaterTask(LivingEntity target) {
|
||||
this.target = target;
|
||||
|
@@ -9,9 +9,9 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import java.util.List;
|
||||
|
||||
public class PistonTrackerTask extends BukkitRunnable {
|
||||
private List<Block> blocks;
|
||||
private BlockFace direction;
|
||||
private Block futureEmptyBlock;
|
||||
private final List<Block> blocks;
|
||||
private final BlockFace direction;
|
||||
private final Block futureEmptyBlock;
|
||||
|
||||
public PistonTrackerTask(List<Block> blocks, BlockFace direction, Block futureEmptyBlock) {
|
||||
this.blocks = blocks;
|
||||
|
@@ -7,9 +7,9 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class StickyPistonTrackerTask extends BukkitRunnable {
|
||||
private BlockFace direction;
|
||||
private Block block;
|
||||
private Block movedBlock;
|
||||
private final BlockFace direction;
|
||||
private final Block block;
|
||||
private final Block movedBlock;
|
||||
|
||||
public StickyPistonTrackerTask(BlockFace direction, Block block, Block movedBlock) {
|
||||
this.direction = direction;
|
||||
|
@@ -16,9 +16,9 @@ public class CleanBackupsTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
List<Integer> savedDays = new ArrayList<Integer>();
|
||||
HashMap<Integer, List<Integer>> savedYearsWeeks = new HashMap<Integer, List<Integer>>();
|
||||
List<File> toDelete = new ArrayList<File>();
|
||||
List<Integer> savedDays = new ArrayList<>();
|
||||
HashMap<Integer, List<Integer>> savedYearsWeeks = new HashMap<>();
|
||||
List<File> toDelete = new ArrayList<>();
|
||||
int amountTotal = 0;
|
||||
int amountDeleted = 0;
|
||||
|
||||
@@ -58,11 +58,7 @@ public class CleanBackupsTask extends BukkitRunnable {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
List<Integer> savedWeeks = savedYearsWeeks.get(year);
|
||||
if (savedWeeks == null) {
|
||||
savedWeeks = new ArrayList<Integer>();
|
||||
savedYearsWeeks.put(year, savedWeeks);
|
||||
}
|
||||
List<Integer> savedWeeks = savedYearsWeeks.computeIfAbsent(year, k -> new ArrayList<>());
|
||||
|
||||
if (!savedWeeks.contains(weekOfYear) && Config.getInstance().getKeepWeeklyPastMonth()) {
|
||||
// Keep one backup of each week
|
||||
|
@@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class McScoreboardKeepTask extends BukkitRunnable {
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
public McScoreboardKeepTask(Player player) {
|
||||
this.player = player;
|
||||
|
@@ -21,11 +21,6 @@ public class DatabaseConversionTask extends BukkitRunnable {
|
||||
public void run() {
|
||||
sourceDatabase.convertUsers(mcMMO.getDatabaseManager());
|
||||
|
||||
mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
});
|
||||
mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, () -> sender.sendMessage(message));
|
||||
}
|
||||
}
|
||||
|
@@ -14,8 +14,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class FormulaConversionTask extends BukkitRunnable {
|
||||
private CommandSender sender;
|
||||
private FormulaType formulaType;
|
||||
private final CommandSender sender;
|
||||
private final FormulaType formulaType;
|
||||
|
||||
public FormulaConversionTask(CommandSender sender, FormulaType formulaType) {
|
||||
this.sender = sender;
|
||||
|
@@ -1,105 +1,130 @@
|
||||
package com.gmail.nossr50.runnables.database;
|
||||
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.uuid.UUIDFetcher;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
||||
private mcMMO plugin;
|
||||
private static final int MAX_LOOKUP = Math.max(HiddenConfig.getInstance().getUUIDConvertAmount(), 100);
|
||||
private static final int RATE_LIMIT = HiddenConfig.getInstance().getMojangRateLimit();
|
||||
private static final long LIMIT_PERIOD = HiddenConfig.getInstance().getMojangLimitPeriod();
|
||||
private static final int BATCH_SIZE = MAX_LOOKUP * 3;
|
||||
public class UUIDUpdateAsyncTask implements Runnable {
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
|
||||
|
||||
private List<String> userNames;
|
||||
private int size;
|
||||
private int checkedUsers;
|
||||
private long startMillis;
|
||||
private static final int HARD_LIMIT_PERIOD = 600; // Mojang rate limit period is 600 seconds, wait that long if they reject us
|
||||
private static final int RETRY_PERIOD = 60; // Wait 60 seconds on connection failure
|
||||
private static final int DELAY_PERIOD = 100; // Wait 100 seconds between each batch
|
||||
|
||||
private static final int BATCH_SIZE = 100; // 100 at a time
|
||||
|
||||
private final Object awaiter = new Object();
|
||||
private final mcMMO plugin;
|
||||
private final ImmutableList<String> userNames;
|
||||
private int position = 0;
|
||||
|
||||
public UUIDUpdateAsyncTask(mcMMO plugin, List<String> userNames) {
|
||||
this.plugin = plugin;
|
||||
this.userNames = userNames;
|
||||
|
||||
this.checkedUsers = 0;
|
||||
this.startMillis = System.currentTimeMillis();
|
||||
this.userNames = ImmutableList.copyOf(userNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
size = userNames.size();
|
||||
// First iteration
|
||||
if (position == 0)
|
||||
plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + userNames.size());
|
||||
|
||||
plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size);
|
||||
List<String> batch = userNames.subList(position, Math.min(userNames.size(), position + BATCH_SIZE));
|
||||
|
||||
List<String> userNamesSection;
|
||||
Map<String, UUID> fetchedUUIDs = new HashMap<String, UUID>();
|
||||
Map<String, UUID> fetchedUUIDs = new HashMap<>();
|
||||
HttpURLConnection connection;
|
||||
try {
|
||||
connection = (HttpURLConnection) new URL(PROFILE_URL).openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
|
||||
while (size != 0) {
|
||||
if (checkedUsers + 100 > RATE_LIMIT) {
|
||||
try {
|
||||
Thread.sleep(LIMIT_PERIOD);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
String body = GSON.toJson(batch.toArray(new String[0]));
|
||||
|
||||
try (OutputStream output = connection.getOutputStream()) {
|
||||
output.write(body.getBytes());
|
||||
output.flush();
|
||||
}
|
||||
switch (connection.getResponseCode()) {
|
||||
case HttpURLConnection.HTTP_OK:
|
||||
break; // All is good
|
||||
case HttpURLConnection.HTTP_BAD_REQUEST:
|
||||
case HttpURLConnection.HTTP_FORBIDDEN:
|
||||
// Rejected, probably rate limit, just wait it out
|
||||
this.runTaskLaterAsynchronously(plugin, Misc.TICK_CONVERSION_FACTOR * HARD_LIMIT_PERIOD);
|
||||
return;
|
||||
default:
|
||||
// Unknown failure
|
||||
this.runTaskLaterAsynchronously(plugin, Misc.TICK_CONVERSION_FACTOR * RETRY_PERIOD);
|
||||
return;
|
||||
}
|
||||
|
||||
try (InputStream input = connection.getInputStream();
|
||||
InputStreamReader reader = new InputStreamReader(input)) {
|
||||
for (JsonObject jsonProfile : GSON.fromJson(reader, JsonObject[].class)) {
|
||||
UUID id = toUUID(jsonProfile.get("id").getAsString());
|
||||
String name = jsonProfile.get("name").getAsString();
|
||||
fetchedUUIDs.put(name, id);
|
||||
}
|
||||
startMillis = System.currentTimeMillis();
|
||||
checkedUsers = 0;
|
||||
}
|
||||
if (size > MAX_LOOKUP) {
|
||||
userNamesSection = userNames.subList(size - MAX_LOOKUP, size);
|
||||
size -= MAX_LOOKUP;
|
||||
}
|
||||
else {
|
||||
userNamesSection = userNames.subList(0, size);
|
||||
size = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
fetchedUUIDs.putAll(new UUIDFetcher(userNamesSection).call());
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Handle 429
|
||||
if(e.getMessage() != null)
|
||||
{
|
||||
if (e.getMessage().contains("429")) {
|
||||
size += userNamesSection.size();
|
||||
try {
|
||||
Thread.sleep(LIMIT_PERIOD);
|
||||
} catch (InterruptedException ex) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e);
|
||||
return;
|
||||
}
|
||||
|
||||
checkedUsers += userNamesSection.size();
|
||||
userNamesSection.clear();
|
||||
size = userNames.size();
|
||||
|
||||
Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);
|
||||
if (fetchedUUIDs.size() >= BATCH_SIZE) {
|
||||
mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs);
|
||||
fetchedUUIDs = new HashMap<String, UUID>();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// failure
|
||||
plugin.getLogger().log(Level.SEVERE, "Unable to contact mojang API!", e);
|
||||
this.runTaskLaterAsynchronously(plugin, Misc.TICK_CONVERSION_FACTOR * RETRY_PERIOD);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fetchedUUIDs.size() == 0 || mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) {
|
||||
if (fetchedUUIDs.size() != 0)
|
||||
mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs);
|
||||
|
||||
position += batch.size();
|
||||
plugin.getLogger().info(String.format("Conversion progress: %d/%d users", position, userNames.size()));
|
||||
|
||||
if (position == userNames.size())
|
||||
{
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
|
||||
plugin.getLogger().info("UUID upgrade completed!");
|
||||
awaiter.notify();
|
||||
}
|
||||
else
|
||||
this.runTaskLaterAsynchronously(plugin, Misc.TICK_CONVERSION_FACTOR * DELAY_PERIOD); // Schedule next batch
|
||||
}
|
||||
|
||||
// Bukkit runnables don't let themselves reschedule themselves, so we are a pseudo bukkit runnable.
|
||||
private void runTaskLaterAsynchronously(mcMMO plugin, int delay) {
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, this, delay);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, this);
|
||||
}
|
||||
|
||||
private static UUID toUUID(String id) {
|
||||
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
|
||||
}
|
||||
|
||||
public void waitUntilFinished() {
|
||||
try {
|
||||
awaiter.wait();
|
||||
} catch (InterruptedException e) {
|
||||
// I guess we don't care in this event
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class UserPurgeTask extends BukkitRunnable {
|
||||
private ReentrantLock lock = new ReentrantLock();
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
@Override
|
||||
public void run() {
|
||||
lock.lock();
|
||||
|
@@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ChimaeraWingWarmup extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private final McMMOPlayer mcMMOPlayer;
|
||||
|
||||
public ChimaeraWingWarmup(McMMOPlayer mcMMOPlayer) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
|
@@ -14,8 +14,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class TeleportationWarmup extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private McMMOPlayer mcMMOTarget;
|
||||
private final McMMOPlayer mcMMOPlayer;
|
||||
private final McMMOPlayer mcMMOTarget;
|
||||
|
||||
public TeleportationWarmup(McMMOPlayer mcMMOPlayer, McMMOPlayer mcMMOTarget) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
|
@@ -18,8 +18,8 @@ public class PartyAutoKickTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
HashMap<OfflinePlayer, Party> toRemove = new HashMap<OfflinePlayer, Party>();
|
||||
List<UUID> processedPlayers = new ArrayList<UUID>();
|
||||
HashMap<OfflinePlayer, Party> toRemove = new HashMap<>();
|
||||
List<UUID> processedPlayers = new ArrayList<>();
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
|
@@ -12,11 +12,11 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class PartyChatTask extends BukkitRunnable {
|
||||
private Plugin plugin;
|
||||
private final Plugin plugin;
|
||||
|
||||
private Party party;
|
||||
private String senderName;
|
||||
private String displayName;
|
||||
private final Party party;
|
||||
private final String senderName;
|
||||
private final String displayName;
|
||||
private String message;
|
||||
|
||||
public PartyChatTask(Plugin plugin, Party party, String senderName, String displayName, String message) {
|
||||
|
@@ -96,7 +96,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
|
||||
if (Config.getInstance().getShowStatsAfterLogin()) {
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
||||
new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, 1 * Misc.TICK_CONVERSION_FACTOR);
|
||||
new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,8 +4,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class PlayerProfileSaveTask extends BukkitRunnable {
|
||||
private PlayerProfile playerProfile;
|
||||
private boolean isSync;
|
||||
private final PlayerProfile playerProfile;
|
||||
private final boolean isSync;
|
||||
|
||||
public PlayerProfileSaveTask(PlayerProfile playerProfile, boolean isSync) {
|
||||
this.playerProfile = playerProfile;
|
||||
|
@@ -5,7 +5,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PlayerUpdateInventoryTask extends BukkitRunnable {
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
public PlayerUpdateInventoryTask(Player player) {
|
||||
this.player = player;
|
||||
|
@@ -7,8 +7,8 @@ import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class AbilityCooldownTask extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private SuperAbilityType ability;
|
||||
private final McMMOPlayer mcMMOPlayer;
|
||||
private final SuperAbilityType ability;
|
||||
|
||||
public AbilityCooldownTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@@ -17,8 +18,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class AbilityDisableTask extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private SuperAbilityType ability;
|
||||
private final McMMOPlayer mcMMOPlayer;
|
||||
private final SuperAbilityType ability;
|
||||
|
||||
public AbilityDisableTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
@@ -41,7 +42,7 @@ public class AbilityDisableTask extends BukkitRunnable {
|
||||
|
||||
case BERSERK:
|
||||
if (Config.getInstance().getRefreshChunksEnabled()) {
|
||||
resendChunkRadiusAt(player, 1);
|
||||
resendChunkRadiusAt(player);
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
@@ -61,18 +62,21 @@ public class AbilityDisableTask extends BukkitRunnable {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_OFF, ability.getAbilityOff());
|
||||
}
|
||||
|
||||
|
||||
SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff());
|
||||
if (AdvancedConfig.getInstance().sendAbilityNotificationToOtherPlayers()) {
|
||||
SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff());
|
||||
}
|
||||
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
private void resendChunkRadiusAt(Player player, int radius) {
|
||||
private void resendChunkRadiusAt(Player player) {
|
||||
Chunk chunk = player.getLocation().getChunk();
|
||||
World world = player.getWorld();
|
||||
|
||||
int chunkX = chunk.getX();
|
||||
int chunkZ = chunk.getZ();
|
||||
|
||||
int radius = 1;
|
||||
|
||||
for (int x = chunkX - radius; x <= chunkX + radius; x++) {
|
||||
for (int z = chunkZ - radius; z <= chunkZ + radius; z++) {
|
||||
world.refreshChunk(x, z);
|
||||
|
@@ -11,9 +11,9 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AlchemyBrewCheckTask extends BukkitRunnable {
|
||||
private Player player;
|
||||
private BrewingStand brewingStand;
|
||||
private ItemStack[] oldInventory;
|
||||
private final Player player;
|
||||
private final BrewingStand brewingStand;
|
||||
private final ItemStack[] oldInventory;
|
||||
|
||||
public AlchemyBrewCheckTask(Player player, BrewingStand brewingStand) {
|
||||
this.player = player;
|
||||
|
@@ -18,14 +18,14 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class AlchemyBrewTask extends BukkitRunnable {
|
||||
private static double DEFAULT_BREW_SPEED = 1.0;
|
||||
private static int DEFAULT_BREW_TICKS = 400;
|
||||
private static final double DEFAULT_BREW_SPEED = 1.0;
|
||||
private static final int DEFAULT_BREW_TICKS = 400;
|
||||
|
||||
private BlockState brewingStand;
|
||||
private Location location;
|
||||
private final BlockState brewingStand;
|
||||
private final Location location;
|
||||
private double brewSpeed;
|
||||
private double brewTimer;
|
||||
private Player player;
|
||||
private final Player player;
|
||||
private int fuel;
|
||||
private boolean firstRun = true;
|
||||
|
||||
|
@@ -8,12 +8,12 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class AwardCombatXpTask extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private double baseXp;
|
||||
private PrimarySkillType primarySkillType;
|
||||
private LivingEntity target;
|
||||
private XPGainReason xpGainReason;
|
||||
private double baseHealth;
|
||||
private final McMMOPlayer mcMMOPlayer;
|
||||
private final double baseXp;
|
||||
private final PrimarySkillType primarySkillType;
|
||||
private final LivingEntity target;
|
||||
private final XPGainReason xpGainReason;
|
||||
private final double baseHealth;
|
||||
|
||||
public AwardCombatXpTask(McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, double baseXp, LivingEntity target, XPGainReason xpGainReason) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
|
@@ -23,7 +23,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class BleedTimerTask extends BukkitRunnable {
|
||||
private static Map<LivingEntity, BleedContainer> bleedList = new HashMap<LivingEntity, BleedContainer>();
|
||||
private static final Map<LivingEntity, BleedContainer> bleedList = new HashMap<>();
|
||||
private static boolean isIterating = false;
|
||||
|
||||
@Override
|
||||
@@ -71,8 +71,7 @@ public class BleedTimerTask extends BukkitRunnable {
|
||||
//Count Armor
|
||||
for(ItemStack armorPiece : ((Player) target).getInventory().getArmorContents())
|
||||
{
|
||||
if(armorPiece != null)
|
||||
armorCount++;
|
||||
armorCount++;
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -155,8 +154,7 @@ public class BleedTimerTask extends BukkitRunnable {
|
||||
int bleedRank = container.bleedRank;
|
||||
int toolTier = container.toolTier;
|
||||
|
||||
BleedContainer newContainer = new BleedContainer(target, bleedTicks, bleedRank, toolTier, source);
|
||||
return newContainer;
|
||||
return new BleedContainer(target, bleedTicks, bleedRank, toolTier, source);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -98,7 +98,7 @@ public class DelayedCropReplant extends BukkitRunnable {
|
||||
|
||||
}
|
||||
|
||||
private class markPlantAsOld extends BukkitRunnable {
|
||||
private static class markPlantAsOld extends BukkitRunnable {
|
||||
|
||||
private final Location cropLoc;
|
||||
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class FurnaceCleanupTask extends BukkitRunnable {
|
||||
|
||||
private final Furnace furnace;
|
||||
|
||||
public FurnaceCleanupTask(Furnace furnace) {
|
||||
this.furnace = furnace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(furnace != null && furnace.getInventory().getResult() == null) {
|
||||
//Furnace is empty so stop tracking it
|
||||
mcMMO.getSmeltingTracker().untrackFurnace(furnace);
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class HerbalismBlockUpdaterTask extends BukkitRunnable {
|
||||
private BlockState blockState;
|
||||
private final BlockState blockState;
|
||||
|
||||
public HerbalismBlockUpdaterTask(BlockState blockState) {
|
||||
this.blockState = blockState;
|
||||
|
@@ -7,9 +7,9 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
|
||||
public class SkillUnlockNotificationTask extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private SubSkillType subSkillType;
|
||||
private int rank;
|
||||
private final McMMOPlayer mcMMOPlayer;
|
||||
private final SubSkillType subSkillType;
|
||||
private final int rank;
|
||||
/**
|
||||
* Notify a player about a newly unlocked subskill
|
||||
* @param mcMMOPlayer target player
|
||||
|
@@ -8,8 +8,8 @@ import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ToolLowerTask extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private ToolType tool;
|
||||
private final McMMOPlayer mcMMOPlayer;
|
||||
private final ToolType tool;
|
||||
|
||||
public ToolLowerTask(McMMOPlayer mcMMOPlayer, ToolType tool) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
|
Reference in New Issue
Block a user