9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-29 03:49:07 +00:00
This commit is contained in:
Xiao-MoMi
2022-10-26 15:11:56 +08:00
parent 3b4635c2a1
commit a99d02f88f
7 changed files with 201 additions and 33 deletions

View File

@@ -117,6 +117,7 @@ public class RedisRankingImpl implements RankingInterface {
public float getFirstScore() {
Jedis jedis = JedisUtil.getJedis();
List<Tuple> players = jedis.zrevrangeWithScores("cf_competition", 0, 0);
jedis.close();
if (players == null) return 0;
if (players.size() == 0) return 0;
return (float) players.get(0).getScore();

View File

@@ -31,8 +31,6 @@ public class SqlConnection {
private boolean secondTry = false;
private boolean firstTry = false;
private boolean isFirstTry = true;
public int waitTimeOut = 10;
private HikariDataSource hikariDataSource;
private String tablePrefix;
@@ -47,10 +45,9 @@ public class SqlConnection {
hikariConfig.setDriverClassName("org.mariadb.jdbc.Driver");
sql = "mariadb";
}
tablePrefix = config.getString("MySQL.table-prefix");
tablePrefix = config.getString(storageMode + ".table-prefix");
hikariConfig.setPoolName("[CustomFishing]");
hikariConfig.setJdbcUrl(String.format("jdbc:%s://%s/%s", sql, config.getString("MySQL.host") + ":" + config.getString("MySQL.port"), config.getString("MySQL.database")));
hikariConfig.setJdbcUrl(String.format("jdbc:%s://%s/%s", sql, config.getString(storageMode + ".host") + ":" + config.getString(storageMode + ".port"), config.getString(storageMode + ".database")));
hikariConfig.setUsername(config.getString(storageMode + ".user"));
hikariConfig.setPassword(config.getString(storageMode + ".password"));
hikariConfig.setMaximumPoolSize(config.getInt(storageMode + ".Pool-Settings.maximum-pool-size"));
@@ -128,7 +125,7 @@ public class SqlConnection {
return getConnectionAndCheck();
} else {
firstTry = true;
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to connect to SQL!</red>");
AdventureUtil.consoleMessage("<red>[CustomFishing] Error! Failed to connect to SQL!</red>");
close();
e.printStackTrace();
return null;

View File

@@ -617,17 +617,19 @@ public class FishingManager extends Function {
private void loseDurability(Player player) {
if (player.getGameMode() == GameMode.CREATIVE) return;
PlayerInventory inventory = player.getInventory();
ItemStack mainHand = inventory.getItemInMainHand();
if (mainHand.getType() == Material.FISHING_ROD){
setDurability(mainHand);
}
else {
ItemStack offHand = inventory.getItemInOffHand();
if (offHand.getType() == Material.FISHING_ROD){
setDurability(offHand);
Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> {
PlayerInventory inventory = player.getInventory();
ItemStack mainHand = inventory.getItemInMainHand();
if (mainHand.getType() == Material.FISHING_ROD){
setDurability(mainHand);
}
}
else {
ItemStack offHand = inventory.getItemInOffHand();
if (offHand.getType() == Material.FISHING_ROD){
setDurability(offHand);
}
}
}, 1);
}
private void setDurability(ItemStack rod) {

View File

@@ -134,43 +134,73 @@ public class IntegrationManager extends Function {
List<AntiGriefInterface> antiGriefsList = new ArrayList<>();
if (config.getBoolean("integrations.Residence",false)){
if (Bukkit.getPluginManager().getPlugin("Residence") == null) Log.warn("Failed to initialize Residence!");
else {antiGriefsList.add(new ResidenceHook());hookMessage("Residence");}
else {
antiGriefsList.add(new ResidenceHook());
hookMessage("Residence");
}
}
if (config.getBoolean("integrations.Kingdoms",false)){
if (Bukkit.getPluginManager().getPlugin("Kingdoms") == null) Log.warn("Failed to initialize Kingdoms!");
else {antiGriefsList.add(new KingdomsXHook());hookMessage("Kingdoms");}
else {
antiGriefsList.add(new KingdomsXHook());
hookMessage("Kingdoms");
}
}
if (config.getBoolean("integrations.WorldGuard",false)){
if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) Log.warn("Failed to initialize WorldGuard!");
else {antiGriefsList.add(new WorldGuardHook());hookMessage("WorldGuard");}
else {
antiGriefsList.add(new WorldGuardHook());
hookMessage("WorldGuard");
}
}
if (config.getBoolean("integrations.GriefDefender",false)){
if(Bukkit.getPluginManager().getPlugin("GriefDefender") == null) Log.warn("Failed to initialize GriefDefender!");
else {antiGriefsList.add(new GriefDefenderHook());hookMessage("GriefDefender");}
else {
antiGriefsList.add(new GriefDefenderHook());
hookMessage("GriefDefender");
}
}
if (config.getBoolean("integrations.PlotSquared",false)){
if(Bukkit.getPluginManager().getPlugin("PlotSquared") == null) Log.warn("Failed to initialize PlotSquared!");
else {antiGriefsList.add(new PlotSquaredHook());hookMessage("PlotSquared");}
else {
antiGriefsList.add(new PlotSquaredHook());
hookMessage("PlotSquared");
}
}
if (config.getBoolean("integrations.Towny",false)){
if (Bukkit.getPluginManager().getPlugin("Towny") == null) Log.warn("Failed to initialize Towny!");
else {antiGriefsList.add(new TownyHook());hookMessage("Towny");}
else {
antiGriefsList.add(new TownyHook());
hookMessage("Towny");
}
}
if (config.getBoolean("integrations.Lands",false)){
if (Bukkit.getPluginManager().getPlugin("Lands") == null) Log.warn("Failed to initialize Lands!");
else {antiGriefsList.add(new LandsHook());hookMessage("Lands");}
else {
antiGriefsList.add(new LandsHook());
hookMessage("Lands");
}
}
if (config.getBoolean("integrations.GriefPrevention",false)){
if (Bukkit.getPluginManager().getPlugin("GriefPrevention") == null) Log.warn("Failed to initialize GriefPrevention!");
else {antiGriefsList.add(new GriefPreventionHook());hookMessage("GriefPrevention");}
else {
antiGriefsList.add(new GriefPreventionHook());
hookMessage("GriefPrevention");
}
}
if (config.getBoolean("integrations.CrashClaim",false)){
if (Bukkit.getPluginManager().getPlugin("CrashClaim") == null) Log.warn("Failed to initialize CrashClaim!");
else {antiGriefsList.add(new CrashClaimHook());hookMessage("CrashClaim");}
else {
antiGriefsList.add(new CrashClaimHook());
hookMessage("CrashClaim");
}
}
if (config.getBoolean("integrations.BentoBox",false)){
if (Bukkit.getPluginManager().getPlugin("BentoBox") == null) Log.warn("Failed to initialize BentoBox!");
else {antiGriefsList.add(new BentoBoxHook());hookMessage("BentoBox");}
else {
antiGriefsList.add(new BentoBoxHook());
hookMessage("BentoBox");
}
}
antiGriefs = antiGriefsList.toArray(new AntiGriefInterface[0]);
}

View File

@@ -56,10 +56,4 @@ public class Function {
public void onOpenInventory(InventoryOpenEvent event) {
}
public void onDragInventory(InventoryDragEvent event) {
}
public void onMoveItemInventory(InventoryMoveItemEvent event) {
}
}