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

Commit 62e27eb

Browse files
authored
NC5.0 (#42)
1 parent fa39f41 commit 62e27eb

37 files changed

+475
-382
lines changed

.travis.yml

+9-11
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ language: java
22
jdk: oraclejdk8
33

44
before_install:
5-
- "sed -i \"s/^\\(version:.*\\)/\\1.0.$TRAVIS_BUILD_NUMBER/\" src/main/resources/plugin.yml"
5+
- export MAJOR_VERSION=`sed -n 's/^ext\.majorVersion = \(.*\)$/\1/p' build.gradle`
6+
- export MINOR_VERSION=`sed -n 's/^ext\.minorVersion = \(.*\)$/\1/p' build.gradle`
7+
- export MC_VERSION=`sed -n 's/^ext\.minecraftVersion = "\(.*\)"$/\1/p' build.gradle`
8+
- export VERSION_STRING=$MAJOR_VERSION.$MINOR_VERSION.$TRAVIS_BUILD_NUMBER-mc$MC_VERSION
9+
- 'sed -i "s/^\(version: \).*\$/\1$VERSION_STRING/g" src/main/resources/plugin.yml'
610
- pushd ~/build/
711
- git clone --depth=1 https://github.com/NyaaCat/NyaaCore NyaaCat/NyaaCore
812
- export NYAACORE_LANG_DIR=`readlink -f ./NyaaCat/NyaaCore/src/main/resources/lang/`
913
- popd
1014
after_success:
11-
- 'cp build/libs/HamsterEcoHelper.jar ./HamsterEcoHelper-$TRAVIS_BRANCH-v$main_version.$TRAVIS_BUILD_NUMBER.jar'
15+
- 'cp build/libs/HamsterEcoHelper.jar ./HamsterEcoHelper-v$VERSION_STRING.jar'
1216
before_deploy:
1317
- git config --global user.email "[email protected]"
1418
- git config --global user.name "Travis CI"
@@ -25,18 +29,12 @@ deploy:
2529
provider: releases
2630
prerelease: true
2731
api_key:
28-
secure: "SeL38ow6S9AvTmxR1xugzDemmAMpxJ35XgLaEnyyZN+f6N/bmCCKKrabpAe9ntOIZAJapfIb2TTR5zyJ2GGuasnIEZ5hqGKCqy+sN4Y/M5JHcjeZRghw8iYx+hQzPWSayln9lJUkiL31zfw4CFVjqPWCv5ejr1bysq6vMSQG4NsgSdnB36vMLCpKtgrgdE+COACYJ7Zp/OFoU+aAZMaeWF8KVFjwfjnJwdYlxwnPrQ9qIfz094RA0ZwkX77BvA3QdpRei1yw6rhp/CeRsUSry/P+P0GSiwFnhuEX2Npqzs89bdQeipx9gJT/0EsNtAk6MOvxOJt9Ykk44OwPLZ/UOXhhA3ZqQGZEdx7jWjJBBRFVfOP8oI6zY+ux0vfHucS10yJ00ErzkoQaGn0YnguOO9Bs++XC/BXnEoMYb6M9re9UDZy6SbMO41oW4xKVHgPNS1ebGmFoEEm5FoGXBhVF5vn66nwWNYtheDLwX06CF3tP1T21D3b6bLATvzLEpYV6Zv3I7DDkAECltLKZaMHMxr5g/7DrvbNnawLR04WDzH4a4+OvoJwhxmUIEJ6bUStjVBfIHTcWmSHyDrg2HeMJrN2SMD4OiXGGjGGnaOhvU6r+95AgAfDrL1vy5vdjB8seQ2f/UGJwSNQH7OWcZUhxfxBP0yBif2GdlMhieDdaHBA="
29-
file: ./HamsterEcoHelper-$TRAVIS_BRANCH-v$main_version.$TRAVIS_BUILD_NUMBER.jar
32+
secure: $GITHUB_DEPLOY_KEY
33+
file: ./HamsterEcoHelper-v$VERSION_STRING.jar
3034
on:
3135
tags: false
32-
all_branches: true
3336

3437
branches:
3538
except:
3639
- "/^*-v[0-9]/"
37-
38-
env:
39-
global:
40-
- secure: "O56CEunSuLO/d1ccLJmNJTlweReZ/tVgDzeTAIYVJBsel0IVBd91um+3Up1GuUvhyXGZHLdXBunsYGWL2tI1HzM7MkqWcnUDGHCzR8sh65aOAR486btZTcmlvUe7LzqmxP4CGPQLa1CcwqisCaYf3+R6u0lbYhq+Ujq0Db3DAbExUBo5gHaaXnCRpHBmNyeibcfTOVHRmUZLmfmYfcuXbaMwQ8ySRK7lo3rqIiJMkowe0q07vfcZRTNNP8fClaY8z6RmZuvoclHN1L+PIIXG0OS9yIkAdUmtu78ib/GpHhOUPjHMtHjYSWg36W1WCnZR7qjQMY2ZS2RR50C3ajwFjzIH+6jok7GUvVodPvc1/kyO3NkIvYmyhZDocn13ArohrrVQxhjBR5a80cKIq45GA0skemLBOWq3nqPvzS50YDZhns1uaaPhLScCG7HYJIHFdw0kx4FPq8iVk+U780J/5sfJMKR8tbVzQJt0FSzS1AYYqFFvAVf5pTcdltXsHxLlp/TUi8BErmZK4fw2drdc9UyzjtN1O98Ul2KBhrFRtxbGjN3RAXRy3RJSW50HRFMc7L+e+qMpQ5t+yDRiobVXI3ZW+ERvoWHyd9Wiq2pkBHYq2WZwsM4rujkmb3XcKwSlZqDtQ0zk/ZSIUoXhLSUfhAEfijdcTnGd5dR3N/L7/oI="
41-
- main_version=3
42-
- trigger_ci=20170624
40+
- "/^*-mc/"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
Economy enhancer & helper for hamsters
66

7-
This spigot plugin depends on [NyaaCore](https://github.com/NyaaCat/NyaaCore)
7+
This spigot plugin depends on [NyaaCore](https://github.com/NyaaCat/NyaaCore) with same major version.
88

build.gradle

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ configurations.all {
66
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
77
}
88

9+
// Version strings used for CI
10+
// Note the spaces before and after the equals sign
11+
ext.majorVersion = 5
12+
ext.minorVersion = 0
13+
ext.minecraftVersion = "1.12"
14+
915
sourceCompatibility = 1.8
1016
targetCompatibility = 1.8
1117

@@ -48,11 +54,8 @@ repositories {
4854
}
4955

5056
dependencies {
51-
compile 'org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT'
5257
compile 'net.milkbowl.vault:VaultAPI:1.6'
53-
compile('cat.nyaa:nyaacore:4.1-SNAPSHOT') {
54-
transitive = false
55-
}
58+
compile 'cat.nyaa:nyaacore:5.0-SNAPSHOT'
5659
compile('net.ess3:Essentials:2.13-SNAPSHOT') {
5760
transitive = false
5861
}

src/main/java/cat/nyaa/HamsterEcoHelper/CommandHandler.java

+27-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import cat.nyaa.HamsterEcoHelper.ads.AdsCommands;
44
import cat.nyaa.HamsterEcoHelper.auction.AuctionCommands;
55
import cat.nyaa.HamsterEcoHelper.balance.BalanceCommands;
6+
import cat.nyaa.HamsterEcoHelper.database.*;
67
import cat.nyaa.HamsterEcoHelper.market.MarketCommands;
78
import cat.nyaa.HamsterEcoHelper.requisition.RequisitionCommands;
89
import cat.nyaa.HamsterEcoHelper.signshop.SearchCommands;
@@ -11,12 +12,18 @@
1112
import cat.nyaa.nyaacore.CommandReceiver;
1213
import cat.nyaa.nyaacore.LanguageRepository;
1314
import cat.nyaa.nyaacore.Message;
15+
import cat.nyaa.nyaacore.database.Database;
16+
import cat.nyaa.nyaacore.database.DatabaseUtils;
17+
import cat.nyaa.nyaacore.database.RelationalDB;
18+
import org.bukkit.Bukkit;
1419
import org.bukkit.Material;
1520
import org.bukkit.command.Command;
1621
import org.bukkit.command.CommandSender;
1722
import org.bukkit.configuration.file.YamlConfiguration;
1823
import org.bukkit.entity.Player;
1924
import org.bukkit.inventory.ItemStack;
25+
import org.bukkit.scheduler.BukkitTask;
26+
import org.librazy.nyaautils_lang_checker.LangKey;
2027

2128
import java.util.ArrayList;
2229
import java.util.List;
@@ -47,7 +54,7 @@ public CommandHandler(HamsterEcoHelper plugin, LanguageRepository i18n) {
4754
public String getHelpPrefix() {
4855
return "";
4956
}
50-
57+
5158
@Override
5259
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
5360
if (args.length > 0) {
@@ -147,4 +154,23 @@ public void userRetrieve(CommandSender sender, Arguments args) {
147154
}
148155
plugin.database.clearTemporaryStorage(p);
149156
}
157+
158+
@SubCommand(value = "dump", permission = "heh.admin")
159+
public void databaseDump(CommandSender sender, Arguments args) {
160+
String from = args.next();
161+
RelationalDB todb = plugin.database.database;
162+
RelationalDB fromdb = DatabaseUtils.get(from).connect();
163+
DatabaseUtils.dumpDatabaseAsync(plugin, fromdb, todb, (cls, r) -> {
164+
if (cls != null) {
165+
msg(sender, "internal.info.dump.ing", cls.getName(), from, r);
166+
} else {
167+
fromdb.close();
168+
if(r == 0){
169+
msg(sender, "internal.info.dump.finished", from);
170+
} else {
171+
msg(sender, "internal.error.command_exception");
172+
}
173+
}
174+
});
175+
}
150176
}

src/main/java/cat/nyaa/HamsterEcoHelper/Events.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public Events(HamsterEcoHelper plugin) {
2828
@EventHandler
2929
public void onInventoryClick(InventoryClickEvent event) {
3030
if (event.getInventory().getHolder() instanceof ShopGUI ||
31-
event.getInventory().getHolder() instanceof MarketGUI) {
31+
event.getInventory().getHolder() instanceof MarketGUI) {
3232
return;
3333
}
3434
if (event.getCurrentItem() != null && MarketManager.isMarketItem(event.getCurrentItem())) {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import cat.nyaa.HamsterEcoHelper.ads.AdsManager;
44
import cat.nyaa.HamsterEcoHelper.auction.AuctionManager;
55
import cat.nyaa.HamsterEcoHelper.balance.SystemBalance;
6+
import cat.nyaa.HamsterEcoHelper.database.Database;
67
import cat.nyaa.HamsterEcoHelper.market.MarketListener;
78
import cat.nyaa.HamsterEcoHelper.market.MarketManager;
89
import cat.nyaa.HamsterEcoHelper.requisition.RequisitionManager;
910
import cat.nyaa.HamsterEcoHelper.signshop.SignShopListener;
1011
import cat.nyaa.HamsterEcoHelper.signshop.SignShopManager;
1112
import cat.nyaa.HamsterEcoHelper.utils.EconomyUtil;
12-
import cat.nyaa.HamsterEcoHelper.database.Database;
1313
import cat.nyaa.nyaacore.component.ISystemBalance;
1414
import cat.nyaa.nyaacore.component.NyaaComponent;
1515
import com.earth2me.essentials.Essentials;
@@ -71,6 +71,7 @@ public void onDisable() {
7171
reqManager.cancel();
7272
systemBalance.cancel();
7373
config.save();
74+
database.database.close();
7475
ess = null;
7576
}
7677

src/main/java/cat/nyaa/HamsterEcoHelper/ads/AdsManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void run() {
102102
player.sendMessage(I18n.format("user.ads.message", adOwner.getName(), getMessage(ads.text)));
103103
it.remove();
104104
if ((!plugin.config.ads_count_afk && isAFK(player)) ||
105-
(!plugin.config.ads_count_self && player.getUniqueId().equals(ads.getUUID()))) {
105+
(!plugin.config.ads_count_self && player.getUniqueId().equals(ads.getUUID()))) {
106106
} else {
107107
ads.displayed++;
108108
displayCount++;
@@ -113,7 +113,7 @@ public void run() {
113113
}
114114
if (displayCount > 0) {
115115
plugin.getServer().getConsoleSender().
116-
sendMessage(I18n.format("user.ads.message", adOwner.getName(), getMessage(ads.text)));
116+
sendMessage(I18n.format("user.ads.message", adOwner.getName(), getMessage(ads.text)));
117117
}
118118
if (ads.displayed >= ads.display_total) {
119119
plugin.config.adsConfig.adsDataList.remove(tmp.get(0));

src/main/java/cat/nyaa/HamsterEcoHelper/auction/AuctionCommands.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public void Auc(CommandSender sender, Arguments args) {
117117
msg(sender, "user.auc.step_price_error");
118118
return;
119119
}
120-
if(MarketManager.containsBook(item)){
121-
msg(sender,"user.error.shulker_box_contains_book");
120+
if (MarketManager.containsBook(item)) {
121+
msg(sender, "user.error.shulker_box_contains_book");
122122
return;
123123
}
124124
int reservePrice = 0;

src/main/java/cat/nyaa/HamsterEcoHelper/auction/AuctionInstance.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public AuctionInstance(OfflinePlayer player, ItemStack itemToGive, double startP
5555
} else {
5656
if (owner == null) {
5757
new Message(I18n.format("user.auc.new_auction_0")).append(itemToGive)
58-
.appendFormat(plugin.i18n, "user.auc.new_auction_1", startPrice, stepPrice, (int) Math.floor(timeout / 20D))
59-
.broadcast();
58+
.appendFormat(plugin.i18n, "user.auc.new_auction_1", startPrice, stepPrice, (int) Math.floor(timeout / 20D))
59+
.broadcast();
6060
} else {
6161
new Message(I18n.format("user.auc.player_auction_0", owner.getName())).append(itemToGive)
62-
.appendFormat(plugin.i18n, "user.auc.player_auction_1", startPrice, stepPrice, (int) Math.floor(timeout / 20D))
63-
.broadcast();
62+
.appendFormat(plugin.i18n, "user.auc.player_auction_1", startPrice, stepPrice, (int) Math.floor(timeout / 20D))
63+
.broadcast();
6464
}
6565
itemName = realName;
6666
}

src/main/java/cat/nyaa/HamsterEcoHelper/auction/AuctionManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public boolean newAuction(AuctionItemTemplate item) {
4949
if (item == null) return false;
5050
currentAuction = new AuctionInstance(null, item.getItemStack(),
5151
item.baseAuctionPrice,
52-
item.bidStepPrice,
52+
item.bidStepPrice,
5353
0,
5454
item.waitTimeTicks,
5555
item.hideName,

src/main/java/cat/nyaa/HamsterEcoHelper/balance/BalanceCommands.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public BalanceCommands(Object plugin, LanguageRepository i18n) {
1616
this.plugin = (HamsterEcoHelper) plugin;
1717
}
1818

19+
@SuppressWarnings("deprecation")
1920
@CommandHandler.SubCommand(value = "pay", permission = "heh.balance.pay")
2021
public void pay(CommandSender sender, CommandHandler.Arguments args) {
2122
if (args.length() >= 5) {
@@ -64,15 +65,15 @@ public String getHelpPrefix() {
6465
return "balance";
6566
}
6667

68+
@SuppressWarnings("deprecation")
6769
@CommandHandler.SubCommand(value = "take", permission = "heh.balance.take")
6870
public void take(CommandSender sender, CommandHandler.Arguments args) {
6971
if (args.length() != 4) {
7072
msg(sender, "manual.balance.take.usage");
7173
return;
7274
}
7375
String playerName = args.next();
74-
double amount = 0.0D;
75-
amount = args.nextDouble("#.##");
76+
double amount = args.nextDouble("#.##");
7677
if (!(amount > 0.0D)) {
7778
msg(sender, "user.error.not_int");
7879
return;
@@ -88,7 +89,6 @@ public void take(CommandSender sender, CommandHandler.Arguments args) {
8889
}
8990
} else {
9091
msg(sender, "user.info.player_not_found", playerName);
91-
return;
9292
}
9393
}
9494

src/main/java/cat/nyaa/HamsterEcoHelper/balance/VariablesConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ protected String getFileName() {
2424
protected JavaPlugin getPlugin() {
2525
return plugin;
2626
}
27-
27+
2828
}

0 commit comments

Comments
 (0)