TCheckpoint
This commit is contained in:
parent
85668b9d93
commit
840896c4fc
23 changed files with 157 additions and 4 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.
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -11,3 +11,11 @@ commands:
|
||||||
description: Displays the world stats including total deaths, total kills, and total money.
|
description: Displays the world stats including total deaths, total kills, and total money.
|
||||||
usage: /logworldstats
|
usage: /logworldstats
|
||||||
permission: grimmsserver.logworldstats
|
permission: grimmsserver.logworldstats
|
||||||
|
getMarketValue:
|
||||||
|
description: Displays the market value of a specified item.
|
||||||
|
usage: /getMarketValue <item>
|
||||||
|
permission: grimmsserver.getMarketValue
|
||||||
|
sellItem:
|
||||||
|
description: Sells the main hand for a certain amount of money.
|
||||||
|
usage: /sellItem
|
||||||
|
permission: grimmsserver.sellItem
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.gsdistance.grimmsServer.Commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class GetItemStockValue implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.gsdistance.grimmsServer.Commands;
|
||||||
|
|
||||||
|
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.ServerStats;
|
||||||
|
|
||||||
|
public class SellItem implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Market market = (Market) ServerStats.getServerStats().getStat("market");
|
||||||
|
market.sell(((Player) sender).getInventory().getItemInMainHand(), (Player) sender);
|
||||||
|
ServerStats.getServerStats().setStat("market", market);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage("This command can only be run by a player.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package org.gsdistance.grimmsServer.Constructable;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemRarity;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||||
|
|
||||||
|
import java.util.Dictionary;
|
||||||
|
|
||||||
|
public class Market {
|
||||||
|
public Dictionary<String, Long> items;
|
||||||
|
public Market() {
|
||||||
|
items = new java.util.Hashtable<>();
|
||||||
|
}
|
||||||
|
public boolean sell(ItemStack itemStack, Player player) {
|
||||||
|
if(player.getInventory().contains(itemStack)) {
|
||||||
|
items.put(itemStack.getType().getKey().toString(), 0L);
|
||||||
|
for (int i = 0; i < itemStack.getAmount(); i++) {
|
||||||
|
PlayerStats.getPlayerStats(player).setStat("money", (double)PlayerStats.getPlayerStats(player).getStat("money") + getPrice(itemStack.getType()));
|
||||||
|
items.put(itemStack.getType().getKey().toString(), items.get(itemStack.getType().getKey().toString()) + 1);
|
||||||
|
}
|
||||||
|
player.getInventory().removeItem(itemStack);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public boolean buy(Material item, int amount, Player player) {
|
||||||
|
if (items.get(item.getKey().toString()) == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
int bought = 0;
|
||||||
|
for (int i = 0; i < amount; i++) {
|
||||||
|
if((double)PlayerStats.getPlayerStats(player).getStat("money") >= getPrice(item)) {
|
||||||
|
PlayerStats.getPlayerStats(player).setStat("money", (double)PlayerStats.getPlayerStats(player).getStat("money") - getPrice(item));
|
||||||
|
items.put(item.getKey().toString(), items.get(item.getKey().toString()) - 1);
|
||||||
|
bought++;
|
||||||
|
}
|
||||||
|
player.getInventory().addItem(new ItemStack(item, bought));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public double getPrice(Material item) {
|
||||||
|
if(items.get(item.getKey().toString()) == null) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
long amount = items.get(item.getKey().toString());
|
||||||
|
return switch (ItemRarity.valueOf(item.getKey().toString())) {
|
||||||
|
case COMMON -> Math.max(1, 25 - Math.sqrt(amount));
|
||||||
|
case UNCOMMON -> Math.max(1, 200 - Math.sqrt(amount));
|
||||||
|
case RARE -> Math.max(1, 600 - Math.sqrt(amount));
|
||||||
|
case EPIC -> Math.max(1, 1200 - Math.sqrt(amount));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.gsdistance.grimmsServer.Events;
|
||||||
|
|
||||||
|
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.WorldStats;
|
||||||
|
|
||||||
|
public class BlockBreakEvent {
|
||||||
|
public static void Event(org.bukkit.event.block.BlockBreakEvent event) {
|
||||||
|
if (event.getPlayer().getType() == org.bukkit.entity.EntityType.PLAYER) {
|
||||||
|
PlayerStats.getPlayerStats(event.getPlayer()).setStat("money", (double) PlayerStats.getPlayerStats(event.getPlayer()).getStat("money") + 0.5D);
|
||||||
|
PlayerStats.getPlayerStats(event.getPlayer()).setStat("tPoint", (double) PlayerStats.getPlayerStats(event.getPlayer()).getStat("tPoint") + 1D);
|
||||||
|
}
|
||||||
|
WorldStats.getWorldStats(event.getBlock().getWorld()).setStat("block_break_count", (long) WorldStats.getWorldStats(event.getBlock().getWorld()).getStat("block_break_count") + 1L);
|
||||||
|
WorldStats.getWorldStats(event.getBlock().getWorld()).setStat("wPoint", (double) WorldStats.getWorldStats(event.getBlock().getWorld()).getStat("wPoint") + 3.0D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,13 +13,25 @@ public class EntityDeathEvent {
|
||||||
public static void Event(org.bukkit.event.entity.EntityDeathEvent event){
|
public static void Event(org.bukkit.event.entity.EntityDeathEvent event){
|
||||||
if(!(event.getEntity().getKiller() == null)){
|
if(!(event.getEntity().getKiller() == null)){
|
||||||
if(event.getEntity().getKiller().getType() == org.bukkit.entity.EntityType.PLAYER){
|
if(event.getEntity().getKiller().getType() == org.bukkit.entity.EntityType.PLAYER){
|
||||||
PlayerStats.getPlayerStats(event.getEntity().getKiller()).changeStat("total_kill_count", 1);
|
PlayerStats playerStats = PlayerStats.getPlayerStats(event.getEntity().getKiller());
|
||||||
|
WorldStats worldStats = WorldStats.getWorldStats(event.getEntity().getWorld());
|
||||||
|
|
||||||
|
playerStats.setStat("total_kill_count", (int) playerStats.getStat("total_kill_count") + 1);
|
||||||
|
playerStats.setStat("money", (double) playerStats.getStat("money") + 3);
|
||||||
|
playerStats.setStat("tPoint", (double) playerStats.getStat("tPoint") + 25);
|
||||||
|
worldStats.setStat("wPoint", (double) worldStats.getStat("wPoint") + 40);
|
||||||
|
|
||||||
|
if(event.getEntity().getType() == org.bukkit.entity.EntityType.PLAYER){
|
||||||
|
playerStats.setStat("money", (double) playerStats.getStat("money") + 12);
|
||||||
|
playerStats.setStat("tPoint", (double) playerStats.getStat("tPoint") + 50);
|
||||||
|
worldStats.setStat("wPoint", (double) worldStats.getStat("wPoint") + 110);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(event.getEntity().getType() == org.bukkit.entity.EntityType.PLAYER){
|
if(event.getEntity().getType() == org.bukkit.entity.EntityType.PLAYER){
|
||||||
PlayerStats.getPlayerStats((org.bukkit.entity.Player) event.getEntity()).changeStat("death_count", 1);
|
PlayerStats.getPlayerStats((org.bukkit.entity.Player) event.getEntity()).setStat("death_count", (int) PlayerStats.getPlayerStats((org.bukkit.entity.Player) event.getEntity()).getStat("death_count") + 1);
|
||||||
}
|
}
|
||||||
WorldStats.getWorldStats(event.getEntity().getWorld()).changeStat("death_count", 1);
|
WorldStats.getWorldStats(event.getEntity().getWorld()).setStat("death_count", (int) WorldStats.getWorldStats(event.getEntity().getWorld()).getStat("death_count") + 1);
|
||||||
ServerStats.getServerStats().changeStat("death_count", 1);
|
ServerStats.getServerStats().setStat("death_count", (int) ServerStats.getServerStats().getStat("death_count") + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package org.gsdistance.grimmsServer.Events;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
|
@ -10,6 +11,9 @@ public class EventTrigger implements Listener {
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
org.gsdistance.grimmsServer.Events.EntityDeathEvent.Event(event);
|
org.gsdistance.grimmsServer.Events.EntityDeathEvent.Event(event);
|
||||||
}
|
}
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
org.gsdistance.grimmsServer.Events.BlockBreakEvent.Event(event);
|
||||||
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
org.gsdistance.grimmsServer.Events.PlayerJoinEvent.Event(event);
|
org.gsdistance.grimmsServer.Events.PlayerJoinEvent.Event(event);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ public class PlayerStats {
|
||||||
Stats.put("money", PersistentDataType.DOUBLE);
|
Stats.put("money", PersistentDataType.DOUBLE);
|
||||||
Stats.put("total_kill_count", PersistentDataType.INTEGER);
|
Stats.put("total_kill_count", PersistentDataType.INTEGER);
|
||||||
Stats.put("join_count", PersistentDataType.INTEGER);
|
Stats.put("join_count", PersistentDataType.INTEGER);
|
||||||
|
Stats.put("tPoint", PersistentDataType.DOUBLE);
|
||||||
}
|
}
|
||||||
public static final Dictionary<String,String> StatNames = new Hashtable<>();
|
public static final Dictionary<String,String> StatNames = new Hashtable<>();
|
||||||
static {
|
static {
|
||||||
|
|
@ -24,6 +25,7 @@ public class PlayerStats {
|
||||||
StatNames.put("money", "Money");
|
StatNames.put("money", "Money");
|
||||||
StatNames.put("total_kill_count", "Total Kill Count");
|
StatNames.put("total_kill_count", "Total Kill Count");
|
||||||
StatNames.put("join_count", "Join Count");
|
StatNames.put("join_count", "Join Count");
|
||||||
|
StatNames.put("tPoint", "Total Points");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package org.gsdistance.grimmsServer.Stats;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.gsdistance.grimmsServer.Constructable.Market;
|
||||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -21,11 +22,13 @@ public class ServerStats {
|
||||||
static {
|
static {
|
||||||
Stats.put("death_count", Integer.class);
|
Stats.put("death_count", Integer.class);
|
||||||
Stats.put("join_count", Integer.class);
|
Stats.put("join_count", Integer.class);
|
||||||
|
Stats.put("market", Market.class);
|
||||||
}
|
}
|
||||||
public static final Dictionary<String,String> StatNames = new Hashtable<>();
|
public static final Dictionary<String,String> StatNames = new Hashtable<>();
|
||||||
static {
|
static {
|
||||||
StatNames.put("death_count", "Death Count");
|
StatNames.put("death_count", "Death Count");
|
||||||
StatNames.put("join_count", "Join Count");
|
StatNames.put("join_count", "Join Count");
|
||||||
|
StatNames.put("market", "Market");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,16 @@ public class WorldStats {
|
||||||
public static final Dictionary<String, PersistentDataType<?, ?>> Stats = new Hashtable<>();
|
public static final Dictionary<String, PersistentDataType<?, ?>> Stats = new Hashtable<>();
|
||||||
static {
|
static {
|
||||||
Stats.put("death_count", PersistentDataType.INTEGER);
|
Stats.put("death_count", PersistentDataType.INTEGER);
|
||||||
|
Stats.put("block_break_count", PersistentDataType.LONG);
|
||||||
|
Stats.put("wPoint", PersistentDataType.DOUBLE);
|
||||||
|
Stats.put("join_count", PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
public static final Dictionary<String,String> StatNames = new Hashtable<>();
|
public static final Dictionary<String,String> StatNames = new Hashtable<>();
|
||||||
static {
|
static {
|
||||||
StatNames.put("death_count", "Death Count");
|
StatNames.put("death_count", "Death Count");
|
||||||
|
StatNames.put("block_break_count", "Block Break Count");
|
||||||
|
StatNames.put("wPoint", "World Points");
|
||||||
|
StatNames.put("join_count", "Join Count");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,11 @@ commands:
|
||||||
description: Displays the world stats including total deaths, total kills, and total money.
|
description: Displays the world stats including total deaths, total kills, and total money.
|
||||||
usage: /logworldstats
|
usage: /logworldstats
|
||||||
permission: grimmsserver.logworldstats
|
permission: grimmsserver.logworldstats
|
||||||
|
getMarketValue:
|
||||||
|
description: Displays the market value of a specified item.
|
||||||
|
usage: /getMarketValue <item>
|
||||||
|
permission: grimmsserver.getMarketValue
|
||||||
|
sellItem:
|
||||||
|
description: Sells the main hand for a certain amount of money.
|
||||||
|
usage: /sellItem
|
||||||
|
permission: grimmsserver.sellItem
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue