Skip to content

Commit abfb0fe

Browse files
committed
spilt api interface (part 3)
1 parent ab04df7 commit abfb0fe

19 files changed

+128
-73
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.jetbrains.annotations.Nullable;
66
import org.maxgamer.quickshop.api.shop.Shop;
77
import org.maxgamer.quickshop.database.DataType;
8-
import org.maxgamer.quickshop.database.WarpedResultSet;
98

109
import java.sql.SQLException;
1110
import java.util.UUID;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* This file is a part of project QuickShop, the name is WarpedResultSet.java
3+
* Copyright (C) PotatoCraft Studio and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License as published by the
7+
* Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
* for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
*/
19+
20+
package org.maxgamer.quickshop.api.database;
21+
22+
import java.sql.ResultSet;
23+
import java.sql.SQLException;
24+
25+
public interface WarpedResultSet {
26+
void close() throws SQLException;
27+
ResultSet getResultSet();
28+
}

src/main/java/org/maxgamer/quickshop/api/permission/PermissionProvider.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.bukkit.command.CommandSender;
2323
import org.jetbrains.annotations.NotNull;
24-
import org.maxgamer.quickshop.permission.PermissionInformationContainer;
2524

2625
public interface PermissionProvider {
2726
/**
@@ -41,15 +40,4 @@ public interface PermissionProvider {
4140
@NotNull
4241
String getName();
4342

44-
/**
45-
* Get the debug infos in provider
46-
*
47-
* @param sender CommandSender
48-
* @param permission The permission want to check
49-
* @return Debug Infos
50-
*/
51-
@NotNull
52-
PermissionInformationContainer getDebugInfo(
53-
@NotNull CommandSender sender, @NotNull String permission);
54-
5543
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.maxgamer.quickshop.api.shop;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.inventory.ItemStack;
6+
import org.jetbrains.annotations.NotNull;
7+
import org.jetbrains.annotations.Nullable;
8+
9+
public interface Info {
10+
/**
11+
* @return ShopAction action, Get shop action.
12+
*/
13+
@NotNull ShopAction getAction();
14+
15+
void setAction(@NotNull ShopAction action);
16+
17+
/**
18+
* @return ItemStack iStack, Get Shop's selling/buying item's ItemStack.
19+
*/
20+
@NotNull ItemStack getItem();
21+
22+
/**
23+
* @return Location loc, Get shop's location,
24+
*/
25+
@NotNull Location getLocation();
26+
27+
/**
28+
* @return Block signBlock, Get block of shop's sign, may return the null.
29+
*/
30+
@Nullable Block getSignBlock();
31+
32+
/**
33+
* Get shop is or not has changed.
34+
*
35+
* @param shop, The need checked with this shop.
36+
* @return hasChanged
37+
*/
38+
boolean hasChanged(@NotNull Shop shop);
39+
40+
}

src/main/java/org/maxgamer/quickshop/api/shop/Shop.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
import org.jetbrains.annotations.NotNull;
3333
import org.jetbrains.annotations.Nullable;
3434
import org.maxgamer.quickshop.QuickShop;
35-
import org.maxgamer.quickshop.shop.*;
3635
import org.maxgamer.quickshop.api.chat.ComponentPackage;
36+
import org.maxgamer.quickshop.shop.ShopSignPersistentDataType;
37+
import org.maxgamer.quickshop.shop.ShopSignStorage;
3738

3839
import java.util.List;
3940
import java.util.Objects;
@@ -246,14 +247,14 @@ default List<ComponentPackage> getSignText(String locale) {
246247
* @return Shop moderators
247248
*/
248249
@NotNull
249-
JavaShopModerator getModerator();
250+
ShopModerator getModerator();
250251

251252
/**
252253
* Set new shop's moderators
253254
*
254255
* @param shopModerator New moderators team you want set
255256
*/
256-
void setModerator(@NotNull JavaShopModerator shopModerator);
257+
void setModerator(@NotNull ShopModerator shopModerator);
257258

258259
/**
259260
* Get shop's owner UUID

src/main/java/org/maxgamer/quickshop/shop/ShopAction.java renamed to src/main/java/org/maxgamer/quickshop/api/shop/ShopAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
package org.maxgamer.quickshop.shop;
20+
package org.maxgamer.quickshop.api.shop;
2121

2222
public enum ShopAction {
2323
// buy = trading create = creating shop cancelled = stopped

src/main/java/org/maxgamer/quickshop/api/shop/ShopManager.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import org.bukkit.entity.Player;
99
import org.jetbrains.annotations.NotNull;
1010
import org.jetbrains.annotations.Nullable;
11-
import org.maxgamer.quickshop.shop.Info;
12-
import org.maxgamer.quickshop.shop.JavaShopChunk;
1311

1412
import java.util.*;
1513

@@ -30,7 +28,7 @@ public interface ShopManager {
3028
*
3129
* @return a map of World - Chunk - Shop
3230
*/
33-
@NotNull Map<String, Map<JavaShopChunk, Map<Location, Shop>>> getShops();
31+
@NotNull Map<String, Map<ShopChunk, Map<Location, Shop>>> getShops();
3432

3533
/**
3634
* Returns a new shop iterator object, allowing iteration over shops easily, instead of sorting
@@ -63,7 +61,7 @@ public interface ShopManager {
6361
* @param world The name of the world (case sensitive) to get the list of shops from
6462
* @return a map of Chunk - Shop
6563
*/
66-
@Nullable Map<JavaShopChunk, Map<Location, Shop>> getShops(@NotNull String world);
64+
@Nullable Map<ShopChunk, Map<Location, Shop>> getShops(@NotNull String world);
6765

6866
/**
6967
* Create a shop use Shop and Info object.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import org.jetbrains.annotations.Nullable;
3131
import org.maxgamer.quickshop.QuickShop;
3232
import org.maxgamer.quickshop.api.command.CommandHandler;
33-
import org.maxgamer.quickshop.shop.Info;
34-
import org.maxgamer.quickshop.shop.ShopAction;
33+
import org.maxgamer.quickshop.shop.JavaInfo;
34+
import org.maxgamer.quickshop.api.shop.ShopAction;
3535
import org.maxgamer.quickshop.util.MsgUtil;
3636
import org.maxgamer.quickshop.util.Util;
3737
import org.maxgamer.quickshop.util.holder.Result;
@@ -148,7 +148,7 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
148148

149149
// Send creation menu.
150150
plugin.getShopManager().getActions().put(sender.getUniqueId(),
151-
new Info(b.getLocation(), ShopAction.CREATE, item, b.getRelative(sender.getFacing().getOppositeFace())));
151+
new JavaInfo(b.getLocation(), ShopAction.CREATE, item, b.getRelative(sender.getFacing().getOppositeFace())));
152152
plugin.getShopManager().handleChat(sender, price);
153153
return;
154154
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import org.jetbrains.annotations.NotNull;
2929
import org.maxgamer.quickshop.QuickShop;
3030
import org.maxgamer.quickshop.api.command.CommandHandler;
31-
import org.maxgamer.quickshop.shop.Info;
32-
import org.maxgamer.quickshop.shop.ShopAction;
31+
import org.maxgamer.quickshop.shop.JavaInfo;
32+
import org.maxgamer.quickshop.api.shop.ShopAction;
3333
import org.maxgamer.quickshop.util.Util;
3434

3535
import java.util.Collections;
@@ -62,7 +62,7 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
6262
return;
6363
}
6464
// Send creation menu.
65-
final Info info = new Info(b.getLocation(), ShopAction.CREATE, sender.getInventory().getItemInMainHand(), b.getRelative(sender.getFacing().getOppositeFace()));
65+
final JavaInfo info = new JavaInfo(b.getLocation(), ShopAction.CREATE, sender.getInventory().getItemInMainHand(), b.getRelative(sender.getFacing().getOppositeFace()));
6666

6767
plugin.getShopManager().getActions().put(sender.getUniqueId(), info);
6868
plugin.text().of(sender, "how-much-to-trade-for", Util.getItemStackName(item), Integer.toString(plugin.isAllowStack() && QuickShop.getPermissionManager().hasPermission(sender, "quickshop.create.stacks") ? item.getAmount() : 1)).send();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ synchronized DatabaseConnection getConnection() {
8181
*
8282
* @return Impl name
8383
*/
84-
abstract @NotNull String getName();
84+
public abstract @NotNull String getName();
8585

8686
/**
8787
* Getting DatabaseCore owned by
8888
*
8989
* @return Owned by
9090
*/
91-
abstract @NotNull Plugin getPlugin();
91+
public abstract @NotNull Plugin getPlugin();
9292

9393
}

0 commit comments

Comments
 (0)