1.5r3
This commit is contained in:
parent
bb2beec3c4
commit
6a655eb289
22 changed files with 376 additions and 11 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.
|
|
@ -44,4 +44,7 @@ processResources {
|
||||||
filesMatching('plugin.yml') {
|
filesMatching('plugin.yml') {
|
||||||
expand props
|
expand props
|
||||||
}
|
}
|
||||||
|
filesMatching('embed/version.embed') {
|
||||||
|
expand props
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -14,9 +14,9 @@ public class Prestige {
|
||||||
|
|
||||||
int currentLevel = levelHandler.getLevel();
|
int currentLevel = levelHandler.getLevel();
|
||||||
int currentPrestige = playerStats.getStat("prestige", Integer.class);
|
int currentPrestige = playerStats.getStat("prestige", Integer.class);
|
||||||
long requiredLevel = (currentPrestige + 1) * 15L;
|
long requiredLevel = 15 + (currentPrestige) * 10L;
|
||||||
|
|
||||||
if (currentLevel <= requiredLevel) {
|
if (currentLevel < requiredLevel) {
|
||||||
player.sendMessage(ChatColor.RED + "You must be at least level " + requiredLevel + " to prestige.");
|
player.sendMessage(ChatColor.RED + "You must be at least level " + requiredLevel + " to prestige.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,203 @@
|
||||||
|
package org.gsdistance.grimmsServer.Commands.GLevelCommand;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.gsdistance.grimmsServer.Config.ActiveConfig;
|
||||||
|
import org.gsdistance.grimmsServer.Config.ConfigKey;
|
||||||
|
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||||
|
import org.gsdistance.grimmsServer.Data.Player.PlayerCapability;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PrestigeShop {
|
||||||
|
public static final String GUI_TITLE = "Prestige Shop";
|
||||||
|
private static final int GUI_SIZE = 27;
|
||||||
|
private static final Map<Player, PrestigeShop> openGUIs = new HashMap<>();
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private final PlayerStats playerStats;
|
||||||
|
private final PlayerMetadata playerMetadata;
|
||||||
|
private Inventory inventory;
|
||||||
|
|
||||||
|
public PrestigeShop(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
this.playerStats = PlayerStats.getPlayerStats(player);
|
||||||
|
this.playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||||
|
this.inventory = Bukkit.createInventory(null, GUI_SIZE, GUI_TITLE);
|
||||||
|
openGUIs.put(player, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open() {
|
||||||
|
renderGUI();
|
||||||
|
player.openInventory(inventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderGUI() {
|
||||||
|
inventory.clear();
|
||||||
|
|
||||||
|
// Display player's prestige points
|
||||||
|
ItemStack pointsItem = new ItemStack(Material.NETHER_STAR);
|
||||||
|
ItemMeta pointsMeta = pointsItem.getItemMeta();
|
||||||
|
if (pointsMeta != null) {
|
||||||
|
long prestigePoints = playerStats.getStat("prestigePoints", Long.class);
|
||||||
|
pointsMeta.setDisplayName(ChatColor.GOLD + "Prestige Points: " + prestigePoints);
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
lore.add(ChatColor.GRAY + "Use these points to purchase capabilities");
|
||||||
|
pointsMeta.setLore(lore);
|
||||||
|
pointsItem.setItemMeta(pointsMeta);
|
||||||
|
}
|
||||||
|
inventory.setItem(13, pointsItem);
|
||||||
|
|
||||||
|
// Render all available capabilities for purchase
|
||||||
|
int slot = 0;
|
||||||
|
for (PlayerCapability capability : PlayerCapability.values()) {
|
||||||
|
if (slot >= 13) slot++; // Skip the center slot
|
||||||
|
if (slot >= 27) break;
|
||||||
|
|
||||||
|
ItemStack capabilityItem = createCapabilityItem(capability);
|
||||||
|
inventory.setItem(slot, capabilityItem);
|
||||||
|
slot++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add close button at the end
|
||||||
|
ItemStack closeItem = new ItemStack(Material.BARRIER);
|
||||||
|
ItemMeta closeMeta = closeItem.getItemMeta();
|
||||||
|
if (closeMeta != null) {
|
||||||
|
closeMeta.setDisplayName(ChatColor.RED + "Close");
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
lore.add(ChatColor.GRAY + "Click to close the prestige shop");
|
||||||
|
closeMeta.setLore(lore);
|
||||||
|
closeItem.setItemMeta(closeMeta);
|
||||||
|
}
|
||||||
|
inventory.setItem(26, closeItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack createCapabilityItem(PlayerCapability capability) {
|
||||||
|
Material material;
|
||||||
|
switch (capability) {
|
||||||
|
case AUTOSELL:
|
||||||
|
material = Material.GOLD_INGOT;
|
||||||
|
break;
|
||||||
|
case MAGNET:
|
||||||
|
material = Material.IRON_NUGGET;
|
||||||
|
break;
|
||||||
|
case VEINMINER:
|
||||||
|
material = Material.DIAMOND_PICKAXE;
|
||||||
|
break;
|
||||||
|
case SATURATION_PERK:
|
||||||
|
material = Material.GOLDEN_CARROT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
material = Material.PAPER;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = new ItemStack(material);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
|
||||||
|
if (meta != null) {
|
||||||
|
boolean isOwned = playerMetadata.capabilities.containsKey(capability);
|
||||||
|
int price = getCapabilityPrice(capability);
|
||||||
|
|
||||||
|
meta.setDisplayName(ChatColor.WHITE + capability.displayName);
|
||||||
|
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
lore.add(ChatColor.GRAY + capability.description);
|
||||||
|
lore.add("");
|
||||||
|
if (isOwned) {
|
||||||
|
lore.add(ChatColor.GREEN + "Status: Owned");
|
||||||
|
lore.add(ChatColor.GRAY + "Toggle in /gUtil setting");
|
||||||
|
} else {
|
||||||
|
lore.add(ChatColor.GOLD + "Price: " + price + " Prestige Points");
|
||||||
|
lore.add(ChatColor.YELLOW + "Click to purchase");
|
||||||
|
}
|
||||||
|
meta.setLore(lore);
|
||||||
|
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCapabilityPrice(PlayerCapability capability) {
|
||||||
|
return switch (capability) {
|
||||||
|
case AUTOSELL -> ActiveConfig.getConfigValue(ConfigKey.PRESTIGE_CAPABILITY_AUTOSELL_PRICE, Integer.class);
|
||||||
|
case MAGNET -> ActiveConfig.getConfigValue(ConfigKey.PRESTIGE_CAPABILITY_MAGNET_PRICE, Integer.class);
|
||||||
|
case VEINMINER -> ActiveConfig.getConfigValue(ConfigKey.PRESTIGE_CAPABILITY_VEINMINER_PRICE, Integer.class);
|
||||||
|
case SATURATION_PERK -> ActiveConfig.getConfigValue(ConfigKey.PRESTIGE_CAPABILITY_SATURATION_PERK_PRICE, Integer.class);
|
||||||
|
default -> 10;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleClick(int slot) {
|
||||||
|
// Check if it's a capability slot
|
||||||
|
if (slot < PlayerCapability.values().length) {
|
||||||
|
PlayerCapability[] capabilities = PlayerCapability.values();
|
||||||
|
if (slot < capabilities.length) {
|
||||||
|
purchaseCapability(capabilities[slot]);
|
||||||
|
renderGUI();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip center slot (prestige points display)
|
||||||
|
if (slot == 13) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjust for skipped center slot
|
||||||
|
int adjustedSlot = slot > 13 ? slot - 1 : slot;
|
||||||
|
if (adjustedSlot < PlayerCapability.values().length) {
|
||||||
|
PlayerCapability[] capabilities = PlayerCapability.values();
|
||||||
|
if (adjustedSlot < capabilities.length) {
|
||||||
|
purchaseCapability(capabilities[adjustedSlot]);
|
||||||
|
renderGUI();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close button
|
||||||
|
if (slot == 26) {
|
||||||
|
player.closeInventory();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void purchaseCapability(PlayerCapability capability) {
|
||||||
|
if (playerMetadata.capabilities.containsKey(capability)) {
|
||||||
|
player.sendMessage(ChatColor.RED + "You already own this capability. Toggle it in /gUtil setting");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int price = getCapabilityPrice(capability);
|
||||||
|
long prestigePoints = playerStats.getStat("prestigePoints", Long.class);
|
||||||
|
|
||||||
|
if (prestigePoints < price) {
|
||||||
|
player.sendMessage(ChatColor.RED + "You don't have enough prestige points. Need " + price + ", have " + prestigePoints);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerStats.setStat("prestigePoints", prestigePoints - price);
|
||||||
|
playerMetadata.capabilities.put(capability, 1);
|
||||||
|
playerMetadata.saveToPDS();
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GREEN + "Purchased: " + capability.displayName);
|
||||||
|
player.sendMessage(ChatColor.GOLD + "Remaining prestige points: " + (prestigePoints - price));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PrestigeShop getGUI(Player player) {
|
||||||
|
return openGUIs.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void closeGUI(Player player) {
|
||||||
|
openGUIs.remove(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,8 @@ public class SettingGUI {
|
||||||
public static final String GUI_TITLE = "Settings";
|
public static final String GUI_TITLE = "Settings";
|
||||||
private static final int GUI_SIZE = 27;
|
private static final int GUI_SIZE = 27;
|
||||||
private static final Map<Player, SettingGUI> openGUIs = new HashMap<>();
|
private static final Map<Player, SettingGUI> openGUIs = new HashMap<>();
|
||||||
|
private static final Map<Player, Long> lastClickTime = new HashMap<>();
|
||||||
|
private static final long COOLDOWN_MS = 1000;
|
||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final PlayerMetadata playerMetadata;
|
private final PlayerMetadata playerMetadata;
|
||||||
|
|
@ -70,6 +72,12 @@ public class SettingGUI {
|
||||||
case MAGNET:
|
case MAGNET:
|
||||||
material = Material.IRON_NUGGET;
|
material = Material.IRON_NUGGET;
|
||||||
break;
|
break;
|
||||||
|
case VEINMINER:
|
||||||
|
material = Material.DIAMOND_PICKAXE;
|
||||||
|
break;
|
||||||
|
case SATURATION_PERK:
|
||||||
|
material = Material.GOLDEN_CARROT;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
material = Material.PAPER;
|
material = Material.PAPER;
|
||||||
}
|
}
|
||||||
|
|
@ -102,6 +110,14 @@ public class SettingGUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleClick(int slot) {
|
public void handleClick(int slot) {
|
||||||
|
// Check cooldown
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
long lastClick = lastClickTime.getOrDefault(player, 0L);
|
||||||
|
if (currentTime - lastClick < COOLDOWN_MS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastClickTime.put(player, currentTime);
|
||||||
|
|
||||||
// Check if it's a setting slot
|
// Check if it's a setting slot
|
||||||
if (slot < PlayerCapability.values().length) {
|
if (slot < PlayerCapability.values().length) {
|
||||||
PlayerCapability[] capabilities = PlayerCapability.values();
|
PlayerCapability[] capabilities = PlayerCapability.values();
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@ public enum ConfigKey {
|
||||||
MARKET_MIN_PRICE("market_min_price", 0.25),
|
MARKET_MIN_PRICE("market_min_price", 0.25),
|
||||||
MARKET_PRICE_REFRESH_INTERVAL("market_price_refresh_interval", 300),
|
MARKET_PRICE_REFRESH_INTERVAL("market_price_refresh_interval", 300),
|
||||||
LOG_LEVEL("log_level", "Info"),
|
LOG_LEVEL("log_level", "Info"),
|
||||||
PRESTIGE_CAPABILITY_AUTOSELL_PRICE("prestige_capability_autosell_price", 5),
|
PRESTIGE_CAPABILITY_AUTOSELL_PRICE("prestige_capability_autosell_price", 4),
|
||||||
PRESTIGE_CAPABILITY_MAGNET_PRICE("prestige_capability_magnet_price", 10);
|
PRESTIGE_CAPABILITY_MAGNET_PRICE("prestige_capability_magnet_price", 2),
|
||||||
|
PRESTIGE_CAPABILITY_VEINMINER_PRICE("prestige_capability_veinminer_price", 3),
|
||||||
|
PRESTIGE_CAPABILITY_SATURATION_PERK_PRICE("prestige_capability_saturation_perk_price", 4);
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
private final Object defaultValue;
|
private final Object defaultValue;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public class PlayerLevelHandler {
|
||||||
for (tMoney = 0.0F; exp > this.getXpToLevel(); ++lvlups) {
|
for (tMoney = 0.0F; exp > this.getXpToLevel(); ++lvlups) {
|
||||||
exp -= this.getXpToLevel();
|
exp -= this.getXpToLevel();
|
||||||
this.playerStats.changeStat("level", 1);
|
this.playerStats.changeStat("level", 1);
|
||||||
tMoney += Math.pow(this.getLevel(), 1.8) * (double) 100.0F;
|
tMoney += Math.pow(this.getLevel(), 1.8) * (double) 100.0F * Math.pow(playerStats.getStat("prestige", Integer.class) + 1,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setXp(exp);
|
this.setXp(exp);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ package org.gsdistance.grimmsServer.Data.Player;
|
||||||
|
|
||||||
public enum PlayerCapability {
|
public enum PlayerCapability {
|
||||||
AUTOSELL("Auto Sell", "Allows the player to automatically sell items in their inventory when they reach a certain threshold.", "autosell"),
|
AUTOSELL("Auto Sell", "Allows the player to automatically sell items in their inventory when they reach a certain threshold.", "autosell"),
|
||||||
MAGNET("Magnet", "Magnetises items in a 10 block radius", "magnet");
|
MAGNET("Magnet", "Magnetises items in a 10 block radius", "magnet"),
|
||||||
|
VEINMINER("Veinminer", "Breaks all adjacent ores of the same type within 8 blocks and teleports drops to you.", "veinminer"),
|
||||||
|
SATURATION_PERK("Saturation Perk", "Gives 10 seconds of saturation that refreshes every second when enabled.", "saturation_perk");
|
||||||
|
|
||||||
public final String displayName;
|
public final String displayName;
|
||||||
public final String description;
|
public final String description;
|
||||||
|
|
@ -16,6 +18,6 @@ public enum PlayerCapability {
|
||||||
|
|
||||||
// $FF: synthetic method
|
// $FF: synthetic method
|
||||||
private static PlayerCapability[] $values() {
|
private static PlayerCapability[] $values() {
|
||||||
return new PlayerCapability[]{AUTOSELL, MAGNET};
|
return new PlayerCapability[]{AUTOSELL, MAGNET, VEINMINER, SATURATION_PERK};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,25 @@
|
||||||
package org.gsdistance.grimmsServer.Events.Listeners;
|
package org.gsdistance.grimmsServer.Events.Listeners;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
import org.gsdistance.grimmsServer.Commands.GAuthCommand.GAuthBaseCommand;
|
import org.gsdistance.grimmsServer.Commands.GAuthCommand.GAuthBaseCommand;
|
||||||
import org.gsdistance.grimmsServer.Constructable.Faction;
|
import org.gsdistance.grimmsServer.Constructable.Faction;
|
||||||
import org.gsdistance.grimmsServer.Constructable.Item.ItemLevelHandler;
|
import org.gsdistance.grimmsServer.Constructable.Item.ItemLevelHandler;
|
||||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerLevelHandler;
|
import org.gsdistance.grimmsServer.Constructable.Player.PlayerLevelHandler;
|
||||||
|
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||||
import org.gsdistance.grimmsServer.Constructable.World.ChunkMetadata;
|
import org.gsdistance.grimmsServer.Constructable.World.ChunkMetadata;
|
||||||
|
import org.gsdistance.grimmsServer.Data.Player.PlayerCapability;
|
||||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||||
import org.gsdistance.grimmsServer.Stats.WorldStats;
|
import org.gsdistance.grimmsServer.Stats.WorldStats;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class BlockBreakEvent {
|
public class BlockBreakEvent {
|
||||||
public BlockBreakEvent() {
|
public BlockBreakEvent() {
|
||||||
}
|
}
|
||||||
|
|
@ -43,5 +53,109 @@ public class BlockBreakEvent {
|
||||||
|
|
||||||
WorldStats.getWorldStats(event.getBlock().getWorld()).changeStat("block_break_count", 1);
|
WorldStats.getWorldStats(event.getBlock().getWorld()).changeStat("block_break_count", 1);
|
||||||
WorldStats.getWorldStats(event.getBlock().getWorld()).changeStat("wPoint", 3);
|
WorldStats.getWorldStats(event.getBlock().getWorld()).changeStat("wPoint", 3);
|
||||||
|
|
||||||
|
// Handle Veinminer capability
|
||||||
|
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(event.getPlayer());
|
||||||
|
if (playerMetadata.capabilities.containsKey(PlayerCapability.VEINMINER) &&
|
||||||
|
playerMetadata.settings.contains(PlayerCapability.VEINMINER.capabilityId)) {
|
||||||
|
handleVeinminer(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleVeinminer(org.bukkit.event.block.BlockBreakEvent event) {
|
||||||
|
Block originalBlock = event.getBlock();
|
||||||
|
Material blockType = originalBlock.getType();
|
||||||
|
|
||||||
|
// Check if it's an ore
|
||||||
|
if (!isOre(blockType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find all adjacent same-type ores within 8 blocks
|
||||||
|
Set<Block> oreBlocks = findAdjacentOres(originalBlock, blockType, 8);
|
||||||
|
|
||||||
|
// Remove the original block since we already have its event
|
||||||
|
oreBlocks.remove(originalBlock);
|
||||||
|
|
||||||
|
if (oreBlocks.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Break all found ores and teleport drops
|
||||||
|
for (Block oreBlock : oreBlocks) {
|
||||||
|
// Collect drops before breaking
|
||||||
|
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<>(oreBlock.getDrops(event.getPlayer().getInventory().getItemInMainHand()));
|
||||||
|
|
||||||
|
// Break the block
|
||||||
|
oreBlock.setType(Material.AIR);
|
||||||
|
|
||||||
|
// Teleport drops to original block location
|
||||||
|
for (org.bukkit.inventory.ItemStack drop : drops) {
|
||||||
|
Item droppedItem = oreBlock.getWorld().dropItemNaturally(originalBlock.getLocation(), drop);
|
||||||
|
droppedItem.setPickupDelay(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a block break event for this block to register stats
|
||||||
|
org.bukkit.event.block.BlockBreakEvent veinEvent = new org.bukkit.event.block.BlockBreakEvent(oreBlock, event.getPlayer());
|
||||||
|
org.bukkit.Bukkit.getPluginManager().callEvent(veinEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isOre(Material material) {
|
||||||
|
return material == Material.COAL_ORE ||
|
||||||
|
material == Material.DEEPSLATE_COAL_ORE ||
|
||||||
|
material == Material.IRON_ORE ||
|
||||||
|
material == Material.DEEPSLATE_IRON_ORE ||
|
||||||
|
material == Material.GOLD_ORE ||
|
||||||
|
material == Material.DEEPSLATE_GOLD_ORE ||
|
||||||
|
material == Material.DIAMOND_ORE ||
|
||||||
|
material == Material.DEEPSLATE_DIAMOND_ORE ||
|
||||||
|
material == Material.EMERALD_ORE ||
|
||||||
|
material == Material.DEEPSLATE_EMERALD_ORE ||
|
||||||
|
material == Material.REDSTONE_ORE ||
|
||||||
|
material == Material.DEEPSLATE_REDSTONE_ORE ||
|
||||||
|
material == Material.LAPIS_ORE ||
|
||||||
|
material == Material.DEEPSLATE_LAPIS_ORE ||
|
||||||
|
material == Material.COPPER_ORE ||
|
||||||
|
material == Material.DEEPSLATE_COPPER_ORE ||
|
||||||
|
material == Material.NETHER_GOLD_ORE ||
|
||||||
|
material == Material.NETHER_QUARTZ_ORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<Block> findAdjacentOres(Block startBlock, Material targetMaterial, int range) {
|
||||||
|
Set<Block> found = new HashSet<>();
|
||||||
|
List<Block> toCheck = new ArrayList<>();
|
||||||
|
toCheck.add(startBlock);
|
||||||
|
|
||||||
|
while (!toCheck.isEmpty()) {
|
||||||
|
Block current = toCheck.remove(0);
|
||||||
|
if (found.contains(current)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current.getType() == targetMaterial) {
|
||||||
|
found.add(current);
|
||||||
|
|
||||||
|
// Check neighbors within range
|
||||||
|
for (int x = -1; x <= 1; x++) {
|
||||||
|
for (int y = -1; y <= 1; y++) {
|
||||||
|
for (int z = -1; z <= 1; z++) {
|
||||||
|
if (x == 0 && y == 0 && z == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block neighbor = current.getRelative(x, y, z);
|
||||||
|
if (!found.contains(neighbor) &&
|
||||||
|
!toCheck.contains(neighbor) &&
|
||||||
|
neighbor.getLocation().distance(startBlock.getLocation()) <= range) {
|
||||||
|
toCheck.add(neighbor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,19 @@ package org.gsdistance.grimmsServer.Events.Listeners;
|
||||||
|
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||||
import org.gsdistance.grimmsServer.Data.Player.PlayerCapability;
|
import org.gsdistance.grimmsServer.Data.Player.PlayerCapability;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class PlayerTickEvent {
|
public class PlayerTickEvent {
|
||||||
private static final List<Player> magnetPlayers = new ArrayList();
|
private static final List<Player> magnetPlayers = new ArrayList();
|
||||||
|
private static final Map<Player, Integer> saturationPerkPlayers = new HashMap();
|
||||||
|
|
||||||
public PlayerTickEvent() {
|
public PlayerTickEvent() {
|
||||||
}
|
}
|
||||||
|
|
@ -20,6 +25,18 @@ public class PlayerTickEvent {
|
||||||
magnetPlayers.add(player);
|
magnetPlayers.add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle Saturation Perk
|
||||||
|
if (playerMetadata.capabilities.containsKey(PlayerCapability.SATURATION_PERK) &&
|
||||||
|
playerMetadata.settings.contains(PlayerCapability.SATURATION_PERK.capabilityId)) {
|
||||||
|
int currentDuration = saturationPerkPlayers.getOrDefault(player, 0);
|
||||||
|
saturationPerkPlayers.put(player, currentDuration + 1);
|
||||||
|
|
||||||
|
// Apply saturation effect with lowest level (1) for 10 seconds
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 200, 0, false, false));
|
||||||
|
} else {
|
||||||
|
saturationPerkPlayers.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void processMagnets() {
|
public static void processMagnets() {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class ServerTickEvent {
|
||||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||||
String jobTitleId = playerStats.getStat("jobTitle", String.class);
|
String jobTitleId = playerStats.getStat("jobTitle", String.class);
|
||||||
if (jobTitleId != null && !jobTitleId.isEmpty()) {
|
if (jobTitleId != null && !jobTitleId.isEmpty()) {
|
||||||
double multiplier = (double) 1.0F + Math.pow((double) playerStats.getStat("level", Integer.class), 2.0F) / (double) 100.0F;
|
double multiplier = (double) 1.0F + Math.pow((double) playerStats.getStat("level", Integer.class), 2.0F) * Math.pow(playerStats.getStat("prestige", Integer.class) + 1,2) / (double) 100.0F;
|
||||||
double payCheck = Math.ceil(JobTitlesBaseValues.jobTitleBaseValues.getOrDefault(jobTitleId, null).paycheckSize() * multiplier);
|
double payCheck = Math.ceil(JobTitlesBaseValues.jobTitleBaseValues.getOrDefault(jobTitleId, null).paycheckSize() * multiplier);
|
||||||
playerStats.setStat("money", playerStats.getStat("money", Double.class) + payCheck);
|
playerStats.setStat("money", playerStats.getStat("money", Double.class) + payCheck);
|
||||||
player.sendMessage(ChatColor.GREEN + "You have received your paycheck: " + ChatColor.GOLD + Shared.formatNumber(payCheck));
|
player.sendMessage(ChatColor.GREEN + "You have received your paycheck: " + ChatColor.GOLD + Shared.formatNumber(payCheck));
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ public class PlayerStats {
|
||||||
Stats.put("autologin", PersistentDataType.BOOLEAN);
|
Stats.put("autologin", PersistentDataType.BOOLEAN);
|
||||||
Stats.put("prestige", PersistentDataType.INTEGER);
|
Stats.put("prestige", PersistentDataType.INTEGER);
|
||||||
Stats.put("prestigePoints", PersistentDataType.LONG);
|
Stats.put("prestigePoints", PersistentDataType.LONG);
|
||||||
StatNames = new Hashtable();
|
StatNames = new Hashtable<>();
|
||||||
StatNames.put("death_count", "Death Count");
|
StatNames.put("death_count", "Death Count");
|
||||||
StatNames.put("money", "Money");
|
StatNames.put("money", "Money");
|
||||||
StatNames.put("total_kill_count", "Total Kill Count");
|
StatNames.put("total_kill_count", "Total Kill Count");
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,12 @@ disabledDimensions: [ ]
|
||||||
forceDisableBroadcasts: false
|
forceDisableBroadcasts: false
|
||||||
bannedWords: [ ]
|
bannedWords: [ ]
|
||||||
enforceAuth: false
|
enforceAuth: false
|
||||||
|
market_gui_enabled: true
|
||||||
|
market_ripoff_multiplier: 10.0
|
||||||
|
market_min_price: 0.25
|
||||||
|
market_price_refresh_interval: 300
|
||||||
log_level: Info
|
log_level: Info
|
||||||
|
prestige_capability_autosell_price: 4
|
||||||
|
prestige_capability_magnet_price: 2
|
||||||
|
prestige_capability_veinminer_price: 3
|
||||||
|
prestige_capability_saturation_perk_price: 4
|
||||||
|
|
@ -1 +1 @@
|
||||||
0
|
${version}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue