Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit 274efcb

Browse files
committed
remove unnecessary getter/setter
1 parent 77e3410 commit 274efcb

19 files changed

+104
-362
lines changed

src/main/java/cat/nyaa/HamsterEcoHelper/database/Database.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,25 @@ public long marketOffer(Player player, ItemStack itemStack, double unit_price) {
142142
MarketItem item = new MarketItem();
143143
item.setItemStack(itemStack);
144144
item.amount = itemStack.getAmount();
145-
item.setPlayerId(player.getUniqueId());
146-
item.setUnitPrice(unit_price);
145+
item.playerId = player.getUniqueId();
146+
item.unitPrice = unit_price;
147147
long id = 1;
148148
for (MarketItem marketItem : query(MarketItem.class).select()) {
149149
if (marketItem.id >= id) {
150150
id = marketItem.id + 1;
151151
}
152152
}
153-
item.setId(id);
153+
item.id = id;
154154
query(MarketItem.class).insert(item);
155-
return item.getId();
155+
return item.id;
156156
}
157157

158158
public void marketBuy(Player player, long itemId, int amount) {
159159
Query<MarketItem> query = query(MarketItem.class).whereEq("id", itemId);
160160
if (query != null && query.count() != 0) {
161161
MarketItem mItem = query.selectUnique();
162-
mItem.setAmount(mItem.getAmount() - amount);
163-
mItem.setId(itemId);
162+
mItem.amount = mItem.amount - amount;
163+
mItem.id = itemId;
164164
query.update(mItem);
165165
}
166166
return;
@@ -201,19 +201,19 @@ public ItemLog getItemLog(long id) {
201201

202202
public long addItemLog(OfflinePlayer player, ItemStack item, double price, int amount) {
203203
ItemLog i = new ItemLog();
204-
i.setOwner(player.getUniqueId());
204+
i.owner = player.getUniqueId();
205205
i.setItemStack(item);
206-
i.setPrice(price);
206+
i.price = price;
207207
i.amount = amount;
208208
long id = 1;
209209
for (ItemLog log : query(ItemLog.class).select()) {
210210
if (log.id >= id) {
211211
id = log.id + 1;
212212
}
213213
}
214-
i.setId(id);
214+
i.id = id;
215215
this.query(ItemLog.class).insert(i);
216-
return i.getId();
216+
return i.id;
217217
}
218218

219219
public List<Sign> getShopSigns() {
@@ -222,10 +222,10 @@ public List<Sign> getShopSigns() {
222222

223223
public Sign createShopSign(OfflinePlayer player, Block block, ShopMode mode) {
224224
Sign shopLocation = new Sign();
225-
shopLocation.setOwner(player.getUniqueId());
225+
shopLocation.owner = player.getUniqueId();
226226
shopLocation.setLocation(block.getLocation());
227227
shopLocation.shopMode = mode;
228-
Query sign = query(Sign.class).whereEq("id", shopLocation.getId());
228+
Query sign = query(Sign.class).whereEq("id", shopLocation.id);
229229
if (sign != null) {
230230
sign.delete();
231231
}
@@ -235,11 +235,11 @@ public Sign createShopSign(OfflinePlayer player, Block block, ShopMode mode) {
235235

236236
public Sign createLottoSign(OfflinePlayer player, Block block, ShopMode mode, double price) {
237237
Sign shopLocation = new Sign();
238-
shopLocation.setOwner(player.getUniqueId());
238+
shopLocation.owner = player.getUniqueId();
239239
shopLocation.setLocation(block.getLocation());
240240
shopLocation.shopMode = mode;
241-
shopLocation.setLotto_price(price);
242-
Query sign = query(Sign.class).whereEq("id", shopLocation.getId());
241+
shopLocation.lotto_price = price;
242+
Query sign = query(Sign.class).whereEq("id", shopLocation.id);
243243
if (sign != null) {
244244
sign.delete();
245245
}
@@ -250,7 +250,7 @@ public Sign createLottoSign(OfflinePlayer player, Block block, ShopMode mode, do
250250
public boolean removeShopSign(Block block) {
251251
Sign shopLocation = new Sign();
252252
shopLocation.setLocation(block.getLocation());
253-
Query sign = query(Sign.class).whereEq("id", shopLocation.getId());
253+
Query sign = query(Sign.class).whereEq("id", shopLocation.id);
254254
if (sign != null) {
255255
sign.delete();
256256
return true;
@@ -261,7 +261,7 @@ public boolean removeShopSign(Block block) {
261261
public boolean removeShopSign(String world, int x, int y, int z) {
262262
Sign shopLocation = new Sign();
263263
shopLocation.setLocation(world, x, y, z);
264-
Query sign = query(Sign.class).whereEq("id", shopLocation.getId());
264+
Query sign = query(Sign.class).whereEq("id", shopLocation.id);
265265
if (sign != null) {
266266
sign.delete();
267267
return true;
@@ -279,7 +279,7 @@ public SignShop getSignShop(UUID owner) {
279279
return shop.selectUnique();
280280
}
281281
SignShop s = new SignShop();
282-
s.setOwner(owner);
282+
s.owner = owner;
283283
return s;
284284
}
285285

src/main/java/cat/nyaa/HamsterEcoHelper/database/ItemLog.java

-28
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
import cat.nyaa.nyaacore.database.DataTable;
55
import cat.nyaa.nyaacore.database.PrimaryKey;
66
import cat.nyaa.nyaacore.utils.ItemStackUtils;
7-
import org.bukkit.configuration.InvalidConfigurationException;
8-
import org.bukkit.configuration.file.YamlConfiguration;
97
import org.bukkit.inventory.ItemStack;
108

11-
import java.util.Base64;
129
import java.util.UUID;
1310

1411
@DataTable("itemlog")
@@ -24,22 +21,6 @@ public class ItemLog {
2421
@DataColumn("price")
2522
public Double price;
2623

27-
public Long getId() {
28-
return id;
29-
}
30-
31-
public void setId(Long id) {
32-
this.id = id;
33-
}
34-
35-
public UUID getOwner() {
36-
return owner;
37-
}
38-
39-
public void setOwner(UUID owner) {
40-
this.owner = owner;
41-
}
42-
4324
public ItemStack getItemStack() {
4425
return getItemStack(amount);
4526
}
@@ -63,13 +44,4 @@ public Long getAmount() {
6344
public void setAmount(Long amount) {
6445
this.amount = amount.intValue();
6546
}
66-
67-
public Double getPrice() {
68-
return price;
69-
}
70-
71-
public void setPrice(Double price) {
72-
this.price = price;
73-
}
74-
7547
}

src/main/java/cat/nyaa/HamsterEcoHelper/database/LottoStorageLocation.java

+6-50
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class LottoStorageLocation {
1414
@DataColumn("owner")
1515
@PrimaryKey
16-
public String owner;
16+
public UUID owner;
1717
@DataColumn("world")
1818
public String world;
1919
@DataColumn("x")
@@ -27,46 +27,10 @@ public LottoStorageLocation() {
2727
}
2828

2929
public LottoStorageLocation(UUID player, Location loc) {
30-
setOwner(player);
30+
this.owner = player;
3131
setLocation(loc);
3232
}
3333

34-
public void setOwner(String owner) {
35-
this.owner = owner;
36-
}
37-
38-
public String getWorld() {
39-
return world;
40-
}
41-
42-
public void setWorld(String world) {
43-
this.world = world;
44-
}
45-
46-
public Long getX() {
47-
return x;
48-
}
49-
50-
public void setX(Long x) {
51-
this.x = x;
52-
}
53-
54-
public Long getY() {
55-
return y;
56-
}
57-
58-
public void setY(Long y) {
59-
this.y = y;
60-
}
61-
62-
public Long getZ() {
63-
return z;
64-
}
65-
66-
public void setZ(Long z) {
67-
this.z = z;
68-
}
69-
7034
public Location getLocation() {
7135
if (Bukkit.getServer().getWorld(world) != null) {
7236
return new Location(Bukkit.getServer().getWorld(world), x, y, z);
@@ -76,21 +40,13 @@ public Location getLocation() {
7640

7741
public void setLocation(Location loc) {
7842
this.world = loc.getWorld().getName();
79-
this.setX((long) loc.getBlockX());
80-
this.setY((long) loc.getBlockY());
81-
this.setZ((long) loc.getBlockZ());
82-
}
83-
84-
public UUID getOwner() {
85-
return UUID.fromString(owner);
86-
}
87-
88-
public void setOwner(UUID uuid) {
89-
this.owner = uuid.toString();
43+
this.x = (long) loc.getBlockX();
44+
this.y = (long) loc.getBlockY();
45+
this.z = (long) loc.getBlockZ();
9046
}
9147

9248
public OfflinePlayer getPlayer() {
93-
return Bukkit.getOfflinePlayer(getOwner());
49+
return Bukkit.getOfflinePlayer(owner);
9450
}
9551

9652
}

src/main/java/cat/nyaa/HamsterEcoHelper/database/MarketItem.java

+6-34
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
import cat.nyaa.nyaacore.utils.ItemStackUtils;
77
import org.bukkit.Bukkit;
88
import org.bukkit.OfflinePlayer;
9-
import org.bukkit.configuration.InvalidConfigurationException;
10-
import org.bukkit.configuration.file.YamlConfiguration;
119
import org.bukkit.inventory.ItemStack;
1210

13-
import java.util.Base64;
1411
import java.util.UUID;
1512

1613
@DataTable("market")
@@ -23,26 +20,11 @@ public class MarketItem {
2320
@DataColumn("item")
2421
public String item;
2522
public int amount;
26-
private Double unitPrice;
27-
28-
public Long getId() {
29-
return id;
30-
}
31-
32-
public void setId(Long id) {
33-
this.id = id;
34-
}
35-
36-
public UUID getPlayerId() {
37-
return playerId;
38-
}
39-
40-
public void setPlayerId(UUID uuid) {
41-
this.playerId = uuid;
42-
}
23+
@DataColumn("unit_price")
24+
public Double unitPrice;
4325

44-
public OfflinePlayer getPlayer(){
45-
return Bukkit.getOfflinePlayer(getPlayerId());
26+
public OfflinePlayer getPlayer() {
27+
return Bukkit.getOfflinePlayer(playerId);
4628
}
4729

4830
public ItemStack getItemStack() {
@@ -51,15 +33,15 @@ public ItemStack getItemStack() {
5133

5234
public void setItemStack(ItemStack item) {
5335
this.item = ItemStackUtils.itemToBase64(item);
54-
amount = item.getAmount();
36+
this.amount = item.getAmount();
5537
}
5638

5739
public ItemStack getItemStack(int amount) {
5840
ItemStack item = ItemStackUtils.itemFromBase64(this.item);
5941
item.setAmount(amount);
6042
return item;
6143
}
62-
44+
6345
@DataColumn("amount")
6446
public Long getAmount() {
6547
return (long) amount;
@@ -68,14 +50,4 @@ public Long getAmount() {
6850
public void setAmount(Long amount) {
6951
this.amount = amount.intValue();
7052
}
71-
72-
@DataColumn("unit_price")
73-
public Double getUnitPrice() {
74-
return unitPrice;
75-
}
76-
77-
public void setUnitPrice(Double unit_price) {
78-
this.unitPrice = unit_price;
79-
}
80-
8153
}

0 commit comments

Comments
 (0)