mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
When converting, include user table
This commit is contained in:
parent
81a02dbbe0
commit
d009b5b782
@ -289,7 +289,8 @@ public class PlayerManager {
|
||||
if (!jPlayer.leaveJob(job))
|
||||
return false;
|
||||
|
||||
Jobs.getJobsDAO().quitJob(jPlayer, job);
|
||||
if (!Jobs.getJobsDAO().quitJob(jPlayer, job))
|
||||
return false;
|
||||
PerformCommands.PerformCommandsOnLeave(jPlayer, job);
|
||||
Jobs.leaveSlot(job);
|
||||
|
||||
@ -319,18 +320,20 @@ public class PlayerManager {
|
||||
* @param oldjob - the old job
|
||||
* @param newjob - the new job
|
||||
*/
|
||||
public void transferJob(JobsPlayer jPlayer, Job oldjob, Job newjob) {
|
||||
public boolean transferJob(JobsPlayer jPlayer, Job oldjob, Job newjob) {
|
||||
// synchronized (jPlayer.saveLock) {
|
||||
if (!jPlayer.transferJob(oldjob, newjob))
|
||||
return;
|
||||
return false;
|
||||
|
||||
JobsDAO dao = Jobs.getJobsDAO();
|
||||
dao.quitJob(jPlayer, oldjob);
|
||||
if (!dao.quitJob(jPlayer, oldjob))
|
||||
return false;
|
||||
oldjob.updateTotalPlayers();
|
||||
dao.joinJob(jPlayer, newjob);
|
||||
newjob.updateTotalPlayers();
|
||||
jPlayer.save();
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@ public class convert implements Cmd {
|
||||
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.fromconsole"));
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length > 0) {
|
||||
@ -38,8 +38,9 @@ public class convert implements Cmd {
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
sender.sendMessage(ChatColor.RED + "Can't read data from data base, please send error log to dev's.");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Jobs.ChangeDatabase();
|
||||
|
||||
if (list == null & archivelist == null)
|
||||
@ -47,10 +48,11 @@ public class convert implements Cmd {
|
||||
try {
|
||||
Jobs.getJobsDAO().continueConvertions(list, "jobs");
|
||||
Jobs.getJobsDAO().continueConvertions(archivelist, "archive");
|
||||
Jobs.getJobsDAO().transferUsers();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
sender.sendMessage(ChatColor.RED + "Can't write data to data base, please send error log to dev's.");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -540,7 +540,7 @@ public class ConfigManager {
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (actionType == ActionType.ENCHANT && material == null) {
|
||||
} else if (actionType == ActionType.ENCHANT) {
|
||||
Enchantment enchant = Enchantment.getByName(myKey);
|
||||
if (enchant != null)
|
||||
id = enchant.getId();
|
||||
|
@ -42,7 +42,6 @@ public class LanguageManager {
|
||||
|
||||
for (String lang : languages) {
|
||||
YmlMaker langFile = new YmlMaker(plugin, "locale" + File.separator + "messages_" + lang + ".yml");
|
||||
if (langFile != null)
|
||||
langFile.saveDefaultConfig();
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,6 @@ public class NameTranslatorManager {
|
||||
|
||||
for (String lang : languages) {
|
||||
YmlMaker langFile = new YmlMaker(plugin, "TranslatableWords" + File.separator + "Words_" + lang + ".yml");
|
||||
if (langFile != null)
|
||||
langFile.saveDefaultConfig();
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class JobsPlayer {
|
||||
* @return the Multiplier
|
||||
*/
|
||||
public double getVipSpawnerMultiplier() {
|
||||
if (OffPlayer == null || !this.OffPlayer.isOnline())
|
||||
if (this.getPlayer() == null || !this.getPlayer().isOnline())
|
||||
return 1.0;
|
||||
if (VipSpawnerMultiplier < 0)
|
||||
updateVipSpawnerMultiplier();
|
||||
|
@ -448,16 +448,49 @@ public abstract class JobsDAO {
|
||||
}
|
||||
}
|
||||
|
||||
public void transferUsers() throws SQLException {
|
||||
JobsConnection conns = this.getConnection();
|
||||
if (conns == null)
|
||||
return;
|
||||
PreparedStatement insert = null;
|
||||
Statement statement = null;
|
||||
try {
|
||||
statement = conns.createStatement();
|
||||
if (Jobs.getGCManager().storageMethod.equalsIgnoreCase("sqlite")) {
|
||||
statement.executeUpdate("TRUNCATE `" + getPrefix() + "users`");
|
||||
} else {
|
||||
statement.executeUpdate("DELETE from `" + getPrefix() + "users`");
|
||||
}
|
||||
|
||||
insert = conns.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`id`, `player_uuid`, `username`) VALUES (?, ?, ?);");
|
||||
conns.setAutoCommit(false);
|
||||
|
||||
for (Entry<String, JobsPlayer> oneUser : Jobs.getPlayerManager().getPlayersCache().entrySet()) {
|
||||
insert.setInt(1, oneUser.getValue().getUserId());
|
||||
insert.setString(2, oneUser.getValue().getPlayerUUID().toString());
|
||||
insert.setString(3, oneUser.getValue().getUserName());
|
||||
insert.addBatch();
|
||||
}
|
||||
insert.executeBatch();
|
||||
conns.commit();
|
||||
conns.setAutoCommit(true);
|
||||
} finally {
|
||||
close(statement);
|
||||
close(insert);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Quit a job (delete player-job entry from storage)
|
||||
* @param player - player that wishes to quit the job
|
||||
* @param job - job that the player wishes to quit
|
||||
*/
|
||||
public synchronized void quitJob(JobsPlayer jPlayer, Job job) {
|
||||
public synchronized boolean quitJob(JobsPlayer jPlayer, Job job) {
|
||||
JobsConnection conn = getConnection();
|
||||
if (conn == null)
|
||||
return;
|
||||
return false;
|
||||
PreparedStatement prest = null;
|
||||
boolean ok = true;
|
||||
try {
|
||||
prest = conn.prepareStatement("DELETE FROM `" + prefix + "jobs` WHERE `userid` = ? AND `job` = ?;");
|
||||
prest.setInt(1, jPlayer.getUserId());
|
||||
@ -465,9 +498,11 @@ public abstract class JobsDAO {
|
||||
prest.execute();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
ok = false;
|
||||
} finally {
|
||||
close(prest);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -567,7 +567,7 @@ public class JobsPaymentListener implements Listener {
|
||||
ItemStack toCraft = event.getCurrentItem();
|
||||
ItemStack toStore = event.getCursor();
|
||||
// Make sure we are actually crafting anything
|
||||
if (player != null && hasItems(toCraft))
|
||||
if (hasItems(toCraft))
|
||||
if (event.isShiftClick())
|
||||
schedulePostDetection(player, toCraft, jPlayer, resultStack, multiplier);
|
||||
else {
|
||||
@ -627,7 +627,7 @@ public class JobsPaymentListener implements Listener {
|
||||
if (a == null)
|
||||
return b == null;
|
||||
else if (b == null)
|
||||
return a == null;
|
||||
return false;
|
||||
return a.getTypeId() == b.getTypeId() && a.getDurability() == b.getDurability() && Objects.equal(a.getData(), b.getData()) && Objects.equal(a.getEnchantments(), b
|
||||
.getEnchantments());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user