mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Runnables cleanup
This commit is contained in:
parent
18a2b686c1
commit
b0fbaa71bf
@ -327,7 +327,7 @@ public class mcPlayerListener implements Listener {
|
||||
|
||||
String format = color + "(" + ChatColor.WHITE + name + color + ") " + event.getMessage();
|
||||
|
||||
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (partyChat && Party.getInstance().inSameParty(player, x))
|
||||
x.sendMessage(format);
|
||||
else if (adminChat && (x.isOp() || mcPermissions.getInstance().adminChat(x))) {
|
||||
|
@ -9,36 +9,37 @@ import org.bukkit.ChatColor;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
|
||||
public class mcLocale
|
||||
{
|
||||
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale"; //$NON-NLS-1$
|
||||
|
||||
public class mcLocale {
|
||||
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale";
|
||||
private static ResourceBundle RESOURCE_BUNDLE = null;
|
||||
|
||||
public static String getString(String key)
|
||||
{
|
||||
public static String getString(String key) {
|
||||
return getString(key, null);
|
||||
}
|
||||
|
||||
public static String getString(String key, Object[] messageArguments)
|
||||
{
|
||||
/**
|
||||
* Gets the appropriate string from the Locale files.
|
||||
*
|
||||
* @param key The key to look up the string with
|
||||
* @param messageArguments Any arguements to be added to the string
|
||||
* @return The properly formatted locale string
|
||||
*/
|
||||
public static String getString(String key, Object[] messageArguments) {
|
||||
try {
|
||||
if (RESOURCE_BUNDLE == null)
|
||||
{
|
||||
if (RESOURCE_BUNDLE == null) {
|
||||
String myLocale = LoadProperties.locale.toLowerCase();
|
||||
try {
|
||||
//attempt to get the locale denoted
|
||||
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, new Locale(myLocale));
|
||||
} catch (MissingResourceException e) {
|
||||
//System.out.println("Failed to load locale specified by mcmmo.properties '"+myLocale+"', defaulting to en_us");
|
||||
}
|
||||
catch (MissingResourceException e) {
|
||||
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, new Locale("en_us"));
|
||||
}
|
||||
}
|
||||
|
||||
String output = RESOURCE_BUNDLE.getString(key);
|
||||
|
||||
if (messageArguments != null)
|
||||
{
|
||||
if (messageArguments != null) {
|
||||
MessageFormat formatter = new MessageFormat("");
|
||||
formatter.applyPattern(output);
|
||||
output = formatter.format(messageArguments);
|
||||
@ -47,7 +48,8 @@ public class mcLocale
|
||||
output = addColors(output);
|
||||
|
||||
return output;
|
||||
} catch (MissingResourceException e) {
|
||||
}
|
||||
catch (MissingResourceException e) {
|
||||
return '!' + key + '!';
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,11 @@ public class RemoveProfileFromMemoryTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String playerName = player.getName();
|
||||
//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());
|
||||
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,11 +9,10 @@ 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
|
||||
|
@ -8,17 +8,14 @@ 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,26 +9,27 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
public class mcTimer implements Runnable
|
||||
{
|
||||
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()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
long curTime = System.currentTimeMillis();
|
||||
for(Player player : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
if(player == null)
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player == null) { //Is this even possible?
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if(PP == null)
|
||||
if (PP == null) { //Is this even possible?
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* MONITOR SKILLS
|
||||
|
Loading…
Reference in New Issue
Block a user