diff --git a/pom.xml b/pom.xml
index 4db056d..9a04426 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
betterbox.mine.game
BetterElo
- 4.3.9-SNAPSHOT
+ 4.3.15-SNAPSHOT
jar
BetterElo
diff --git a/src/main/java/betterbox/mine/game/betterelo/BetterElo.java b/src/main/java/betterbox/mine/game/betterelo/BetterElo.java
index 2807005..48c511b 100644
--- a/src/main/java/betterbox/mine/game/betterelo/BetterElo.java
+++ b/src/main/java/betterbox/mine/game/betterelo/BetterElo.java
@@ -136,11 +136,11 @@ public void onEnable() {
rewardStates.put("monthly", true);
// Inicjalizacja nagród i ich harmonogramów (kod z metody onEnable z klasy RewardManager)
loadRewards();
- pluginLogger.log(PluginLogger.LogLevel.DEBUG,"BetterElo: onEnable: Planowanie nagród dziennych...");
+ pluginLogger.log(PluginLogger.LogLevel.INFO,"Scheduling daily ranking rewards...");
scheduleRewards("daily", TimeUnit.DAYS.toMillis(1), false);
- pluginLogger.log(PluginLogger.LogLevel.DEBUG,"BetterElo: onEnable: Planowanie nagród tygodniowych...");
+ pluginLogger.log(PluginLogger.LogLevel.INFO,"Scheduling weekly ranking rewards...");
scheduleRewards("weekly", TimeUnit.DAYS.toMillis(7), false);
- pluginLogger.log(PluginLogger.LogLevel.DEBUG,"BetterElo: onEnable: Planowanie nagród miesięcznych...");
+ pluginLogger.log(PluginLogger.LogLevel.INFO,"Scheduling monthly ranking rewards...");
scheduleRewards("monthly", 0, true);
File dataFolder = this.getDataFolder();
@@ -346,35 +346,39 @@ public void scheduleRewards(String period, long periodMillis, boolean useNextMon
FileConfiguration config = getConfig();
long lastScheduledTime = config.getLong(period + "LastScheduledTime", System.currentTimeMillis());
long delay;
- pluginLogger.log(PluginLogger.LogLevel.DEBUG, "BetterElo: scheduleRewards: period: "+period+" periodMillis: "+periodMillis+" LastScheduledTime: "+lastScheduledTime);
- if (useNextMonthTime) {
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeInMillis(lastScheduledTime);
- calendar.add(Calendar.MONTH, 1);
- delay = (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000 * 20;
- } else {
- delay = (periodMillis - (System.currentTimeMillis() - lastScheduledTime)) / 1000 * 20;
- }
+ try{
+ pluginLogger.log(PluginLogger.LogLevel.RANKING_REWARDS, "BetterElo: scheduleRewards: period: " + period + " periodMillis: " + periodMillis + " LastScheduledTime: " + lastScheduledTime);
+ if (useNextMonthTime) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(lastScheduledTime);
+ calendar.add(Calendar.MONTH, 1);
+ delay = (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000 * 20;
+ } else {
+ delay = (periodMillis - (System.currentTimeMillis() - lastScheduledTime)) / 1000 * 20;
+ }
- pluginLogger.log(PluginLogger.LogLevel.DEBUG, "BetterElo: scheduleRewards: period: "+period+" periodMillis: "+periodMillis+" Computed delay: " + delay);
+ pluginLogger.log(PluginLogger.LogLevel.RANKING_REWARDS, "BetterElo: scheduleRewards: period: " + period + " periodMillis: " + periodMillis + " Computed delay: " + delay);
- if (delay < 0) {
- pluginLogger.log(PluginLogger.LogLevel.DEBUG, "BetterElo: scheduleRewards: Negative delay detected, starting rewardAndReschedule");
- rewardAndReschedule(period, periodMillis, useNextMonthTime);
- pluginLogger.log(PluginLogger.LogLevel.DEBUG, "BetterElo: scheduleRewards: BukkitRunnable: rewardAndReschedule done");
- return;
- }
- //saveConfig();
- new BukkitRunnable() {
- @Override
- public void run() {
- if (rewardStates.get(period)) {
- pluginLogger.log(PluginLogger.LogLevel.DEBUG, "BetterElo: scheduleRewards: BukkitRunnable: starting rewardAndReschedule");
- rewardAndReschedule(period, periodMillis, useNextMonthTime);
- pluginLogger.log(PluginLogger.LogLevel.DEBUG, "BetterElo: scheduleRewards: BukkitRunnable: rewardAndReschedule done");
- }
+ if (delay < 0) {
+ pluginLogger.log(PluginLogger.LogLevel.RANKING_REWARDS, "BetterElo: scheduleRewards: Negative delay detected, starting rewardAndReschedule");
+ rewardAndReschedule(period, periodMillis, useNextMonthTime);
+ pluginLogger.log(PluginLogger.LogLevel.INFO, "Ranking "+period+" has finished!");
+ return;
}
- }.runTaskLater(this, delay);
+ //saveConfig();
+ new BukkitRunnable() {
+ @Override
+ public void run() {
+ if (rewardStates.get(period)) {
+ pluginLogger.log(PluginLogger.LogLevel.RANKING_REWARDS, "BetterElo: scheduleRewards: BukkitRunnable: starting rewardAndReschedule");
+ rewardAndReschedule(period, periodMillis, useNextMonthTime);
+ pluginLogger.log(PluginLogger.LogLevel.RANKING_REWARDS, "BetterElo: scheduleRewards: BukkitRunnable: rewardAndReschedule done");
+ }
+ }
+ }.runTaskLater(this, delay);
+ }catch (Exception e){
+ pluginLogger.log(PluginLogger.LogLevel.ERROR, "BetterElo: scheduleRewards exception: "+e.getMessage());
+ }
}
public void stopEvent(){
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "BetterElo.stopEvent called");
diff --git a/src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java b/src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java
index 26bdc1c..781a85f 100644
--- a/src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java
+++ b/src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java
@@ -76,6 +76,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
case "reroll":
if(sender.isOp() || sender.hasPermission("betterelo.reroll")) {
handleRerollCommand(sender);
+ }else{
+ noPermission(sender);
}
break;
case "killallmobs":
@@ -843,5 +845,8 @@ public void handleAddSpawnerCommand(CommandSender sender, String spawnerName, St
pluginLogger.log(PluginLogger.LogLevel.WARNING, "BetterEloCommand:handleAddSpawnerCommand this is only-player command!");
}
}
+ private void noPermission(CommandSender sender){
+ sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED + " You don't have permission to use that command");
+ }
}
diff --git a/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java b/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java
index ff8e59a..1f7a6ee 100644
--- a/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java
+++ b/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java
@@ -179,7 +179,7 @@ public static String dropAverageDamage() {
// Używamy funkcji wykładniczej do zmniejszenia prawdopodobieństwa wyższych wartości
double x = -Math.log(random.nextDouble()) / 10.0; // Dostosuj parametr 10.0, aby zmienić rozkład
//double y = random.
- int bonus = (int) Math.round(x * 40); // Skalowanie wyniku
+ int bonus = (int) Math.round(x * 60); // Skalowanie wyniku
// Ograniczamy wartość bonusu do maksymalnie 60%
bonus = Math.min(bonus, 60);
diff --git a/src/main/java/betterbox/mine/game/betterelo/Event.java b/src/main/java/betterbox/mine/game/betterelo/Event.java
index dd20961..541375a 100644
--- a/src/main/java/betterbox/mine/game/betterelo/Event.java
+++ b/src/main/java/betterbox/mine/game/betterelo/Event.java
@@ -1242,6 +1242,11 @@ public boolean isValidAverageDamage (ArrayList equippedItems){
}
@EventHandler(priority = EventPriority.LOW)
public void onInventoryClick(InventoryClickEvent event) {
+ Player player = (Player) event.getWhoClicked();
+ if (player.hasMetadata("avgDmgRerolled")) {
+ pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick avgDmgRerolled event already handled!");
+ return;
+ }
if(event.getCurrentItem()==null){
return;
}
@@ -1250,7 +1255,7 @@ public void onInventoryClick(InventoryClickEvent event) {
event.setCancelled(true);
}
- Player player = (Player) event.getWhoClicked();
+
ItemStack currentItem = event.getCurrentItem();
Inventory playerInventory = player.getInventory();
ItemStack[] savedInventory = playerInventory.getContents();
@@ -1340,6 +1345,7 @@ public void onInventoryClick(InventoryClickEvent event) {
Inventory inventory = event.getInventory();
ItemStack item0 = inventory.getItem(3);
if (item0 != null && item0.hasItemMeta()) {
+
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick reroll, item0: "+item0+", item0.hasItemMeta(): "+item0.hasItemMeta());
ItemMeta meta0 = item0.getItemMeta();
boolean slot0Condition = meta0.getLore().stream().anyMatch(line -> line.contains("Average Damage"));
@@ -1357,6 +1363,13 @@ public void onInventoryClick(InventoryClickEvent event) {
if( guiManager.checkAndRemoveBetterCoins(player)) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick reroll, player paid, re-rolling..." );
lore.set(i, customMobs.dropAverageDamage());
+ player.setMetadata("avgDmgRerolled", new FixedMetadataValue(plugin, true));
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ @Override
+ public void run() {
+ player.removeMetadata("avgDmgRerolled", plugin);
+ }
+ }, 1L);
break;
}
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick reroll, player has no money for the re-roll." );
@@ -1384,9 +1397,9 @@ public void onInventoryClose(InventoryCloseEvent event) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Checking items in closed GUI");
ItemStack itemInSlot0 = closedInventory.getItem(3);
- if (itemInSlot0 != null && itemInSlot0.hasItemMeta()) {
+ if (itemInSlot0 != null) {
ItemMeta meta = itemInSlot0.getItemMeta();
- if (meta.getLore().stream().anyMatch(line -> line.contains("Average Damage"))) {
+ //if (meta.getLore().stream().anyMatch(line -> line.contains("Average Damage"))) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Item with 'Average damage' found in slot 0");
// Optional: Directly give back the item to the player's inventory
@@ -1400,7 +1413,7 @@ public void onInventoryClose(InventoryCloseEvent event) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Inventory full, item dropped at player's location");
closedInventory.clear(3); // Clear the slot
}
- }
+ //}
}
}
}
diff --git a/src/main/java/betterbox/mine/game/betterelo/PluginLogger.java b/src/main/java/betterbox/mine/game/betterelo/PluginLogger.java
index bbf85fc..1a06a32 100644
--- a/src/main/java/betterbox/mine/game/betterelo/PluginLogger.java
+++ b/src/main/java/betterbox/mine/game/betterelo/PluginLogger.java
@@ -20,7 +20,7 @@ public class PluginLogger {
// Enumeracja dla poziomów logowania
public enum LogLevel {
- INFO, WARNING, ERROR,CUSTOM_MOBS, DEBUG, DEBUG_LVL2, DEBUG_LVL3,DEBUG_LVL4,CHEATERS ,FLAMETHROWER,DROP,SPAWNERS, ZEPHYR, KILL_EVENT, COMMAND, PLACEHOLDER, BLOCK_BREAK, BLOCK_PLACE, PLAYER_INTERACT, ELYTRA_CHECK, ANTYWEB
+ INFO, WARNING, ERROR,CUSTOM_MOBS, DEBUG, DEBUG_LVL2, DEBUG_LVL3,DEBUG_LVL4,CHEATERS, RANKING_REWARDS ,FLAMETHROWER,DROP,SPAWNERS, ZEPHYR, KILL_EVENT, COMMAND, PLACEHOLDER, BLOCK_BREAK, BLOCK_PLACE, PLAYER_INTERACT, ELYTRA_CHECK, ANTYWEB
}
public PluginLogger(String folderPath, Set enabledLogLevels, JavaPlugin plugin) {
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 9949825..e06a806 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -94,5 +94,9 @@ permissions:
betterelo.flamethrower:
description: flamethrower
default: op
+ betterelo.reroll:
+ description: Grants access to /be reroll
+ default: op
+