1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Fix when some signs does not work with sign states

Fixes #1134
This commit is contained in:
montlikadani 2021-03-29 13:00:19 +02:00
parent 8af1b51d84
commit 3ef805f22f
9 changed files with 29 additions and 38 deletions

View File

@ -201,7 +201,7 @@ public class SignUtil {
Map<String, List<TopList>> temp = new HashMap<>();
boolean save = false;
for (jobsSign jSign : (new HashMap<>(signs)).values()) {
for (jobsSign jSign : new HashMap<>(signs).values()) {
Location loc = jSign.getLocation();
if (loc == null)
continue;

View File

@ -39,9 +39,8 @@ public class BlockOwnerShip {
}
material = type;
this.type = BlockTypes.getFromCMIMaterial(type);
switch (this.type) {
switch (this.type = BlockTypes.getFromCMIMaterial(type)) {
case BLAST_FURNACE:
metadataName = "jobsBlastFurnaceOwner";
break;

View File

@ -551,9 +551,8 @@ public abstract class JobsDAO {
private boolean checkDefaultCollumns() {
for (DBTables one : DBTables.values()) {
for (JobsTableInterface oneT : one.getInterface()) {
if (isCollumn(one.getTableName(), oneT.getCollumn()))
continue;
addCollumn(one.getTableName(), oneT.getCollumn(), oneT.getType());
if (!isCollumn(one.getTableName(), oneT.getCollumn()))
addCollumn(one.getTableName(), oneT.getCollumn(), oneT.getType());
}
}

View File

@ -1,17 +1,14 @@
package com.gamingmesh.jobs.dao;
import java.io.File;
import java.io.IOException;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ConfigReader;
public class JobsManager {
private JobsDAO dao;
private Jobs plugin;
private DataBaseType DbType = DataBaseType.SqLite;
private DataBaseType dbType = DataBaseType.SqLite;
public enum DataBaseType {
MySQL, SqLite
@ -30,31 +27,30 @@ public class JobsManager {
dao.closeConnections();
// Picking opposite database then it is currently
switch (DbType) {
switch (dbType) {
case MySQL:
// If it MySQL lets change to SqLite
DbType = DataBaseType.SqLite;
dbType = DataBaseType.SqLite;
dao = startSqlite();
if (dao != null)
dao.setDbType(DbType);
dao.setDbType(dbType);
break;
case SqLite:
// If it SqLite lets change to MySQL
DbType = DataBaseType.MySQL;
dbType = DataBaseType.MySQL;
dao = startMysql();
if (dao != null)
dao.setDbType(DbType);
dao.setDbType(dbType);
break;
default:
break;
}
File f = new File(Jobs.getFolder(), "generalConfig.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
ConfigReader config = Jobs.getGCManager().getConfig();
config.set("storage.method", DbType.toString().toLowerCase());
config.set("storage.method", dbType.toString().toLowerCase());
try {
config.save(f);
config.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
@ -84,15 +80,15 @@ public class JobsManager {
encoding = c.get("mysql.encoding", "UTF-8");
if (storageMethod.equalsIgnoreCase("mysql")) {
DbType = DataBaseType.MySQL;
dbType = DataBaseType.MySQL;
dao = startMysql();
} else if (storageMethod.equalsIgnoreCase("sqlite")) {
DbType = DataBaseType.SqLite;
dbType = DataBaseType.SqLite;
dao = startSqlite();
} else {
Jobs.consoleMsg("&cInvalid storage method! Changing method to sqlite!");
c.set("storage.method", "sqlite");
DbType = DataBaseType.SqLite;
dbType = DataBaseType.SqLite;
dao = startSqlite();
}
Jobs.setDAO(dao);
@ -134,7 +130,7 @@ public class JobsManager {
}
public DataBaseType getDbType() {
return DbType;
return dbType;
}
}

View File

@ -51,7 +51,7 @@ public class JobsMySQL extends JobsDAO {
try {
return conn.prepareStatement(query);
} catch (SQLException | NumberFormatException e) {
} catch (SQLException e) {
e.printStackTrace();
}
return null;

View File

@ -15,17 +15,14 @@ public class JobsSQLite extends JobsDAO {
}
public JobsSQLite initialize(File dir) {
if (!dir.exists())
dir.mkdirs();
dir.mkdirs();
setUp();
return this;
}
JobsSQLite(Jobs plugin, File file) {
super(plugin, "org.sqlite.JDBC", "jdbc:sqlite:" + new File(file, "jobs.sqlite.db").getPath(), null, null, "");
if (!file.exists())
file.mkdirs();
file.mkdirs();
setDbType(DataBaseType.SqLite);
}
@ -49,7 +46,7 @@ public class JobsSQLite extends JobsDAO {
try {
return conn.prepareStatement(query);
} catch (SQLException | NumberFormatException e) {
} catch (SQLException e) {
e.printStackTrace();
}
return null;

View File

@ -42,7 +42,7 @@ public class BufferedPayment {
return offlinePlayer;
}
public Double get(CurrencyType type) {
public double get(CurrencyType type) {
return payments.getOrDefault(type, 0d);
}

View File

@ -267,15 +267,14 @@ public class JobsListener implements Listener {
return;
}
Sign sign = (Sign) block.getState();
final Job job = Jobs.getJob(CMIChatColor.stripColor(plugin.getComplement().getLine(sign, 2)).toLowerCase());
final Job job = Jobs.getJob(CMIChatColor.stripColor(plugin.getComplement().getLine(event, 2)).toLowerCase());
if (type == SignTopType.toplist && job == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.top.error.nojob"));
return;
}
boolean special = false;
String numberString = CMIChatColor.stripColor(plugin.getComplement().getLine(sign, 3)).toLowerCase();
String numberString = CMIChatColor.stripColor(plugin.getComplement().getLine(event, 3)).toLowerCase();
if (numberString.contains("s")) {
numberString = numberString.replace("s", "");
special = true;
@ -291,7 +290,7 @@ public class JobsListener implements Listener {
jobsSign signInfo = new jobsSign();
signInfo.setLoc(sign.getLocation());
signInfo.setLoc(block.getLocation());
signInfo.setNumber(number);
if (job != null)
signInfo.setJobName(job.getName());

View File

@ -12,12 +12,12 @@ import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.meta.ItemMeta;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
public class Complement2 implements Complement {
protected String serialize(Component component) {
return PlainComponentSerializer.plain().serialize(component);
return LegacyComponentSerializer.legacyAmpersand().serialize(component);
}
protected Component deserialize(String t) {
@ -31,7 +31,8 @@ public class Complement2 implements Complement {
@Override
public String getLine(SignChangeEvent event, int line) {
return event.line(line) == null ? "" : serialize(event.line(line));
Component l = event.line(line);
return l == null ? "" : serialize(l);
}
@Override