1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Implement some missing codes

Fixed issue when added the schedules to list but cleared in for-loop.
This commit is contained in:
montlikadani 2019-08-04 12:56:56 +02:00
parent 0cef1e8dfd
commit 13432fe35f
13 changed files with 75 additions and 33 deletions

View File

@ -239,6 +239,8 @@ public class ItemManager {
} }
} }
break;
default:
break; break;
} }
@ -3489,6 +3491,8 @@ public class ItemManager {
return SlabType.BOTTOM; return SlabType.BOTTOM;
case "DOUBLE": case "DOUBLE":
return SlabType.DOUBLE; return SlabType.DOUBLE;
default:
break;
} }
} }
@ -3536,6 +3540,8 @@ public class ItemManager {
default: default:
return SlabType.DOUBLE; return SlabType.DOUBLE;
} }
default:
break;
} }
} }

View File

@ -192,7 +192,7 @@ public class Jobs extends JavaPlugin {
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType"); Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
getServer().getPluginManager().registerEvents(new McMMO2_X_listener(this), this); getServer().getPluginManager().registerEvents(new McMMO2_X_listener(this), this);
consoleMsg("&e[Jobs] Registered McMMO 2.x listener"); consoleMsg("&e[Jobs] Registered McMMO 2.x listener");
} catch (Throwable e) { } catch (ClassNotFoundException e) {
getServer().getPluginManager().registerEvents(new McMMO1_X_listener(this), this); getServer().getPluginManager().registerEvents(new McMMO1_X_listener(this), this);
consoleMsg("&e[Jobs] Registered McMMO 1.x listener"); consoleMsg("&e[Jobs] Registered McMMO 1.x listener");
} }
@ -247,10 +247,10 @@ public class Jobs extends JavaPlugin {
return false; return false;
if (getVersionCheckManager().convertVersion(getServer().getPluginManager() if (getVersionCheckManager().convertVersion(getServer().getPluginManager()
.getPlugin("PlaceholderAPI").getDescription().getVersion()) >= getVersionCheckManager().convertVersion("2.10.0")) { .getPlugin("PlaceholderAPI").getDescription().getVersion()) >= getVersionCheckManager().convertVersion("2.10.0")) {
if ((new NewPlaceholderAPIHook(this)).register()) if (new NewPlaceholderAPIHook(this).register())
consoleMsg("&e[Jobs] PlaceholderAPI hooked."); consoleMsg("&e[Jobs] PlaceholderAPI hooked.");
} else { } else {
if ((new PlaceholderAPIHook(this)).hook()) if (new PlaceholderAPIHook(this).hook())
consoleMsg("&e[Jobs] PlaceholderAPI hooked. This is a deprecated version. In the PlaceholderAPI" consoleMsg("&e[Jobs] PlaceholderAPI hooked. This is a deprecated version. In the PlaceholderAPI"
+ " new version has removed the extension and we using the latest."); + " new version has removed the extension and we using the latest.");
} }
@ -687,7 +687,7 @@ public class Jobs extends JavaPlugin {
try { try {
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType"); Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
getInstance().getServer().getPluginManager().registerEvents(new McMMO2_X_listener(instance), instance); getInstance().getServer().getPluginManager().registerEvents(new McMMO2_X_listener(instance), instance);
} catch (Exception e) { } catch (ClassNotFoundException e) {
getInstance().getServer().getPluginManager().registerEvents(new McMMO1_X_listener(instance), instance); getInstance().getServer().getPluginManager().registerEvents(new McMMO1_X_listener(instance), instance);
} }
} }

View File

@ -591,7 +591,7 @@ public class PlayerManager {
if (player == null || !player.isOnline()) if (player == null || !player.isOnline())
return; return;
Firework f = (Firework) player.getWorld().spawn(player.getLocation(), Firework.class); Firework f = player.getWorld().spawn(player.getLocation(), Firework.class);
FireworkMeta fm = f.getFireworkMeta(); FireworkMeta fm = f.getFireworkMeta();
if (Jobs.getGCManager().UseRandom) { if (Jobs.getGCManager().UseRandom) {

View File

@ -377,11 +377,14 @@ public class editjobs implements Cmd {
case "offhand": case "offhand":
item = ItemReflection.getItemInOffHand(player); item = ItemReflection.getItemInOffHand(player);
key = item.getType().name() + "-" + item.getData().getData(); key = item.getType().name() + "-" + item.getData().getData();
break;
case "looking": case "looking":
case "lookingat": case "lookingat":
Block block = Util.getTargetBlock(player, 30); Block block = Util.getTargetBlock(player, 30);
key = block.getType().name() + "-" + block.getData(); key = block.getType().name() + "-" + block.getData();
break; break;
default:
break;
} }
String myKey = key; String myKey = key;
@ -464,6 +467,8 @@ public class editjobs implements Cmd {
type = "ARMOR_STAND"; type = "ARMOR_STAND";
meta = "1"; meta = "1";
break c; break c;
default:
break;
} }
if (actionT == ActionType.BREAK || actionT == ActionType.PLACE || actionT == ActionType.STRIPLOGS) { if (actionT == ActionType.BREAK || actionT == ActionType.PLACE || actionT == ActionType.STRIPLOGS) {
@ -543,6 +548,11 @@ public class editjobs implements Cmd {
id = 68; id = 68;
meta = "1"; meta = "1";
break; break;
default:
type = CMIEntityType.getByName(myKey.toUpperCase()).name();
id = CMIEntityType.getByName(myKey.toUpperCase()).getId();
meta = "1";
break;
} }
} }
@ -617,6 +627,8 @@ public class editjobs implements Cmd {
return true; return true;
} }
break;
default:
break; break;
} }

View File

@ -61,6 +61,8 @@ public class editpoints implements Cmd {
"%playername%", jPlayer.getUserName(), "%playername%", jPlayer.getUserName(),
"%amount%", amount)); "%amount%", amount));
break; break;
default:
break;
} }
return true; return true;
} }

View File

@ -48,6 +48,8 @@ public class exp implements Cmd {
case "take": case "take":
action = Action.Take; action = Action.Take;
break; break;
default:
break;
} }
double amount = 0.0; double amount = 0.0;
@ -72,6 +74,8 @@ public class exp implements Cmd {
case Take: case Take:
prog.takeExperience(amount); prog.takeExperience(amount);
break; break;
default:
break;
} }
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();

View File

@ -40,6 +40,8 @@ public class level implements Cmd {
case "take": case "take":
action = Action.Take; action = Action.Take;
continue; continue;
default:
break;
} }
try { try {
@ -83,6 +85,8 @@ public class level implements Cmd {
case Take: case Take:
prog.setLevel(amount); prog.setLevel(amount);
break; break;
default:
break;
} }
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();

View File

@ -250,6 +250,8 @@ public class ConfigManager {
id = 30; id = 30;
meta = "1"; meta = "1";
break c; break c;
default:
break;
} }
// Break and Place actions MUST be blocks // Break and Place actions MUST be blocks
@ -343,6 +345,11 @@ public class ConfigManager {
id = 68; id = 68;
meta = "1"; meta = "1";
break; break;
default:
type = CMIEntityType.getByName(myKey.toUpperCase()).name();
id = CMIEntityType.getByName(myKey.toUpperCase()).getId();
meta = "1";
break;
} }
} }
@ -1034,6 +1041,8 @@ public class ConfigManager {
id = 30; id = 30;
meta = "1"; meta = "1";
break c; break c;
default:
break;
} }
// Break and Place actions MUST be blocks // Break and Place actions MUST be blocks
@ -1122,6 +1131,11 @@ public class ConfigManager {
id = 68; id = 68;
meta = "1"; meta = "1";
break; break;
default:
type = CMIEntityType.getByName(myKey.toUpperCase()).name();
id = CMIEntityType.getByName(myKey.toUpperCase()).getId();
meta = "1";
break;
} }
} }

View File

@ -105,6 +105,7 @@ public class NameTranslatorManager {
return one.getName(); return one.getName();
} }
} }
break;
default: default:
break; break;
} }

View File

@ -157,6 +157,8 @@ public class ScheduleManager {
return "saturday"; return "saturday";
case 1: case 1:
return "sunday"; return "sunday";
default:
break;
} }
return "all"; return "all";
} }

View File

@ -83,11 +83,11 @@ public class Schedule {
} }
public void setBoost(CurrencyType type, double amount) { public void setBoost(CurrencyType type, double amount) {
this.BM.add(type, amount - 1); BM.add(type, amount - 1);
} }
public double getBoost(CurrencyType type) { public double getBoost(CurrencyType type) {
return this.BM.get(type); return BM.get(type);
} }
public BoostMultiplier getBoost() { public BoostMultiplier getBoost() {
@ -138,13 +138,14 @@ public class Schedule {
} }
public void setJobs(List<String> JobsNameList) { public void setJobs(List<String> JobsNameList) {
for (int z = 0; z < JobsNameList.size(); z++) { JobsList.clear();
List<Job> jobl = Jobs.getJobs();
for (int z = 0; z < JobsNameList.size(); z++) {
if (JobsNameList.get(z).equalsIgnoreCase("all")) { if (JobsNameList.get(z).equalsIgnoreCase("all")) {
JobsList.clear();
List<Job> jobl = Jobs.getJobs();
if (jobl != null) if (jobl != null)
JobsList.addAll(Jobs.getJobs()); JobsList.addAll(Jobs.getJobs());
return; return;
} }
@ -177,7 +178,7 @@ public class Schedule {
for (String one : msg) { for (String one : msg) {
temp.add(ChatColor.translateAlternateColorCodes('&', one.replace("[until]", Until).replace("[from]", From))); temp.add(ChatColor.translateAlternateColorCodes('&', one.replace("[until]", Until).replace("[from]", From)));
} }
this.MessageOnStart.addAll(temp); MessageOnStart.addAll(temp);
} }
public List<String> GetMessageOnStart() { public List<String> GetMessageOnStart() {
@ -189,7 +190,7 @@ public class Schedule {
for (String one : msg) { for (String one : msg) {
temp.add(ChatColor.translateAlternateColorCodes('&', one.replace("[until]", Until).replace("[from]", From))); temp.add(ChatColor.translateAlternateColorCodes('&', one.replace("[until]", Until).replace("[from]", From)));
} }
this.MessageOnStop.addAll(temp); MessageOnStop.addAll(temp);
} }
public List<String> GetMessageOnStop() { public List<String> GetMessageOnStop() {
@ -201,7 +202,7 @@ public class Schedule {
for (String one : msg) { for (String one : msg) {
temp.add(ChatColor.translateAlternateColorCodes('&', one.replace("[until]", Until).replace("[from]", From))); temp.add(ChatColor.translateAlternateColorCodes('&', one.replace("[until]", Until).replace("[from]", From)));
} }
this.MessageToBroadcast.addAll(temp); MessageToBroadcast.addAll(temp);
} }
public List<String> GetMessageToBroadcast() { public List<String> GetMessageToBroadcast() {

View File

@ -127,7 +127,6 @@ public class JobsMySQL extends JobsDAO {
try { try {
statement = conn.createStatement(); statement = conn.createStatement();
statement.execute(query); statement.execute(query);
statement.close();
} catch (SQLException e) { } catch (SQLException e) {
Jobs.consoleMsg("&cCould not create table, SQLException: " + e.getMessage()); Jobs.consoleMsg("&cCould not create table, SQLException: " + e.getMessage());
return false; return false;
@ -174,8 +173,9 @@ public class JobsMySQL extends JobsDAO {
return false; return false;
} catch (SQLException e) { } catch (SQLException e) {
Jobs.consoleMsg("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|"); Jobs.consoleMsg("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|");
close(statement);
return false; return false;
} finally {
close(statement);
} }
} }
@ -190,12 +190,12 @@ public class JobsMySQL extends JobsDAO {
} }
try { try {
statement.executeQuery("SELECT `" + collumn + "` FROM `" + table + "`;"); statement.executeQuery("SELECT `" + collumn + "` FROM `" + table + "`;");
statement.close();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
Jobs.consoleMsg("Not a culumn |" + "SELECT " + collumn + " FROM " + table + "|"); Jobs.consoleMsg("Not a culumn |" + "SELECT " + collumn + " FROM " + table + "|");
close(statement);
return false; return false;
} finally {
close(statement);
} }
} }
@ -211,11 +211,11 @@ public class JobsMySQL extends JobsDAO {
try { try {
Jobs.consoleMsg("Creating culumn |" + "ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";" + "|"); Jobs.consoleMsg("Creating culumn |" + "ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";" + "|");
statement.executeUpdate("ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";"); statement.executeUpdate("ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";");
statement.close();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
close(statement);
return false; return false;
} finally {
close(statement);
} }
} }
@ -231,14 +231,13 @@ public class JobsMySQL extends JobsDAO {
statement = getConnection().createStatement(); statement = getConnection().createStatement();
query = "DELETE FROM " + table + ";"; query = "DELETE FROM " + table + ";";
statement.executeUpdate(query); statement.executeUpdate(query);
statement.close();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
Jobs.consoleMsg("&cCould not wipe table, SQLException: " + e.getMessage()); Jobs.consoleMsg("&cCould not wipe table, SQLException: " + e.getMessage());
close(statement);
e.printStackTrace(); e.printStackTrace();
return false; return false;
} finally {
close(statement);
} }
} }
@ -254,14 +253,13 @@ public class JobsMySQL extends JobsDAO {
statement = getConnection().createStatement(); statement = getConnection().createStatement();
query = "DROP TABLE IF EXISTS `" + table + "`;"; query = "DROP TABLE IF EXISTS `" + table + "`;";
statement.executeUpdate(query); statement.executeUpdate(query);
statement.close();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
Jobs.consoleMsg("&cCould not wipe table, SQLException: " + e.getMessage()); Jobs.consoleMsg("&cCould not wipe table, SQLException: " + e.getMessage());
close(statement);
e.printStackTrace(); e.printStackTrace();
return false; return false;
} finally {
close(statement);
} }
} }
} }

View File

@ -121,12 +121,12 @@ public class JobsSQLite extends JobsDAO {
statement = getConnection().createStatement(); statement = getConnection().createStatement();
statement.execute(query); statement.execute(query);
statement.close();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
Jobs.consoleMsg("&cCould not create table, SQLException: " + e.getMessage()); Jobs.consoleMsg("&cCould not create table, SQLException: " + e.getMessage());
close(statement);
return false; return false;
} finally {
close(statement);
} }
} }
@ -177,11 +177,11 @@ public class JobsSQLite extends JobsDAO {
} }
try { try {
statement.executeQuery("ALTER TABLE `" + table + "` ADD `" + collumn + "` " + type); statement.executeQuery("ALTER TABLE `" + table + "` ADD `" + collumn + "` " + type);
statement.close();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
close(statement);
return false; return false;
} finally {
close(statement);
} }
} }
@ -197,14 +197,14 @@ public class JobsSQLite extends JobsDAO {
statement = getConnection().createStatement(); statement = getConnection().createStatement();
query = "DELETE FROM `" + table + "`;"; query = "DELETE FROM `" + table + "`;";
statement.executeQuery(query); statement.executeQuery(query);
statement.close();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
if (!(e.getMessage().toLowerCase().contains("locking") || e.getMessage().toLowerCase().contains("locked")) && if (!(e.getMessage().toLowerCase().contains("locking") || e.getMessage().toLowerCase().contains("locked")) &&
!e.toString().contains("not return ResultSet")) !e.toString().contains("not return ResultSet"))
Jobs.consoleMsg("&cError in wipeTable() query: " + e); Jobs.consoleMsg("&cError in wipeTable() query: " + e);
close(statement);
return false; return false;
} finally {
close(statement);
} }
} }
@ -220,13 +220,11 @@ public class JobsSQLite extends JobsDAO {
statement = getConnection().createStatement(); statement = getConnection().createStatement();
query = "DROP TABLE IF EXISTS `" + table + "`;"; query = "DROP TABLE IF EXISTS `" + table + "`;";
statement.executeQuery(query); statement.executeQuery(query);
statement.close();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
if (!(e.getMessage().toLowerCase().contains("locking") || e.getMessage().toLowerCase().contains("locked")) && if (!(e.getMessage().toLowerCase().contains("locking") || e.getMessage().toLowerCase().contains("locked")) &&
!e.toString().contains("not return ResultSet")) !e.toString().contains("not return ResultSet"))
Jobs.consoleMsg("&cError in dropTable() query: " + e); Jobs.consoleMsg("&cError in dropTable() query: " + e);
close(statement);
return false; return false;
} finally { } finally {
close(statement); close(statement);