Update + Fix
This commit is contained in:
parent
4cf487503b
commit
3772181b21
14 changed files with 68 additions and 7 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.
|
|
@ -35,3 +35,7 @@ commands:
|
||||||
description: Sends money to another player.
|
description: Sends money to another player.
|
||||||
usage: /sendMoney <player> <amount>
|
usage: /sendMoney <player> <amount>
|
||||||
permission: grimmsserver.sendMoney
|
permission: grimmsserver.sendMoney
|
||||||
|
buyRipoff:
|
||||||
|
description: Buys the item for 10x base price, but can be bought when not available.
|
||||||
|
usage: /buyRipoff <item> <amount>
|
||||||
|
permission: grimmsserver.buyRipoff
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,46 @@
|
||||||
|
package org.gsdistance.grimmsServer.Commands;
|
||||||
|
|
||||||
|
import Data.MarketBaseValues;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.gsdistance.grimmsServer.Constructable.Market;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||||
|
|
||||||
|
public class BuyRipoffItem implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
if (args.length < 2) {
|
||||||
|
sender.sendMessage("Usage: /buy <item> <amount>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Material.matchMaterial(args[0]) == null) {
|
||||||
|
sender.sendMessage("Invalid item id:" + args[0]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(MarketBaseValues.marketBaseValues.containsKey(Material.matchMaterial(args[0]))){
|
||||||
|
sender.sendMessage("This item is not available in the market.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PlayerStats playerStats = PlayerStats.getPlayerStats((Player) sender);
|
||||||
|
double bought = 0;
|
||||||
|
for (int i = 0; i < Integer.parseInt(args[1]); i++) {
|
||||||
|
if((Double) playerStats.getStat("money") > MarketBaseValues.marketBaseValues.get(Material.matchMaterial(args[0]))*10){
|
||||||
|
playerStats.setStat("money", (Double) playerStats.getStat("money") - MarketBaseValues.marketBaseValues.get(Material.matchMaterial(args[0]))*10);
|
||||||
|
bought++;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sender.sendMessage("You bought " + bought + " many of " + args[0] + " for " + MarketBaseValues.marketBaseValues.get(Material.matchMaterial(args[0]))*10*bought + " money.");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("This command can only be run by a player.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,5 +13,6 @@ public class CommandRegistry {
|
||||||
GrimmsServer.instance.getCommand("getMarket").setExecutor(new LogEntireMarket());
|
GrimmsServer.instance.getCommand("getMarket").setExecutor(new LogEntireMarket());
|
||||||
GrimmsServer.instance.getCommand("logLeaderboard").setExecutor(new LogLeaderBoard());
|
GrimmsServer.instance.getCommand("logLeaderboard").setExecutor(new LogLeaderBoard());
|
||||||
GrimmsServer.instance.getCommand("sendMoney").setExecutor(new SendMoney());
|
GrimmsServer.instance.getCommand("sendMoney").setExecutor(new SendMoney());
|
||||||
|
GrimmsServer.instance.getCommand("buyRipoff").setExecutor(new BuyRipoffItem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,11 @@ public class Market {
|
||||||
items.put(item.getKey().toString(), items.get(item.getKey().toString()) - 1);
|
items.put(item.getKey().toString(), items.get(item.getKey().toString()) - 1);
|
||||||
bought++;
|
bought++;
|
||||||
}
|
}
|
||||||
player.getInventory().addItem(new ItemStack(item, bought));
|
else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
player.getInventory().addItem(new ItemStack(item, bought));
|
||||||
return boughtP;
|
return boughtP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ import org.bukkit.entity.Player;
|
||||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||||
|
|
||||||
public class LevelHandler {
|
public class LevelHandler {
|
||||||
private final String playerName;
|
private final Player player;
|
||||||
private final PlayerStats playerStats;
|
private final PlayerStats playerStats;
|
||||||
public LevelHandler(Player player) {
|
public LevelHandler(Player player) {
|
||||||
this.playerStats = PlayerStats.getPlayerStats(player);
|
this.playerStats = PlayerStats.getPlayerStats(player);
|
||||||
this.playerName = player.getName();
|
this.player = player;
|
||||||
}
|
}
|
||||||
public static LevelHandler getLevelHandler(Player player) {
|
public static LevelHandler getLevelHandler(Player player) {
|
||||||
return new LevelHandler(player);
|
return new LevelHandler(player);
|
||||||
|
|
@ -25,16 +25,19 @@ public class LevelHandler {
|
||||||
public int addExp(double xp){
|
public int addExp(double xp){
|
||||||
double exp = xp + getXp();
|
double exp = xp + getXp();
|
||||||
int lvlups = 0;
|
int lvlups = 0;
|
||||||
|
double tMoney = 0;
|
||||||
while(exp > getXpToLevel()){
|
while(exp > getXpToLevel()){
|
||||||
exp -= getXpToLevel();
|
exp -= getXpToLevel();
|
||||||
playerStats.changeStat("level",1);
|
playerStats.changeStat("level",1);
|
||||||
playerStats.changeStat("money", (int) Math.min(2147483645,Math.pow(getLevel(),1.5) * 10));
|
tMoney += Math.pow(getLevel(),1.5) * 10;
|
||||||
lvlups++;
|
lvlups++;
|
||||||
}
|
}
|
||||||
playerStats.setStat("xp",exp);
|
playerStats.setStat("xp",exp);
|
||||||
playerStats.setStat("xp_required",getXpToLevel());
|
playerStats.setStat("xp_required",getXpToLevel());
|
||||||
if(lvlups>0){
|
if(lvlups>0){
|
||||||
GrimmsServer.instance.getServer().broadcastMessage("[" + playerName + "] " + "Has leveled up to " + getLevel() + "!");
|
playerStats.setStat("money", (Double) playerStats.getStat("money") + tMoney);
|
||||||
|
GrimmsServer.instance.getServer().broadcastMessage("[" + player.getDisplayName() + "] " + "Has leveled up to " + getLevel() + "!");
|
||||||
|
player.sendMessage("By leveling up " + lvlups + " times, you have gained " + Math.round(tMoney) + " money!");
|
||||||
}
|
}
|
||||||
return lvlups;
|
return lvlups;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,3 +35,7 @@ commands:
|
||||||
description: Sends money to another player.
|
description: Sends money to another player.
|
||||||
usage: /sendMoney <player> <amount>
|
usage: /sendMoney <player> <amount>
|
||||||
permission: grimmsserver.sendMoney
|
permission: grimmsserver.sendMoney
|
||||||
|
buyRipoff:
|
||||||
|
description: Buys the item for 10x base price, but can be bought when not available.
|
||||||
|
usage: /buyRipoff <item> <amount>
|
||||||
|
permission: grimmsserver.buyRipoff
|
||||||
Loading…
Add table
Add a link
Reference in a new issue