Skip to content

Commit

Permalink
Merge pull request #30 from Grzybol/UPDATE-4.0
Browse files Browse the repository at this point in the history
WorldGuard!
  • Loading branch information
Grzybol authored Apr 4, 2024
2 parents 5f45117 + 1df94c6 commit 97ca72e
Show file tree
Hide file tree
Showing 9 changed files with 312 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>betterbox.mine.game</groupId>
<artifactId>BetterElo</artifactId>
<version>3.2.73-SNAPSHOT</version>
<version>4.0.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BetterElo</name>
Expand Down Expand Up @@ -106,6 +106,10 @@
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -137,5 +141,20 @@
<version>2.11.4</version>
<scope>provided</scope>
</dependency>
<!-- WorldEdit -->
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.0</version> <!-- Zaktualizuj do wersji kompatybilnej z Twoim serwerem -->
<scope>provided</scope>
</dependency>

<!-- WorldGuard -->
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.4</version> <!-- Zaktualizuj do wersji kompatybilnej z Twoim serwerem -->
<scope>provided</scope>
</dependency>
</dependencies>
</project>
27 changes: 26 additions & 1 deletion src/main/java/betterbox/mine/game/betterelo/BetterElo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package betterbox.mine.game.betterelo;

import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.Flags;
import me.clip.placeholderapi.libs.kyori.adventure.platform.facet.Facet;
import org.bukkit.*;
import org.bukkit.configuration.file.FileConfiguration;
Expand All @@ -12,12 +14,18 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;

import java.io.Console;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
public final class BetterElo extends JavaPlugin {
private PluginLogger pluginLogger;
private DataManager dataManager;
Expand All @@ -38,6 +46,22 @@ public final class BetterElo extends JavaPlugin {
private ExtendedConfigManager configManager;
public Map<String, Boolean> rewardStates = new HashMap<>();
public boolean useHolographicDisplays;
//public static final Flag<StateFlag.State> NO_ELO_FLAG = new StateFlag("noElo", false);
public static StateFlag IS_ELO_ALLOWED;
@Override
public void onLoad() {
getLogger().info("Registering custom WorldGuard flags.");
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
try {
StateFlag allowElo = new StateFlag("allowElo", false);
registry.register(allowElo);
IS_ELO_ALLOWED = allowElo; // only set our field if there was no error
getLogger().info("Custom WorldGuard flags registered.");
} catch (Exception e) {
getLogger().info("NoElo flag registration exception: " + e);
}
}

@Override
public void onEnable() {
// Inicjalizacja PluginLoggera
Expand Down Expand Up @@ -131,7 +155,9 @@ public void onEnable() {
}



}

@Override
public void onDisable() {
pluginLogger.log(PluginLogger.LogLevel.DEBUG,"BetterElo: onDisable: Zapisywanie danych przed wyłączeniem pluginu...");
Expand Down Expand Up @@ -409,7 +435,6 @@ public void rewardTopPlayers(String rewardType) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "BetterElo: rewardTopPlayers: Saving the event ranking");
dataManager.saveDataToFileEvent();
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "BetterElo: rewardTopPlayers: Resetting the event ranking timer");
//updateLastScheduledTime(rewardType);
break;
}
}
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,33 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

case 3:

if ((sender.hasPermission("betterelo.flamethrower") || sender.isOp()) && sender instanceof Player && Objects.equals(args[0], "flamethrower")) {
Player player = ((Player) sender).getPlayer();
assert player != null;
ItemStack itemInHand = player.getInventory().getItemInMainHand();
if (itemInHand.getType().isAir()) {
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED + "You must hold an item in your hand to add Antyweb lore!");
return true;
}
int radius;
int distance;
try {
// Spróbuj przekonwertować argument na liczbę
radius = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED +"Invalid radius! Please provide a number.");
return true;
}
try {
// Spróbuj przekonwertować argument na liczbę
distance = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED +"Invalid radius! Please provide a number.");
return true;
}
addFlamethrowerLore(player, itemInHand, radius, distance);
}
if (sender.isOp()&& Objects.equals(args[0], "holo")&& Objects.equals(args[1], "delete")&&args[2].equals("event")){
hologramEvent.delete();
//hologramEvent.isDeleted();
Expand Down Expand Up @@ -643,6 +670,22 @@ public void addAntywebLore(Player player, ItemStack itemStack, int radius) {
itemStack.setItemMeta(itemMeta);
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Added Antyweb lore with radius "+radius);

}
public void addFlamethrowerLore(Player player, ItemStack itemStack, int radius, int distance) {
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null) {
return; // Przerwij, jeśli nie można pobrać metadanych przedmiotu
}
String antywebLore = ChatColor.GOLD + "" + ChatColor.BOLD + "Flamethrower " + radius+"/"+distance;
List<String> lore = itemMeta.getLore();
if (lore == null) {
lore = new ArrayList<>();
}
lore.add(antywebLore);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Added Antyweb lore with radius "+radius);

}
public void addElytraLore(Player player, ItemStack itemStack) {
ItemMeta itemMeta = itemStack.getItemMeta();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ public void CheckCheatersFromBetterRanks() {

FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
Set<String> playerNames = config.getKeys(false);
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "BetterRanksCheaters: CheckCheatersFromBetterRanks checking..");
pluginLogger.log(PluginLogger.LogLevel.CHEATERS, "BetterRanksCheaters: CheckCheatersFromBetterRanks checking..");
cheatersList.clear();
for (String playerName : playerNames) {
String rank = config.getString(playerName + ".rank");
if (rank != null && rank.equalsIgnoreCase("CHEATER")) {
cheatersList.add(playerName);
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "BetterRanksCheaters: CheckCheatersFromBetterRanks: adding cheater " + playerName);
pluginLogger.log(PluginLogger.LogLevel.CHEATERS, "BetterRanksCheaters: CheckCheatersFromBetterRanks: adding cheater " + playerName);
}
}
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "BetterRanksCheaters: CheckCheatersFromBetterRanks: Cheaters found: " + cheatersList);
pluginLogger.log(PluginLogger.LogLevel.CHEATERS, "BetterRanksCheaters: CheckCheatersFromBetterRanks: Cheaters found: " + cheatersList);
}

public List<String> getCheatersList() {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "BetterRanksCheaters: getCheatersList called");
pluginLogger.log(PluginLogger.LogLevel.CHEATERS, "BetterRanksCheaters: getCheatersList called");
return cheatersList;
}
}
Loading

0 comments on commit 97ca72e

Please sign in to comment.