mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2025-02-03 05:01:23 +01:00
Merge branch 'development'
This commit is contained in:
commit
9fee86a1c6
32
pom.xml
32
pom.xml
@ -1,25 +1,33 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicFurnaces</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>4.7.3</version>
|
||||
<version>4.8.0</version>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>EpicFurnaces-${project.version}</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
@ -28,6 +36,7 @@
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<configuration>
|
||||
<file>${project.build.directory}/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
@ -38,10 +47,12 @@
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
@ -49,14 +60,17 @@
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
@ -67,6 +81,7 @@
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
@ -79,34 +94,41 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache.snapshots</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<url>https://repo.songoda.com/repository/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.17</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>2.5.13</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>skyblock</artifactId>
|
||||
<version>2.2.13</version>
|
||||
<version>2.3.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -66,7 +66,6 @@ import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EpicFurnaces extends SongodaPlugin {
|
||||
|
||||
private static EpicFurnaces INSTANCE;
|
||||
|
||||
private final Config furnaceRecipeFile = new Config(this, "Furnace Recipes.yml");
|
||||
@ -94,7 +93,9 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
shutdownDataManager(this.dataManager);
|
||||
this.databaseConnector.closeConnection();
|
||||
|
||||
HologramManager.removeAllHolograms();
|
||||
}
|
||||
|
||||
@ -475,4 +476,4 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
public DataManager getDataManager() {
|
||||
return dataManager;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,17 +15,55 @@ import org.bukkit.plugin.Plugin;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class DataManager extends DataManagerAbstract {
|
||||
private final Set<Furnace> furnaceUpdateQueue = new HashSet<>();
|
||||
|
||||
public DataManager(DatabaseConnector connector, Plugin plugin) {
|
||||
super(connector, plugin);
|
||||
|
||||
// Updating furnaces every 3 minutes should be plenty I believe
|
||||
Bukkit.getScheduler().runTaskTimer(plugin, this::bulkUpdateFurnaceQueue, 20 * 60 * 3, 20 * 60 * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownTaskQueue() {
|
||||
bulkUpdateFurnaceQueue();
|
||||
|
||||
super.shutdownTaskQueue();
|
||||
}
|
||||
|
||||
public void queueFurnaceForUpdate(Furnace furnace) {
|
||||
synchronized (this.furnaceUpdateQueue) {
|
||||
this.furnaceUpdateQueue.add(furnace);
|
||||
}
|
||||
}
|
||||
|
||||
public void dequeueFurnaceForUpdate(Furnace furnace) {
|
||||
synchronized (this.furnaceUpdateQueue) {
|
||||
this.furnaceUpdateQueue.remove(furnace);
|
||||
}
|
||||
}
|
||||
|
||||
public void bulkUpdateFurnaceQueue() {
|
||||
synchronized (this.furnaceUpdateQueue) {
|
||||
updateFurnaces(new LinkedHashSet<>(this.furnaceUpdateQueue));
|
||||
this.furnaceUpdateQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void createBoost(BoostData boostData) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String createBoostedPlayer = "INSERT INTO " + this.getTablePrefix() + "boosted_players (player, multiplier, end_time) VALUES (?, ?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createBoostedPlayer)) {
|
||||
statement.setString(1, boostData.getPlayer().toString());
|
||||
@ -37,8 +75,9 @@ public class DataManager extends DataManagerAbstract {
|
||||
}
|
||||
|
||||
public void getBoosts(Consumer<List<BoostData>> callback) {
|
||||
List<BoostData> boosts = new ArrayList<>();
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
List<BoostData> boosts = new ArrayList<>();
|
||||
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String selectBoostedPlayers = "SELECT * FROM " + this.getTablePrefix() + "boosted_players";
|
||||
ResultSet result = statement.executeQuery(selectBoostedPlayers);
|
||||
@ -55,8 +94,9 @@ public class DataManager extends DataManagerAbstract {
|
||||
}
|
||||
|
||||
public void deleteBoost(BoostData boostData) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String deleteBoost = "DELETE FROM " + this.getTablePrefix() + "boosted_players WHERE end_time = ?";
|
||||
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteBoost)) {
|
||||
statement.setLong(1, boostData.getEndTime());
|
||||
statement.executeUpdate();
|
||||
@ -114,21 +154,28 @@ public class DataManager extends DataManagerAbstract {
|
||||
}), "create");
|
||||
}
|
||||
|
||||
public void updateFurnace(Furnace furnace) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
String updateHopper = "UPDATE " + this.getTablePrefix() + "active_furnaces SET level = ?, nickname = ?, uses = ? WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(updateHopper)) {
|
||||
statement.setInt(1, furnace.getLevel().getLevel());
|
||||
statement.setString(2, furnace.getNickname());
|
||||
statement.setInt(3, furnace.getUses());
|
||||
statement.setInt(4, furnace.getId());
|
||||
statement.executeUpdate();
|
||||
public void updateFurnaces(Collection<Furnace> furnaces) {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String updateFurnace = "UPDATE " + this.getTablePrefix() + "active_furnaces SET level =?, nickname =?, uses =? WHERE id =?;";
|
||||
try (PreparedStatement statement = connection.prepareStatement(updateFurnace)) {
|
||||
for (Furnace furnace : furnaces) {
|
||||
statement.setInt(1, furnace.getLevel().getLevel());
|
||||
statement.setString(2, furnace.getNickname());
|
||||
statement.setInt(3, furnace.getUses());
|
||||
statement.setInt(4, furnace.getId());
|
||||
|
||||
statement.addBatch();
|
||||
}
|
||||
|
||||
statement.executeBatch();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void deleteFurnace(Furnace furnace) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
dequeueFurnaceForUpdate(furnace);
|
||||
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String deleteFurnace = "DELETE FROM " + this.getTablePrefix() + "active_furnaces WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteFurnace)) {
|
||||
statement.setInt(1, furnace.getId());
|
||||
@ -150,7 +197,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
}
|
||||
|
||||
public void createAccessPlayer(Furnace furnace, UUID uuid) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String createAccessPlayer = "INSERT INTO " + this.getTablePrefix() + "access_list (furnace_id, uuid) VALUES (?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createAccessPlayer)) {
|
||||
statement.setInt(1, furnace.getId());
|
||||
@ -163,7 +210,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
// These will be used in the future when the access list gets revamped.
|
||||
// Probably by me since I already have a custom version in my server.
|
||||
public void deleteAccessPlayer(Furnace furnace, UUID uuid) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String deleteAccessPlayer = "DELETE FROM " + this.getTablePrefix() + "access_list WHERE furnace_id = ? AND uuid = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteAccessPlayer)) {
|
||||
statement.setInt(1, furnace.getId());
|
||||
@ -174,7 +221,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
}
|
||||
|
||||
public void updateAccessPlayers(Furnace furnace) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String deletePlayers = "DELETE FROM " + this.getTablePrefix() + "access_list WHERE furnace_id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deletePlayers)) {
|
||||
statement.setInt(1, furnace.getId());
|
||||
@ -194,7 +241,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
}
|
||||
|
||||
public void updateLevelupItems(Furnace furnace, CompatibleMaterial material, int amount) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String deleteLevelupItem = "DELETE FROM " + this.getTablePrefix() + "to_level_new WHERE furnace_id = ? AND item = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteLevelupItem)) {
|
||||
statement.setInt(1, furnace.getId());
|
||||
@ -213,7 +260,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
}
|
||||
|
||||
public void getFurnaces(Consumer<Map<Integer, Furnace>> callback) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
Map<Integer, Furnace> furnaces = new HashMap<>();
|
||||
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
|
@ -79,7 +79,7 @@ public class Furnace {
|
||||
if (!block.getType().name().contains("FURNACE") && !block.getType().name().contains("SMOKER")) return;
|
||||
|
||||
this.uses++;
|
||||
plugin.getDataManager().updateFurnace(this);
|
||||
plugin.getDataManager().queueFurnaceForUpdate(this);
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getResult());
|
||||
int needed = -1;
|
||||
@ -172,7 +172,7 @@ public class Furnace {
|
||||
private void upgradeFinal(Player player) {
|
||||
levelUp();
|
||||
syncName();
|
||||
plugin.getDataManager().updateFurnace(this);
|
||||
plugin.getDataManager().queueFurnaceForUpdate(this);
|
||||
if (plugin.getLevelManager().getHighestLevel() != level) {
|
||||
plugin.getLocale().getMessage("event.upgrade.success")
|
||||
.processPlaceholder("level", level.getLevel()).sendPrefixedMessage(player);
|
||||
|
@ -148,7 +148,7 @@ public class GUIOverview extends CustomizableGui {
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getDataManager().updateFurnace(furnace);
|
||||
plugin.getDataManager().queueFurnaceForUpdate(furnace);
|
||||
furnace.setNickname(promptEvent.getMessage());
|
||||
plugin.getLocale().getMessage("event.remote.nicknamesuccess").sendPrefixedMessage(player);
|
||||
}).setOnClose(() -> guiManager.showGUI(player, new GUIOverview(plugin, furnace, player)));
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: EpicFurnaces
|
||||
description: EpicFurnaces
|
||||
version: maven-version-number
|
||||
softdepend: [FabledSkyBlock, HolographicDisplays, PlotSquared, GriefPrevention, USkyBlock, SkyBlock, WorldGuard, Factions, Lands, RedProtect, UltimateClaims, BentoBox]
|
||||
softdepend: [ FabledSkyBlock, HolographicDisplays, PlotSquared, GriefPrevention, USkyBlock, SkyBlock, WorldGuard, Factions, Lands, RedProtect, UltimateClaims, BentoBox, Vault ]
|
||||
main: com.songoda.epicfurnaces.EpicFurnaces
|
||||
author: songoda
|
||||
api-version: 1.13
|
||||
@ -9,5 +9,5 @@ commands:
|
||||
ef:
|
||||
description: I have no idea.
|
||||
default: true
|
||||
aliases: [EpicFurnaces]
|
||||
usage: /<command> [reload]
|
||||
aliases: [ EpicFurnaces ]
|
||||
usage: /<command> [reload]
|
||||
|
Loading…
Reference in New Issue
Block a user