first commit
This commit is contained in:
commit
79d0dfd757
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
TrashGames.iml
|
|
@ -0,0 +1,85 @@
|
|||
<?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>eu.univento</groupId>
|
||||
<artifactId>TrashGames</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<name>univento.eu TrashGames Secret Minigame</name>
|
||||
<url>http://univento.eu</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>eu.univento.trashgames.TrashGames</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!--TODO: add maven repo for univento code-->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.univento</groupId>
|
||||
<artifactId>Core</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,76 @@
|
|||
package eu.univento.trashgames;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import eu.univento.core.api.server.ServerType;
|
||||
import eu.univento.trashgames.commands.Setloc;
|
||||
import eu.univento.trashgames.game.GameState;
|
||||
import eu.univento.trashgames.listeners.JoinQuit;
|
||||
import eu.univento.trashgames.listeners.PlayerEvents;
|
||||
import eu.univento.trashgames.timers.LobbyCountdown;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class TrashGames extends JavaPlugin {
|
||||
|
||||
private static TrashGames instance;
|
||||
|
||||
public static TrashGames getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static GameState state;
|
||||
|
||||
public static GameState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public static void setState(GameState state) {
|
||||
TrashGames.state = state;
|
||||
ServerSettings.setGameState(state.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
Core.getInstance().registerPlugin(this);
|
||||
|
||||
ServerSettings.setGame(true);
|
||||
ServerSettings.setServerType(ServerType.GAME_TRASHGAMES);
|
||||
ServerSettings.setGameMode(GameMode.ADVENTURE);
|
||||
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
|
||||
pm.registerEvents(new JoinQuit(), this);
|
||||
pm.registerEvents(new PlayerEvents(), this);
|
||||
|
||||
new Setloc(this, "setloc", "sets locations");
|
||||
|
||||
setState(GameState.LOBBY);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TrashGames.getInstance(), () -> Core.getCommons().getLoggingHandler().getTrashGames().info("\n" +
|
||||
"\n" +
|
||||
"_________ _______ _______ _______ _______ _______ _______ _______ _______ _______ _ _ _________ _ _______ \n" +
|
||||
"\\__ __/( ____ )( ___ )( ____ \\|\\ /|( ____ \\( ___ )( )( ____ \\( ____ \\ ( ___ )( ( /|( \\ \\__ __/( ( /|( ____ \\\n" +
|
||||
" ) ( | ( )|| ( ) || ( \\/| ) ( || ( \\/| ( ) || () () || ( \\/| ( \\/ | ( ) || \\ ( || ( ) ( | \\ ( || ( \\/\n" +
|
||||
" | | | (____)|| (___) || (_____ | (___) || | | (___) || || || || (__ | (_____ | | | || \\ | || | | | | \\ | || (__ \n" +
|
||||
" | | | __)| ___ |(_____ )| ___ || | ____ | ___ || |(_)| || __) (_____ ) | | | || (\\ \\) || | | | | (\\ \\) || __) \n" +
|
||||
" | | | (\\ ( | ( ) | ) || ( ) || | \\_ )| ( ) || | | || ( ) | | | | || | \\ || | | | | | \\ || ( \n" +
|
||||
" | | | ) \\ \\__| ) ( |/\\____) || ) ( || (___) || ) ( || ) ( || (____/\\/\\____) | | (___) || ) \\ || (____/\\___) (___| ) \\ || (____/\\\n" +
|
||||
" )_( |/ \\__/|/ \\|\\_______)|/ \\|(_______)|/ \\||/ \\|(_______/\\_______) (_______)|/ )_)(_______/\\_______/|/ )_)(_______/\n" +
|
||||
" \n" +
|
||||
"\n"));
|
||||
new LobbyCountdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Core.getInstance().unregisterPlugin(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package eu.univento.trashgames.commands;
|
||||
|
||||
import eu.univento.commons.player.Rank;
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.trashgames.TrashGames;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Setloc extends AutoCommand<TrashGames>{
|
||||
|
||||
public Setloc(TrashGames plugin, String command, String description, String... aliases) {
|
||||
super(plugin, command, description, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) {
|
||||
if(args.length == 1) {
|
||||
Config.write("TrashGames.Locs." + args[0], p.getLocation());
|
||||
p.sendMessage("§aLocation gesetzt");
|
||||
}else {
|
||||
p.sendMessage("§6Nutze /setloc <Ort>");
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(msgs.NO_PERMS());
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("Spawn.1");
|
||||
list.add("Spawn.2");
|
||||
list.add("Corner.1");
|
||||
list.add("Corner.2");
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package eu.univento.trashgames.game;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public enum GameState {
|
||||
|
||||
LOBBY("Lobby"),
|
||||
GAME("Ingame"),
|
||||
RESTART("Restarting");
|
||||
|
||||
private String name;
|
||||
|
||||
GameState(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package eu.univento.trashgames.listeners;
|
||||
|
||||
import eu.univento.core.api.Utils;
|
||||
import eu.univento.core.api.game.PlayerManager;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.SpectateManager;
|
||||
import eu.univento.core.api.player.Spectator;
|
||||
import eu.univento.trashgames.TrashGames;
|
||||
import eu.univento.trashgames.game.GameState;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class JoinQuit implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(PlayerManager.size() > 2) {
|
||||
new Spectator(p);
|
||||
}else {
|
||||
PlayerManager.add(p);
|
||||
if(PlayerManager.size() == 2) {
|
||||
//new GameCountdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(PlayerManager.contains(p)) {
|
||||
PlayerManager.remove(p);
|
||||
if(TrashGames.getState() == GameState.GAME) {
|
||||
e.setQuitMessage(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " hat uns verlassen");
|
||||
PlayerManager.getPlayers().get(0).getDatabasePlayer().addCoins(50);
|
||||
Utils.restart();
|
||||
}
|
||||
}
|
||||
if(SpectateManager.contains(p)) {
|
||||
e.setQuitMessage(null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package eu.univento.trashgames.listeners;
|
||||
|
||||
import eu.univento.core.api.Utils;
|
||||
import eu.univento.core.api.game.PlayerManager;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.trashgames.TrashGames;
|
||||
import eu.univento.trashgames.game.GameState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.SpectralArrow;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class PlayerEvents implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getEntity());
|
||||
if(PlayerManager.contains(p)) {
|
||||
PlayerManager.remove(p);
|
||||
TrashGames.setState(GameState.RESTART);
|
||||
Bukkit.broadcastMessage(PlayerManager.getPlayers().get(0) + " hat gewonnen");
|
||||
PlayerManager.getPlayers().get(0).getDatabasePlayer().addCoins(50);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent e) {
|
||||
if(PlayerManager.size() == 1) Utils.restart();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent e) {
|
||||
if(e.getEntity() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
|
||||
p.sendMessage(String.valueOf(p.getHealth()));
|
||||
p.sendMessage("DamageModifer.Armor: " + e.getDamage(EntityDamageEvent.DamageModifier.ARMOR));
|
||||
p.sendMessage("DamageModifier.Blocking: " + e.getDamage(EntityDamageEvent.DamageModifier.BLOCKING));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamageByEntity(EntityDamageByEntityEvent e) {
|
||||
if(e.getEntity() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
|
||||
if(e.getDamager() instanceof Player) {
|
||||
CustomPlayer t = CustomPlayer.getPlayer((Player) e.getDamager());
|
||||
p.sendMessage("Du hast was abgekriegt von " + t.getDatabasePlayer().getRank().getColor() + t.getDisplayName());
|
||||
}
|
||||
if(e.getDamager() instanceof Arrow) {
|
||||
Arrow arrow = (Arrow) e.getDamager();
|
||||
CustomPlayer shooter = CustomPlayer.getPlayer((Player) arrow.getShooter());
|
||||
p.sendMessage("Der Pfeil kam von " + shooter.getDatabasePlayer().getRank().getColor() + shooter.getDisplayName());
|
||||
}
|
||||
if(e.getDamager() instanceof SpectralArrow) {
|
||||
SpectralArrow arrow = (SpectralArrow) e.getDamager();
|
||||
CustomPlayer shooter = CustomPlayer.getPlayer((Player) arrow.getShooter());
|
||||
p.sendMessage("Du bist nun erleuchtet worden von " + shooter.getDatabasePlayer().getRank().getColor() + shooter.getDisplayName());
|
||||
}
|
||||
if(e.getDamager() instanceof FishHook) {
|
||||
FishHook hook = (FishHook) e.getDamager();
|
||||
CustomPlayer shooter = CustomPlayer.getPlayer((Player) hook.getShooter());
|
||||
p.sendMessage("Du wurdest geangelt von " + shooter.getDatabasePlayer().getRank().getColor() + shooter.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(e.getClickedBlock() == null) return;
|
||||
if(e.getClickedBlock().getType() == Material.CHEST) {
|
||||
e.setCancelled(true);
|
||||
p.playEffect(e.getClickedBlock().getLocation(), Effect.CLOUD, 200);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
package eu.univento.trashgames.timers;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.Utils;
|
||||
import eu.univento.core.api.blocks.banners.BannerString;
|
||||
import eu.univento.core.api.blocks.banners.FloatingText;
|
||||
import eu.univento.core.api.game.PlayerManager;
|
||||
import eu.univento.core.api.map.Cuboid;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.trashgames.TrashGames;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class GameCountdown extends BukkitRunnable {
|
||||
|
||||
private int time = 3611;
|
||||
private Cuboid blocks;
|
||||
|
||||
public GameCountdown() {
|
||||
runTaskTimer(TrashGames.getInstance(), 20L, 20L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Core.getCommons().getLoggingHandler().getTrashGames().info("GameCountdown running: " + time);
|
||||
time--;
|
||||
|
||||
if(time == 3610) {
|
||||
Bukkit.broadcastMessage("Teleport");
|
||||
blocks = new Cuboid(Config.readLocation("TrashGames.Locs.Corner.1"), Config.readLocation("TrashGames.Locs.Corner.2"));
|
||||
Bukkit.broadcastMessage("Blocks: " + blocks.getBlocks().size());
|
||||
int i = 0;
|
||||
for(CustomPlayer player : PlayerManager.getPlayers()) {
|
||||
i++;
|
||||
player.teleport(Config.readLocation("TrashGames.Locs.Spawn." + i));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 10, 10000, false));
|
||||
}
|
||||
|
||||
ArrayList<Banner> wallBanners = blocks.getBlocks().stream().filter(block -> block.getType() == Material.WALL_BANNER).map(block -> (Banner) block.getState()).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<Banner> banners = blocks.getBlocks().stream().filter(block -> block.getType() == Material.STANDING_BANNER).map(block -> (Banner) block.getState()).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
BannerString string = new BannerString(wallBanners);
|
||||
FloatingText text = new FloatingText("§FeuniventoEU", 4);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
string.draw(text.next());
|
||||
}
|
||||
}.runTaskTimer(TrashGames.getInstance(), 2, 3);
|
||||
|
||||
BannerString string1 = new BannerString(banners);
|
||||
FloatingText text1 = new FloatingText("§F3TrashGames", 4);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
string1.draw(text1.next());
|
||||
}
|
||||
}.runTaskTimer(TrashGames.getInstance(), 2, 3);
|
||||
}
|
||||
|
||||
if (time == 3600) {
|
||||
for(CustomPlayer player : PlayerManager.getPlayers()) {
|
||||
dropItems(player.getLocation().add(0.0D, 3.0D, 0.0D));
|
||||
player.sendTitle(1, 5, 1, "§5Los", "§egehts");
|
||||
}
|
||||
Bukkit.broadcastMessage("Jetzt aber schnell");
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
blocks.getEntities().stream().filter(entity -> entity instanceof Item).forEach(Entity::remove);
|
||||
}
|
||||
}.runTaskLater(TrashGames.getInstance(), 10 * 20L);
|
||||
}
|
||||
|
||||
if (time == 3400) {
|
||||
Bukkit.broadcastMessage("Die Hälfte ist geschaft");
|
||||
blocks.getBlocks().stream().filter(block -> block.getType() == Material.CHEST).forEach(block -> {
|
||||
for (CustomPlayer players : PlayerManager.getPlayers()) {
|
||||
players.changeChestState(block.getLocation(), true);
|
||||
players.playSound(block.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0F, 1.0F);
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<Material> materials = Arrays.asList(Material.DIAMOND_SWORD, Material.IRON_SWORD, Material.DIAMOND_AXE, Material.DIAMOND_CHESTPLATE);
|
||||
int random = new Random().nextInt(materials.size());
|
||||
Item item = block.getWorld().dropItem(block.getLocation().add(0.0D, 1.0D, 0.0D), new ItemStack(materials.get(random)));
|
||||
item.setPickupDelay(5);
|
||||
item.setGlowing(true);
|
||||
item.setVelocity(item.getLocation().getDirection().multiply(0D).setY(0.5D));
|
||||
for (CustomPlayer player : PlayerManager.getPlayers())
|
||||
player.playSound(block.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.0F);
|
||||
}
|
||||
}.runTaskLater(TrashGames.getInstance(), 3 * 20L);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (CustomPlayer players : PlayerManager.getPlayers()) {
|
||||
players.changeChestState(block.getLocation(), false);
|
||||
players.playSound(block.getLocation(), Sound.BLOCK_CHEST_CLOSE, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(TrashGames.getInstance(), 5 * 20L);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (time == 0) {
|
||||
Bukkit.broadcastMessage("Die Zeit ist um");
|
||||
this.cancel();
|
||||
Utils.restart();
|
||||
for(CustomPlayer players : Core.getOnlinePlayers())
|
||||
players.sendTitle("§eBesser als", "CrazyCubics.net, Portzone.net");
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for(CustomPlayer players : Core.getOnlinePlayers())
|
||||
players.sendTitle("§3Besser als", "Revlax.de, Tubehome.net");
|
||||
}
|
||||
}.runTaskLater(TrashGames.getInstance(), 5 * 20L);
|
||||
}
|
||||
for (CustomPlayer player : Core.getOnlinePlayers()) {
|
||||
player.setLevel(time);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItems(Location loc) {
|
||||
List<ItemStack> items = Arrays.asList(new ItemStack(Material.APPLE, 64), new ItemStack(Material.WORKBENCH),
|
||||
new ItemStack(Material.COBBLESTONE, 2), new ItemStack(Material.STICK, 4), new ItemStack(Material.ROTTEN_FLESH, 64),
|
||||
new ItemStack(Material.APPLE, 20));
|
||||
for (ItemStack itemStack : items) {
|
||||
Item item = loc.getWorld().dropItemNaturally(loc, itemStack);
|
||||
item.setPickupDelay(3);
|
||||
item.setGlowing(true);
|
||||
item.setVelocity(item.getLocation().getDirection().multiply(0D).setY(0.5D));
|
||||
for (CustomPlayer player : PlayerManager.getPlayers())
|
||||
player.playSound(item.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package eu.univento.trashgames.timers;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.game.PlayerManager;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.trashgames.TrashGames;
|
||||
import eu.univento.trashgames.game.GameState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class LobbyCountdown extends BukkitRunnable{
|
||||
|
||||
private int time = 60;
|
||||
|
||||
public LobbyCountdown() {
|
||||
runTaskTimer(TrashGames.getInstance(), 20L, 20L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(PlayerManager.size() == 2) {
|
||||
time--;
|
||||
for(CustomPlayer player : Core.getOnlinePlayers()) {
|
||||
player.setLevel(time);
|
||||
player.playSound(player.getEyeLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
if(time == 0) {
|
||||
if(PlayerManager.size() == 2) {
|
||||
this.cancel();
|
||||
TrashGames.setState(GameState.GAME);
|
||||
new GameCountdown();
|
||||
for(CustomPlayer players : Core.getOnlinePlayers()) {
|
||||
players.setHealth(20.0D);
|
||||
players.setFoodLevel(20);
|
||||
players.clearPotionEffects();
|
||||
players.getInventory().clear();
|
||||
}
|
||||
}else{
|
||||
Bukkit.broadcastMessage("Und noch mal warten");
|
||||
this.cancel();
|
||||
new LobbyCountdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
name: TrashGames
|
||||
main: eu.univento.trashgames.TrashGames
|
||||
version: 0.1
|
||||
author: joethei
|
||||
website: http://univento.eu
|
||||
description: univento.eu Secret Minigame
|
||||
depend: [Core]
|
Loading…
Reference in New Issue