1.5.0
Working on Docs now.
This commit is contained in:
1 parent
b5f3babc4c
commit
5a77e45910
14 files changed
+325
-25
No files matched your search
@@ -55,10 +55,20 @@ Your plugins folder should now contain:
|
||||
```
|
||||
plugins/
|
||||
└── RS-Warehouse/
|
||||
└── db-files-templates
|
||||
├── empty_database.db
|
||||
└── populated_database.db
|
||||
├── config.yml
|
||||
└── database.db
|
||||
|
||||
|
||||
```
|
||||
|
||||
📷 Screenshot
|
||||
```
|
||||
NOTE:
|
||||
RS-Warehouse comes with 2 additional database files.
|
||||
1) empty_database.md = A totally empty database file. No categories, no items.
|
||||
the only items contained in this databse are the Uncategorized, Server
|
||||
Rules, Server Commands, and Auto-Deposit categories
|
||||
|
||||

|
||||
```
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.6 KiB |
@@ -19,22 +19,65 @@
|
||||
<build>
|
||||
<resources>
|
||||
|
||||
<!-- Normal resources that need filtering -->
|
||||
<resource>
|
||||
|
||||
<directory>src/main/resources</directory>
|
||||
|
||||
<filtering>true</filtering>
|
||||
|
||||
<excludes>
|
||||
<exclude>database.db</exclude>
|
||||
|
||||
<exclude>
|
||||
database.db
|
||||
</exclude>
|
||||
|
||||
<exclude>
|
||||
db-files-templates/*.db
|
||||
</exclude>
|
||||
|
||||
</excludes>
|
||||
|
||||
</resource>
|
||||
|
||||
<!-- Main database copied as binary -->
|
||||
<resource>
|
||||
|
||||
<directory>src/main/resources</directory>
|
||||
|
||||
<filtering>false</filtering>
|
||||
|
||||
<includes>
|
||||
<include>database.db</include>
|
||||
|
||||
<include>
|
||||
database.db
|
||||
</include>
|
||||
|
||||
</includes>
|
||||
|
||||
</resource>
|
||||
|
||||
<!-- Database template files copied as binary -->
|
||||
<resource>
|
||||
|
||||
<directory>
|
||||
src/main/resources/db-files-templates
|
||||
</directory>
|
||||
|
||||
<targetPath>
|
||||
db-files-templates
|
||||
</targetPath>
|
||||
|
||||
<filtering>false</filtering>
|
||||
|
||||
<includes>
|
||||
|
||||
<include>
|
||||
*.db
|
||||
</include>
|
||||
|
||||
</includes>
|
||||
|
||||
</resource>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+49
-2
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -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,
|
||||
|
||||
+10
-4
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user