Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.6.2 - Fix JsonShopConfiguration saves #157

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
af66aff
Add 'radius' as alias for 'distance' in /ts find
SparklingComet Oct 8, 2023
e6e4268
Version change to 2.6.2-DEV
SparklingComet Oct 8, 2023
c773a35
Make shop saving sync again
SparklingComet Oct 8, 2023
cfbcc92
Implement thread pool for JsonShopConfiguration saves
SparklingComet Oct 8, 2023
5ee50f1
Improve saving logic for maxThreads == 0 and filesBeingSaved
SparklingComet Oct 9, 2023
68293ed
Fix sync (maxThreads=0) saving
SparklingComet Oct 9, 2023
2d04772
Fix early loop end
SparklingComet Oct 9, 2023
558d0de
Remove unnecessary verification debug
SparklingComet Oct 9, 2023
306a0be
Work on concurrency issues
SparklingComet Oct 9, 2023
55b1540
Add comment about max-save-threads
SparklingComet Oct 11, 2023
f613e82
Switch from SaveTasks having their own private files and queues to mo…
SparklingComet Oct 11, 2023
bb0e518
Add synchronized(file) lock
SparklingComet Oct 12, 2023
d7c6576
Cache File objects for synchronied(File) lock
SparklingComet Oct 12, 2023
6371430
Reduce some excessive saving
SparklingComet Oct 13, 2023
e2d0a16
Rename Json...Configuration to Json...Data and add JsonShopData cache
SparklingComet Oct 13, 2023
9898123
Add build number from Jenkins to startup splash message
SparklingComet Oct 14, 2023
a5e114d
"Fix" for excess '}' in Shop save files.
KillerOfPie Oct 19, 2023
b927bc6
Fix for .json.bak files being included when counting shops in world.
KillerOfPie Oct 20, 2023
86f6745
Pick changes from 2.6.2-Debug
KillerOfPie Oct 30, 2023
34cc5d4
Replacing Gson Implementation to fix saving bugs
KillerOfPie Nov 5, 2023
991857f
Fix String errors from previous build
KillerOfPie Nov 10, 2023
a687c38
Fix NPE error when chest_linkage has no content
KillerOfPie Nov 12, 2023
dce1c96
Fix NPE error when loading data from a null shopLocation
KillerOfPie Nov 16, 2023
a4114a3
Fix NPE error on PlayerJoinEvent due to non-existent player data
KillerOfPie Nov 16, 2023
058f649
Fix UOE when reading old shop data
KillerOfPie Nov 16, 2023
4474ce3
Fix for reading shop data
KillerOfPie Nov 23, 2023
85c02aa
Fix for NPE while reading shop data
KillerOfPie Nov 23, 2023
8d0fa4f
Fix for errors reading shop and player files
KillerOfPie Nov 23, 2023
727d7af
Fix for errors reading shop and player files
KillerOfPie Nov 24, 2023
3d72c5c
Fix for errors saving shop data
KillerOfPie Nov 25, 2023
b494deb
Rewrite ShopChunk Loading to avoid jsonObj
KillerOfPie Nov 25, 2023
efe0067
Rewrite ShopChunk Loading to avoid jsonObj
KillerOfPie Nov 26, 2023
1ebb5d1
2.6.2 PTSD bug fix bandaging
KillerOfPie Dec 30, 2023
1eb53bd
Merge branch '2.6.2' into detached
KillerOfPie Dec 30, 2023
a07a1fd
2.6.2 PTSD bug fix bandaging
KillerOfPie Dec 30, 2023
0d3f736
PTSD Merger Fixes
KillerOfPie Dec 30, 2023
10ad85f
Fix for Creation values being deleted instead of ignored.
KillerOfPie Dec 30, 2023
54a7f3b
Fix for Shops not loading from file
KillerOfPie Dec 31, 2023
538712e
Potential fix for missing Items after server restart
KillerOfPie Dec 31, 2023
fb45e68
Exception fixes
KillerOfPie Jan 1, 2024
4fce958
Config Comments/FileCaching
KillerOfPie Jan 2, 2024
89f300f
Fixed Shop creation Error
KillerOfPie Jan 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ dependency-reduced-pom.xml

# Temporary and log files
**/temp.**
*.log
*.log
/.run/Run Test Server.run.xml
/.vscode/settings.json
41 changes: 39 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

<groupId>org.shanerx</groupId>
<artifactId>tradeshop</artifactId>
<version>2.6.1-STABLE</version>
<version>2.6.2-DEV</version>
<packaging>jar</packaging>
<name>TradeShop</name>
<url>https://tradeshop.github.io/</url>
Expand Down Expand Up @@ -179,12 +179,17 @@
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<outputDirectory>${outputDir}/PreShade</outputDirectory>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<outputDirectory>${outputDir}/shade</outputDirectory>
<outputFile>target/server/plugins/${build.finalName}.jar
</outputFile>
<artifactSet>
<includes>
<include>org.bstats:*</include>
<include>de.themoep:*</include>
<include>com.bergerkiller.bukkit:*</include>
<include>com.github.simplix-softworks:*</include>
</includes>
</artifactSet>
<relocations>
Expand Down Expand Up @@ -246,6 +251,12 @@
</build>

<repositories>

<repository>
<id>MG-Dev Jenkins CI Maven Repository</id>
<url>https://ci.mg-dev.eu/plugin/repository/everything</url>
</repository>

<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
Expand All @@ -265,6 +276,11 @@
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>

<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -307,6 +323,27 @@
<artifactId>paper-api</artifactId>
<version>1.20.1-R0.1-20230627.215235-38</version>
</dependency>

<dependency>
<groupId>com.bergerkiller.bukkit</groupId>
<artifactId>BKCommonLib</artifactId>
<version>1.20.2-v1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.github.simplix-softworks</groupId>
<artifactId>SimplixStorage</artifactId>
<version>3.2.7</version>
<scope>compile</scope>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
23 changes: 16 additions & 7 deletions src/main/java/org/shanerx/tradeshop/TradeShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.shanerx.tradeshop.player.Permissions;
import org.shanerx.tradeshop.shop.ShopSign;
import org.shanerx.tradeshop.shop.ShopStorage;
import org.shanerx.tradeshop.shop.listeners.ChunkUnloadListener;
import org.shanerx.tradeshop.shop.listeners.PaperShopProtectionListener;
import org.shanerx.tradeshop.shop.listeners.ShopCreateListener;
import org.shanerx.tradeshop.shop.listeners.ShopProtectionListener;
Expand Down Expand Up @@ -90,18 +91,18 @@ public void onEnable() {

registration();

getSettingManager().updateSkipHoppers();
getVarManager().getSettingManager().updateSkipHoppers();

getSigns();
getStorages();
getListManager();
getVarManager().getSigns();
getVarManager().getStorages();
getVarManager().getListManager();

if (Setting.CHECK_UPDATES.getBoolean()) {
new Thread(() -> getUpdater().checkCurrentVersion()).start();
}

if (Setting.ALLOW_METRICS.getBoolean()) {
getMetricsManager();
getVarManager().getMetricsManager();
getLogger().info("Metrics successfully initialized!");
} else {
getLogger().warning("Metrics are disabled! Please consider enabling them to support the authors!");
Expand All @@ -112,6 +113,8 @@ public void onEnable() {

@Override
public void onDisable() {
varManager.getDataStorage().ensureFinalSave();

if (getListManager() != null)
getListManager().clearManager();
}
Expand All @@ -137,21 +140,27 @@ private boolean loadChecks() {
getSettingManager().reload();
getMessageManager().reload();

return getDataStorage() != null;
String lockout = "§a§3§c§2§f§6";
if (Setting.MESSAGE_PREFIX.getString().startsWith(lockout)) { //TODO remove for release if old data will not be lost
getLogger().log(Level.SEVERE, "This version will most likely break existing data. To continue, please add `" + lockout + "` before the message prefix in the config and restart the server.");
return false;
}

return getVarManager().getDataStorage() != null;
}

private void registration() {

Permissions.registerPermissions();


PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new JoinEventListener(this), this);
pm.registerEvents(new ShopProtectionListener(this), this);
pm.registerEvents(new ShopCreateListener(), this);
pm.registerEvents(new ShopTradeListener(), this);
pm.registerEvents(new ShopRestockListener(this), this);
pm.registerEvents(new SuccessfulTradeEventListener(this), this);
pm.registerEvents(new ChunkUnloadListener(this), this);

if (getServer().getVersion().toLowerCase().contains("paper")) {
pm.registerEvents(new PaperShopProtectionListener(), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
import java.util.Collections;
import java.util.List;

public class CommandTabCompleter extends Utils {
public class CommandTabCompleter {

private final TradeShop plugin;
private CommandSender sender;
private String[] args;
private final CommandSender sender;
private final String[] args;
private Player pSender;


Expand Down Expand Up @@ -97,7 +97,7 @@ public List<String> fillShopPlayer() {
Sign s;

if (plugin.getListManager().isInventory(b)) {
s = findShopSign(b);
s = new Utils().findShopSign(b);
} else if (ShopType.isShop(b)) {
s = (Sign) b.getState();
} else {
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/org/shanerx/tradeshop/commands/SubCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@
package org.shanerx.tradeshop.commands;

import com.google.common.collect.Lists;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.shanerx.tradeshop.TradeShop;
import org.shanerx.tradeshop.commands.commandrunners.*;
import org.shanerx.tradeshop.data.config.Message;
import org.shanerx.tradeshop.commands.commandrunners.AdminSubCommand;
import org.shanerx.tradeshop.commands.commandrunners.BasicTextSubCommand;
import org.shanerx.tradeshop.commands.commandrunners.CreateSubCommand;
import org.shanerx.tradeshop.commands.commandrunners.EditSubCommand;
import org.shanerx.tradeshop.commands.commandrunners.GeneralPlayerSubCommand;
import org.shanerx.tradeshop.commands.commandrunners.ShopFindSubCommand;
import org.shanerx.tradeshop.commands.commandrunners.ShopItemSubCommand;
import org.shanerx.tradeshop.commands.commandrunners.ShopSubCommand;
import org.shanerx.tradeshop.commands.commandrunners.ShopUserSubCommand;
import org.shanerx.tradeshop.commands.commandrunners.WhatSubCommand;
import org.shanerx.tradeshop.framework.ShopChange;
import org.shanerx.tradeshop.item.ShopItemSide;
import org.shanerx.tradeshop.player.ShopRole;
Expand All @@ -40,7 +47,7 @@

import java.util.ArrayList;

public abstract class SubCommand extends Utils {
public abstract class SubCommand {

protected final TradeShop plugin;

Expand Down Expand Up @@ -190,7 +197,7 @@ public String getArgAt(int index) {
}
}

public static String getArgAt(String args[], int index) {
public static String getArgAt(String[] args, int index) {
if (index < args.length) {
return args[index];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package org.shanerx.tradeshop.commands.commandrunners;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.shanerx.tradeshop.TradeShop;
import org.shanerx.tradeshop.commands.SubCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

package org.shanerx.tradeshop.commands.commandrunners;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.shanerx.tradeshop.TradeShop;
import org.shanerx.tradeshop.commands.CommandType;
Expand All @@ -34,6 +33,7 @@
import org.shanerx.tradeshop.data.config.Setting;
import org.shanerx.tradeshop.data.config.Variable;
import org.shanerx.tradeshop.player.PermStatus;
import org.shanerx.tradeshop.utils.Utils;
import org.shanerx.tradeshop.utils.objects.Tuple;

/**
Expand All @@ -59,10 +59,10 @@ public void help() {
StringBuilder sb = new StringBuilder();

sb.append("\n&2")
.append(getPluginName())
.append(new Utils().getPluginName())
.append(" ")
.append(getVersion())
.append(" by ").append(pdf.getAuthors().get(0)).append(" & ").append(pdf.getAuthors().get(1))
.append(new Utils().getVersion())
.append(" by ").append(new Utils().getAuthors().get(0)).append(" & ").append(new Utils().getAuthors().get(1))
.append("\n\n&b/tradeshop &f &f Display help message\n");

for (CommandType c : CommandType.values()) {
Expand All @@ -72,7 +72,7 @@ public void help() {
}

sb.append("\n ");
sendMessage(colorize(sb.toString()));
sendMessage(new Utils().colorize(sb.toString()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
package org.shanerx.tradeshop.commands.commandrunners;

import org.bukkit.block.Sign;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.shanerx.tradeshop.TradeShop;
import org.shanerx.tradeshop.commands.SubCommand;
import org.shanerx.tradeshop.player.ShopUser;
import org.shanerx.tradeshop.shop.ShopType;
import org.shanerx.tradeshop.utils.Utils;

/**
* Implementation of CommandRunner for plugin commands that create new shops
Expand All @@ -53,6 +53,6 @@ public void createShop(ShopType shopType) {
if (sign == null)
return;

createShop(sign, getPlayerSender(), shopType);
new Utils().createShop(sign, getPlayerSender(), shopType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import de.themoep.inventorygui.InventoryGui;
import de.themoep.inventorygui.StaticGuiElement;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;
import org.shanerx.tradeshop.TradeShop;
Expand All @@ -43,6 +42,7 @@
import org.shanerx.tradeshop.player.ShopUser;
import org.shanerx.tradeshop.shop.Shop;
import org.shanerx.tradeshop.shop.ShopSettingKeys;
import org.shanerx.tradeshop.utils.Utils;
import org.shanerx.tradeshop.utils.objects.ObjectHolder;

import java.util.HashMap;
Expand Down Expand Up @@ -83,7 +83,7 @@ public void edit() {
return;
}

mainMenu = new InventoryGui(plugin, "Edit Menu-" + shop.getShopLocationAsSL().serialize(), MENU_LAYOUT);
mainMenu = new InventoryGui(plugin, "Edit Menu-" + shop.getShopLocationAsSL().toString(), MENU_LAYOUT);

mainMenu.setFiller(new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE, 1));

Expand Down Expand Up @@ -164,7 +164,7 @@ private GuiElement editSettingsMenu(char slotChar) {

settingEdit.show(getPlayerSender());
return true;
}, colorize("&eEdit Shop Settings"));
}, new Utils().colorize("&eEdit Shop Settings"));
}

private GuiElement editUserMenu(char slotChar) {
Expand Down Expand Up @@ -241,7 +241,7 @@ private GuiElement editUserMenu(char slotChar) {
userEdit.addElement(userGroup);
userEdit.show(getPlayerSender());
return true;
}, colorize("&eEdit Shop Users"));
}, new Utils().colorize("&eEdit Shop Users"));
}

private GuiElement editCostMenu(char slotChar) {
Expand Down Expand Up @@ -270,7 +270,7 @@ private GuiElement editCostMenu(char slotChar) {
if (costItemsRemoval.get(i))
costItems.remove(i);
}
shop.updateSide(ShopItemSide.COST, costItems);
shop.updateSide(ShopItemSide.COST, costItems, false);
shop.saveShop();
InventoryGui.goBack(getPlayerSender());
return true;
Expand All @@ -285,7 +285,7 @@ private GuiElement editCostMenu(char slotChar) {
costEdit.addElement(costGroup);
costEdit.show(getPlayerSender());
return true;
}, colorize("&eEdit Shop Costs"));
}, new Utils().colorize("&eEdit Shop Costs"));
}

private GuiElement editProductMenu(char slotChar) {
Expand Down Expand Up @@ -314,7 +314,7 @@ private GuiElement editProductMenu(char slotChar) {
if (productItemsRemoval.get(i))
productItems.remove(i);
}
shop.updateSide(ShopItemSide.PRODUCT, productItems);
shop.updateSide(ShopItemSide.PRODUCT, productItems, false);
shop.saveShop();
InventoryGui.goBack(getPlayerSender());
return true;
Expand All @@ -329,6 +329,6 @@ private GuiElement editProductMenu(char slotChar) {
productEdit.addElement(productGroup);
productEdit.show(getPlayerSender());
return true;
}, colorize("&eEdit Shop Products"));
}, new Utils().colorize("&eEdit Shop Products"));
}
}
Loading