1.5
This commit is contained in:
parent
b9e029cbe3
commit
c21d1e4848
19 changed files with 51 additions and 39 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -3,7 +3,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'org.gsdistance'
|
group = 'org.gsdistance'
|
||||||
version = '1.5r3'
|
version = '1.5'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
||||||
BIN
build/libs/GrimmsServer-1.5.jar
Normal file
BIN
build/libs/GrimmsServer-1.5.jar
Normal file
Binary file not shown.
Binary file not shown.
|
|
@ -4,7 +4,7 @@ description: A spigot plugin made by Grimm and tyuXX, it adds player leveling, a
|
||||||
website: www.gsdistance.org
|
website: www.gsdistance.org
|
||||||
prefix: Grimm's
|
prefix: Grimm's
|
||||||
main: org.gsdistance.grimmsServer.GrimmsServer
|
main: org.gsdistance.grimmsServer.GrimmsServer
|
||||||
version: 1.5r3
|
version: 1.5
|
||||||
api-version: 1.20
|
api-version: 1.20
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
commands:
|
commands:
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -26,21 +26,7 @@ public class Info {
|
||||||
|
|
||||||
player.sendMessage("Total item count: " + Shared.formatNumber(totalItemCount));
|
player.sendMessage("Total item count: " + Shared.formatNumber(totalItemCount));
|
||||||
|
|
||||||
double totalValue = 0.0;
|
double totalValue = Math.pow(market.NegMarketSaturation, 4);
|
||||||
|
|
||||||
// OPTIMIZATION: Iterating over entrySet() prevents redundant .get() lookups on every loop cycle
|
|
||||||
for (Map.Entry<String, Long> entry : market.items.entrySet()) {
|
|
||||||
Material material = Material.matchMaterial(entry.getKey());
|
|
||||||
|
|
||||||
if (material != null) {
|
|
||||||
long amount = entry.getValue();
|
|
||||||
Double price = MarketBaseValues.marketBaseValues.get(material);
|
|
||||||
|
|
||||||
// Cleaned up double casting syntax with a modern fallback assignment
|
|
||||||
double unitPrice = (price != null) ? price : 0.25;
|
|
||||||
totalValue += amount * unitPrice;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage("Total value: " + Shared.formatNumber(totalValue));
|
player.sendMessage("Total value: " + Shared.formatNumber(totalValue));
|
||||||
player.sendMessage("Unique item count: " + market.items.size());
|
player.sendMessage("Unique item count: " + market.items.size());
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,9 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Market {
|
public class Market {
|
||||||
public double NegMarketSaturation = 0.0F;
|
public double NegMarketSaturation = 0.0;
|
||||||
public final Map<String, Long> items = new HashMap();
|
public final Map<String, Long> items = new HashMap<>();
|
||||||
|
public final Map<String, Long> enchantments = new HashMap<>();
|
||||||
|
|
||||||
public Market() {
|
public Market() {
|
||||||
}
|
}
|
||||||
|
|
@ -32,18 +33,22 @@ public class Market {
|
||||||
|
|
||||||
public double sell(ItemStack itemStack, Player player) {
|
public double sell(ItemStack itemStack, Player player) {
|
||||||
if (!player.getInventory().contains(itemStack)) {
|
if (!player.getInventory().contains(itemStack)) {
|
||||||
return 0.0F;
|
return 0.0;
|
||||||
} else {
|
} else {
|
||||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||||
this.items.putIfAbsent(itemStack.getType().getKey().getKey(), 0L);
|
this.items.putIfAbsent(itemStack.getType().getKey().getKey(), 0L);
|
||||||
long initialAmount = this.items.get(itemStack.getType().getKey().getKey());
|
long initialAmount = this.items.get(itemStack.getType().getKey().getKey());
|
||||||
double sold = 0.0F;
|
double sold = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < itemStack.getAmount(); ++i) {
|
for (int i = 0; i < itemStack.getAmount(); ++i) {
|
||||||
sold += this.getISPriceWithAmount(itemStack.getType(), itemStack.getEnchantments(), initialAmount + i);
|
sold += this.getISPriceWithAmount(itemStack.getType(), itemStack.getEnchantments(), initialAmount + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.items.put(itemStack.getType().getKey().getKey(), initialAmount + (long) itemStack.getAmount());
|
this.items.put(itemStack.getType().getKey().getKey(), initialAmount + (long) itemStack.getAmount());
|
||||||
|
for (Enchantment enchantment : itemStack.getEnchantments().keySet()){
|
||||||
|
this.enchantments.putIfAbsent(enchantment.getName(), 0L);
|
||||||
|
this.enchantments.compute(enchantment.getName(), (k, initialEnchantmentAmount) -> initialEnchantmentAmount + (long) itemStack.getAmount());
|
||||||
|
}
|
||||||
playerStats.setStat("money", playerStats.getStat("money", Double.class) + sold);
|
playerStats.setStat("money", playerStats.getStat("money", Double.class) + sold);
|
||||||
player.getInventory().removeItem(itemStack);
|
player.getInventory().removeItem(itemStack);
|
||||||
return sold;
|
return sold;
|
||||||
|
|
@ -53,24 +58,28 @@ public class Market {
|
||||||
public void unsafeSell(ItemStack itemStack, Player player) {
|
public void unsafeSell(ItemStack itemStack, Player player) {
|
||||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||||
this.items.putIfAbsent(itemStack.getType().getKey().getKey(), 0L);
|
this.items.putIfAbsent(itemStack.getType().getKey().getKey(), 0L);
|
||||||
double sold = 0.0F;
|
double sold = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < itemStack.getAmount(); ++i) {
|
for (int i = 0; i < itemStack.getAmount(); ++i) {
|
||||||
sold += this.getISPrice(itemStack.getType(), itemStack.getEnchantments());
|
sold += this.getISPrice(itemStack.getType(), itemStack.getEnchantments());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.items.put(itemStack.getType().getKey().getKey(), this.items.get(itemStack.getType().getKey().getKey()) + (long) itemStack.getAmount());
|
this.items.put(itemStack.getType().getKey().getKey(), this.items.get(itemStack.getType().getKey().getKey()) + (long) itemStack.getAmount());
|
||||||
|
for (Enchantment enchantment : itemStack.getEnchantments().keySet()){
|
||||||
|
this.enchantments.putIfAbsent(enchantment.getName(), 0L);
|
||||||
|
this.enchantments.compute(enchantment.getName(), (k, initialEnchantmentAmount) -> initialEnchantmentAmount + (long) itemStack.getAmount());
|
||||||
|
}
|
||||||
playerStats.setStat("money", playerStats.getStat("money", Double.class) + sold);
|
playerStats.setStat("money", playerStats.getStat("money", Double.class) + sold);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Data<Double, Integer> sellAll(Material item, Player player) {
|
public Data<Double, Integer> sellAll(Material item, Player player) {
|
||||||
if (!player.getInventory().contains(item)) {
|
if (!player.getInventory().contains(item)) {
|
||||||
return Data.of((double) 0.0F, 0);
|
return Data.of(0.0, 0);
|
||||||
} else {
|
} else {
|
||||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||||
this.items.putIfAbsent(item.getKey().getKey(), 0L);
|
this.items.putIfAbsent(item.getKey().getKey(), 0L);
|
||||||
long initialAmount = this.items.get(item.getKey().getKey());
|
long initialAmount = this.items.get(item.getKey().getKey());
|
||||||
Double sold = (double) 0.0F;
|
Double sold = 0.0;
|
||||||
int amount = player.getInventory().all(item).values().stream().mapToInt(ItemStack::getAmount).sum();
|
int amount = player.getInventory().all(item).values().stream().mapToInt(ItemStack::getAmount).sum();
|
||||||
|
|
||||||
for (int i = 0; i < amount; ++i) {
|
for (int i = 0; i < amount; ++i) {
|
||||||
|
|
@ -86,9 +95,9 @@ public class Market {
|
||||||
|
|
||||||
public double buy(Material item, int amount, Player player) {
|
public double buy(Material item, int amount, Player player) {
|
||||||
if (this.items.get(item.getKey().getKey()) == null) {
|
if (this.items.get(item.getKey().getKey()) == null) {
|
||||||
return 0.0F;
|
return 0.0;
|
||||||
} else if ((long) amount > this.items.get(item.getKey().getKey())) {
|
} else if ((long) amount > this.items.get(item.getKey().getKey())) {
|
||||||
return 0.0F;
|
return 0.0;
|
||||||
} else {
|
} else {
|
||||||
long initialAmount = this.items.get(item.getKey().getKey());
|
long initialAmount = this.items.get(item.getKey().getKey());
|
||||||
|
|
||||||
|
|
@ -115,8 +124,8 @@ public class Market {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double reCalcNegMarketSaturation() {
|
public void reCalcNegMarketSaturation() {
|
||||||
double totalValue = 0.0F;
|
double totalValue = 0.0;
|
||||||
|
|
||||||
for (String string : this.items.keySet()) {
|
for (String string : this.items.keySet()) {
|
||||||
Material material = Material.matchMaterial(string);
|
Material material = Material.matchMaterial(string);
|
||||||
|
|
@ -126,18 +135,30 @@ public class Market {
|
||||||
if (price != null) {
|
if (price != null) {
|
||||||
totalValue += (double) amount * price;
|
totalValue += (double) amount * price;
|
||||||
} else {
|
} else {
|
||||||
totalValue += (double) amount * (double) 0.25F;
|
totalValue += (double) amount * 0.25;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String string : this.enchantments.keySet()){
|
||||||
|
Enchantment enchantment = Enchantment.getByName(string);
|
||||||
|
if(enchantment != null){
|
||||||
|
long amount = this.enchantments.get(string);
|
||||||
|
Double price = EnchantBaseValues.enchantBaseValues.get(enchantment) / 10;
|
||||||
|
if(price != null){
|
||||||
|
totalValue += (double) amount * price;
|
||||||
|
}else{
|
||||||
|
totalValue += (double) amount * 0.25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.NegMarketSaturation = Math.floor(Math.sqrt(Math.sqrt(totalValue)));
|
this.NegMarketSaturation = Math.floor(Math.sqrt(Math.sqrt(totalValue)));
|
||||||
return this.NegMarketSaturation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPrice(Material item) {
|
public double getPrice(Material item) {
|
||||||
if (this.items.get(item.getKey().getKey()) == null) {
|
if (this.items.get(item.getKey().getKey()) == null) {
|
||||||
return 0.0F;
|
return 0.0;
|
||||||
} else {
|
} else {
|
||||||
return this.getPriceWithAmount(item, this.items.get(item.getKey().getKey()));
|
return this.getPriceWithAmount(item, this.items.get(item.getKey().getKey()));
|
||||||
}
|
}
|
||||||
|
|
@ -159,10 +180,10 @@ public class Market {
|
||||||
double rt = this.getPrice(item);
|
double rt = this.getPrice(item);
|
||||||
|
|
||||||
for (Enchantment e : enchantments.keySet()) {
|
for (Enchantment e : enchantments.keySet()) {
|
||||||
Double enchantValue = EnchantBaseValues.enchantBaseValues.get(e);
|
Long enchantmentAmount = this.enchantments.get(e.getName());
|
||||||
if (enchantValue != null) {
|
double enchantValue = EnchantBaseValues.enchantBaseValues.get(e) - (Math.sqrt((enchantmentAmount != null ? enchantmentAmount : 0L) * 300) * 10) + this.NegMarketSaturation*10;
|
||||||
rt += enchantValue * Math.sqrt(enchantments.get(e));
|
double minValue = Math.sqrt(EnchantBaseValues.enchantBaseValues.get(e)) * Math.sqrt(NegMarketSaturation);
|
||||||
}
|
rt += Math.max(enchantValue,minValue) * enchantments.get(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rt;
|
return rt;
|
||||||
|
|
@ -172,8 +193,13 @@ public class Market {
|
||||||
double rt = this.getPriceWithAmount(item, amount);
|
double rt = this.getPriceWithAmount(item, amount);
|
||||||
|
|
||||||
for (Enchantment e : enchantments.keySet()) {
|
for (Enchantment e : enchantments.keySet()) {
|
||||||
Double enchantValue = EnchantBaseValues.enchantBaseValues.get(e);
|
Long enchantmentAmount = this.enchantments.get(e.getName());
|
||||||
if (enchantValue != null) {
|
Double baseEnchantValue = EnchantBaseValues.enchantBaseValues.get(e);
|
||||||
|
if (baseEnchantValue != null) {
|
||||||
|
double enchantValue = baseEnchantValue - (Math.sqrt((enchantmentAmount != null ? enchantmentAmount : 0L) * 300) * 10) + this.NegMarketSaturation*10;
|
||||||
|
if(enchantValue < 0){
|
||||||
|
enchantValue = this.NegMarketSaturation;
|
||||||
|
}
|
||||||
rt += enchantValue * Math.sqrt(enchantments.get(e));
|
rt += enchantValue * Math.sqrt(enchantments.get(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class JobTitlesBaseValues {
|
public class JobTitlesBaseValues {
|
||||||
public static final Map<String, JobTitle> jobTitleBaseValues = Map.ofEntries(Map.entry("dictator", new JobTitle("Dictator", "Dictator of a dictatorship. Requires title 'Dictator'", 95, 50000.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Dictator"))), Map.entry("executioner", new JobTitle("Executioner", "Executioner, self explanatory. Requires title 'Executioner'", 65, 8500.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Executioner"))), Map.entry("", new JobTitle("None", "No Job", -1, 0.0F, (player) -> true)), Map.entry("miner", new JobTitle("Miner", "Minin' for a quick buck, requires title 'Miner'", -1, 750.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Miner"))), Map.entry("farmer", new JobTitle("Farmer", "Farming, but inefficiently.", 60, 650.0F, (player) -> true)), Map.entry("hitman", new JobTitle("Hitman", "Killing as a job? Right away! Requires title 'Hitman'", 75, 17500.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Hitman"))), Map.entry("ceo", new JobTitle("CEO", "Makin money while laying back, the best life! Requires title 'Millionaire'", 80, 11500.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Millionaire"))));
|
public static final Map<String, JobTitle> jobTitleBaseValues = Map.ofEntries(Map.entry("dictator", new JobTitle("Dictator", "Dictator of a dictatorship. Requires title 'Dictator'", 95, 50000.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Dictator"))), Map.entry("executioner", new JobTitle("Executioner", "Executioner, self explanatory. Requires title 'Executioner'", 65, 8500.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Executioner"))), Map.entry("", new JobTitle("None", "No Job", -1, 0.0F, (player) -> true)), Map.entry("miner", new JobTitle("Miner", "Minin' for a quick buck, requires title 'Miner'", -1, 750.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Miner"))), Map.entry("farmer", new JobTitle("Farmer", "Farming, but inefficiently.", 60, 650.0F, (player) -> true)), Map.entry("hitman", new JobTitle("Hitman", "Killing as a job? Right away! Requires title 'Hitman'", 75, 5750.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Hitman"))), Map.entry("ceo", new JobTitle("CEO", "Makin' money while laying back, the best life! Requires title 'Millionaire'", 80, 4150.0F, (player) -> PlayerTitles.getPlayerTitles(player).hasTitle("Millionaire"))));
|
||||||
|
|
||||||
public JobTitlesBaseValues() {
|
public JobTitlesBaseValues() {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import org.gsdistance.grimmsServer.GrimmsServer;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class PlayerStats {
|
public class PlayerStats {
|
||||||
public static final Dictionary<String, PersistentDataType<?, ?>> Stats = new Hashtable();
|
public static final Dictionary<String, PersistentDataType<?, ?>> Stats = new Hashtable<>();
|
||||||
public static final Dictionary<String, String> StatNames;
|
public static final Dictionary<String, String> StatNames;
|
||||||
public static final List<String> StatOrder;
|
public static final List<String> StatOrder;
|
||||||
public static final Map<String, ?> StatDefaultValues;
|
public static final Map<String, ?> StatDefaultValues;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue