rewrote entire plugin with new backend
This commit is contained in:
parent
1f1149b383
commit
b5554d5b3e
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
13
.idea/compiler.xml
generated
Normal file
13
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="Tridentwar" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
25
.idea/jarRepositories.xml
generated
Normal file
25
.idea/jarRepositories.xml
generated
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="spigot-repo" />
|
||||
<option name="name" value="spigot-repo" />
|
||||
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
19
.idea/misc.xml
generated
Normal file
19
.idea/misc.xml
generated
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
10
.idea/runConfigurations.xml
generated
Normal file
10
.idea/runConfigurations.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
12
Tridentwar.iml
Normal file
12
Tridentwar.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
</module>
|
@ -1,4 +0,0 @@
|
||||
spawn: unset
|
||||
spectator: unset
|
||||
endLoc: unset
|
||||
time: 600
|
44
pom.xml
Normal file
44
pom.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.steev</groupId>
|
||||
<artifactId>Tridentwar</artifactId>
|
||||
<version>1.0</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
<repositories>
|
||||
<!-- This adds the Spigot Maven repository to the build -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!--This adds the Spigot API artifact to the build -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,146 +0,0 @@
|
||||
package de.steev.tridentwar;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class command implements CommandExecutor {
|
||||
// TODO: add permissions to the commands
|
||||
private main plugin;
|
||||
public command(main plugin){ this.plugin = plugin; }
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
if(args.length > 0){
|
||||
switch (args[0].toLowerCase()){
|
||||
default:
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " Dieser Befehl ist nicht bekannt bitte gib /tw help ein");
|
||||
break;
|
||||
case "help":
|
||||
player.sendMessage("======================= " + ChatColor.AQUA + "Steev's Trident War" + " =======================\n" +
|
||||
ChatColor.AQUA + ChatColor.BOLD + "help: " + ChatColor.RESET + "Listet dir eine Hilfe des plugins auf\n" +
|
||||
ChatColor.AQUA + ChatColor.BOLD + "start: " + ChatColor.RESET + "Zum starten eines Trident Wars\n" +
|
||||
ChatColor.AQUA + ChatColor.BOLD + "stop: " + ChatColor.RESET + "Zum stopen eines Trident Wars\n"+
|
||||
ChatColor.AQUA + ChatColor.BOLD + "leave: " + ChatColor.RESET + "Verlässt den Trident War\n"+
|
||||
ChatColor.AQUA + ChatColor.BOLD + "setSpawn: " + ChatColor.RESET + "Setzt den anfangspunkt für alle Spieler\n" +
|
||||
ChatColor.AQUA + ChatColor.BOLD + "setSpectate: " + ChatColor.RESET + "Setzt den spawn für gestorbene Spieler\n" +
|
||||
ChatColor.AQUA + ChatColor.BOLD + "setEndLocation: " + ChatColor.RESET + "Setzt den spawn für alle Spieler nach dem Trident War");
|
||||
break;
|
||||
case "start":
|
||||
if(commandSender.hasPermission("tw.admin")){
|
||||
// checks if more then 1 person is online
|
||||
if(Bukkit.getServer().getOnlinePlayers().size() >= 2){
|
||||
// ensures that no war already is active
|
||||
if(!plugin.eventActive){
|
||||
plugin.eventActive = true; // Tells the plugin there is a war ongoing
|
||||
for(Player p : Bukkit.getServer().getOnlinePlayers()){
|
||||
p.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " Ein Trident War beginnt!");
|
||||
p.sendTitle(ChatColor.GREEN + "Beginnt!", ChatColor.GOLD + "Der Trident War beginnt.", 1, 20, 1);
|
||||
|
||||
// Teleports players to Spawn
|
||||
if(plugin.playerDataConfig.get("spectator") != null){
|
||||
p.teleport(((Location) plugin.playerDataConfig.get("spectator")));
|
||||
}
|
||||
}
|
||||
warcontroller.StartTridentWar(plugin);
|
||||
} else {
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " Ein Trident War ist bereits im Gange");
|
||||
}
|
||||
} else {
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + "Allein kanst du keinen Trident War starten");
|
||||
}
|
||||
} else {
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " dir fehlen die Rechte dazu");
|
||||
}
|
||||
break;
|
||||
case "stop":
|
||||
if(commandSender.hasPermission("tw.admin")){
|
||||
if(plugin.eventActive){
|
||||
plugin.eventActive = false;
|
||||
for(Player p : Bukkit.getOnlinePlayers()){
|
||||
p.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " Der Trident War endet!");
|
||||
p.sendTitle("Ende!", "Der Trident war Endet.", 1, 20, 1);
|
||||
}
|
||||
warcontroller.StopTridentWar(plugin);
|
||||
} else {
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " es ist kein Trident im Gange");
|
||||
}
|
||||
} else {
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " dir fehlen die Rechte dazu");
|
||||
}
|
||||
break;
|
||||
case "leave":
|
||||
plugin.playerDataConfig.set(((Player) commandSender).getPlayer().getUniqueId() + "", null);
|
||||
if(plugin.playerDataConfig.get("endLoc") != "unset"){
|
||||
((Player) commandSender).getPlayer().teleport(((Location)plugin.playerDataConfig.get("endLoc")));
|
||||
}
|
||||
|
||||
// Check if enough players are in for a trident war
|
||||
if(plugin.playerDataConfig.getKeys(false).size() < 2){
|
||||
warcontroller.StopTridentWar(plugin);
|
||||
|
||||
// Message and teleport everyone if not
|
||||
for(Player p : Bukkit.getServer().getOnlinePlayers()){
|
||||
if(plugin.playerDataConfig.getString(p.getUniqueId() + ".name") != null){
|
||||
p.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " Ein Trident War beginnt!");
|
||||
p.sendTitle(ChatColor.RED + "Abgebrochen!", ChatColor.RED + "Zu wenig Spieler.", 1, 20, 1);
|
||||
|
||||
// Teleports players to Spawn
|
||||
if(plugin.playerDataConfig.get("endLoc") != null){
|
||||
p.teleport(((Location) plugin.playerDataConfig.get("endLoc")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + "Du hast den Trident war verlassen");
|
||||
break;
|
||||
case "setspawn":
|
||||
if(commandSender.hasPermission("tw.admin")){
|
||||
if(args[1].toLowerCase() == "unset"){
|
||||
plugin.config.set("spawn", "unset");
|
||||
plugin.saveDefaultConfig();
|
||||
} else {
|
||||
plugin.config.set("spawn", player.getLocation());
|
||||
plugin.saveDefaultConfig();
|
||||
}
|
||||
} else {
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " dir fehlen die Rechte dazu");
|
||||
}
|
||||
break;
|
||||
case "setspectate":
|
||||
if(commandSender.hasPermission("tw.admin")){
|
||||
if(args[1].toLowerCase() == "unset"){
|
||||
plugin.config.set("spectator", "unset");
|
||||
plugin.saveDefaultConfig();
|
||||
} else {
|
||||
plugin.config.set("spectator", player.getLocation());
|
||||
plugin.saveDefaultConfig();
|
||||
}
|
||||
} else {
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " dir fehlen die Rechte dazu");
|
||||
}
|
||||
break;
|
||||
case "setendlocation":
|
||||
if(commandSender.hasPermission("tw.admin")){
|
||||
if(args[1].toLowerCase() == "unset"){
|
||||
plugin.config.set("endLoc", "unset");
|
||||
plugin.saveDefaultConfig();
|
||||
} else {
|
||||
plugin.config.set("endLoc", player.getLocation());
|
||||
plugin.saveDefaultConfig();
|
||||
}
|
||||
} else {
|
||||
commandSender.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " dir fehlen die Rechte dazu");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package de.steev.tridentwar.data;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class Items {
|
||||
public static ItemStack trident(){
|
||||
ItemStack trident = new ItemStack(Material.TRIDENT);
|
||||
ItemMeta meta = trident.getItemMeta();
|
||||
meta.setDisplayName("Kriegs Dreizack");
|
||||
trident.setItemMeta(meta);
|
||||
return trident;
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
package de.steev.tridentwar.events;
|
||||
|
||||
import de.steev.tridentwar.data.Items;
|
||||
import de.steev.tridentwar.main;
|
||||
import de.steev.tridentwar.warcontroller;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerConnectionEvents implements Listener {
|
||||
private main plugin;
|
||||
|
||||
public PlayerConnectionEvents(main plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event){
|
||||
|
||||
if(plugin.eventActive) {
|
||||
|
||||
// Scans player inventory for tridents to prevent multiple tridents
|
||||
for(ItemStack is : event.getPlayer().getInventory()) {
|
||||
try {
|
||||
if(is.getItemMeta().getDisplayName().contains("Kriegs Dreizack")){
|
||||
return;
|
||||
}
|
||||
} catch (Exception e){
|
||||
// nothing happens
|
||||
}
|
||||
}
|
||||
|
||||
// Gives player needed tools for war
|
||||
event.getPlayer().getInventory().addItem(Items.trident());
|
||||
|
||||
// messages the player about ongoing round
|
||||
event.getPlayer().sendMessage(ChatColor.AQUA + "Steev's Trident War: " + "Achtung hier herscht grade krieg");
|
||||
|
||||
// Add player to the game
|
||||
plugin.playerDataConfig.set( event.getPlayer().getUniqueId() + ".life", 4 );
|
||||
plugin.playerDataConfig.set( event.getPlayer().getUniqueId() + ".name", event.getPlayer().getDisplayName());
|
||||
plugin.saveplayerdata();
|
||||
} else {
|
||||
for(ItemStack is : event.getPlayer().getInventory().getContents()){
|
||||
try {
|
||||
if(is.getItemMeta() != null){
|
||||
if(is.getItemMeta().getDisplayName().contains("Kriegs Dreizack")){
|
||||
// System.out.println( is.getItemMeta().getDisplayName().contains("Kriegs Dreizack"));
|
||||
event.getPlayer().getInventory().remove(is);
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
// this wont be catched
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(PlayerQuitEvent event){
|
||||
if(plugin.eventActive) {
|
||||
// stops war when less then 2 players are online
|
||||
if(Bukkit.getServer().getOnlinePlayers().size() < 2){
|
||||
warcontroller.StopTridentWar(plugin);
|
||||
|
||||
// Message and teleport everyone if not
|
||||
for(Player p : Bukkit.getServer().getOnlinePlayers()){
|
||||
if(plugin.playerDataConfig.getString(p.getUniqueId() + ".name") != null){
|
||||
p.sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " Ein Trident War beginnt!");
|
||||
p.sendTitle(ChatColor.RED + "Abgebrochen!", ChatColor.RED + "Zu wenig Spieler.", 1, 20, 1);
|
||||
|
||||
// Teleports players to Spawn
|
||||
if(plugin.playerDataConfig.get("endLoc") != null){
|
||||
p.teleport(((Location) plugin.playerDataConfig.get("endLoc")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Removes player from game
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
plugin.playerDataConfig.set( "" + uuid, null);
|
||||
plugin.saveplayerdata();
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package de.steev.tridentwar.events;
|
||||
|
||||
import de.steev.tridentwar.main;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class itemDrop implements Listener {
|
||||
private main plugin;
|
||||
|
||||
public itemDrop(main plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// deletes trident from player drops
|
||||
@EventHandler
|
||||
public void onItemDrop(PlayerDeathEvent event){
|
||||
for(ItemStack item : event.getDrops()){
|
||||
try {
|
||||
if(item.getItemMeta().getDisplayName() == "Kriegs Dreizack"){
|
||||
item.setType(Material.AIR);
|
||||
}
|
||||
} catch (Exception e){
|
||||
// Nothing gets handled here
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Stops players from droping the war trident
|
||||
@EventHandler
|
||||
public void onItemDrop(PlayerDropItemEvent event){
|
||||
if(plugin.eventActive){
|
||||
if(plugin.playerDataConfig.get(event.getPlayer().getUniqueId() + ".name") != null){
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
package de.steev.tridentwar.events;
|
||||
|
||||
import de.steev.tridentwar.data.Items;
|
||||
import de.steev.tridentwar.main;
|
||||
import de.steev.tridentwar.warcontroller;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Trident;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class onHit implements Listener {
|
||||
private main plugin;
|
||||
public onHit(main plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTridentHit(ProjectileHitEvent event){
|
||||
if(plugin.eventActive){
|
||||
try {
|
||||
if(event.getEntity().getShooter() instanceof Player){
|
||||
if(event.getEntityType() == EntityType.TRIDENT){
|
||||
if(event.getHitEntity() instanceof Player){
|
||||
|
||||
if(plugin.playerDataConfig.getString(((Player)event.getHitEntity()).getUniqueId() + ".life") != null){
|
||||
|
||||
UUID uuid = ((Player)event.getHitEntity()).getUniqueId();
|
||||
int life = plugin.playerDataConfig.getInt(uuid + ".life") - 1;
|
||||
|
||||
// Detects when trident hits a not player block
|
||||
event.getEntity().remove();
|
||||
|
||||
// Gives Player a Trident
|
||||
((Player) event.getEntity().getShooter()).getInventory().addItem(Items.trident());
|
||||
|
||||
// play a "Ding" sound on the attackers side at hit
|
||||
if(life == 4) {
|
||||
((Player)event.getEntity().getShooter()).playSound(((Player)event.getEntity().getShooter()).getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1f, 0.5f);
|
||||
} else if(life == 3) {
|
||||
((Player)event.getEntity().getShooter()).playSound(((Player)event.getEntity().getShooter()).getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1f, 1f);
|
||||
} else if(life == 2) {
|
||||
((Player)event.getEntity().getShooter()).playSound(((Player)event.getEntity().getShooter()).getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1f, 1.5f);
|
||||
} else if(life == 1) {
|
||||
((Player)event.getEntity().getShooter()).playSound(((Player)event.getEntity().getShooter()).getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1f, 2f);
|
||||
}
|
||||
|
||||
// Runs sound when a player gets hit
|
||||
((Player)event.getHitEntity()).playSound(((Player)event.getHitEntity()).getLocation(), Sound.ENTITY_PLAYER_DEATH, 1f, 1f);
|
||||
|
||||
// Subtracts life and spams the chat with debug messages
|
||||
plugin.playerDataConfig.set( uuid + ".life", life);
|
||||
((Player)event.getHitEntity()).sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " du wurdest getroffen und hast noch: " + ChatColor.BOLD + life + ChatColor.RESET + ChatColor.RED + " Leben");
|
||||
if(life == 4) {
|
||||
((Player)event.getHitEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.GREEN + "Leben: " + life));
|
||||
} else if(life < 1) {
|
||||
((Player)event.getHitEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.YELLOW + "Leben: " + life));
|
||||
} else if(life <= 1) {
|
||||
((Player)event.getHitEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.RED + "Leben: " + life));
|
||||
}
|
||||
|
||||
plugin.saveplayerdata();
|
||||
|
||||
// Handles Death
|
||||
if( life == 0){
|
||||
// Deletes player from Database
|
||||
plugin.playerDataConfig.set(uuid.toString(), null);
|
||||
plugin.saveplayerdata();
|
||||
|
||||
// Messages Player about Death
|
||||
((Player)event.getHitEntity()).playSound(((Player)event.getHitEntity()).getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1f, 1f);
|
||||
((Player)event.getHitEntity()).sendTitle(ChatColor.RED + "Ausgeschieden!", ChatColor.RED + "Du bist aus dem Trident War ausgeschieden", 1, 20, 1);
|
||||
|
||||
// Deletes trident of people who died
|
||||
for(Trident t : ((Player)event.getHitEntity()).getWorld().getEntitiesByClass(Trident.class)){
|
||||
for(String pd : plugin.playerDataConfig.getKeys(false)) {
|
||||
if(((Player)t.getShooter()).getDisplayName() == plugin.playerDataConfig.getString(pd + ".name")){
|
||||
return;
|
||||
}
|
||||
}
|
||||
t.remove();
|
||||
}
|
||||
|
||||
// Checks if only one is alive
|
||||
Bukkit.getLogger().info(ChatColor.GRAY + "[" + ChatColor.YELLOW + ChatColor.BOLD + "DEBUG" + ChatColor.RESET + ChatColor.GRAY + "]: is alive: " + plugin.playerDataConfig.getKeys(false).size());
|
||||
if(plugin.playerDataConfig.getKeys(false).size() <= 1){
|
||||
|
||||
if(plugin.playerDataConfig.getKeys(false).size() > 0){
|
||||
for(String pd : plugin.playerDataConfig.getKeys(false)) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
// Message players about the winner
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_YES, 1f, 1f);
|
||||
p.sendTitle(ChatColor.GREEN + "ENDE!",ChatColor.GOLD + plugin.playerDataConfig.getString(pd + ".name") +" Hat den Trident War gewonnen!");
|
||||
}
|
||||
|
||||
// for security loop all players once more and remove all tridents with meeting criteria
|
||||
for(ItemStack is : Bukkit.getServer().getPlayer(plugin.playerDataConfig.getString(pd + ".name")).getInventory()) {
|
||||
try {
|
||||
if(is.getItemMeta().getDisplayName().contains("Kriegs Dreizack")){
|
||||
Bukkit.getServer().getPlayer(plugin.playerDataConfig.getString(pd + ".name")).getInventory().remove(is);
|
||||
}
|
||||
} catch (Exception e){
|
||||
// nothing happens
|
||||
}
|
||||
}
|
||||
|
||||
// Remove trident entity
|
||||
for(Trident t : ((Player)event.getHitEntity()).getWorld().getEntitiesByClass(Trident.class)){
|
||||
t.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: make endlocation lobby porting
|
||||
|
||||
warcontroller.StopTridentWar(plugin);
|
||||
} else {
|
||||
((Player)event.getHitEntity()).sendMessage(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.RED + " es gibt keinen Sieger!");
|
||||
warcontroller.StopTridentWar(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
// Sends Player to Spawn
|
||||
if(plugin.config.get("spectator") != "unset"){ ((Player)event.getHitEntity()).teleport(((Location)plugin.config.get("spectator"))); }
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Detects when trident hits a not player block
|
||||
event.getEntity().remove();
|
||||
|
||||
// Gives Player a Trident
|
||||
((Player) event.getEntity().getShooter()).getInventory().addItem(Items.trident());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
// Nothing to print here
|
||||
// this would only happen when no entity should be an entity
|
||||
}
|
||||
|
||||
// disables damage
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package de.steev.tridentwar.events;
|
||||
|
||||
import de.steev.tridentwar.data.Items;
|
||||
import de.steev.tridentwar.main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class onProjectileLaunch implements Listener {
|
||||
private main plugin;
|
||||
public HashMap<UUID, BukkitTask> tasks = new HashMap<UUID, BukkitTask>();
|
||||
|
||||
public onProjectileLaunch(main plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event){
|
||||
try {
|
||||
tasks.get(((Player)event.getEntity().getShooter()).getUniqueId()).cancel();
|
||||
} catch (Exception e){
|
||||
// eigentlich sollte hier jetzt error handling passieren, aber nö.
|
||||
}
|
||||
BukkitTask task = Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(plugin.eventActive){
|
||||
for(ItemStack is : ((Player)event.getEntity().getShooter()).getInventory()) {
|
||||
try {
|
||||
if(is.getItemMeta().getDisplayName().contains("Kriegs Dreizack")){
|
||||
return;
|
||||
}
|
||||
} catch (Exception e){
|
||||
// nothing happens
|
||||
}
|
||||
}
|
||||
|
||||
// When no trident was found give a new trident to the player
|
||||
((Player)event.getEntity().getShooter()).getInventory().addItem(Items.trident());
|
||||
}
|
||||
}
|
||||
},200);
|
||||
tasks.put(((Player)event.getEntity().getShooter()).getUniqueId(), task);
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package de.steev.tridentwar.events;
|
||||
|
||||
import de.steev.tridentwar.data.Items;
|
||||
import de.steev.tridentwar.main;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class playerRespawn implements Listener {
|
||||
|
||||
private main plugin;
|
||||
public playerRespawn(main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event){
|
||||
Player p = event.getPlayer();
|
||||
|
||||
for(String pd : plugin.playerDataConfig.getKeys(false)){
|
||||
if(plugin.playerDataConfig.getString(event.getPlayer().getUniqueId() + ".name") == p.getDisplayName()){
|
||||
|
||||
for(ItemStack is : p.getInventory()) {
|
||||
try {
|
||||
if(is.getItemMeta().getDisplayName().contains("Kriegs Dreizack")){
|
||||
return;
|
||||
}
|
||||
} catch (Exception e){
|
||||
// nothing happens
|
||||
}
|
||||
}
|
||||
|
||||
p.getInventory().addItem(Items.trident());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
// when a player respawns remove trident from inventory
|
||||
for(ItemStack is : p.getInventory()) {
|
||||
try {
|
||||
if(is.getItemMeta().getDisplayName().contains("Kriegs Dreizack")){
|
||||
p.getInventory().remove(is);
|
||||
}
|
||||
} catch (Exception e){
|
||||
// nothing happens
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package de.steev.tridentwar;
|
||||
|
||||
import de.steev.tridentwar.events.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class main extends JavaPlugin implements Listener {
|
||||
|
||||
public static boolean eventActive = false;
|
||||
public FileConfiguration config = this.getConfig();
|
||||
public static int alive = 0;
|
||||
|
||||
// Custom Playerdata File
|
||||
public static File playerdata;
|
||||
public static FileConfiguration playerDataConfig;
|
||||
public static final String playerdatafilename = "game.yml";
|
||||
|
||||
public void onEnable(){
|
||||
this.getLogger().info(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.YELLOW + " Plugin lädt");
|
||||
|
||||
// Registers Events
|
||||
this.getLogger().info(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.YELLOW + " Registriere Events");
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
this.getServer().getPluginManager().registerEvents(new onHit(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new itemDrop(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new onProjectileLaunch(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerConnectionEvents(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new playerRespawn(this), this);
|
||||
|
||||
|
||||
// Registers Commands
|
||||
this.getLogger().info(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.YELLOW + " Lade Befehle");
|
||||
this.getCommand("tw").setExecutor(new command(this));
|
||||
|
||||
/*
|
||||
* ====================================================
|
||||
* # Deletes old game.yml from previus plugin session #
|
||||
* ====================================================
|
||||
*/
|
||||
// Writes a file with playername, uuid and playermods
|
||||
playerdata = new File(this.getDataFolder(), playerdatafilename);
|
||||
|
||||
try{
|
||||
// Check for already existing file
|
||||
if(playerdata.exists()){
|
||||
// Delete the file if it does exist
|
||||
playerdata.delete();
|
||||
this.getLogger().info(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.YELLOW + " game.yml wird neu erstellt");
|
||||
}
|
||||
}catch (Exception e){
|
||||
this.getLogger().warning("Error while creating File\n===================================================\n" + e);
|
||||
}
|
||||
|
||||
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
|
||||
saveplayerdata();
|
||||
saveDefaultConfig();
|
||||
}
|
||||
|
||||
public void onDisable(){
|
||||
this.getLogger().info(ChatColor.AQUA + "Steev's Trident War: " + ChatColor.YELLOW + " Plugin fährt runter");
|
||||
}
|
||||
|
||||
/*
|
||||
* ================================
|
||||
* # File Handler #
|
||||
* ================================
|
||||
*/
|
||||
/** Handles Player data */
|
||||
public static void saveplayerdata(){
|
||||
try {
|
||||
playerDataConfig.save(playerdata);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().warning("Unable to save " + playerdatafilename); // shouldn't really happen, but save throws the exception
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
package de.steev.tridentwar;
|
||||
|
||||
import de.steev.tridentwar.data.Items;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class warcontroller {
|
||||
/** Handles Starting the Trident War */
|
||||
public static void StartTridentWar(main plugin) {
|
||||
// TODO: set everyone in adventure
|
||||
plugin.alive = Bukkit.getOnlinePlayers().size();
|
||||
// TODO: Create Bossbar with timer in it
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
p.getInventory().addItem(Items.trident());
|
||||
plugin.playerDataConfig.set(p.getUniqueId() + ".life", 4);
|
||||
plugin.playerDataConfig.set(p.getUniqueId() + ".name", p.getDisplayName());
|
||||
}
|
||||
plugin.saveplayerdata();
|
||||
}
|
||||
|
||||
/** Handles stoping a trident war */
|
||||
public static void StopTridentWar(main plugin) {
|
||||
|
||||
// TODO set everyone to default gamemode
|
||||
plugin.alive = 0;
|
||||
plugin.eventActive = false;
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
for(ItemStack is : p.getInventory().getContents()){
|
||||
try {
|
||||
if(is.getItemMeta() != null){
|
||||
if(is.getItemMeta().getDisplayName().contains("Kriegs Dreizack")){
|
||||
p.getInventory().remove(is);
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
// this wont be catched
|
||||
}
|
||||
}
|
||||
|
||||
plugin.playerDataConfig.set(p.getUniqueId() + "", null);
|
||||
}
|
||||
plugin.saveplayerdata();
|
||||
}
|
||||
}
|
26
src/main/java/de/steev/Tridentwar/Tridentwar.java
Normal file
26
src/main/java/de/steev/Tridentwar/Tridentwar.java
Normal file
@ -0,0 +1,26 @@
|
||||
package de.steev.Tridentwar;
|
||||
|
||||
import de.steev.Tridentwar.commands.TridentwarCommand;
|
||||
import de.steev.Tridentwar.listeners.ProjectileHitListener;
|
||||
import de.steev.Tridentwar.listeners.ProjectileLaunchListener;
|
||||
import de.steev.Tridentwar.manager.GameManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Tridentwar extends JavaPlugin {
|
||||
private GameManager gameManager;
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
super.onEnable();
|
||||
this.gameManager = new GameManager(this);
|
||||
getServer().getPluginManager().registerEvents(new ProjectileLaunchListener(this.gameManager, this), this);
|
||||
getServer().getPluginManager().registerEvents(new ProjectileHitListener(this.gameManager), this);
|
||||
getCommand("tw").setExecutor(new TridentwarCommand(gameManager));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(){
|
||||
super.onDisable();
|
||||
gameManager.cleanup();
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package de.steev.Tridentwar.commands;
|
||||
|
||||
import de.steev.Tridentwar.manager.GameManager;
|
||||
import de.steev.Tridentwar.manager.GameState;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class TridentwarCommand implements CommandExecutor {
|
||||
|
||||
private GameManager gameManager;
|
||||
|
||||
public TridentwarCommand(GameManager gameManager){
|
||||
this.gameManager = gameManager;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
|
||||
if (args[0] == null) return false;
|
||||
|
||||
switch (args[0].toLowerCase()){
|
||||
case "start":
|
||||
gameManager.setGameState(GameState.STARTING);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package de.steev.Tridentwar.listeners;
|
||||
|
||||
import de.steev.Tridentwar.manager.GameManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ProjectileHitListener implements Listener {
|
||||
private GameManager gameManager;
|
||||
|
||||
public ProjectileHitListener(GameManager gameManager){
|
||||
this.gameManager = gameManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTridentHit(ProjectileHitEvent event){
|
||||
if(this.gameManager.getTridentManager().getTask((Player)event.getEntity().getShooter()) != null) {
|
||||
this.gameManager.getTridentManager().getTask((Player) event.getEntity().getShooter()).cancel();
|
||||
this.gameManager.getTridentManager().removeTridentTast((Player) event.getEntity().getShooter());
|
||||
}
|
||||
|
||||
if(event.getHitEntity() instanceof Player) ((Player) event.getEntity().getShooter()).playSound(((Player) event.getEntity().getShooter()).getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1f, 0.5f);
|
||||
|
||||
event.getEntity().remove();
|
||||
((Player) event.getEntity().getShooter()).getInventory().addItem(new ItemStack(Material.TRIDENT));
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package de.steev.Tridentwar.listeners;
|
||||
|
||||
import de.steev.Tridentwar.Tridentwar;
|
||||
import de.steev.Tridentwar.manager.GameManager;
|
||||
import de.steev.Tridentwar.tasks.TridentResetTask;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
|
||||
public class ProjectileLaunchListener implements Listener {
|
||||
|
||||
private GameManager gameManager;
|
||||
private TridentResetTask tridentResetTask;
|
||||
private Tridentwar plugin;
|
||||
|
||||
public ProjectileLaunchListener(GameManager gameManager, Tridentwar plugin){
|
||||
this.gameManager = gameManager;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnProjectileLaunch(ProjectileLaunchEvent event){
|
||||
this.tridentResetTask = new TridentResetTask(this.gameManager, (Player)event.getEntity().getShooter());
|
||||
this.tridentResetTask.runTaskLater(plugin, 300);
|
||||
gameManager.getTridentManager().setTasks((Player)event.getEntity().getShooter(), this.tridentResetTask);
|
||||
}
|
||||
}
|
45
src/main/java/de/steev/Tridentwar/manager/GameManager.java
Normal file
45
src/main/java/de/steev/Tridentwar/manager/GameManager.java
Normal file
@ -0,0 +1,45 @@
|
||||
package de.steev.Tridentwar.manager;
|
||||
|
||||
import de.steev.Tridentwar.Tridentwar;
|
||||
import de.steev.Tridentwar.tasks.GameStartCountdownTask;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class GameManager {
|
||||
private final Tridentwar plugin;
|
||||
private TridentManager tridentManager;
|
||||
private GameStartCountdownTask gameStartCountdownTask;
|
||||
public GameState gameState = GameState.LOBBY;
|
||||
private PlayerManager playerManager;
|
||||
|
||||
|
||||
public GameManager(Tridentwar plugin) {
|
||||
this.plugin = plugin;
|
||||
this.tridentManager = new TridentManager(this);
|
||||
this.playerManager = new PlayerManager(this);
|
||||
}
|
||||
|
||||
public void setGameState(GameState gameState){
|
||||
if(this.gameState == GameState.ACTIVE && gameState == GameState.STARTING) return;
|
||||
this.gameState = gameState;
|
||||
|
||||
switch (gameState){
|
||||
case ACTIVE:
|
||||
Bukkit.broadcastMessage("Active!");
|
||||
this.playerManager.giveKits();
|
||||
break;
|
||||
case STARTING:
|
||||
Bukkit.broadcastMessage("Starting!");
|
||||
this.gameStartCountdownTask = new GameStartCountdownTask(this);
|
||||
this.gameStartCountdownTask.runTaskTimer(plugin, 0 , 20);
|
||||
// teleport players
|
||||
// clear inventories
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanup(){}
|
||||
|
||||
public TridentManager getTridentManager() { return tridentManager; }
|
||||
public PlayerManager getPlayerManager() { return playerManager; }
|
||||
public GameState getGameState() { return gameState; }
|
||||
}
|
5
src/main/java/de/steev/Tridentwar/manager/GameState.java
Normal file
5
src/main/java/de/steev/Tridentwar/manager/GameState.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.steev.Tridentwar.manager;
|
||||
|
||||
public enum GameState {
|
||||
LOBBY, STARTING, ACTIVE, WON, RESTARTING, STOPPING;
|
||||
}
|
23
src/main/java/de/steev/Tridentwar/manager/PlayerManager.java
Normal file
23
src/main/java/de/steev/Tridentwar/manager/PlayerManager.java
Normal file
@ -0,0 +1,23 @@
|
||||
package de.steev.Tridentwar.manager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PlayerManager {
|
||||
private GameManager gameManager;
|
||||
|
||||
public PlayerManager(GameManager gameManager) {
|
||||
this.gameManager = gameManager;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package de.steev.Tridentwar.manager;
|
||||
|
||||
import de.steev.Tridentwar.tasks.TridentResetTask;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TridentManager {
|
||||
private HashMap<Player, TridentResetTask> tasks;
|
||||
private GameManager gameManager;
|
||||
|
||||
public TridentManager(GameManager gameManager) { this.gameManager = gameManager; }
|
||||
public void setTasks(Player thrower, TridentResetTask task) { this.tasks.put(thrower, task); }
|
||||
public TridentResetTask getTask (Player thrower) { return tasks.get(thrower); }
|
||||
public void removeTridentTast(Player thrower) { tasks.remove(thrower); }
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package de.steev.Tridentwar.tasks;
|
||||
|
||||
import de.steev.Tridentwar.manager.GameManager;
|
||||
import de.steev.Tridentwar.manager.GameState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class GameStartCountdownTask extends BukkitRunnable {
|
||||
private GameManager gameManager;
|
||||
public GameStartCountdownTask (GameManager gameManager) {
|
||||
this.gameManager = gameManager;
|
||||
}
|
||||
|
||||
private int timeLeft = 10;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
timeLeft--;
|
||||
if(timeLeft <= 0) {
|
||||
cancel();
|
||||
gameManager.setGameState(GameState.ACTIVE);
|
||||
return;
|
||||
}
|
||||
Bukkit.broadcastMessage(timeLeft + " seconds Until game starts!");
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package de.steev.Tridentwar.tasks;
|
||||
|
||||
import de.steev.Tridentwar.manager.GameManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class TridentResetTask extends BukkitRunnable {
|
||||
|
||||
private GameManager gameManager;
|
||||
private Player thrower;
|
||||
|
||||
public TridentResetTask (GameManager gameManager, Player thrower) {
|
||||
this.gameManager = gameManager;
|
||||
this.thrower = thrower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
thrower.getInventory().addItem(new ItemStack(Material.TRIDENT));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user