mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Major cleanup
This commit is contained in:
@ -15,11 +15,9 @@ import com.gmail.nossr50.skills.Combat;
|
||||
|
||||
public class BleedTimer implements Runnable {
|
||||
private final static int MAX_BLEED_TICKS = 10;
|
||||
|
||||
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
|
||||
private static Map<LivingEntity, Integer> bleedAddList = new HashMap<LivingEntity, Integer>();
|
||||
private static List<LivingEntity> bleedRemoveList = new ArrayList<LivingEntity>();
|
||||
|
||||
private static boolean lock = false;
|
||||
|
||||
@Override
|
||||
|
@ -5,15 +5,15 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.SkillTools;
|
||||
|
||||
public class GainXp implements Runnable {
|
||||
private Player player = null;
|
||||
private PlayerProfile profile = null;
|
||||
private double baseXp = 0;
|
||||
private SkillType skillType = null;
|
||||
private LivingEntity target = null;
|
||||
private int baseHealth = 0;
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
private double baseXp;
|
||||
private SkillType skillType;
|
||||
private LivingEntity target;
|
||||
private int baseHealth;
|
||||
|
||||
public GainXp(Player player, PlayerProfile profile, SkillType skillType, double baseXp, LivingEntity target) {
|
||||
this.player = player;
|
||||
@ -39,6 +39,6 @@ public class GainXp implements Runnable {
|
||||
damage += health;
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, profile, skillType, (int) (damage * baseXp));
|
||||
SkillTools.xpProcessing(player, profile, skillType, (int) (damage * baseXp));
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import com.gmail.nossr50.skills.AbilityType;
|
||||
import com.gmail.nossr50.skills.SkillType;
|
||||
|
||||
public class GreenThumbTimer implements Runnable {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private Block block;
|
||||
private PlayerProfile profile;
|
||||
private Material type;
|
||||
@ -23,15 +22,16 @@ public class GreenThumbTimer implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.block.getType() != this.type)
|
||||
if (this.block.getType() != this.type) {
|
||||
this.block.setType(this.type);
|
||||
}
|
||||
|
||||
int skillLevel = this.profile.getSkillLevel(SkillType.HERBALISM);
|
||||
int greenThumbStage = (int) ((double) skillLevel / (double) AdvancedConfig.getInstance().getGreenThumbStageChange());
|
||||
|
||||
final int STAGE_CHANGE = advancedConfig.getGreenThumbStageChange();
|
||||
|
||||
int greenThumbStage = (int) ((double) skillLevel / (double) STAGE_CHANGE);
|
||||
if (greenThumbStage > 4) greenThumbStage = 4;
|
||||
if (greenThumbStage > 4) {
|
||||
greenThumbStage = 4;
|
||||
}
|
||||
|
||||
switch(this.type) {
|
||||
case CROPS:
|
||||
|
@ -5,14 +5,12 @@ import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.SkillTools;
|
||||
|
||||
public class McRankAsync implements Runnable {
|
||||
private Database database = mcMMO.getPlayerDatabase();
|
||||
private final String playerName;
|
||||
private final CommandSender sender;
|
||||
|
||||
@ -23,23 +21,26 @@ public class McRankAsync implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final Map<String, Integer> skills = database.readSQLRank(playerName);
|
||||
final Map<String, Integer> skills = Database.readSQLRank(playerName);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName}));
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) continue;
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (skillType.equals(SkillType.ALL))
|
||||
continue; // We want the overall ranking to be at the bottom
|
||||
|
||||
if (skills.get(skillType.name()) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} ));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} ));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), skills.get(skillType.name())} ));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), skills.get(skillType.name())} ));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,37 +5,34 @@ import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class MobStoreCleaner implements Runnable
|
||||
{
|
||||
public class MobStoreCleaner implements Runnable {
|
||||
private int taskID;
|
||||
|
||||
public MobStoreCleaner()
|
||||
{
|
||||
public MobStoreCleaner() {
|
||||
taskID = -1;
|
||||
start();
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
if (taskID >= 0)
|
||||
public void start() {
|
||||
if (taskID >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
|
||||
taskID = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
if(taskID < 0)
|
||||
public void stop() {
|
||||
if (taskID < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().cancelTask(taskID);
|
||||
taskID = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
mcMMO.placeStore.cleanMobLists();
|
||||
}
|
||||
}
|
@ -9,17 +9,11 @@ import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class SQLConversionTask implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
public SQLConversionTask(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String location = mcMMO.getUsersFile();
|
||||
String location = mcMMO.getUsersFilePath();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
@ -166,7 +160,7 @@ public class SQLConversionTask implements Runnable {
|
||||
}
|
||||
|
||||
//Check to see if the user is in the DB
|
||||
id = database.getInt("SELECT id FROM "
|
||||
id = Database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '" + playerName + "'");
|
||||
|
||||
@ -174,11 +168,11 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Update the skill values
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@ -194,7 +188,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
@ -215,32 +209,32 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Create the user in the DB
|
||||
database.write("INSERT INTO "
|
||||
Database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "users (user, lastlogin) VALUES ('"
|
||||
+ playerName + "',"
|
||||
+ System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
||||
id = database.getInt("SELECT id FROM "
|
||||
id = Database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '"
|
||||
+ playerName + "'");
|
||||
database.write("INSERT INTO "
|
||||
Database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "skills (user_id) VALUES (" + id + ")");
|
||||
database.write("INSERT INTO "
|
||||
Database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "experience (user_id) VALUES (" + id
|
||||
+ ")");
|
||||
//Update the skill values
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET party = '" + party
|
||||
+ "' WHERE id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@ -256,7 +250,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
@ -279,7 +273,7 @@ public class SQLConversionTask implements Runnable {
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,19 +7,13 @@ import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SQLReconnect implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public SQLReconnect(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Database.checkConnected()) {
|
||||
Users.saveAll(); //Save all profiles
|
||||
Users.clearAll(); //Clear the profiles
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
}
|
||||
}
|
||||
|
@ -8,23 +8,17 @@ import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SaveTimer implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public SaveTimer(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
BukkitScheduler bukkitScheduler = plugin.getServer().getScheduler();
|
||||
BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler();
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : Users.getPlayers().values()) {
|
||||
bukkitScheduler.scheduleSyncDelayedTask(plugin, new ProfileSaveTask(mcMMOPlayer), count);
|
||||
bukkitScheduler.scheduleSyncDelayedTask(mcMMO.p, new ProfileSaveTask(mcMMOPlayer), count);
|
||||
count++;
|
||||
}
|
||||
|
||||
PartyManager.getInstance().saveParties();
|
||||
PartyManager.saveParties();
|
||||
}
|
||||
}
|
||||
|
@ -6,22 +6,15 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.skills.AbilityType;
|
||||
import com.gmail.nossr50.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.SkillTools;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillMonitor implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public SkillMonitor(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
long curTime = System.currentTimeMillis();
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
/*
|
||||
@ -29,7 +22,7 @@ public class SkillMonitor implements Runnable {
|
||||
*/
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.getTool() != null && skill.getAbility() != null) {
|
||||
Skills.monitorSkill(player, profile, curTime, skill);
|
||||
SkillTools.monitorSkill(player, profile, curTime, skill);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,8 +30,8 @@ public class SkillMonitor implements Runnable {
|
||||
* COOLDOWN MONITORING
|
||||
*/
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
if (ability.getCooldown() > 0 ) {
|
||||
Skills.watchCooldown(player, profile, ability);
|
||||
if (ability.getCooldown() > 0) {
|
||||
SkillTools.watchCooldown(player, profile, ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,13 @@ public class StickyPistonTracker implements Runnable {
|
||||
Block newBlock = event.getBlock().getRelative(event.getDirection());
|
||||
Block originalBlock = newBlock.getRelative(event.getDirection());
|
||||
|
||||
if (originalBlock.getType() != Material.AIR)
|
||||
if (originalBlock.getType() != Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mcMMO.placeStore.isTrue(originalBlock))
|
||||
if (!mcMMO.placeStore.isTrue(originalBlock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.placeStore.setFalse(originalBlock);
|
||||
mcMMO.placeStore.setTrue(newBlock);
|
||||
|
@ -1,23 +1,16 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
|
||||
public class UserPurgeTask implements Runnable {
|
||||
private Database database = mcMMO.getPlayerDatabase();
|
||||
|
||||
public UserPurgeTask() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
database.purgePowerlessSQL();
|
||||
Database.purgePowerlessSQL();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
database.purgeOldSQL();
|
||||
Database.purgeOldSQL();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -53,8 +53,9 @@ public class BlockStoreConversionMain implements Runnable {
|
||||
this.xDirs = this.dataDir.listFiles();
|
||||
|
||||
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) {
|
||||
if (this.converters[this.i] == null)
|
||||
if (this.converters[this.i] == null) {
|
||||
this.converters[this.i] = new BlockStoreConversionXDirectory();
|
||||
}
|
||||
|
||||
this.converters[this.i].start(this.world, this.xDirs[this.i]);
|
||||
}
|
||||
@ -63,8 +64,9 @@ public class BlockStoreConversionMain implements Runnable {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (this.taskID < 0)
|
||||
if (this.taskID < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.scheduler.cancelTask(this.taskID);
|
||||
this.taskID = -1;
|
||||
|
@ -25,8 +25,9 @@ public class BlockStoreConversionXDirectory implements Runnable {
|
||||
this.converters = new BlockStoreConversionZDirectory[HiddenConfig.getInstance().getConversionRate()];
|
||||
this.dataDir = dataDir;
|
||||
|
||||
if (this.taskID >= 0)
|
||||
if (this.taskID >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1);
|
||||
return;
|
||||
@ -54,8 +55,9 @@ public class BlockStoreConversionXDirectory implements Runnable {
|
||||
this.zDirs = this.dataDir.listFiles();
|
||||
|
||||
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) {
|
||||
if (this.converters[this.i] == null)
|
||||
if (this.converters[this.i] == null) {
|
||||
this.converters[this.i] = new BlockStoreConversionZDirectory();
|
||||
}
|
||||
|
||||
this.converters[this.i].start(this.world, this.dataDir, this.zDirs[this.i]);
|
||||
}
|
||||
@ -64,8 +66,9 @@ public class BlockStoreConversionXDirectory implements Runnable {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (this.taskID < 0)
|
||||
if (this.taskID < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.scheduler.cancelTask(this.taskID);
|
||||
this.taskID = -1;
|
||||
|
@ -38,8 +38,9 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
||||
this.dataDir = dataDir;
|
||||
this.xDir = xDir;
|
||||
|
||||
if (this.taskID >= 0)
|
||||
if (this.taskID >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1);
|
||||
return;
|
||||
@ -110,8 +111,9 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
||||
|
||||
for (this.y2 = (64 * this.y); this.y2 < (64 * this.y + 64); this.y2++) {
|
||||
try {
|
||||
if (!this.manager.isTrue(this.cxPos, this.y2, this.czPos, this.world))
|
||||
if (!this.manager.isTrue(this.cxPos, this.y2, this.czPos, this.world)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.newManager.setTrue(this.cxPos, this.y2, this.czPos, this.world);
|
||||
}
|
||||
@ -119,6 +121,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -128,17 +131,26 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
||||
|
||||
for (this.x = 0; this.x < 16; this.x++) {
|
||||
for (this.z = 0; this.z < 16; this.z++) {
|
||||
if (this.primitiveChunklet != null)
|
||||
if (this.primitiveChunklet != null) {
|
||||
this.oldArray = this.primitiveChunklet.store[x][z];
|
||||
if (this.primitiveExChunklet != null)
|
||||
}
|
||||
|
||||
if (this.primitiveExChunklet != null) {
|
||||
this.oldArray = this.primitiveExChunklet.store[x][z];
|
||||
else
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
this.newArray = this.currentChunk.store[x][z];
|
||||
if (this.oldArray.length < 64)
|
||||
|
||||
if (this.oldArray.length < 64) {
|
||||
return;
|
||||
else if (this.newArray.length < ((this.y * 64) + 64))
|
||||
}
|
||||
else if (this.newArray.length < ((this.y * 64) + 64)) {
|
||||
return;
|
||||
}
|
||||
|
||||
System.arraycopy(this.oldArray, 0, this.newArray, (this.y * 64), 64);
|
||||
}
|
||||
}
|
||||
@ -148,8 +160,9 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
||||
this.newManager.unloadChunk(this.cx, this.cz, this.world);
|
||||
|
||||
for (File yFile : dataDir.listFiles()) {
|
||||
if (!yFile.exists())
|
||||
if (!yFile.exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
yFile.delete();
|
||||
}
|
||||
|
Reference in New Issue
Block a user