Working on Docs now.
This commit is contained in:
BigPappa committed 2026-08-20 19:30:08 -05:00
1 parent b5f3babc4c
commit 5a77e45910
14 files changed
+325 -25

No files matched your search

@@ -2,6 +2,7 @@ package com.rsscripting.rswarehouse.category.categorymenu;
import com.rsscripting.rswarehouse.dao.CategoryDAO;
import com.rsscripting.rswarehouse.config.ConfigManager;
import com.rsscripting.rswarehouse.dao.ItemDAO;
import com.rsscripting.rswarehouse.menuholder.RSMenuHolder;
import com.rsscripting.rswarehouse.model.WarehouseCategory;
import com.rsscripting.rswarehouse.constants.RSKeys;
@@ -404,7 +405,15 @@ public class CategoryMenu {
}
if (uncategorized != null) {
if (
uncategorized != null
&& (
ConfigManager.isAlwaysShowUncategorized()
|| ItemDAO.categoryHasItems(
uncategorized.id()
)
)
) {
ItemStack icon =
RSMenuUtils.createMenuItem(
@@ -3,6 +3,12 @@ package com.rsscripting.rswarehouse.config;
import com.rsscripting.rswarehouse.RSWarehouse;
import org.bukkit.configuration.file.FileConfiguration;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.logging.Level;
import java.io.InputStream;
public class ConfigManager {
private static FileConfiguration config;
@@ -22,6 +28,10 @@ public class ConfigManager {
RSWarehouse.getInstance()
.getConfig();
setupDefaultDatabase();
setupDatabaseTemplates();
}
/*
@@ -53,19 +63,6 @@ public class ConfigManager {
}
/*
| Uncateforized enabled
*/
public boolean isUncategorizedEnabled() {
return config.getBoolean(
"allow-uncategorized-item-creation",
true
);
}
/*
|--------------------------------------------------------------------------
| Server Commands Enabled
@@ -90,4 +87,127 @@ public class ConfigManager {
}
/*
|--------------------------------------------------------------------------
| UnCategorized Enabled
|--------------------------------------------------------------------------
*/
public static boolean isAlwaysShowUncategorized() {
return config.getBoolean(
"always-show-uncategorized",
false
);
}
private static void setupDatabaseTemplates() {
RSWarehouse plugin =
RSWarehouse.getInstance();
File templatesFolder =
new File(
plugin.getDataFolder(),
"db-files-templates"
);
if (!templatesFolder.exists()) {
templatesFolder.mkdirs();
}
File emptyDatabase =
new File(
templatesFolder,
"empty_database.db"
);
if (!emptyDatabase.exists()) {
plugin.saveResource(
"db-files-templates/empty_database.db",
false
);
}
File populatedDatabase =
new File(
templatesFolder,
"populated_database.db"
);
if (!populatedDatabase.exists()) {
plugin.saveResource(
"db-files-templates/populated_database.db",
false
);
}
}
private static void setupDefaultDatabase() {
RSWarehouse plugin =
RSWarehouse.getInstance();
File databaseFile =
new File(
plugin.getDataFolder(),
"database.db"
);
if (databaseFile.exists()) {
return;
}
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdirs();
}
try (
InputStream input =
plugin.getResource(
"db-files-templates/populated_database.db"
)
) {
if (input == null) {
plugin.getLogger().severe(
"Could not find populated_database.db in plugin resources."
);
return;
}
Files.copy(
input,
databaseFile.toPath()
);
}
catch (IOException exception) {
plugin.getLogger().log(
Level.SEVERE,
"Failed to create default database.",
exception
);
}
}
}
@@ -1,5 +1,7 @@
package com.rsscripting.rswarehouse.item;
import com.rsscripting.rswarehouse.adminmenu.AdminMenu;
import com.rsscripting.rswarehouse.category.categorymenu.CategoryMenu;
import com.rsscripting.rswarehouse.dao.CategoryDAO;
import com.rsscripting.rswarehouse.dao.ItemDAO;
import com.rsscripting.rswarehouse.item.options.ItemOptionsMenu;
@@ -81,7 +83,37 @@ public class ItemsMenuListener
if (event.getSlot() == 4) {
NavigationManager.back(player);
if (
session.getItemsCategoryId() == 1000
|| session.getItemsCategoryId() == 1001
) {
if (session.isRulesAndCommandsReturnToAdmin()) {
session.setRulesAndCommandsReturnToAdmin(
false
);
AdminMenu.open(
player
);
} else {
CategoryMenu.open(
player,
0
);
}
return;
}
NavigationManager.back(
player
);
return;
@@ -1,5 +1,6 @@
package com.rsscripting.rswarehouse.item.deleteitem;
import com.rsscripting.rswarehouse.category.categorymenu.CategoryMenu;
import com.rsscripting.rswarehouse.item.options.ItemOptionsMenu;
import com.rsscripting.rswarehouse.dao.InventoryQuantityDAO;
import com.rsscripting.rswarehouse.dao.WarehouseReferenceDAO;
@@ -100,6 +101,12 @@ public class DeleteConfirmationMenuListener
warehouseItem.inventoryId()
);
/*
* More than one reference means another item also
* points to this inventory row.
*
* Delete this reference only.
*/
if (references > 1) {
WarehouseReferenceDAO.deleteItemReference(
@@ -110,12 +117,40 @@ public class DeleteConfirmationMenuListener
"§aItem reference deleted."
);
player.closeInventory();
CategoryMenu.open(
player,
1
);
return;
}
/*
* This is the only reference.
*
* Check whether inventory still contains items.
*/
long quantity =
InventoryQuantityDAO.getInventoryQuantity(
warehouseItem.inventoryId()
);
if (quantity > 0) {
player.sendMessage(
"§cCannot delete this item because it still has "
+ quantity
+ " item(s) in the warehouse."
);
return;
}
/*
* Do not delete if variants still exist.
*/
if (DamagedVariantsDAO.hasDamagedVariants(
warehouseItem.inventoryId()
)) {
@@ -152,6 +187,13 @@ public class DeleteConfirmationMenuListener
}
/*
* Only reference remaining.
* Quantity is zero.
* No variants exist.
*
* Safe to delete both.
*/
WarehouseReferenceDAO.deleteItemReference(
warehouseItem.id()
);
@@ -164,7 +206,12 @@ public class DeleteConfirmationMenuListener
"§aItem deleted."
);
player.closeInventory();
CategoryMenu.open(
player,
1
);
return;
}
@@ -5,6 +5,8 @@ import com.rsscripting.rswarehouse.item.ItemsMenu;
import com.rsscripting.rswarehouse.menuholder.RSMenuHolder;
import com.rsscripting.rswarehouse.session.admin.ServerCommandCreationSession;
import com.rsscripting.rswarehouse.session.admin.ServerCommandCreationSessionManager;
import com.rsscripting.rswarehouse.session.GuiSession;
import com.rsscripting.rswarehouse.session.GuiSessionManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -120,6 +122,15 @@ public class ServerCommandMaterialPickerMenuListener
"§aServer Command created successfully."
);
GuiSession guiSession =
GuiSessionManager.getSession(
player
);
guiSession.setRulesAndCommandsReturnToAdmin(
true
);
ItemsMenu.open(
player,
1001,
@@ -3,6 +3,8 @@ package com.rsscripting.rswarehouse.serverrule;
import com.rsscripting.rswarehouse.dao.admin.CreateServerRuleDAO;
import com.rsscripting.rswarehouse.item.ItemsMenu;
import com.rsscripting.rswarehouse.menuholder.RSMenuHolder;
import com.rsscripting.rswarehouse.session.GuiSession;
import com.rsscripting.rswarehouse.session.GuiSessionManager;
import com.rsscripting.rswarehouse.session.admin.ServerRuleCreationSession;
import com.rsscripting.rswarehouse.session.admin.ServerRuleCreationSessionManager;
import org.bukkit.entity.Player;
@@ -69,10 +71,6 @@ public class ServerRuleMaterialPickerMenuListener
}
/*
* Previous page
*/
/*
* Current material picker page.
*/
@@ -157,6 +155,14 @@ public class ServerRuleMaterialPickerMenuListener
"§aServer Rule created successfully."
);
GuiSession guiSession =
GuiSessionManager.getSession(
player
);
guiSession.setRulesAndCommandsReturnToAdmin(
true
);
ItemsMenu.open(
player,
@@ -6,6 +6,8 @@ import java.util.UUID;
public class GuiSession {
private boolean rulesAndCommandsReturnToAdmin;
/*
|--------------------------------------------------------------------------
| Player Session
@@ -500,5 +502,20 @@ public class GuiSession {
}
public boolean isRulesAndCommandsReturnToAdmin() {
return rulesAndCommandsReturnToAdmin;
}
public void setRulesAndCommandsReturnToAdmin(
boolean rulesAndCommandsReturnToAdmin
) {
this.rulesAndCommandsReturnToAdmin =
rulesAndCommandsReturnToAdmin;
}
}
+5
View File
@@ -36,6 +36,11 @@ chest-auto-processing:
# if item is not currently in warehouse.
allow-uncategorized-item-creation: true
# Whether or not to always show the Uncategorized category.
# True = Uncategorized will always show.
# False = Uncategorized will only show if it has items inside.
always-show-uncategorized: false
# Allow damaged items to be added to
# damaged variant menu of base items.
allow-damaged-item-creation: true
Binary file not shown.