Work has been done
This commit is contained in:
parent
6113228196
commit
6c4776f88a
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,2 +1,8 @@
|
||||
# LetThemEatCake
|
||||
|
||||
## Game concept
|
||||
|
||||
### Goal
|
||||
- Idea 1 - As you kill people, you gain their points, for each hit you gain points based on damage dealt and distance for bow shots. Winner is the person with the most points after 1 minute.
|
||||
- Idea 2 - Center monument with a cake at the top, winner is the one who eats the most cake?
|
||||
- Idea 3 - As you kill people, you give them your points, for each hit, the person hit gains points based on damage and distance, person with the most points gets decapitated during an end game show? Winner is the person with the least points.
|
||||
|
@ -48,4 +48,4 @@ processResources {
|
||||
filesMatching('plugin.yml') {
|
||||
expand props
|
||||
}
|
||||
}
|
||||
}
|
76
src/main/java/org/lunamc/letthemeatcake/Game.java
Normal file
76
src/main/java/org/lunamc/letthemeatcake/Game.java
Normal file
@ -0,0 +1,76 @@
|
||||
package org.lunamc.letthemeatcake;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Game {
|
||||
private JavaPlugin plugin;
|
||||
private boolean openStatus;
|
||||
private List<Player> players;
|
||||
|
||||
public Game(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
openStatus = true;
|
||||
players = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds player to the game queue
|
||||
* @param player player that will join the game queue
|
||||
* @return 0 if the player has been added, 1 if the game is full
|
||||
*/
|
||||
public int addPlayer(Player player) {
|
||||
players.add(player);
|
||||
if (players.size() == 8) {
|
||||
openStatus = false;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple players to the game queue
|
||||
* @param players array of players to be added
|
||||
* @return 0 if the players have been added, 1 if the game is full, or 2 if the players have been added AND the queue is full (use to trigger start early)
|
||||
*/
|
||||
public int addPlayers(Player ... players) {
|
||||
if (players.length <= (8 - this.players.size())) {
|
||||
this.players.addAll(List.of(players));
|
||||
if (this.players.size() == 8) {
|
||||
openStatus = false;
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple players to the game queue
|
||||
* @param players array of players to be added
|
||||
* @return 0 if the players have been added, 1 if the game is full, or 2 if the players have been added AND the queue is full (use to trigger start early)
|
||||
*/
|
||||
public int addPlayers(List<Player> players) {
|
||||
if (players.size() <= (8 - this.players.size())) {
|
||||
this.players.addAll(players);
|
||||
if (this.players.size() == 8) {
|
||||
openStatus = false;
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
openStatus = false;
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return openStatus;
|
||||
}
|
||||
|
||||
}
|
20
src/main/java/org/lunamc/letthemeatcake/GamesManager.java
Normal file
20
src/main/java/org/lunamc/letthemeatcake/GamesManager.java
Normal file
@ -0,0 +1,20 @@
|
||||
package org.lunamc.letthemeatcake;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GamesManager {
|
||||
private static List<Game> games = new ArrayList<>();
|
||||
|
||||
public static void addToGame() {
|
||||
for (Game game : games) {
|
||||
if (game.isOpen()) {
|
||||
switch (game.addPlayers()) {
|
||||
case 0: {} // Success
|
||||
case 1: {} // Full
|
||||
case 2: {} // Success and Full
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
src/main/java/org/lunamc/letthemeatcake/JoinGameCommand.java
Normal file
26
src/main/java/org/lunamc/letthemeatcake/JoinGameCommand.java
Normal file
@ -0,0 +1,26 @@
|
||||
package org.lunamc.letthemeatcake;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JoinGameCommand implements CommandExecutor {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
public JoinGameCommand(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,24 +1,48 @@
|
||||
package org.lunamc.letthemeatcake;
|
||||
|
||||
import com.grinderwolf.swm.api.SlimePlugin;
|
||||
import com.grinderwolf.swm.api.exceptions.CorruptedWorldException;
|
||||
import com.grinderwolf.swm.api.exceptions.NewerFormatException;
|
||||
import com.grinderwolf.swm.api.exceptions.UnknownWorldException;
|
||||
import com.grinderwolf.swm.api.exceptions.WorldInUseException;
|
||||
import com.grinderwolf.swm.api.loaders.SlimeLoader;
|
||||
import com.grinderwolf.swm.api.world.SlimeWorld;
|
||||
import com.grinderwolf.swm.api.world.properties.SlimeProperties;
|
||||
import com.grinderwolf.swm.api.world.properties.SlimeProperty;
|
||||
import com.grinderwolf.swm.api.world.properties.SlimePropertyMap;
|
||||
import com.grinderwolf.swm.api.world.properties.type.SlimePropertyString;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class LetThemEatCake extends JavaPlugin {
|
||||
private SlimePropertyMap properties;
|
||||
private SlimePlugin swm;
|
||||
private SlimeLoader swmLoader;
|
||||
private SlimeWorld swmWorld;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
SlimePropertyMap propertymap = new SlimePropertyMap();
|
||||
propertymap.setValue(SlimeProperties.SPAWN_X, 0);
|
||||
propertymap.setValue(SlimeProperties.SPAWN_Y, 0);
|
||||
propertymap.setValue(SlimeProperties.SPAWN_Z, 0);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
// Unload swm worlds
|
||||
}
|
||||
|
||||
private void loadSWM() {
|
||||
properties = new SlimePropertyMap();
|
||||
properties.setValue(SlimeProperties.SPAWN_X, 0);
|
||||
properties.setValue(SlimeProperties.SPAWN_Y, 0);
|
||||
properties.setValue(SlimeProperties.SPAWN_Z, 0);
|
||||
|
||||
swm = (SlimePlugin) Bukkit.getPluginManager().getPlugin("SlimeWorldManager");
|
||||
swmLoader = swm.getLoader("file");
|
||||
try {
|
||||
swmWorld = swm.loadWorld(swmLoader, "map", true, properties);
|
||||
swm.generateWorld(swmWorld);
|
||||
} catch (UnknownWorldException | IOException | CorruptedWorldException | NewerFormatException | WorldInUseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,62 @@ package org.lunamc.letthemeatcake;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PointsManager {
|
||||
private int playerSize;
|
||||
private Player[] players;
|
||||
private int[] points;
|
||||
|
||||
private Map<Player, Integer> playerPoints;
|
||||
|
||||
public PointsManager() {
|
||||
playerPoints = new HashMap<>();
|
||||
|
||||
public PointsManager(int playerSize) {
|
||||
this.playerSize = playerSize;
|
||||
players = new Player[playerSize];
|
||||
points = new int[playerSize];
|
||||
}
|
||||
|
||||
public Player[] getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
public int getPlayerNumber(Player player) {
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
if (players[i].equals(player)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public Player getPlayerByNumber(int player) {
|
||||
if (player < 0 || player > playerSize) {
|
||||
return null;
|
||||
}
|
||||
return players[player];
|
||||
}
|
||||
|
||||
/**
|
||||
* If player does not exist, returns -1;
|
||||
* @param player player to get points from
|
||||
* @return int value of points
|
||||
*/
|
||||
public int getPlayerPoints(int player) {
|
||||
if (player < 0 || player > playerSize) {
|
||||
return -1;
|
||||
}
|
||||
return points[player];
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link org.lunamc.letthemeatcake.PointsManager#getPlayerPoints(int)} if possible for performance reasons.<br>
|
||||
* If player does not exist, returns -1;
|
||||
* @param player player to get points from
|
||||
* @return int value of points
|
||||
*/
|
||||
public int getPlayerPoints(Player player) {
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
if (players[i].equals(player)) {
|
||||
return points[i];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user