Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.andrei1058.bedwars</groupId>
<artifactId>proxy</artifactId>
<version>1.2.5</version>
<version>1.2.6</version>
<modules>
<module>proxy-api</module>
<module>proxy-plugin</module>
Expand All @@ -23,10 +23,10 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/releases/</url>
</repository>
</repositories>

<build>
Expand Down
2 changes: 1 addition & 1 deletion proxy-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>proxy</artifactId>
<groupId>com.andrei1058.bedwars</groupId>
<version>1.2.5</version>
<version>1.2.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
82 changes: 73 additions & 9 deletions proxy-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>proxy</artifactId>
<groupId>com.andrei1058.bedwars</groupId>
<version>1.2.5</version>
<version>1.2.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -37,13 +37,17 @@
<id>andrei1058-repo2</id>
<url>https://repo.andrei1058.dev/snapshots/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -73,7 +77,7 @@
<dependency>
<groupId>com.andrei1058.spigot.versionsupport</groupId>
<artifactId>itemstack-version</artifactId>
<version>1.6.3</version>
<version>1.7.1-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand All @@ -85,7 +89,7 @@
<dependency>
<groupId>com.andrei1058.spigot.versionsupport</groupId>
<artifactId>sounds-version</artifactId>
<version>1.6.3</version>
<version>1.7.1-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand All @@ -97,7 +101,7 @@
<dependency>
<groupId>com.andrei1058.spigot.versionsupport</groupId>
<artifactId>material-version</artifactId>
<version>1.6.3</version>
<version>1.7.1-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand All @@ -109,7 +113,7 @@
<dependency>
<groupId>com.andrei1058.spigot.versionsupport</groupId>
<artifactId>block-version</artifactId>
<version>1.6.3</version>
<version>1.7.1-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -166,6 +170,45 @@
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<!-- MockBukkit for different Minecraft versions -->
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.16</artifactId>
<version>1.5.2</version>
<scope>test</scope>
</dependency>
<!-- Mockito for mocking -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
Expand All @@ -184,10 +227,21 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<testSource>1.8</testSource>
<testTarget>1.8</testTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M2</version>
<version>3.1.3</version>
<configuration>
<skip>true</skip>
</configuration>
Expand All @@ -203,7 +257,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.1-SNAPSHOT</version>
<version>3.6.0</version>
<configuration>
<relocations>
<relocation>
Expand All @@ -225,6 +279,16 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.andrei1058.bedwars.proxy;

import com.andrei1058.bedwars.proxy.api.BedWars;
import com.andrei1058.bedwars.proxy.arenamanager.ArenaManager;
import com.andrei1058.bedwars.proxy.arenamanager.ArenaSelectorListener;
import com.andrei1058.bedwars.proxy.arenasign.SignManager;
import com.andrei1058.bedwars.proxy.command.RejoinCommand;
Expand All @@ -20,10 +19,7 @@
import com.andrei1058.bedwars.proxy.socketmanager.ServerSocketTask;
import com.andrei1058.bedwars.proxy.socketmanager.TimeOutTask;
import com.andrei1058.bedwars.proxy.support.papi.SupportPAPI;
import com.andrei1058.spigot.versionsupport.BlockSupport;
import com.andrei1058.spigot.versionsupport.ItemStackSupport;
import com.andrei1058.spigot.versionsupport.MaterialSupport;
import com.andrei1058.spigot.versionsupport.SoundSupport;
import com.andrei1058.spigot.versionsupport.*;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
Expand Down Expand Up @@ -71,6 +67,10 @@ public void onEnable() {
blockAdapter = BlockSupport.SupportBuilder.load();
itemAdapter = ItemStackSupport.SupportBuilder.load();

if (null == soundAdapter) {
soundAdapter = new sound_v1_18_R1();
}

LanguageManager.init();
config = new BedWarsConfig();
if (config.getBoolean("database.enable")) {
Expand Down
2 changes: 1 addition & 1 deletion proxy-plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: BedWarsProxy
version: ${gitVer}${project.version}
version: 1.2.4
description: Arena connecter for BedWars1058
main: com.andrei1058.bedwars.proxy.BedWarsProxy
author: andrei1058
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package com.andrei1058.bedwars.proxy.test;

import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock;
import be.seeseemelk.mockbukkit.entity.PlayerMock;
import com.andrei1058.bedwars.proxy.BedWarsProxy;
import com.andrei1058.bedwars.proxy.api.BedWars;
import com.andrei1058.bedwars.proxy.api.Language;
import com.andrei1058.bedwars.proxy.configuration.ConfigPath;
import com.andrei1058.bedwars.proxy.language.LanguageManager;
import com.andrei1058.bedwars.proxy.party.Party;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.util.UUID;

import static org.junit.jupiter.api.Assertions.*;

/**
* Tests for BedWarsProxy plugin functionality.
* These tests verify that the plugin's features work correctly.
*/
public class BedWarsProxyFunctionalityTest extends BedWarsProxyTestBase {

@Test
@DisplayName("Test language system")
public void testLanguageSystem() {
// Get the default language
Language defaultLang = LanguageManager.get().getDefaultLanguage();
assertNotNull(defaultLang, "Default language should not be null");

// Test getting a message
String message = defaultLang.getMsg(ConfigPath.GENERAL_CONFIGURATION_DISABLED_LANGUAGES);
assertNotNull(message, "Should be able to get a message from the language file");
assertFalse(message.isEmpty(), "Message should not be empty");

// Test language for a player
PlayerMock player = server.addPlayer();
Language playerLang = LanguageManager.get().getPlayerLanguage(player);
assertNotNull(playerLang, "Player language should not be null");
assertEquals(defaultLang, playerLang, "New player should have default language");
}

@Test
@DisplayName("Test party system")
public void testPartySystem() {
// Get the party system
Party party = BedWarsProxy.getParty();
assertNotNull(party, "Party system should not be null");

// Create test players
PlayerMock leader = server.addPlayer();
PlayerMock member1 = server.addPlayer();
PlayerMock member2 = server.addPlayer();

// Test creating a party
party.createParty(leader);
assertTrue(party.hasParty(leader.getUniqueId()), "Leader should be in a party");
assertTrue(party.isOwner(leader.getUniqueId()), "Leader should be the party owner");

// Test adding members
party.addMember(leader.getUniqueId(), member1);
assertTrue(party.hasParty(member1.getUniqueId()), "Member should be in a party");
assertFalse(party.isOwner(member1.getUniqueId()), "Member should not be the party owner");

party.addMember(leader.getUniqueId(), member2);
assertTrue(party.hasParty(member2.getUniqueId()), "Member should be in a party");

// Test getting party members
assertTrue(party.getMembers(leader.getUniqueId()).contains(member1.getUniqueId()), "Party should contain member1");
assertTrue(party.getMembers(leader.getUniqueId()).contains(member2.getUniqueId()), "Party should contain member2");

// Test removing members
party.removeFromParty(member1.getUniqueId());
assertFalse(party.hasParty(member1.getUniqueId()), "Member should no longer be in a party");
assertTrue(party.hasParty(member2.getUniqueId()), "Other member should still be in the party");

// Test disbanding party
party.disband(leader.getUniqueId());
assertFalse(party.hasParty(leader.getUniqueId()), "Leader should no longer be in a party");
assertFalse(party.hasParty(member2.getUniqueId()), "Member should no longer be in a party");
}

@Test
@DisplayName("Test stats cache")
public void testStatsCache() {
// Get the stats cache
assertNotNull(BedWarsProxy.getStatsCache(), "Stats cache should not be null");

// Create a test player
PlayerMock player = server.addPlayer();

// Test initial stats
assertEquals(0, BedWarsProxy.getStatsCache().getPlayerWins(player.getUniqueId()), "New player should have 0 wins");
assertEquals(0, BedWarsProxy.getStatsCache().getPlayerKills(player.getUniqueId()), "New player should have 0 kills");
assertEquals(0, BedWarsProxy.getStatsCache().getPlayerFinalKills(player.getUniqueId()), "New player should have 0 final kills");
assertEquals(0, BedWarsProxy.getStatsCache().getPlayerLoses(player.getUniqueId()), "New player should have 0 losses");
assertEquals(0, BedWarsProxy.getStatsCache().getPlayerDeaths(player.getUniqueId()), "New player should have 0 deaths");
assertEquals(0, BedWarsProxy.getStatsCache().getPlayerBedsDestroyed(player.getUniqueId()), "New player should have 0 beds destroyed");
assertEquals(0, BedWarsProxy.getStatsCache().getPlayerGamesPlayed(player.getUniqueId()), "New player should have 0 games played");
}

@Test
@DisplayName("Test version support adapters")
public void testVersionSupportAdapters() {
// Test sound adapter
assertNotNull(BedWarsProxy.getSoundAdapter(), "Sound adapter should not be null");

// Test material adapter
assertNotNull(BedWarsProxy.getMaterialAdapter(), "Material adapter should not be null");

// Test block adapter
assertNotNull(BedWarsProxy.getBlockAdapter(), "Block adapter should not be null");

// Test item adapter
assertNotNull(BedWarsProxy.getItemAdapter(), "Item adapter should not be null");
}
}
Loading