mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Runnables cleanup
This commit is contained in:
@ -5,18 +5,19 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.Users;
|
||||
|
||||
public class RemoveProfileFromMemoryTask implements Runnable {
|
||||
private Player player;
|
||||
private Player player;
|
||||
|
||||
public RemoveProfileFromMemoryTask(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
public RemoveProfileFromMemoryTask(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
|
||||
if(Users.players.containsKey(player.getName().toLowerCase())) {
|
||||
Users.getProfile(player.getName()).save(); //We save here so players don't quit/reconnect to cause lag
|
||||
Users.removeUserByName(player.getName());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
String playerName = player.getName();
|
||||
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
|
||||
if (Users.players.containsKey(playerName.toLowerCase())) {
|
||||
Users.getProfile(playerName).save(); //We save here so players don't quit/reconnect to cause lag
|
||||
Users.removeUserByName(playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
|
||||
public class SQLConversionTask implements Runnable {
|
||||
public SQLConversionTask() {}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -175,40 +174,36 @@ public class SQLConversionTask implements Runnable {
|
||||
+ " WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "skills SET " + " taming = taming+"
|
||||
+ m.getInt(taming) + ", mining = mining+"
|
||||
+ m.getInt(mining) + ", repair = repair+"
|
||||
+ m.getInt(repair)
|
||||
+ ", woodcutting = woodcutting+"
|
||||
+ m.getInt(woodcutting)
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + m.getInt(taming)
|
||||
+ ", mining = mining+" + m.getInt(mining)
|
||||
+ ", repair = repair+" + m.getInt(repair)
|
||||
+ ", woodcutting = woodcutting+" + m.getInt(woodcutting)
|
||||
+ ", unarmed = unarmed+" + m.getInt(unarmed)
|
||||
+ ", herbalism = herbalism+"
|
||||
+ m.getInt(herbalism)
|
||||
+ ", excavation = excavation+"
|
||||
+ m.getInt(excavation)
|
||||
+ ", herbalism = herbalism+" + m.getInt(herbalism)
|
||||
+ ", excavation = excavation+" + m.getInt(excavation)
|
||||
+ ", archery = archery+" + m.getInt(archery)
|
||||
+ ", swords = swords+" + m.getInt(swords)
|
||||
+ ", axes = axes+" + m.getInt(axes)
|
||||
+ ", acrobatics = acrobatics+"
|
||||
+ m.getInt(acrobatics)
|
||||
+ ", acrobatics = acrobatics+" + m.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + m.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "experience SET " + " taming = "
|
||||
+ m.getInt(tamingXP) + ", mining = "
|
||||
+ m.getInt(miningXP) + ", repair = "
|
||||
+ m.getInt(repairXP) + ", woodcutting = "
|
||||
+ m.getInt(woodCuttingXP) + ", unarmed = "
|
||||
+ m.getInt(unarmedXP) + ", herbalism = "
|
||||
+ m.getInt(herbalismXP) + ", excavation = "
|
||||
+ m.getInt(excavationXP) + ", archery = "
|
||||
+ m.getInt(archeryXP) + ", swords = "
|
||||
+ m.getInt(swordsXP) + ", axes = "
|
||||
+ m.getInt(axesXP) + ", acrobatics = "
|
||||
+ m.getInt(acrobaticsXP) + ", fishing = "
|
||||
+ m.getInt(fishingXP) + " WHERE user_id = "
|
||||
+ id);
|
||||
+ "experience SET "
|
||||
+ " taming = " + m.getInt(tamingXP)
|
||||
+ ", mining = " + m.getInt(miningXP)
|
||||
+ ", repair = " + m.getInt(repairXP)
|
||||
+ ", woodcutting = " + m.getInt(woodCuttingXP)
|
||||
+ ", unarmed = " + m.getInt(unarmedXP)
|
||||
+ ", herbalism = " + m.getInt(herbalismXP)
|
||||
+ ", excavation = " + m.getInt(excavationXP)
|
||||
+ ", archery = " + m.getInt(archeryXP)
|
||||
+ ", swords = " + m.getInt(swordsXP)
|
||||
+ ", axes = " + m.getInt(axesXP)
|
||||
+ ", acrobatics = " + m.getInt(acrobaticsXP)
|
||||
+ ", fishing = " + m.getInt(fishingXP)
|
||||
+ " WHERE user_id = " + id);
|
||||
}
|
||||
else {
|
||||
theCount++;
|
||||
@ -241,40 +236,40 @@ public class SQLConversionTask implements Runnable {
|
||||
+ "' WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "skills SET " + " taming = "
|
||||
+ m.getInt(taming) + ", mining = "
|
||||
+ m.getInt(mining) + ", repair = "
|
||||
+ m.getInt(repair) + ", woodcutting = "
|
||||
+ m.getInt(woodcutting) + ", unarmed = "
|
||||
+ m.getInt(unarmed) + ", herbalism = "
|
||||
+ m.getInt(herbalism) + ", excavation = "
|
||||
+ m.getInt(excavation) + ", archery = "
|
||||
+ m.getInt(archery) + ", swords = "
|
||||
+ m.getInt(swords) + ", axes = "
|
||||
+ m.getInt(axes) + ", acrobatics = "
|
||||
+ m.getInt(acrobatics) + ", fishing = "
|
||||
+ m.getInt(fishing) + " WHERE user_id = "
|
||||
+ id);
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + m.getInt(taming)
|
||||
+ ", mining = mining+" + m.getInt(mining)
|
||||
+ ", repair = repair+" + m.getInt(repair)
|
||||
+ ", woodcutting = woodcutting+" + m.getInt(woodcutting)
|
||||
+ ", unarmed = unarmed+" + m.getInt(unarmed)
|
||||
+ ", herbalism = herbalism+" + m.getInt(herbalism)
|
||||
+ ", excavation = excavation+" + m.getInt(excavation)
|
||||
+ ", archery = archery+" + m.getInt(archery)
|
||||
+ ", swords = swords+" + m.getInt(swords)
|
||||
+ ", axes = axes+" + m.getInt(axes)
|
||||
+ ", acrobatics = acrobatics+" + m.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + m.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "experience SET " + " taming = "
|
||||
+ m.getInt(tamingXP) + ", mining = "
|
||||
+ m.getInt(miningXP) + ", repair = "
|
||||
+ m.getInt(repairXP) + ", woodcutting = "
|
||||
+ m.getInt(woodCuttingXP) + ", unarmed = "
|
||||
+ m.getInt(unarmedXP) + ", herbalism = "
|
||||
+ m.getInt(herbalismXP) + ", excavation = "
|
||||
+ m.getInt(excavationXP) + ", archery = "
|
||||
+ m.getInt(archeryXP) + ", swords = "
|
||||
+ m.getInt(swordsXP) + ", axes = "
|
||||
+ m.getInt(axesXP) + ", acrobatics = "
|
||||
+ m.getInt(acrobaticsXP) + ", fishing = "
|
||||
+ m.getInt(fishingXP) + " WHERE user_id = "
|
||||
+ id);
|
||||
+ "experience SET "
|
||||
+ " taming = " + m.getInt(tamingXP)
|
||||
+ ", mining = " + m.getInt(miningXP)
|
||||
+ ", repair = " + m.getInt(repairXP)
|
||||
+ ", woodcutting = " + m.getInt(woodCuttingXP)
|
||||
+ ", unarmed = " + m.getInt(unarmedXP)
|
||||
+ ", herbalism = " + m.getInt(herbalismXP)
|
||||
+ ", excavation = " + m.getInt(excavationXP)
|
||||
+ ", archery = " + m.getInt(archeryXP)
|
||||
+ ", swords = " + m.getInt(swordsXP)
|
||||
+ ", axes = " + m.getInt(axesXP)
|
||||
+ ", acrobatics = " + m.getInt(acrobaticsXP)
|
||||
+ ", fishing = " + m.getInt(fishingXP)
|
||||
+ " WHERE user_id = " + id);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB");
|
||||
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB"); //TODO: Locale
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -9,13 +9,12 @@ import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
|
||||
public class SpoutStart implements Runnable{
|
||||
|
||||
mcMMO plugin;
|
||||
|
||||
private final mcMMO plugin;
|
||||
|
||||
public SpoutStart(mcMMO m) {
|
||||
plugin = m;
|
||||
this.plugin = m;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Bukkit.getPluginManager().getPlugin("Spout") != null) {
|
||||
@ -24,7 +23,7 @@ public class SpoutStart implements Runnable{
|
||||
else {
|
||||
LoadProperties.spoutEnabled = false;
|
||||
}
|
||||
|
||||
|
||||
//Spout Stuff
|
||||
if (LoadProperties.spoutEnabled) {
|
||||
SpoutStuff.setupSpoutConfigs();
|
||||
|
@ -52,7 +52,7 @@ public class mcBleedTimer implements Runnable {
|
||||
}
|
||||
|
||||
PP.decreaseBleedTicks();
|
||||
|
||||
|
||||
if (PP.getBleedTicks() == 0) {
|
||||
player.sendMessage(mcLocale.getString("Swords.StoppedBleeding"));
|
||||
}
|
||||
|
@ -7,19 +7,16 @@ import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class mcSaveTimer implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public mcSaveTimer(final mcMMO plugin)
|
||||
{
|
||||
|
||||
public mcSaveTimer(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
//All player data will be saved periodically through this
|
||||
for(Player player : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.getProfile(player).save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -9,49 +9,50 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
public class mcTimer implements Runnable
|
||||
{
|
||||
private final mcMMO plugin;
|
||||
public class mcTimer implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public mcTimer(final mcMMO plugin)
|
||||
{
|
||||
public mcTimer(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
long curTime = System.currentTimeMillis();
|
||||
for(Player player : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
if(player == null)
|
||||
continue;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if(PP == null)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* MONITOR SKILLS
|
||||
*/
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.AXES);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.EXCAVATION);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.HERBALISM);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.MINING);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.SWORDS);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.UNARMED);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.WOODCUTTING);
|
||||
|
||||
/*
|
||||
* COOLDOWN MONITORING
|
||||
*/
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SKULL_SPLIITER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.GIGA_DRILL_BREAKER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.GREEN_TERRA);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SUPER_BREAKER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SERRATED_STRIKES);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.BERSERK);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.TREE_FELLER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.BLAST_MINING);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
long curTime = System.currentTimeMillis();
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player == null) { //Is this even possible?
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (PP == null) { //Is this even possible?
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* MONITOR SKILLS
|
||||
*/
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.AXES);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.EXCAVATION);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.HERBALISM);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.MINING);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.SWORDS);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.UNARMED);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.WOODCUTTING);
|
||||
|
||||
/*
|
||||
* COOLDOWN MONITORING
|
||||
*/
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SKULL_SPLIITER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.GIGA_DRILL_BREAKER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.GREEN_TERRA);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SUPER_BREAKER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SERRATED_STRIKES);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.BERSERK);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.TREE_FELLER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.BLAST_MINING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user