Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei1058 committed Dec 10, 2023
1 parent f6928c4 commit 7fb15d7
Show file tree
Hide file tree
Showing 15 changed files with 522 additions and 6 deletions.
14 changes: 11 additions & 3 deletions bedwars-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-base</artifactId>
<version>23.2</version>
<version>23.12</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>dev.andrei1058.bedwars.common</groupId>
<artifactId>common-api</artifactId>
<version>23.12-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
Expand All @@ -71,8 +79,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<source>14</source>
<target>14</target>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@

package com.andrei1058.bedwars.api.arena;

import dev.andrei1058.bedwars.common.api.arena.GameStage;

public enum GameState {
waiting, starting, playing, restarting
waiting, starting, playing, restarting;


public GameStage toStage(IArena arena) {
return switch (this) {
case playing -> GameStage.IN_GAME;
case waiting -> GameStage.WAITING;
case starting -> GameStage.STARTING;
case restarting -> arena.getRestartingTask().getRestarting() > 7 ? GameStage.CELEBRATING : GameStage.STOPPING;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import com.andrei1058.bedwars.api.tasks.PlayingTask;
import com.andrei1058.bedwars.api.tasks.RestartingTask;
import com.andrei1058.bedwars.api.tasks.StartingTask;
import dev.andrei1058.bedwars.common.api.arena.DisplayableArena;
import dev.andrei1058.bedwars.common.api.arena.GameStage;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
Expand All @@ -42,7 +45,9 @@
import java.util.concurrent.ConcurrentHashMap;

@SuppressWarnings("unused")
public interface IArena {
public interface IArena extends DisplayableArena {

UUID getGameId();

/**
* Check if a player is spectating on this arena.
Expand Down Expand Up @@ -104,6 +109,7 @@ public interface IArena {
*
* @return A string with - and _ replaced by a space.
*/
@Deprecated
String getDisplayName();

/**
Expand All @@ -116,8 +122,14 @@ public interface IArena {
/**
* Get arena status.
*/
@Deprecated
GameState getStatus();

@Override
default GameStage getGameState() {
return getStatus().toStage(this);
}

/**
* Get players in arena.
*/
Expand Down Expand Up @@ -168,13 +180,34 @@ public interface IArena {
*/
boolean addPlayer(Player p, boolean skipOwnerCheck);

@Override
default boolean joinPlayer(Player player, boolean b) {
return addPlayer(player, b);
}

/**
* Add a player as Spectator
*
* @param p Player to be added
* @param playerBefore True if the player has played in this arena before and he died so now should be a spectator.
*/
boolean addSpectator(Player p, boolean playerBefore, Location staffTeleport);
boolean addSpectator(Player p, boolean playerBefore, @Nullable Location staffTeleport);

@Override
default boolean joinSpectator(Player player) {
return addSpectator(player, false, null);
}

@Override
default boolean joinSpectator(Player player, @Nullable String target) {
var targetPlayer = null == target ? null : Bukkit.getPlayerExact(target);
return addSpectator(player, false, null == targetPlayer ? null : targetPlayer.getLocation());
}

@Override
default boolean joinSpectator(Player player, @Nullable String target, boolean b) {
return joinSpectator(player, target);
}

/**
* Remove a player from the arena
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package dev.andrei1058.bedwars.api;

public class dsda {
}
30 changes: 30 additions & 0 deletions bedwars-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,32 @@
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>dev.andrei1058.bedwars.common</groupId>
<artifactId>common-api</artifactId>
<version>23.12-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>dev.andrei1058.bedwars.common</groupId>
<artifactId>common-impl</artifactId>
<version>23.12-SNAPSHOT</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.jalu</groupId>
<artifactId>configme</artifactId>
<version>1.4.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -375,6 +401,10 @@
<pattern>com.andrei1058.spigot.sidebarutils</pattern>
<shadedPattern>com.andrei1058.bedwars.libs.updater</shadedPattern>
</relocation>
<relocation>
<pattern>ch.jalu.configme</pattern>
<shadedPattern>com.andrei1058.bedwars.libs.configme</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import com.andrei1058.bedwars.lobbysocket.LoadedUsersCleaner;
import com.andrei1058.bedwars.lobbysocket.SendTask;
import com.andrei1058.bedwars.maprestore.internal.InternalAdapter;
import com.andrei1058.bedwars.messaging.SlaveMessagingService;
import com.andrei1058.bedwars.metrics.MetricsManager;
import com.andrei1058.bedwars.money.internal.MoneyListeners;
import com.andrei1058.bedwars.shop.ShopManager;
Expand All @@ -81,6 +82,7 @@
import com.andrei1058.bedwars.support.vipfeatures.VipListeners;
import com.andrei1058.vipfeatures.api.IVipFeatures;
import com.andrei1058.vipfeatures.api.MiniGameAlreadyRegistered;
import dev.andrei1058.bedwars.common.messaging.MessagingCommonManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
Expand Down Expand Up @@ -169,6 +171,9 @@ public void onLoad() {
return;
}

// Init messaging service (BedWarsProxy)
MessagingCommonManager.init(this);

api = new API();
Bukkit.getServicesManager().register(com.andrei1058.bedwars.api.BedWars.class, api, this, ServicePriority.Highest);

Expand Down Expand Up @@ -519,6 +524,9 @@ public void onEnable() {

// Warn user if current server version support is deprecated
this.performDeprecationCheck();

// When everything is ready, start heart beat (BedWarsProxy)
SlaveMessagingService.init();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import com.andrei1058.bedwars.support.paper.TeleportManager;
import com.andrei1058.bedwars.support.papi.SupportPAPI;
import com.andrei1058.bedwars.support.vault.WithEconomy;
import lombok.Getter;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.*;
Expand Down Expand Up @@ -180,6 +181,9 @@ public class Arena implements IArena {
private boolean allowMapBreak = false;
private @Nullable ITeam winner;

@Getter
private UUID gameId;

/**
* Load an arena.
* This will check if it was set up right.
Expand Down Expand Up @@ -277,6 +281,7 @@ public Arena(String name, Player p) {
return;
}
if (error) return;
gameId = UUID.randomUUID();
yKillHeight = yml.getInt(ConfigPath.ARENA_Y_LEVEL_KILL);
addToEnableQueue(this);
Language.saveIfNotExists(Messages.ARENA_DISPLAY_GROUP_PATH + getGroup().toLowerCase(), String.valueOf(getGroup().charAt(0)).toUpperCase() + group.substring(1).toLowerCase());
Expand Down Expand Up @@ -1336,6 +1341,12 @@ public String getDisplayName() {
: getConfig().getString(ConfigPath.ARENA_DISPLAY_NAME);
}

@Override
public String getDisplayName(org.intellij.lang.annotations.@Nullable Language language) {
// todo make me language supported
return getDisplayName();
}

@Override
public void setWorldName(String name) {
this.worldName = name;
Expand All @@ -1346,6 +1357,18 @@ public String getGroup() {
return group;
}

@Override
public void setGroup() {
// todo
throw new RuntimeException("NOT IMPLEMENTED YET");
}

@Override
public ItemStack getDisplayItem() {
// todo
throw new RuntimeException("NOT IMPLEMENTED YET");
}

@Override
public String getArenaName() {
return arenaName;
Expand Down Expand Up @@ -2470,6 +2493,11 @@ public String getWorldName() {
return worldName;
}

@Override
public String getTemplate() {
return worldName;
}

@Override
public int getRenderDistance() {
return renderDistance;
Expand Down Expand Up @@ -2703,4 +2731,69 @@ public boolean isTeamBed(Location location) {
public GameStatsHolder getStatsHolder() {
return gameStats;
}

@Override
public boolean isFull() {
return getPlayers().size() >= getMaxPlayers();
}

@Override
public String getSpectatePermission() {
// todo
// throw new RuntimeException("NOT IMPLEMENTED YET");
return null;
}

@Override
public boolean isPrivateGame() {
// todo
// throw new RuntimeException("NOT IMPLEMENTED YET!");
return false;
}

@Override
public void setPrivateGame() {
// todo
throw new RuntimeException("NOT IMPLEMENTED YET");
}

@Override
public void setPlayerHost(UUID uuid) {
// todo
throw new RuntimeException("NOT IMPLEMENTED YET");
}

@Override
public @Nullable UUID getPlayerHost() {
// todo
// throw new RuntimeException("NOT IMPLEMENTED YET");
return null;
}

@Override
public boolean isLocal() {
return true;
}

@Override
public int getCurrentVips() {
return (int) getPlayers().stream().filter(Arena::isVip).count();
}

@Override
public int getCurrentPlayers() {
return getPlayers().size();
}

@Override
public int getCurrentSpectators() {
return getSpectators().size();
}

@Override
public int getMinPlayers() {
return minPlayers;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

@Deprecated
public class ArenaListeners implements Listener {

@EventHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;

@Deprecated
public class ArenaSocket {

public static List<String> lobbies = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

@Deprecated
public class LoadedUser {

private static final long waitSeconds = BedWars.config.getYml().getLong(ConfigPath.GENERAL_CONFIGURATION_BUNGEE_OPTION_BWP_TIME_OUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.LinkedList;
import java.util.List;

@Deprecated
public class LoadedUsersCleaner implements Runnable {

private final List<LoadedUser> toRemove = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.List;

@Deprecated
public class SendTask {

/**
Expand Down
Loading

0 comments on commit 7fb15d7

Please sign in to comment.