Merge branch 'main' of https://github.com/steevLP/tridentwar
This commit is contained in:
commit
3b624c51c0
5
.gitignore
vendored
5
.gitignore
vendored
@ -1 +1,4 @@
|
||||
.idea
|
||||
.idea
|
||||
out
|
||||
target
|
||||
Tridentwar.iml
|
15
README.md
Normal file
15
README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# tridentwar
|
||||
Tridentwar is a minigame inspired by friends.
|
||||
## History
|
||||
The development of this plugin originated on a server, a friend of mine hosted, where we played around with all sorts of items.
|
||||
I later took the idea and started designing a plugin all around it.
|
||||
|
||||
## Supported version
|
||||
I am using the most recent stable Minecraft spigot versions and cannot guarantee downwards compatibility.
|
||||
|
||||
## License
|
||||
You are free to use this plugin on your server but, you have to mention me as the author and have to keep credit notices I placed inside the plugin.
|
||||
|
||||
## Current Roadmap
|
||||
Because this plugin currently is in its early development phase I will update this to more interesting features down the road
|
||||
my main goal, for now, is to get a stable plugin to host on servers without issues.
|
@ -1,5 +1,5 @@
|
||||
name: TridentWar
|
||||
main: de.steev.tridentwar.main
|
||||
main: de.steev.Tridentwar.Tridentwar
|
||||
version: 0.1
|
||||
api-version: 1.13
|
||||
commands:
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.steev.Tridentwar;
|
||||
|
||||
import de.steev.Tridentwar.commands.TridentwarCommand;
|
||||
import de.steev.Tridentwar.listeners.PlayerDeathListener;
|
||||
import de.steev.Tridentwar.listeners.ProjectileHitListener;
|
||||
import de.steev.Tridentwar.listeners.ProjectileLaunchListener;
|
||||
import de.steev.Tridentwar.manager.GameManager;
|
||||
@ -15,6 +16,7 @@ public class Tridentwar extends JavaPlugin {
|
||||
this.gameManager = new GameManager(this);
|
||||
getServer().getPluginManager().registerEvents(new ProjectileLaunchListener(this.gameManager, this), this);
|
||||
getServer().getPluginManager().registerEvents(new ProjectileHitListener(this.gameManager), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerDeathListener(this.gameManager), this);
|
||||
getCommand("tw").setExecutor(new TridentwarCommand(gameManager));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
package de.steev.Tridentwar.listeners;
|
||||
|
||||
import de.steev.Tridentwar.manager.GameManager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
public class PlayerDeathListener implements Listener {
|
||||
private GameManager gameManager;
|
||||
|
||||
public PlayerDeathListener(GameManager gameManager) {
|
||||
this.gameManager = gameManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
this.gameManager.getPlayerManager().playerDeath();
|
||||
}
|
||||
}
|
@ -21,8 +21,8 @@ public class ProjectileLaunchListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void OnProjectileLaunch(ProjectileLaunchEvent event){
|
||||
this.tridentResetTask = new TridentResetTask(this.gameManager, (Player)event.getEntity().getShooter());
|
||||
this.tridentResetTask.runTaskLater(plugin, 300);
|
||||
this.tridentResetTask = new TridentResetTask(this.gameManager, (Player)event.getEntity().getShooter(), event.getEntity());
|
||||
this.tridentResetTask.runTaskLater(plugin, 1000);
|
||||
gameManager.getTridentManager().setTasks((Player)event.getEntity().getShooter(), this.tridentResetTask);
|
||||
}
|
||||
}
|
||||
|
@ -25,14 +25,24 @@ public class GameManager {
|
||||
switch (gameState){
|
||||
case ACTIVE:
|
||||
Bukkit.broadcastMessage("Active!");
|
||||
this.playerManager.setAlive(Bukkit.getOnlinePlayers().size());
|
||||
this.playerManager.giveKits();
|
||||
break;
|
||||
case STARTING:
|
||||
if(Bukkit.getOnlinePlayers().size() < 2) return; // TODO: Message about minimal player count not beeing reached
|
||||
Bukkit.broadcastMessage("Starting!");
|
||||
this.gameStartCountdownTask = new GameStartCountdownTask(this);
|
||||
this.gameStartCountdownTask.runTaskTimer(plugin, 0 , 20);
|
||||
// teleport players
|
||||
// clear inventories
|
||||
break;
|
||||
case WON:
|
||||
Bukkit.broadcastMessage("WON");
|
||||
break;
|
||||
case STOPPING:
|
||||
Bukkit.broadcastMessage("Stopping Game");
|
||||
break;
|
||||
case ABORTING:
|
||||
Bukkit.broadcastMessage("No Player Alive game aborts");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
package de.steev.Tridentwar.manager;
|
||||
|
||||
public enum GameState {
|
||||
LOBBY, STARTING, ACTIVE, WON, RESTARTING, STOPPING;
|
||||
LOBBY, STARTING, ACTIVE, WON, RESTARTING, STOPPING, ABORTING;
|
||||
}
|
||||
|
@ -8,16 +8,26 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PlayerManager {
|
||||
private GameManager gameManager;
|
||||
private int alive = 0;
|
||||
|
||||
public PlayerManager(GameManager gameManager) {
|
||||
this.gameManager = gameManager;
|
||||
}
|
||||
|
||||
public void giveKits() {
|
||||
Bukkit.getOnlinePlayers().stream().filter(player -> player.getGameMode() == GameMode.SURVIVAL).forEach(this::giveKit);
|
||||
}
|
||||
|
||||
public void giveKits() { Bukkit.getOnlinePlayers().stream().filter(player -> player.getGameMode() == GameMode.SURVIVAL).forEach(this::giveKit); }
|
||||
public void giveKit(Player player){
|
||||
player.getInventory().addItem(new ItemStack(Material.TRIDENT));
|
||||
}
|
||||
|
||||
public void playerDeath(){
|
||||
this.alive--;
|
||||
if(this.alive == 1) {
|
||||
this.gameManager.setGameState(GameState.WON);
|
||||
} else if(this.alive == 0) {
|
||||
this.gameManager.setGameState(GameState.ABORTING);
|
||||
}
|
||||
}
|
||||
|
||||
public int getAlive() { return alive; }
|
||||
public void setAlive(int alive) { this.alive = alive; }
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package de.steev.Tridentwar.tasks;
|
||||
|
||||
import de.steev.Tridentwar.manager.GameManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -10,14 +11,17 @@ public class TridentResetTask extends BukkitRunnable {
|
||||
|
||||
private GameManager gameManager;
|
||||
private Player thrower;
|
||||
private Entity projektile;
|
||||
|
||||
public TridentResetTask (GameManager gameManager, Player thrower) {
|
||||
public TridentResetTask (GameManager gameManager, Player thrower, Entity projektile) {
|
||||
this.gameManager = gameManager;
|
||||
this.thrower = thrower;
|
||||
this.projektile = projektile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
projektile.remove();
|
||||
thrower.getInventory().addItem(new ItemStack(Material.TRIDENT));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user