Skip to content

Commit f7bf2a8

Browse files
committed
Format and cleanup code
1 parent e5c83b6 commit f7bf2a8

39 files changed

+142
-118
lines changed

src/main/java/org/maxgamer/quickshop/QuickShop.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public boolean loadEcon() {
505505
}
506506
}
507507

508-
// /**
508+
// /**
509509
// * Logs the given string to qs.log, if QuickShop is configured to do so.
510510
// *
511511
// * @param s The string to log. It will be prefixed with the date and time.
@@ -518,7 +518,7 @@ public boolean loadEcon() {
518518
// this.getLogWatcher().log(s);
519519
// }
520520

521-
public void logEvent(@NotNull Object eventObject){
521+
public void logEvent(@NotNull Object eventObject) {
522522
getDatabaseHelper().insertHistoryRecord(eventObject);
523523
}
524524

@@ -961,9 +961,9 @@ public void run() {
961961
getDatabaseHelper().insertHistoryRecord(new TestRecord());
962962
}
963963

964-
static class TestRecord{
965-
private String test = "Hello World!";
966-
private ShopChunk chunk = new ShopChunk("hello!",2,3);
964+
static class TestRecord {
965+
private final String test = "Hello World!";
966+
private final ShopChunk chunk = new ShopChunk("hello!", 2, 3);
967967
}
968968

969969
private void loadItemMatcher() {
@@ -1920,7 +1920,7 @@ private void updateConfig(int selectedVersion) throws IOException {
19201920
getConfig().set("purge.days", 60);
19211921
getConfig().set("purge.banned", true);
19221922
getConfig().set("purge.skip-op", true);
1923-
getConfig().set("purge.return-create-fee",true);
1923+
getConfig().set("purge.return-create-fee", true);
19241924
getConfig().set("config-version", ++selectedVersion);
19251925
}
19261926

src/main/java/org/maxgamer/quickshop/chat/QuickChat.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ void sendItemHologramChat(
6060

6161
/**
6262
* Generate the chat component with preview item hover event
63-
* @param shop The shop
63+
*
64+
* @param shop The shop
6465
* @param itemStack The itemstack
65-
* @param player The player
66-
* @param message The message with hover event
66+
* @param player The player
67+
* @param message The message with hover event
6768
* @return The component
6869
*/
6970
@NotNull QuickComponent getItemHologramChat(@NotNull Shop shop, @NotNull ItemStack itemStack, @NotNull Player player, @NotNull String message);
@@ -91,9 +92,9 @@ void sendItemHologramChat(
9192
/**
9293
* Send click-suggest-command chat to specified receiver
9394
*
94-
* @param receiver The PLAYER will receive this message
95-
* @param message The text will sent
96-
* @param command The command when click to be suggested
95+
* @param receiver The PLAYER will receive this message
96+
* @param message The text will sent
97+
* @param command The command when click to be suggested
9798
* @param hoverText The text while player hover on the text
9899
*/
99100
void sendSuggestedChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command);

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Clean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabe
6666
}
6767

6868
for (Shop shop : pendingRemoval) {
69-
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender),"/qs clean",shop.saveToInfoStorage()));
69+
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender), "/qs clean", shop.saveToInfoStorage()));
7070
shop.delete();
7171
}
7272

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_CleanGhost.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,23 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabe
7171
if (shop.getItem().getType() == Material.AIR) {
7272
MsgUtil.sendDirectMessage(sender,
7373
ChatColor.YELLOW + "Deleting shop " + shop + " because of corrupted item data.");
74-
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender),"/qs cleanghost command",shop.saveToInfoStorage()));
74+
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender), "/qs cleanghost command", shop.saveToInfoStorage()));
7575
Util.mainThreadRun(shop::delete);
7676
continue;
7777
}
7878
if (!shop.getLocation().isWorldLoaded()) {
7979
MsgUtil.sendDirectMessage(sender,
8080
ChatColor.YELLOW + "Deleting shop " + shop + " because the its world is not loaded.");
8181
Util.mainThreadRun(shop::delete);
82-
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender),"/qs cleanghost command",shop.saveToInfoStorage()));
82+
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender), "/qs cleanghost command", shop.saveToInfoStorage()));
8383
continue;
8484
}
8585
//noinspection ConstantConditions
8686
if (shop.getOwner() == null) {
8787
MsgUtil.sendDirectMessage(sender,
8888
ChatColor.YELLOW + "Deleting shop " + shop + " because of corrupted owner data.");
8989
Util.mainThreadRun(shop::delete);
90-
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender),"/qs cleanghost command",shop.saveToInfoStorage()));
90+
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender), "/qs cleanghost command", shop.saveToInfoStorage()));
9191
continue;
9292
}
9393
// Shop exist check

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Remove.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
5353
if (shop.getModerator().isModerator(sender.getUniqueId())
5454
|| QuickShop.getPermissionManager().hasPermission(sender, "quickshop.other.destroy")) {
5555
shop.delete();
56-
plugin.logEvent(new ShopRemoveLog(sender.getUniqueId(),"/qs remove command",shop.saveToInfoStorage()));
56+
plugin.logEvent(new ShopRemoveLog(sender.getUniqueId(), "/qs remove command", shop.saveToInfoStorage()));
5757
} else {
5858
plugin.text().of(sender, "no-permission").send();
5959
}

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_RemoveAll.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabe
6767
}
6868
for (Shop shop : tempList) {
6969
if (shop.getOwner().equals(shopOwner.getUniqueId())) {
70-
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender),"Deleting shop " + shop + " as requested by the /qs removeall command.",shop.saveToInfoStorage()));
70+
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender), "Deleting shop " + shop + " as requested by the /qs removeall command.", shop.saveToInfoStorage()));
7171
shop.delete();
7272
i++;
7373
}
@@ -83,7 +83,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabe
8383
}
8484
for (Shop shop : tempList) {
8585
if (shop.getOwner().equals(((OfflinePlayer) sender).getUniqueId())) {
86-
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender),"Deleting shop " + shop + " as requested by the /qs removeall command.",shop.saveToInfoStorage()));
86+
plugin.logEvent(new ShopRemoveLog(Util.getSenderUniqueId(sender), "Deleting shop " + shop + " as requested by the /qs removeall command.", shop.saveToInfoStorage()));
8787
shop.delete();
8888
i++;
8989
}

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_SilentRemove.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
5555
return;
5656
}
5757

58-
plugin.logEvent(new ShopRemoveLog(sender.getUniqueId(),"/qs silentremove command",shop.saveToInfoStorage()));
58+
plugin.logEvent(new ShopRemoveLog(sender.getUniqueId(), "/qs silentremove command", shop.saveToInfoStorage()));
5959
shop.delete();
6060
}
6161
}

src/main/java/org/maxgamer/quickshop/database/DatabaseHelper.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ private void init() throws SQLException {
6666
if (!manager.hasTable(plugin.getDbPrefix() + "messages")) {
6767
createMessagesTable();
6868
}
69-
if(!manager.hasTable(plugin.getDbPrefix() + "logs")){
69+
if (!manager.hasTable(plugin.getDbPrefix() + "logs")) {
7070
createLogsTable();
7171
}
72-
if(!manager.hasTable(plugin.getDbPrefix()+"external_cache")){
72+
if (!manager.hasTable(plugin.getDbPrefix() + "external_cache")) {
7373
createExternalCacheTable();
7474
}
7575
checkColumns();
@@ -100,15 +100,15 @@ private void createMessagesTable() {
100100
manager.runInstantTask(new DatabaseTask(createTable));
101101
}
102102

103-
private void createLogsTable(){
103+
private void createLogsTable() {
104104
String createTable = "CREATE TABLE " + plugin.getDbPrefix()
105105
+ "logs (time BIGINT(32) NOT NULL);";
106106
manager.runInstantTask(new DatabaseTask(createTable));
107107
createColumn("logs", "classname", new DataType(DataTypeMapping.TEXT, null, ""));
108108
createColumn("logs", "data", new DataType(DataTypeMapping.LONGTEXT, null, ""));
109109
}
110110

111-
private void createExternalCacheTable(){
111+
private void createExternalCacheTable() {
112112
String createTable = "CREATE TABLE " + plugin.getDbPrefix()
113113
+ "external_cache ( x INTEGER(32) NOT NULL, y INTEGER(32) NOT NULL, z INTEGER(32) NOT NULL, world VARCHAR(32) NOT NULL );";
114114
manager.runInstantTask(new DatabaseTask(createTable));
@@ -322,7 +322,7 @@ public void updateOwner2UUID(@NotNull String ownerUUID, int x, int y, int z, @No
322322
}));
323323
}
324324

325-
public void updateExternalInventoryProfileCache(@NotNull Shop shop, int space, int stock){
325+
public void updateExternalInventoryProfileCache(@NotNull Shop shop, int space, int stock) {
326326

327327
}
328328

@@ -352,13 +352,13 @@ public void updateShop(@NotNull String owner, @NotNull ItemStack item, int unlim
352352

353353
}
354354

355-
public void insertHistoryRecord(Object record){
355+
public void insertHistoryRecord(Object record) {
356356
String sqlString = "INSERT INTO " + plugin.getDbPrefix() + "logs (time, classname, data) VALUES (?, ?, ?)";
357357
manager.addDelayTask(
358358
new DatabaseTask(
359359
sqlString,
360360
(ps) -> {
361-
ps.setLong(1,System.currentTimeMillis());
361+
ps.setLong(1, System.currentTimeMillis());
362362
ps.setString(2, record.getClass().getName());
363363
ps.setString(3, JsonUtil.getGson().toJson(record));
364364
}));

src/main/java/org/maxgamer/quickshop/database/DatabaseTask.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void run(@NonNull Connection connection) {
5959
interface Task {
6060
/**
6161
* Edit action before commit the PreparedStatement
62+
*
6263
* @param ps The PreparedStatement
6364
* @throws SQLException Throws if any exception throws
6465
*/
@@ -72,6 +73,7 @@ default void onSuccess() {
7273

7374
/**
7475
* Calling when PreparedStatement failed to commit
76+
*
7577
* @param e The exception
7678
*/
7779
default void onFailed(SQLException e) {

src/main/java/org/maxgamer/quickshop/economy/EconomyTransaction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ default boolean onCommit(@NotNull EconomyTransaction economyTransaction) {
265265
*/
266266
default void onSuccess(@NotNull EconomyTransaction economyTransaction) {
267267
Util.debugLog("Transaction succeed.");
268-
QuickShop.getInstance().logEvent(new EconomyTransactionLog(true,economyTransaction.getFrom(),economyTransaction.getTo(),economyTransaction.getCurrency(),economyTransaction.getTax(),economyTransaction.getTaxer().getUniqueId(),economyTransaction.getAmount(),economyTransaction.getLastError()));
268+
QuickShop.getInstance().logEvent(new EconomyTransactionLog(true, economyTransaction.getFrom(), economyTransaction.getTo(), economyTransaction.getCurrency(), economyTransaction.getTax(), economyTransaction.getTaxer().getUniqueId(), economyTransaction.getAmount(), economyTransaction.getLastError()));
269269
}
270270

271271
/**
@@ -277,7 +277,7 @@ default void onSuccess(@NotNull EconomyTransaction economyTransaction) {
277277
*/
278278
default void onFailed(@NotNull EconomyTransaction economyTransaction) {
279279
Util.debugLog("Transaction failed: " + economyTransaction.getLastError() + ".");
280-
QuickShop.getInstance().logEvent(new EconomyTransactionLog(false,economyTransaction.getFrom(),economyTransaction.getTo(),economyTransaction.getCurrency(),economyTransaction.getTax(),economyTransaction.getTaxer().getUniqueId(),economyTransaction.getAmount(),economyTransaction.getLastError()));
280+
QuickShop.getInstance().logEvent(new EconomyTransactionLog(false, economyTransaction.getFrom(), economyTransaction.getTo(), economyTransaction.getCurrency(), economyTransaction.getTax(), economyTransaction.getTaxer().getUniqueId(), economyTransaction.getAmount(), economyTransaction.getLastError()));
281281
}
282282

283283
/**
@@ -289,7 +289,7 @@ default void onFailed(@NotNull EconomyTransaction economyTransaction) {
289289
*/
290290
default void onTaxFailed(@NotNull EconomyTransaction economyTransaction) {
291291
Util.debugLog("Tax Transaction failed: " + economyTransaction.getLastError() + ".");
292-
QuickShop.getInstance().logEvent(new EconomyTransactionLog(false,economyTransaction.getFrom(),economyTransaction.getTo(),economyTransaction.getCurrency(),economyTransaction.getTax(),economyTransaction.getTaxer().getUniqueId(),economyTransaction.getAmount(),economyTransaction.getLastError()));
292+
QuickShop.getInstance().logEvent(new EconomyTransactionLog(false, economyTransaction.getFrom(), economyTransaction.getTo(), economyTransaction.getCurrency(), economyTransaction.getTax(), economyTransaction.getTaxer().getUniqueId(), economyTransaction.getAmount(), economyTransaction.getLastError()));
293293
}
294294

295295
}

0 commit comments

Comments
 (0)