Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
882aa12
Fixed inventory loss after tie with own equipment
szumielxd May 9, 2023
75ec0c4
Add damage check for timed out
rejomy Nov 15, 2023
9a57891
Boxing & Clear items & Tie commands
rejomy Jan 28, 2024
aef5eec
Improve boxing & Add sumo start move duration
rejomy Jan 28, 2024
2802765
Merge remote-tracking branch 'own-inventory-fix/own-inventory-fix'
rejomy Feb 3, 2024
cb596ab
Fixed inventory loss after tie with own equipment
szumielxd May 9, 2023
f1c332d
- Added minY.
rejomy Mar 3, 2024
47dede1
- Improve interact blocker
rejomy Mar 3, 2024
0d0b26d
- Improve interact blocker
rejomy Mar 3, 2024
124c6f6
- Improve boxing
rejomy Mar 3, 2024
6b9d6c3
- Improve potion handling
rejomy Mar 6, 2024
c033322
Add hunger check option.
rejomy Mar 19, 2024
337e40c
pre bedfight
rejomy Apr 27, 2024
e793eca
idk what
rejomy May 9, 2024
a453764
Remove instant kill bug
rejomy May 29, 2024
ba1ab2d
Add antirelog hook
rejomy May 29, 2024
ca4fe05
Fix interact with due commands while player is hide. (AntiCheatAdditi…
rejomy May 29, 2024
2799b46
Add auto kit select if kit no selected.
rejomy May 29, 2024
bbde363
Fix error when spectator is null
rejomy May 29, 2024
3affec6
Fix bug when player is quit from match
rejomy May 29, 2024
b355d18
Liquids fix
rejomy Aug 15, 2024
d3d0991
Liquids fix
rejomy Sep 13, 2024
1af9d57
dd
rejomy Sep 14, 2024
8ebc749
Fix sumo prevention move delay.
rejomy Sep 15, 2024
6d8ae85
Update dependencies
rejomy Oct 5, 2025
951185c
Correct option position in config.
rejomy Oct 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ subprojects {
repositories {
mavenCentral()

maven {
name = 'citizens-repo'
url = 'https://maven.citizensnpcs.co/repo'
}

maven {
name 'spigot-repo'
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
Expand All @@ -42,7 +47,6 @@ subprojects {
}

maven {
name 'clip-repo'
url 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}

Expand Down
2 changes: 1 addition & 1 deletion duels-api/src/main/java/me/realized/duels/api/Duels.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public interface Duels extends Plugin {
*/
@NotNull
DQueueManager getQueueManager();


/**
* Gets the QueueSignManager singleton used by Duels.
Expand Down
6 changes: 5 additions & 1 deletion duels-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ processResources {
}

dependencies {
compileOnly('net.citizensnpcs:citizens-main:2.0.33-SNAPSHOT') {
exclude group: '*', module: '*'
}
compileOnly 'org.jetbrains:annotations-java5:22.0.0'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
implementation 'org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT'
implementation 'com.mojang:authlib:1.5.21'
implementation 'me.clip:placeholderapi:2.11.1'
implementation 'me.clip:placeholderapi:2.11.6'
implementation 'com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT'
implementation ('net.essentialsx:EssentialsX:2.19.2') {
transitive = false
Expand All @@ -29,6 +32,7 @@ dependencies {
}
implementation name: 'Vault-1.6.7'
implementation name: 'CombatTagPlus'
implementation name: 'AntiRelog-3.0.11'
implementation name: 'PvPManager-3.7.16'
implementation name: 'Factions-1.6.9.5-U0.1.14'
implementation name: 'MassiveCore'
Expand Down
2 changes: 2 additions & 0 deletions duels-plugin/src/main/java/me/realized/duels/DuelsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import me.realized.duels.arena.ArenaManagerImpl;
import me.realized.duels.betting.BettingManager;
import me.realized.duels.command.commands.SpectateCommand;
import me.realized.duels.command.commands.bot.BotDuelCommand;
import me.realized.duels.command.commands.duel.DuelCommand;
import me.realized.duels.command.commands.duels.DuelsCommand;
import me.realized.duels.command.commands.queue.QueueCommand;
Expand Down Expand Up @@ -228,6 +229,7 @@ public void onDisable() {
private boolean load() {
registerCommands(
new DuelCommand(this),
new BotDuelCommand(this),
new QueueCommand(this),
new SpectateCommand(this),
new DuelsCommand(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public final class Permissions {

public static final String DUEL = "duels.duel";
public static final String DUEL_BOT = "duels.duel.bot";
public static final String STATS = "duels.stats";
public static final String STATS_OTHERS = STATS + ".others";
public static final String TOGGLE = "duels.toggle";
Expand Down
54 changes: 50 additions & 4 deletions duels-plugin/src/main/java/me/realized/duels/arena/ArenaImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
import me.realized.duels.util.inventory.ItemBuilder;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
Expand All @@ -45,7 +49,7 @@ public class ArenaImpl extends BaseButton implements Arena {
private final Map<Integer, Location> positions = new HashMap<>();
@Getter
private MatchImpl match;
@Getter(value = AccessLevel.PACKAGE)
@Getter
@Setter(value = AccessLevel.PACKAGE)
private Countdown countdown;
@Getter
Expand Down Expand Up @@ -164,6 +168,48 @@ public void endMatch(final UUID winner, final UUID loser, final Reason reason) {

final Queue source = match.getSource();
match.setFinished();

for(Block block : match.placedBlocks) {
block.setType(Material.AIR);
}

for(Map.Entry<Location, BlockData> map : match.brokenBlocks.entrySet()) {
map.getKey().getBlock().setBlockData(map.getValue());
}

for (Block block : match.liquids) {
Location loc = block.getLocation();
int radius = 1;

while (true) {
boolean waterFound = false;

for (int x = -radius; x <= radius; x++) {
for (int y = -radius; y <= radius; y++) {
for (int z = -radius; z <= radius; z++) {
Block findBlock = loc.clone().add(x, y, z).getBlock();
String type = findBlock.getType().name().toLowerCase();

if (type.contains("water") || type.contains("lava") || type.contains("cobblestone") || type.contains("obsidian")) {
waterFound = true;
findBlock.setType(Material.AIR);
}
}
}
}

if (!waterFound) {
break;
}

radius++;
}
}

if(config.isClearItemsAfterMatch()) {
match.droppedItems.forEach(Entity::remove);
}

match = null;

if (source != null) {
Expand Down Expand Up @@ -192,18 +238,18 @@ boolean isCounting() {
@Override
public boolean has(@NotNull final Player player) {
Objects.requireNonNull(player, "player");
return isUsed() && !match.getPlayerMap().getOrDefault(player, true);
return isUsed() && !match.getPlayerMap().getOrDefault(player, new MatchImpl.PlayerStatus(true)).isDead;
}

public void add(final Player player) {
if (isUsed()) {
match.getPlayerMap().put(player, false);
match.getPlayerMap().put(player, new MatchImpl.PlayerStatus(false));
}
}

public void remove(final Player player) {
if (isUsed() && match.getPlayerMap().containsKey(player)) {
match.getPlayerMap().put(player, true);
match.getPlayerMap().put(player, new MatchImpl.PlayerStatus(true));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.projectiles.ProjectileSource;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -230,19 +234,22 @@ public void clearBinds(final KitImpl kit) {

private class ArenaListener implements Listener {

@EventHandler(ignoreCancelled = true)
@EventHandler
public void on(final PlayerInteractEvent event) {
if (!event.hasBlock() || !config.isPreventInteract()) {
if(event.getAction() != Action.RIGHT_CLICK_AIR && event.isCancelled() || !config.isPreventInteract()) {
return;
}

final ArenaImpl arena = get(event.getPlayer());
Player player = event.getPlayer();

final ArenaImpl arena = get(player);

if (arena == null || !arena.isCounting()) {
return;
}

event.setCancelled(true);
player.updateInventory();
}

@EventHandler(ignoreCancelled = true)
Expand Down Expand Up @@ -274,7 +281,7 @@ public void on(final ProjectileLaunchEvent event) {

final ArenaImpl arena = get((Player) shooter);

if (arena == null || !arena.isCounting()) {
if (arena == null || !arena.isCounting() || event.getEntity().getClass().getName().contains("Potion")) {
return;
}

Expand All @@ -283,20 +290,29 @@ public void on(final ProjectileLaunchEvent event) {

@EventHandler(ignoreCancelled = true)
public void on(final PlayerMoveEvent event) {
final Location to = event.getTo();

if (!config.isPreventMovement()) {
return;
}

final Location from = event.getFrom();
final Location to = event.getTo();

if (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ()) {
return;
}

final ArenaImpl arena = get(event.getPlayer());

if (arena == null || !arena.isCounting()) {
if (arena == null) {
return;
}

if(to.getBlockY() < config.getMinY()) {
event.getPlayer().damage(99999);
}

if(!arena.isCounting()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class Countdown extends BukkitRunnable {

@Override
public void run() {
if (finished) {
return;
}
if (finished) return;

final String rawMessage = messages.remove(0);
final String message = StringUtil.color(rawMessage);
Expand All @@ -44,7 +42,7 @@ public void run() {
arena.getPlayers().forEach(player -> {
config.playSound(player, rawMessage);

final Pair<String, Integer> info = this.info.get(player.getUniqueId());
final Pair<String, Integer> info = this.info.get(player.getUniqueId());

if (info != null) {
player.sendMessage(message
Expand Down
72 changes: 60 additions & 12 deletions duels-plugin/src/main/java/me/realized/duels/arena/MatchImpl.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
package me.realized.duels.arena;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import lombok.Getter;
import me.realized.duels.api.match.Match;
import me.realized.duels.kit.KitImpl;
import me.realized.duels.queue.Queue;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

public class MatchImpl implements Match {

public static class PlayerStatus {

public PlayerStatus(boolean isDead) {
this.isDead = isDead;
}

// Player is dead value
public boolean isDead;
// How much damage to your opponent.
public double damageCount;

public int hits;

}

@Getter
private final ArenaImpl arena;
@Getter
Expand All @@ -35,8 +48,13 @@ public class MatchImpl implements Match {
@Getter
private boolean finished;

public List<Item> droppedItems = new ArrayList<>();
public List<Block> placedBlocks = new ArrayList<>();
public List<Block> liquids = new ArrayList<>();
public HashMap<Location, BlockData> brokenBlocks = new HashMap<>();

// Default value for players is false, which is set to true if player is killed in the match.
private final Map<Player, Boolean> players = new HashMap<>();
private final Map<Player, PlayerStatus> players = new HashMap<>();

MatchImpl(final ArenaImpl arena, final KitImpl kit, final Map<UUID, List<ItemStack>> items, final int bet, final Queue source) {
this.arena = arena;
Expand All @@ -47,20 +65,50 @@ public class MatchImpl implements Match {
this.source = source;
}

Map<Player, Boolean> getPlayerMap() {
Map<Player, PlayerStatus> getPlayerMap() {
return players;
}

Set<Player> getAlivePlayers() {
return players.entrySet().stream().filter(entry -> !entry.getValue()).map(Entry::getKey).collect(Collectors.toSet());
return players.entrySet().stream().filter(entry -> !entry.getValue().isDead).map(Entry::getKey).collect(Collectors.toSet());
}

public void addDamageToPlayer(Player player, double damage) {
PlayerStatus status = players.get(player);
status.damageCount += damage;
status.hits++;
}

public int getHits(Player player) {
return players.get(player).hits;
}

public Player getWinnerOfDamage() {
Player winner = players.entrySet()
.stream()
.max(Comparator.comparingDouble(entry -> entry.getValue().damageCount))
.map(Map.Entry::getKey)
.orElse(null);

return winner;
}

public Player getLooserOfDamage() {
Player looser = players.entrySet()
.stream()
.min(Comparator.comparingDouble(entry -> entry.getValue().damageCount))
.map(Map.Entry::getKey)
.orElse(null);

return looser;
}

public Set<Player> getAllPlayers() {
return players.keySet();
}

public boolean isDead(final Player player) {
return players.getOrDefault(player, true);
return players.getOrDefault(player, new PlayerStatus(true)).isDead;
}

public boolean isFromQueue() {
Expand Down
Loading