mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-23 10:45:57 +01:00
core conversion progress
This commit is contained in:
parent
aaa9ecf8d1
commit
fff00f77ae
@ -7,28 +7,45 @@ import com.songoda.core.compatibility.CompatibleMaterial;
|
|||||||
import com.songoda.core.configuration.Config;
|
import com.songoda.core.configuration.Config;
|
||||||
import com.songoda.core.database.DataMigrationManager;
|
import com.songoda.core.database.DataMigrationManager;
|
||||||
import com.songoda.core.database.DatabaseConnector;
|
import com.songoda.core.database.DatabaseConnector;
|
||||||
|
import com.songoda.core.database.MySQLConnector;
|
||||||
|
import com.songoda.core.database.SQLiteConnector;
|
||||||
import com.songoda.core.gui.GuiManager;
|
import com.songoda.core.gui.GuiManager;
|
||||||
import com.songoda.core.hooks.EconomyManager;
|
import com.songoda.core.hooks.EconomyManager;
|
||||||
import com.songoda.core.hooks.HologramManager;
|
import com.songoda.core.hooks.HologramManager;
|
||||||
import com.songoda.core.utils.TextUtils;
|
import com.songoda.core.utils.TextUtils;
|
||||||
import com.songoda.ultimatekits.commands.*;
|
import com.songoda.ultimatekits.commands.CommandCreatekit;
|
||||||
|
import com.songoda.ultimatekits.commands.CommandEdit;
|
||||||
|
import com.songoda.ultimatekits.commands.CommandKey;
|
||||||
|
import com.songoda.ultimatekits.commands.CommandKit;
|
||||||
|
import com.songoda.ultimatekits.commands.CommandPreviewKit;
|
||||||
|
import com.songoda.ultimatekits.commands.CommandReload;
|
||||||
|
import com.songoda.ultimatekits.commands.CommandRemove;
|
||||||
|
import com.songoda.ultimatekits.commands.CommandSet;
|
||||||
|
import com.songoda.ultimatekits.commands.CommandSettings;
|
||||||
|
import com.songoda.ultimatekits.commands.CommandUltimateKits;
|
||||||
import com.songoda.ultimatekits.conversion.Convert;
|
import com.songoda.ultimatekits.conversion.Convert;
|
||||||
import com.songoda.ultimatekits.database.DataManager;
|
import com.songoda.ultimatekits.database.DataManager;
|
||||||
import com.songoda.ultimatekits.database.MySQLConnector;
|
|
||||||
import com.songoda.ultimatekits.database.SQLiteConnector;
|
|
||||||
import com.songoda.ultimatekits.database.migrations._1_InitialMigration;
|
import com.songoda.ultimatekits.database.migrations._1_InitialMigration;
|
||||||
|
import com.songoda.ultimatekits.database.migrations._2_DuplicateMigration;
|
||||||
import com.songoda.ultimatekits.handlers.DisplayItemHandler;
|
import com.songoda.ultimatekits.handlers.DisplayItemHandler;
|
||||||
import com.songoda.ultimatekits.handlers.ParticleHandler;
|
import com.songoda.ultimatekits.handlers.ParticleHandler;
|
||||||
import com.songoda.ultimatekits.key.Key;
|
import com.songoda.ultimatekits.key.Key;
|
||||||
import com.songoda.ultimatekits.key.KeyManager;
|
import com.songoda.ultimatekits.key.KeyManager;
|
||||||
import com.songoda.ultimatekits.kit.*;
|
import com.songoda.ultimatekits.kit.Kit;
|
||||||
|
import com.songoda.ultimatekits.kit.KitAnimation;
|
||||||
|
import com.songoda.ultimatekits.kit.KitBlockData;
|
||||||
|
import com.songoda.ultimatekits.kit.KitItem;
|
||||||
|
import com.songoda.ultimatekits.kit.KitManager;
|
||||||
|
import com.songoda.ultimatekits.kit.KitType;
|
||||||
import com.songoda.ultimatekits.listeners.BlockListeners;
|
import com.songoda.ultimatekits.listeners.BlockListeners;
|
||||||
import com.songoda.ultimatekits.listeners.ChatListeners;
|
import com.songoda.ultimatekits.listeners.ChatListeners;
|
||||||
import com.songoda.ultimatekits.listeners.EntityListeners;
|
import com.songoda.ultimatekits.listeners.EntityListeners;
|
||||||
import com.songoda.ultimatekits.listeners.InteractListeners;
|
import com.songoda.ultimatekits.listeners.InteractListeners;
|
||||||
import com.songoda.ultimatekits.utils.*;
|
|
||||||
import com.songoda.ultimatekits.settings.Settings;
|
import com.songoda.ultimatekits.settings.Settings;
|
||||||
|
import com.songoda.ultimatekits.utils.ItemSerializer;
|
||||||
|
import com.songoda.ultimatekits.utils.Methods;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -37,7 +54,6 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class UltimateKits extends SongodaPlugin {
|
public class UltimateKits extends SongodaPlugin {
|
||||||
private static UltimateKits INSTANCE;
|
private static UltimateKits INSTANCE;
|
||||||
@ -147,7 +163,8 @@ public class UltimateKits extends SongodaPlugin {
|
|||||||
|
|
||||||
this.dataManager = new DataManager(this.databaseConnector, this);
|
this.dataManager = new DataManager(this.databaseConnector, this);
|
||||||
this.dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager,
|
this.dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager,
|
||||||
new _1_InitialMigration());
|
new _1_InitialMigration(),
|
||||||
|
new _2_DuplicateMigration(this.databaseConnector instanceof SQLiteConnector));
|
||||||
this.dataMigrationManager.runMigrations();
|
this.dataMigrationManager.runMigrations();
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -29,8 +29,7 @@ public class DataManager extends DataManagerAbstract {
|
|||||||
"displayItems = ?, particles = ?, itemOverride = ? " +
|
"displayItems = ?, particles = ?, itemOverride = ? " +
|
||||||
"WHERE world = ? AND x = ? AND y = ? AND z = ?";
|
"WHERE world = ? AND x = ? AND y = ? AND z = ?";
|
||||||
try (PreparedStatement statement = connection.prepareStatement(updateData)) {
|
try (PreparedStatement statement = connection.prepareStatement(updateData)) {
|
||||||
for (int i = 0; i < blockData.size(); i++) {
|
for (KitBlockData data : blockData.values()) {
|
||||||
KitBlockData data = blockData.get(i);
|
|
||||||
if (data == null) continue;
|
if (data == null) continue;
|
||||||
statement.setString(1, data.getType().toString());
|
statement.setString(1, data.getType().toString());
|
||||||
statement.setString(2, data.getKit().getName());
|
statement.setString(2, data.getKit().getName());
|
||||||
@ -131,6 +130,7 @@ public class DataManager extends DataManagerAbstract {
|
|||||||
location, type, holograms, particles, displayItems, itemOverride);
|
location, type, holograms, particles, displayItems, itemOverride);
|
||||||
blockData.put(location, kitBlockData);
|
blockData.put(location, kitBlockData);
|
||||||
}
|
}
|
||||||
|
result.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sync(() -> callback.accept(blockData));
|
this.sync(() -> callback.accept(blockData));
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
package com.songoda.ultimatekits.database;
|
|
||||||
|
|
||||||
import com.songoda.core.database.DatabaseConnector;
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class MySQLConnector implements DatabaseConnector {
|
|
||||||
|
|
||||||
private final Plugin plugin;
|
|
||||||
private HikariDataSource hikari;
|
|
||||||
private boolean initializedSuccessfully;
|
|
||||||
|
|
||||||
public MySQLConnector(Plugin plugin, String hostname, int port, String database, String username, String password, boolean useSSL) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
HikariConfig config = new HikariConfig();
|
|
||||||
|
|
||||||
config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database + "?useSSL=" + useSSL);
|
|
||||||
config.setUsername(username);
|
|
||||||
config.setPassword(password);
|
|
||||||
config.setMaximumPoolSize(3);
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.hikari = new HikariDataSource(config);
|
|
||||||
this.initializedSuccessfully = true;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
this.initializedSuccessfully = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInitialized() {
|
|
||||||
return this.initializedSuccessfully;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeConnection() {
|
|
||||||
this.hikari.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void connect(ConnectionCallback callback) {
|
|
||||||
try (Connection connection = this.hikari.getConnection()) {
|
|
||||||
callback.accept(connection);
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
this.plugin.getLogger().severe("An error occurred executing a MySQL query: " + ex.getMessage());
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package com.songoda.ultimatekits.database;
|
|
||||||
|
|
||||||
import com.songoda.core.database.DatabaseConnector;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class SQLiteConnector implements DatabaseConnector {
|
|
||||||
|
|
||||||
private final Plugin plugin;
|
|
||||||
private final String connectionString;
|
|
||||||
private Connection connection;
|
|
||||||
|
|
||||||
public SQLiteConnector(Plugin plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.connectionString = "jdbc:sqlite:" + plugin.getDataFolder() + File.separator + plugin.getDescription().getName().toLowerCase() + ".db";
|
|
||||||
|
|
||||||
try {
|
|
||||||
Class.forName("org.sqlite.JDBC"); // This is required to put here for Spigot 1.10 and below for some reason
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInitialized() {
|
|
||||||
return true; // Always available
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeConnection() {
|
|
||||||
try {
|
|
||||||
if (this.connection != null) {
|
|
||||||
this.connection.close();
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
this.plugin.getLogger().severe("An error occurred closing the SQLite database connection: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void connect(ConnectionCallback callback) {
|
|
||||||
if (this.connection == null) {
|
|
||||||
try {
|
|
||||||
this.connection = DriverManager.getConnection(this.connectionString);
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
this.plugin.getLogger().severe("An error occurred retrieving the SQLite database connection: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
callback.accept(this.connection);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
this.plugin.getLogger().severe("An error occurred executing an SQLite query: " + ex.getMessage());
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -26,10 +26,10 @@ public class _1_InitialMigration extends DataMigration {
|
|||||||
"displayItems BOOLEAN NOT NULL," +
|
"displayItems BOOLEAN NOT NULL," +
|
||||||
"particles BOOLEAN NOT NULL," +
|
"particles BOOLEAN NOT NULL," +
|
||||||
"itemOverride BOOLEAN NOT NULL," +
|
"itemOverride BOOLEAN NOT NULL," +
|
||||||
"world TEXT NOT NULL," +
|
"world TEXT NOT NULL," + // PK
|
||||||
"x INTEGER NOT NULL," +
|
"x INTEGER NOT NULL," + // PK
|
||||||
"y INTEGER NOT NULL," +
|
"y INTEGER NOT NULL," + // PK
|
||||||
"z INTEGER NOT NULL " +
|
"z INTEGER NOT NULL " + // PK
|
||||||
")");
|
")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
package com.songoda.ultimatekits.database.migrations;
|
||||||
|
|
||||||
|
import com.songoda.core.database.DataMigration;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class _2_DuplicateMigration extends DataMigration {
|
||||||
|
|
||||||
|
final boolean sqlite;
|
||||||
|
public _2_DuplicateMigration(boolean sqlite) {
|
||||||
|
super(2);
|
||||||
|
this.sqlite = sqlite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
||||||
|
// Fix duplicate data caused by old sqlite data duplication bug
|
||||||
|
if(sqlite) {
|
||||||
|
HashMap<String, TempKitData> data = new HashMap();
|
||||||
|
// grab a copy of the unique data values
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
|
ResultSet allData = statement.executeQuery("SELECT * FROM " + tablePrefix + "blockdata");
|
||||||
|
while (allData.next()) {
|
||||||
|
String world = allData.getString("world");
|
||||||
|
int x = allData.getInt("x");
|
||||||
|
int y = allData.getInt("y");
|
||||||
|
int z = allData.getInt("z");
|
||||||
|
String key = world + ";" + x + ";" + y + ";" + z + ";";
|
||||||
|
if(!data.containsKey(key)) {
|
||||||
|
data.put(key, new TempKitData(
|
||||||
|
allData.getString("type"),
|
||||||
|
allData.getString("kit"),
|
||||||
|
allData.getBoolean("holograms"),
|
||||||
|
allData.getBoolean("displayItems"),
|
||||||
|
allData.getBoolean("particles"),
|
||||||
|
allData.getBoolean("itemOverride"),
|
||||||
|
world, x, y, z
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
allData.close();
|
||||||
|
}
|
||||||
|
if(data.isEmpty()) return;
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
// first delete old data
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
|
statement.executeUpdate("DELETE FROM " + tablePrefix + "blockdata");
|
||||||
|
}
|
||||||
|
// then re-add valid unique data
|
||||||
|
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + tablePrefix + "blockdata (" +
|
||||||
|
"type, kit, holograms, displayItems, particles, itemOverride, world, x, y, z)" +
|
||||||
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
|
||||||
|
for(TempKitData blockData : data.values()) {
|
||||||
|
statement.setString(1, blockData.type);
|
||||||
|
statement.setString(2, blockData.kit);
|
||||||
|
statement.setBoolean(3, blockData.holograms);
|
||||||
|
statement.setBoolean(4, blockData.displayItems);
|
||||||
|
statement.setBoolean(5, blockData.particles);
|
||||||
|
statement.setBoolean(6, blockData.itemOverride);
|
||||||
|
statement.setString(7, blockData.world);
|
||||||
|
statement.setInt(8, blockData.x);
|
||||||
|
statement.setInt(9, blockData.y);
|
||||||
|
statement.setInt(10, blockData.z);
|
||||||
|
statement.executeUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connection.commit();
|
||||||
|
connection.setAutoCommit(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class TempKitData {
|
||||||
|
final String type, kit, world;
|
||||||
|
final int x, y, z;
|
||||||
|
final boolean holograms, displayItems, particles, itemOverride;
|
||||||
|
|
||||||
|
public TempKitData(String type, String kit, boolean holograms, boolean displayItems, boolean particles, boolean itemOverride, String world, int x, int y, int z) {
|
||||||
|
this.type = type;
|
||||||
|
this.kit = kit;
|
||||||
|
this.world = world;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.holograms = holograms;
|
||||||
|
this.displayItems = displayItems;
|
||||||
|
this.particles = particles;
|
||||||
|
this.itemOverride = itemOverride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.songoda.ultimatekits.gui;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jacob
|
||||||
|
*/
|
||||||
|
public class AnimatedKitGui {
|
||||||
|
|
||||||
|
}
|
@ -387,7 +387,7 @@ public class GUIKitEditor extends AbstractGUI {
|
|||||||
|
|
||||||
if (!isInInventory) {
|
if (!isInInventory) {
|
||||||
registerClickable(9, true, ((player, inventory, cursor, slot, type) ->
|
registerClickable(9, true, ((player, inventory, cursor, slot, type) ->
|
||||||
new GUIGeneralOptions(plugin, player, this, kit)));
|
new KitGeneralOptionsGui(plugin, player, this, kit)));
|
||||||
registerClickable(12, true, ((player, inventory, cursor, slot, type) ->
|
registerClickable(12, true, ((player, inventory, cursor, slot, type) ->
|
||||||
new KitGuiOptionsGui(plugin, player, this, kit)));
|
new KitGuiOptionsGui(plugin, player, this, kit)));
|
||||||
registerClickable(10, true, ((player, inventory, cursor, slot, type) ->
|
registerClickable(10, true, ((player, inventory, cursor, slot, type) ->
|
||||||
|
@ -1,25 +1,22 @@
|
|||||||
package com.songoda.ultimatekits.gui;
|
package com.songoda.ultimatekits.gui;
|
||||||
|
|
||||||
|
import com.songoda.core.gui.Gui;
|
||||||
import com.songoda.core.utils.ItemUtils;
|
import com.songoda.core.utils.ItemUtils;
|
||||||
import com.songoda.core.utils.TextUtils;
|
import com.songoda.core.utils.TextUtils;
|
||||||
import com.songoda.ultimatekits.UltimateKits;
|
import com.songoda.ultimatekits.UltimateKits;
|
||||||
import com.songoda.ultimatekits.kit.Kit;
|
import com.songoda.ultimatekits.kit.Kit;
|
||||||
import com.songoda.ultimatekits.utils.Methods;
|
import com.songoda.ultimatekits.utils.Methods;
|
||||||
import com.songoda.ultimatekits.utils.ServerVersion;
|
|
||||||
import com.songoda.ultimatekits.utils.gui.AbstractGUI;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GUIKitSelector extends AbstractGUI {
|
public class GUIKitSelector extends Gui {
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private UltimateKits plugin;
|
private UltimateKits plugin;
|
||||||
@ -33,10 +30,11 @@ public class GUIKitSelector extends AbstractGUI {
|
|||||||
private boolean glassless;
|
private boolean glassless;
|
||||||
|
|
||||||
public GUIKitSelector(UltimateKits plugin, Player player) {
|
public GUIKitSelector(UltimateKits plugin, Player player) {
|
||||||
super(player);
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
setTitle(plugin.getLocale().getMessage("interface.selector.title").getMessage());
|
||||||
|
|
||||||
kitList = new ArrayList<>();
|
kitList = new ArrayList<>();
|
||||||
|
|
||||||
setUpPage();
|
setUpPage();
|
||||||
@ -62,8 +60,6 @@ public class GUIKitSelector extends AbstractGUI {
|
|||||||
}
|
}
|
||||||
if (glassless) max -= 18;
|
if (glassless) max -= 18;
|
||||||
|
|
||||||
init(plugin.getLocale().getMessage("interface.selector.title").getMessage(), max);
|
|
||||||
|
|
||||||
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||||
if (inventory.getViewers().isEmpty()) return;
|
if (inventory.getViewers().isEmpty()) return;
|
||||||
constructGUI();
|
constructGUI();
|
||||||
@ -234,7 +230,7 @@ public class GUIKitSelector extends AbstractGUI {
|
|||||||
|
|
||||||
|
|
||||||
if (type == ClickType.LEFT) {
|
if (type == ClickType.LEFT) {
|
||||||
kit.display(player, this);
|
kit.display(player, guiManager, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ import com.songoda.ultimatekits.utils.Methods;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
public class GUIGeneralOptions extends Gui {
|
public class KitGeneralOptionsGui extends Gui {
|
||||||
|
|
||||||
public GUIGeneralOptions(UltimateKits plugin, Player player, Kit kit, Gui back) {
|
public KitGeneralOptionsGui(UltimateKits plugin, Player player, Kit kit, Gui back) {
|
||||||
super(back);
|
super(back);
|
||||||
setRows(3);
|
setRows(3);
|
||||||
setTitle(plugin.getLocale().getMessage("interface.kitoptions.title")
|
setTitle(plugin.getLocale().getMessage("interface.kitoptions.title")
|
@ -20,12 +20,10 @@ public class KitBlockData {
|
|||||||
this.items = items;
|
this.items = items;
|
||||||
this.itemOverride = itemOverride;
|
this.itemOverride = itemOverride;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
UltimateKits.getInstance().getDataManager().createBlockData(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KitBlockData(Kit kit, Location location) {
|
public KitBlockData(Kit kit, Location location) {
|
||||||
this(kit, location, KitType.PREVIEW, false, false, false, false);
|
this(kit, location, KitType.PREVIEW, false, false, false, false);
|
||||||
UltimateKits.getInstance().getDataManager().createBlockData(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
@ -7,8 +7,8 @@ import java.util.*;
|
|||||||
|
|
||||||
public final class KitManager {
|
public final class KitManager {
|
||||||
|
|
||||||
private Map<Location, KitBlockData> kitsAtLocations = new HashMap<>();
|
private final Map<Location, KitBlockData> kitsAtLocations = new HashMap<>();
|
||||||
private List<Kit> registeredKits = new LinkedList<>();
|
private final List<Kit> registeredKits = new LinkedList<>();
|
||||||
|
|
||||||
public boolean addKit(Kit kit) {
|
public boolean addKit(Kit kit) {
|
||||||
if (kit == null) return false;
|
if (kit == null) return false;
|
||||||
@ -35,8 +35,10 @@ public final class KitManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addKitToLocation(Kit kit, Location location, KitType type, boolean hologram, boolean particles, boolean items, boolean itemOverride) {
|
public void addKitToLocation(Kit kit, Location location, KitType type, boolean hologram, boolean particles, boolean items, boolean itemOverride) {
|
||||||
KitBlockData kitBlockData = kitsAtLocations.put(roundLocation(location), new KitBlockData(kit, location, type, hologram, particles, items, itemOverride));
|
KitBlockData data = new KitBlockData(kit, location, type, hologram, particles, items, itemOverride);
|
||||||
UltimateKits.getInstance().updateHologram(kitBlockData);
|
kitsAtLocations.put(roundLocation(location), data);
|
||||||
|
UltimateKits.getInstance().getDataManager().createBlockData(data);
|
||||||
|
UltimateKits.getInstance().updateHologram(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Kit removeKitFromLocation(Location location) {
|
public Kit removeKitFromLocation(Location location) {
|
||||||
@ -69,7 +71,8 @@ public final class KitManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setKitLocations(Map<Location, KitBlockData> kits) {
|
public void setKitLocations(Map<Location, KitBlockData> kits) {
|
||||||
kitsAtLocations = kits;
|
kitsAtLocations.clear();
|
||||||
|
kitsAtLocations.putAll(kits);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearKits() {
|
public void clearKits() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: UltimateKits
|
name: UltimateKits
|
||||||
main: com.songoda.ultimatekits.UltimateKits
|
main: com.songoda.ultimatekits.UltimateKits
|
||||||
version: maven-version-number
|
version: maven-version-number
|
||||||
softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, Vault, UltimateCore, Essentials, MiniKitPvP]
|
softdepend: [HolographicDisplays, Holograms, CMI, Vault, PlayerPoints, Reserve, PlaceholderAPI, UltimateCore, Essentials, MiniKitPvP]
|
||||||
description: View a kit before you purchase it!
|
description: View a kit before you purchase it!
|
||||||
author: Songoda
|
author: Songoda
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
Loading…
Reference in New Issue
Block a user