Skip to content

Commit

Permalink
Update to v1.8.2 (Team-Inceptus#120)
Browse files Browse the repository at this point in the history
* Fix Team-Inceptus#114 (Team-Inceptus#115)

Co-authored-by: ajh123 <ajh123@users.noreply.github.com>

* Fix typo in custom_model_data and fix Vault (Team-Inceptus#116)

* Fix Team-Inceptus#114

* Fix another typo

* Make vault load once database has

* Move vault and loadFiles into onLoad

* Fix Plugin attempted to register task while disabled initializing

* Fix another register task while disabled initializing

---------

Co-authored-by: ajh123 <ajh123@users.noreply.github.com>
Co-authored-by: Gregory Mitchell <gamercoder215@gmail.com>

* Bump org.mockito:mockito-core from 5.5.0 to 5.6.0 (Team-Inceptus#118)

Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.5.0 to 5.6.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v5.5.0...v5.6.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gregory Mitchell <gamercoder215@gmail.com>

* Fix 1.20.2 Protocol Changes, Null Checks (Closes Team-Inceptus#111)

* Update Lamp to v3.1.7

* Fix API Errors (Closes Team-Inceptus#117)

- Update Lamp
- Add Null Check for NovaPlayer#stats
- Make Generic Settings Serializable

* Update Version to 1.8.2

* Fix 1.20.2 Support

Fix Packet Handlers

* Fix `#playerStatistics`, Add Market Stock Command

* Add Market Stock Implementation, Update Market API

- Add Checks in `#setStock`
- Add `setStock(Iterable, long)`
- Create MaterialSelector for parsing tags and `all` as Material types

* Add Market Stock Command Translations

* Update Novaconomy.java

Update Donation Link

* Add Whitelisted & Blacklisted Market Economies (Closes Team-Inceptus#113)

* Update GUIManager.java

Fix Whitelisted/Blacklisted Economies

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Samuel Hulme <41990982+ajh123@users.noreply.github.com>
Co-authored-by: ajh123 <ajh123@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 15, 2023
2 parents 520b3fa + 267340a commit 7255e42
Show file tree
Hide file tree
Showing 32 changed files with 539 additions and 171 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package us.teaminceptus.novaconomy.util.command;

import com.google.common.collect.ImmutableSet;
import org.bukkit.Material;
import us.teaminceptus.novaconomy.api.NovaConfig;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public final class MaterialSelector {

private final Set<Material> materials = new HashSet<>();

MaterialSelector() {}

MaterialSelector(Material... materials) {
this.materials.addAll(Arrays.asList(materials));
}

MaterialSelector(Iterable<Material> materials) {
materials.forEach(this.materials::add);
}

public MaterialSelector add(Material material) {
materials.add(material);
return this;
}

public Set<Material> getMaterials() {
return ImmutableSet.copyOf(materials);
}

@SuppressWarnings("unchecked")
public static MaterialSelector of(String entry) {
String[] split = entry.split(":");
String entry0 = split[split.length - 1];

if (entry0.equalsIgnoreCase("all"))
return new MaterialSelector(Material.values());

if (entry0.startsWith("#")) {
try {
Class<?> tags = Class.forName("org.bukkit.Tag");

Object tag = tags.getField(entry0.substring(1).toUpperCase()).get(null);
Set<Material> materials = (Set<Material>) tags.getMethod("getValues").invoke(tag);

return new MaterialSelector(materials);
} catch (ClassNotFoundException ignored) {
return null;
} catch (ReflectiveOperationException e) {
NovaConfig.print(e);
}
} else
return new MaterialSelector(Material.matchMaterial(entry0));

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static ItemStack head(String name) {
ItemStack head = new ItemStack(w.isLegacy() ? Material.matchMaterial("SKULL_ITEM") : Material.matchMaterial("PLAYER_HEAD"));

SkullMeta meta = (SkullMeta) head.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
GameProfile profile = new GameProfile(UUID.randomUUID(), name);
profile.getProperties().put("textures", new Property("textures", texture));
try {
Method mtd = meta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ static FileConfiguration loadConfig() {
if (!config.isBoolean("Market.Membership.Enabled")) config.set("Market.Membership.Enabled", true);
if (!config.isInt("Market.Membership.Amount") && !config.isDouble("Market.Membership.Amount")) config.set("Market.Membership.Amount", 10000.0);

if (!config.isConfigurationSection("Market.Purchasing")) config.createSection("Market.Purchasing");
if (!config.isList("Market.Purchasing.WhitelistedEconomies")) config.set("Market.Purchasing.WhitelistedEconomies", new ArrayList<>());
if (!config.isList("Market.Purchasing.BlacklistedEconomies")) config.set("Market.Purchasing.BlacklistedEconomies", new ArrayList<>());

try { config.save(f); } catch (IOException e) { print(e); }

return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ private static void checkTable() throws SQLException {
db.createStatement().execute("ALTER TABLE businesses ADD custom_model_data INT NOT NULL");

if (!(rs = md.getColumns(null, null, "businesses", "supply_chests")).next())
db.createStatement().execute("ALTER TABLE businessess ADD supply_chests LONGBLOB NOT NULL");
db.createStatement().execute("ALTER TABLE businesses ADD supply_chests LONGBLOB NOT NULL");
} finally {
if (rs != null) rs.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ private static void checkTable() throws SQLException {

try {
if (!(rs = md.getColumns(null, null, "corporations", "custom_model_data")).next())
db.createStatement().execute("ALTER TABLE corporations ADD COLUMN custom_model_dat INT NOT NULL");
db.createStatement().execute("ALTER TABLE corporations ADD COLUMN custom_model_data INT NOT NULL");
} finally {
if (rs != null) rs.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ default boolean isSold(@NotNull Material m) {
*/
void setStock(@NotNull Material m, long stock) throws IllegalArgumentException;

/**
* Sets the amount of stock for Materials on the Market.
* @param materials Materials to set
* @param stock Stock to set
* @throws IllegalArgumentException if stock is negative
*/
void setStock(@NotNull Iterable<Material> materials, long stock) throws IllegalArgumentException;

/**
* Adds stock to a Material on the Market.
* @param m Material to add
Expand Down Expand Up @@ -390,4 +398,31 @@ default void addCustomItem(@NotNull Material material, @NotNull MarketCategory c
* @param material Material to remove
*/
void removeCustomItem(@NotNull Material material);

/**
* Fetches an immutable set of all economies allowed to be used when buying from the Novaconomy Market.
* @return Set of Economies
*/
@NotNull
Set<Economy> getWhitelistedEconomies();

/**
* Sets the economies allowed to be used when buying from the Novaconomy Market.
* @param economies Iterable of Economies
*/
void setWhitelistedEconomies(@NotNull Iterable<Economy> economies);

/**
* Sets the economies disallowed to be used when buying from the Novaconomy Market.
* @return Set of Economies
*/
@NotNull
Set<Economy> getBlacklistedEconomies();

/**
* Sets the economies disallowed to be used when buying from the Novaconomy Market.
* @param economies Iterable of Economies
*/
void setBlacklistedEconomies(@NotNull Iterable<Economy> economies);

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class NovaPlayer {

private final Map<String, Object> pConfig = new HashMap<>();

final PlayerStatistics stats;
PlayerStatistics stats;

private static void checkTable() throws SQLException {
Connection db = NovaConfig.getConfiguration().getDatabaseConnection();
Expand Down Expand Up @@ -96,13 +96,11 @@ public NovaPlayer(@NotNull OfflinePlayer p) throws IllegalArgumentException {
BukkitObjectInputStream statsBIs = new BukkitObjectInputStream(statsIs);
stats = (PlayerStatistics) statsBIs.readObject();
statsBIs.close();
} else
stats = new PlayerStatistics(p);
}

rs.close();
} catch (Exception e) {
NovaConfig.print(e);
stats = new PlayerStatistics(p);
}
else {
if (!NovaConfig.getPlayerDirectory().exists()) NovaConfig.getPlayerDirectory().mkdir();
Expand Down Expand Up @@ -194,6 +192,7 @@ public void setBalance(@NotNull Economy econ, double newBal) throws IllegalArgum
if (newBal < 0) throw new IllegalArgumentException("Balance cannot be negative");
if (econ == null) throw new IllegalArgumentException("Economy cannot be null");

checkStats();
pConfig.put("economies." + econ.getName().toLowerCase() + ".balance", newBal);

if (newBal > stats.highestBalance) {
Expand Down Expand Up @@ -277,6 +276,7 @@ public PlayerStatistics getStatistics() {
*/
public void add(@NotNull Economy econ, double add) throws IllegalArgumentException {
if (econ == null) throw new IllegalArgumentException("Economy cannot be null");
checkStats();

stats.moneyAdded += add;
setBalance(econ, getBalance(econ) + add);
Expand All @@ -290,6 +290,7 @@ public void add(@NotNull Economy econ, double add) throws IllegalArgumentExcepti
*/
public void remove(@NotNull Economy econ, double remove) throws IllegalArgumentException {
if (econ == null) throw new IllegalArgumentException("Economy cannot be null");
checkStats();

stats.totalMoneySpent += remove;
setBalance(econ, getBalance(econ) - remove);
Expand Down Expand Up @@ -359,6 +360,7 @@ public void withdraw(@NotNull Economy econ, double amount) throws IllegalArgumen
if (System.currentTimeMillis() - 86400000 < (long) pConfig.getOrDefault(LBW + ".timestamp", 0))
throw new UnsupportedOperationException("Last withdraw was less than 24 hours ago");

checkStats();
Bank.removeBalance(econ, amount);
add(econ, amount);

Expand Down Expand Up @@ -769,4 +771,9 @@ public Set<Receipt> getPurchases(@NotNull Material m) {
.collect(Collectors.toList())
);
}

private void checkStats() {
if (stats == null)
stats = new PlayerStatistics(p);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
import us.teaminceptus.novaconomy.api.corporation.Corporation.JoinType;
import us.teaminceptus.novaconomy.api.events.business.BusinessSupplyEvent;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;

Expand Down Expand Up @@ -181,7 +179,7 @@ public Boolean parseValue(@NotNull String value) {
/**
* Represents Business Settings
*/
public static final class Business<T> implements NovaSetting<T> {
public static final class Business<T> implements NovaSetting<T>, Serializable {
/**
* Whether the owner of the Business is public.
*/
Expand Down Expand Up @@ -223,6 +221,8 @@ public static final class Business<T> implements NovaSetting<T> {
@SettingDescription("settings.business.supply_interval")
public static final Business<BusinessSupplyEvent.Interval> SUPPLY_INTERVAL = ofEnum("supply_interval","constants.settings.name.supply_interval", BusinessSupplyEvent.Interval.class, BusinessSupplyEvent.Interval.HOUR);

private static final long serialVersionUID = -7174484717138758485L;

private final String key;
private final Supplier<T> defaultValue;
private final String dKey;
Expand Down Expand Up @@ -355,12 +355,25 @@ public T parseValue(@NotNull String value) {

throw new IllegalArgumentException("Unknown Business Setting: " + key);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Business<?> business = (Business<?>) o;
return Objects.equals(key, business.key);
}

@Override
public int hashCode() {
return Objects.hash(key);
}
}

/**
* Represents Corporation Settings
*/
public static final class Corporation<T> implements NovaSetting<T> {
public static final class Corporation<T> implements NovaSetting<T>, Serializable {

/**
* The privacy setting of a Corporation, determining how and whether businesses can join.
Expand All @@ -386,6 +399,8 @@ public static final class Corporation<T> implements NovaSetting<T> {
@SettingDescription("settings.corporation.feature_products")
public static final Corporation<Boolean> FEATURE_PRODUCTS = ofBoolean("feature_products", "constants.settings.name.feature_products", true);

private static final long serialVersionUID = 2912177260114871976L;

private final String key;
private final T defaultValue;
private final String dKey;
Expand Down Expand Up @@ -515,6 +530,18 @@ public T parseValue(@NotNull String value) {
}
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Corporation<?> that = (Corporation<?>) o;
return Objects.equals(key, that.key);
}

@Override
public int hashCode() {
return Objects.hash(key);
}
}


Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy.properties
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ error.economy.transfer_not_convertable=The economy %s is not convertable!
success.economy.enable_convertable=The economy %s is now convertable!
success.economy.disable_convertable=The economy %s is now not convertable!
constants.market.category.redstone=Redstone
success.market.set_stock=Successfully set the stock of item '%s' to %s!
success.market.set_stock.multiple=Successfully set the stock of %s items to %s!
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ error.economy.transfer_not_convertable=Die Wirtschaft %s ist nicht konvertierbar
success.economy.enable_convertable=Die Wirtschaft %s ist nicht konvertierbar!
success.economy.disable_convertable=Die Wirtschaft %s ist jetzt nicht konvertierbar!
constants.market.category.redstone=Roter Stein
success.market.set_stock=Der Bestand des Artikels "%s" wurde erfolgreich auf %s gesetzt!
success.market.set_stock.multiple=Der Bestand von %s Artikeln wurde erfolgreich auf %s gesetzt!
2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,7 @@ error.economy.transfer_not_convertable=La econom\u00EDa %s no es convertible!
success.economy.enable_convertable=La econom\u00EDa %s no es convertible!
success.economy.disable_convertable=La econom\u00EDa %s ya no es convertible!
constants.market.category.redstone=Piedra Roja
success.market.set_stock=Estableci\u00F3 exitosamente el stock del art\u00EDculo '%s' en %s!
success.market.set_stock.multiple=Establec\u00ED exitosamente el stock de %s art\u00EDculos en %s!


2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_fi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ error.economy.transfer_not_convertable=Talous %s ei ole vaihdettavissa!
success.economy.enable_convertable=Talous %s ei ole vaihdettavissa!
success.economy.disable_convertable=Talous %s ei ole nyt vaihdettavissa!
constants.market.category.redstone=Punainen Kivi
success.market.set_stock=Tuotteen '%s' varaston asettaminen onnistuneesti arvoon %s!
success.market.set_stock.multiple=%s tuotteen varaston asettaminen onnistuneesti arvoon %s!



2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ error.economy.transfer_not_convertable=L'\u00E9conomie %s n'est pas convertible!
success.economy.enable_convertable=L'\u00E9conomie %s n'est pas convertible!
success.economy.disable_convertable=L'\u00E9conomie %s n'est plus convertible!
constants.market.category.redstone=Pierre Rouge
success.market.set_stock=D\u00E9finissez avec succ\u00E8s le stock de l'article '%s' sur %s!
success.market.set_stock.multiple=D\u00E9finissez avec succ\u00E8s le stock de %s articles sur %s!



2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_id.properties
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ error.economy.transfer_not_convertable=Perekonomian %s tidak dapat dikonversi!
success.economy.enable_convertable=Perekonomian %s tidak dapat dikonversi!
success.economy.disable_convertable=Perekonomian %s sekarang tidak dapat dikonversi!
constants.market.category.redstone=Batu Merah
success.market.set_stock=Berhasil mengatur stok barang '%s' ke %s!
success.market.set_stock.multiple=Berhasil mengatur stok %s item ke %s!



Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,7 @@ error.economy.transfer_not_convertable=L'economia %s non \u00E8 convertibile!
success.economy.enable_convertable=L'economia %s non \u00E8 convertibile!
success.economy.disable_convertable=L'economia %s ora non \u00E8 convertibile!
constants.market.category.redstone=Pietra Rossa
success.market.set_stock=Imposta con successo lo stock dell'articolo '%s' su %s!
success.market.set_stock.multiple=Imposta con successo lo stock di %s articoli su %s!
2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -455,5 +455,7 @@ error.economy.transfer_not_convertable=\u7D4C\u6E08 %s \u306F\u514C\u63DB\u53EF\
success.economy.enable_convertable=\u7D4C\u6E08 %s \u306F\u514C\u63DB\u53EF\u80FD\u3067\u306F\u3042\u308A\u307E\u305B\u3093!
success.economy.disable_convertable=\u30A8\u30B3\u30CE\u30DF\u30FC %s \u306F\u73FE\u5728\u4EA4\u63DB\u3067\u304D\u307E\u305B\u3093!
constants.market.category.redstone=\u8D64\u77F3
success.market.set_stock=\u30A2\u30A4\u30C6\u30E0 '%s' \u306E\u5728\u5EAB\u3092 %s \u306B\u8A2D\u5B9A\u3057\u307E\u3057\u305F.
success.market.set_stock.multiple=%s \u30A2\u30A4\u30C6\u30E0\u306E\u5728\u5EAB\u3092 %s \u306B\u8A2D\u5B9A\u3057\u307E\u3057\u305F\u3002


2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_ko.properties
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,7 @@ error.economy.transfer_not_convertable=\uACBD\uC81C %s\uC740(\uB294) \uC804\uD65
success.economy.enable_convertable=\uACBD\uC81C %s\uC740(\uB294) \uC804\uD658\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!
success.economy.disable_convertable=\uACBD\uC81C %s\uC740(\uB294) \uC774\uC81C \uC804\uD658\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!
constants.market.category.redstone=\uBD89\uC740 \uC0C9 \uB3CC
success.market.set_stock='%s' \uD56D\uBAA9\uC758 \uC7AC\uACE0\uB97C %s(\uC73C)\uB85C \uC124\uC815\uD588\uC2B5\uB2C8\uB2E4!
success.market.set_stock.multiple=%s\uAC1C \uD56D\uBAA9\uC758 \uC7AC\uACE0\uB97C %s(\uC73C)\uB85C \uC124\uC815\uD588\uC2B5\uB2C8\uB2E4!


2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_nb.properties
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ error.economy.transfer_not_convertable=\u00D8konomien %s er ikke konvertibel!
success.economy.enable_convertable=\u00D8konomien %s er ikke konvertibel!
success.economy.disable_convertable=\u00D8konomien %s er n\u00E5 ikke konvertibel!
constants.market.category.redstone=R\u00F8d Stein
success.market.set_stock=Sett beholdningen av varen '%s' til %s!
success.market.set_stock.multiple=Sett beholdningen av %s varer til %s!



Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/lang/novaconomy_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ error.economy.transfer_not_convertable=A economia %s n\u00E3o \u00E9 convers\u00
success.economy.enable_convertable=A economia %s n\u00E3o \u00E9 convers\u00EDvel!
success.economy.disable_convertable=A economia %s agora n\u00E3o \u00E9 convers\u00EDvel!
constants.market.category.redstone=Redstone
success.market.set_stock=O estoque do item '%s' foi definido com sucesso para %s!
success.market.set_stock.multiple=O estoque de %s itens foi definido com sucesso para %s!
Loading

0 comments on commit 7255e42

Please sign in to comment.