first commit

This commit is contained in:
Johannes Theiner 2016-09-17 12:04:34 +02:00
commit 900983dcb2
15 changed files with 667 additions and 0 deletions

45
Maya.iml Normal file
View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.10-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="Core" />
<orderEntry type="module" module-name="CloudCommons" />
<orderEntry type="module" module-name="Commons" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.8" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-async:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:bson:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb.morphia:morphia:1.2.1" level="project" />
<orderEntry type="library" name="Maven: cglib:cglib-nodep:2.2.2" level="project" />
<orderEntry type="library" name="Maven: com.thoughtworks.proxytoys:proxytoys:1.0" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:2.4.5" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.16" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.36.Final" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
</component>
</module>

80
pom.xml Normal file
View File

@ -0,0 +1,80 @@
<?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>groupId</groupId>
<artifactId>Maya</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Univento.eu Maya 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-beta-5</version>
<configuration>
<archive>
<manifest>
<mainClass>eu.univento.maya.Maya</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>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Core</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

19
src/main/Maya.iml Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="target" level="project" />
<orderEntry type="library" name="target1" level="project" />
<orderEntry type="library" name="Kartoffelsuppe" level="project" />
<orderEntry type="library" name="Core" level="project" />
<orderEntry type="library" name="FakeCore" level="project" />
<orderEntry type="library" name="test-1.0-SNAPSHOT-jar-with-dependencies" level="project" />
<orderEntry type="module" module-name="FakeCore" />
<orderEntry type="module" module-name="Core" />
</component>
</module>

View File

@ -0,0 +1,109 @@
package eu.univento.maya;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import eu.univento.core.api.server.Game;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.maya.game.GameStage;
import eu.univento.maya.game.LobbyCounter;
import eu.univento.maya.listener.PlayerEvents;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
/**
* main class
* @author joethei
* @version 0.1
*/
public class Maya extends JavaPlugin{
/**
* instance
*/
private static Maya instance;
/**
* @return plugin instance
*/
public static Maya getInstance() {
return instance;
}
/**
* logging and stuff
*/
private static Logger logger = Bukkit.getLogger();
/**
* game stage
*/
private static GameStage stage;
/**
* @return GameStage
*/
public static GameStage getStage() {
return stage;
}
/**
* sets gamestage
* @param stage GameStage
*/
public static void setStage(GameStage stage) {
Maya.stage = stage;
}
public static int getMinPlayers() {
return 1;
}
public static int getMaxPlayers() {
return 12;
}
private static ArrayList<Player> players = new ArrayList<>();
public static ArrayList<Player> getPlayers() {
return players;
}
public static int lobbyID;
public static int warmupID;
public static int gameID;
public static int buyID;
public static int deathmatchID;
public static int restartID;
/**
* @param level Log level
* @param string String
*/
public static void log(Level level, String string) {
logger.log(level, "[" + getInstance().getDescription().getName() + "] " + string);
}
@SuppressWarnings("deprecation")
@Override
public void onEnable() {
instance = this;
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerEvents(), this);
ServerSettings.setGame(true);
ServerSettings.setPlayedGame(Game.Maya);
ServerSettings.setGameMode(GameMode.ADVENTURE);
log(Level.INFO, "Plugin Version: " + getDescription().getVersion() + " gestartet");
stage = GameStage.Lobby;
lobbyID = getServer().getScheduler().scheduleSyncRepeatingTask(getInstance(), new LobbyCounter(), 20L, 20L);
}
@Override
public void onDisable() {
log(Level.INFO, "Plugin beendet");
}
}

View File

@ -0,0 +1,30 @@
package eu.univento.maya;
import eu.univento.maya.game.GameStage;
import eu.univento.maya.game.RestartCounter;
import org.bukkit.Bukkit;
/**
* @author joethei
* @version 0.1
*/
public class Utils {
public static void endGame(GameStage stage) {
Maya.setStage(GameStage.Restart);
Maya.restartID = Maya.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(Maya.getInstance(), new RestartCounter(), 20L, 20L);
Bukkit.getScheduler().cancelTask(getSchedulerId(stage));
}
static int getSchedulerId(GameStage stage) {
switch (stage) {
case Lobby: return Maya.lobbyID;
case Warmup: return Maya.warmupID;
case InGame: return Maya.gameID;
case Buy: return Maya.buyID;
case DeathMatch: return Maya.deathmatchID;
case Restart: return Maya.restartID;
default: return 0;
}
}
}

View File

@ -0,0 +1,33 @@
package eu.univento.maya.game;
import eu.univento.core.api.Title;
import eu.univento.maya.Maya;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
/**
* @author joethei
* @version 0.1
*/
public class BuyCounter extends BukkitRunnable{
int time = 60;
public void run() {
if(Maya.getStage() == GameStage.Buy) {
for(Player players : Bukkit.getOnlinePlayers()) {
Title.sendTitle(players, 1, 1, 1, "§6" + time, "");
players.playSound(players.getEyeLocation(), Sound.ENTITY_ARROW_HIT, 1.0F, 1.0F);
}
if(time == 0) {
Maya.setStage(GameStage.DeathMatch);
Maya.deathmatchID = Maya.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(Maya.getInstance(), new DeathmatchCounter(), 20L, 20L);
Bukkit.getScheduler().cancelTask(Maya.buyID);
}
time--;
}
return;
}
}

View File

@ -0,0 +1,33 @@
package eu.univento.maya.game;
import eu.univento.core.api.Title;
import eu.univento.maya.Maya;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
/**
* @author joethei
* @version 0.1
*/
public class DeathmatchCounter extends BukkitRunnable{
int time = 20;
public void run() {
if(Maya.getStage() == GameStage.DeathMatch) {
for(Player players : Bukkit.getOnlinePlayers()) {
Title.sendTitle(players, 1, 1, 1, "§6" + time, "");
players.playSound(players.getEyeLocation(), Sound.ENTITY_ARROW_HIT, 1.0F, 1.0F);
}
if(time == 0) {
Maya.setStage(GameStage.Restart);
Bukkit.getScheduler().cancelTask(Maya.deathmatchID);
Maya.restartID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Maya.getInstance(), new RestartCounter(), 20L, 20L);
}
time--;
}
return;
}
}

View File

@ -0,0 +1,57 @@
package eu.univento.maya.game;
import eu.univento.maya.Maya;
import eu.univento.maya.Utils;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
/**
* runnable for game counter
* @author joethei
* @version 0.2
*/
public class GameCounter extends BukkitRunnable{
int time = 0;
int maxTime = 80;
public void run() {
if(Maya.getStage() == GameStage.InGame) {
updateScoreboard();
if(Maya.getPlayers().size() <= 1) {
Utils.endGame(Maya.getStage());
}
if(time == maxTime) {
Maya.setStage(GameStage.Buy);
Maya.buyID = Maya.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(Maya.getInstance(), new BuyCounter(), 20L, 20L);
Bukkit.getScheduler().cancelTask(Maya.gameID);
}
time++;
}
return;
}
void updateScoreboard() {
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
Objective obj = board.getObjective("maya");
if(obj == null) {
obj = board.registerNewObjective("maya", "dummy");
}
obj.setDisplayName("§6Maya");
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
Score time = obj.getScore("§6Zeit:");
time.setScore(this.time);
if(this.time == maxTime) {
obj.unregister();
}
}
}

View File

@ -0,0 +1,59 @@
package eu.univento.maya.game;
/**
* enum for gamestages
* @author joethei
* @version 1.0
*/
public enum GameStage {
/**
* players are waiting in the lobby until min player count is reached
*/
Lobby(1),
/**
* players waiting while map is being loaded
*/
Warmup(2),
/**
* game has been started, teams are hiding there block
*/
InGame(3),
/**
* players can buy items
*/
Buy(4),
/**
* players can fight
*/
DeathMatch(5),
/**
* server is reseting map and restarts
*/
Restart(6);
/**
* id of stage
*/
private int id;
/**
* gets gamestage for id
* @param id Integer
*/
private GameStage(int id) {
this.setId(id);
}
/**
* gets id of gamestage
* @return Integer
*/
public int getId() {
return id;
}
/**
* sets id
* @param id Integer
*/
public void setId(int id) {
this.id = id;
}
}

View File

@ -0,0 +1,40 @@
package eu.univento.maya.game;
import eu.univento.maya.Maya;
import eu.univento.maya.modules.Modules;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
/**
* runnable for lobby counter
* @author joethei
* @version 0.2
*/
public class LobbyCounter extends BukkitRunnable{
int time = 60;
public void run() {
if(Maya.getStage() == GameStage.Lobby && Bukkit.getOnlinePlayers().size() >= Maya.getMinPlayers()) {
for(Player players : Bukkit.getOnlinePlayers()) {
players.setLevel(time);
if(time == 30) {
Modules.generate();
}
if(time <= 10) {
players.playSound(players.getEyeLocation(), Sound.ENTITY_ARROW_HIT, 1.0F, 1.0F);
}
}
if(time == 0) {
Maya.setStage(GameStage.Warmup);
Maya.warmupID = Maya.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(Maya.getInstance(), new WarmupCounter(), 20L, 20L);
Bukkit.getScheduler().cancelTask(Maya.lobbyID);
}
time--;
}
return;
}
}

View File

@ -0,0 +1,33 @@
package eu.univento.maya.game;
import eu.univento.core.api.server.Servers;
import eu.univento.core.api.Utils;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.maya.Maya;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
/**
* @author joethei
* @version 0.1
*/
public class RestartCounter extends BukkitRunnable{
int time = 10;
public void run() {
if(Maya.getStage() == GameStage.Restart) {
Bukkit.broadcastMessage("§6Server startet neu in " + time + " Sekunden");
if(time == 0) {
Bukkit.getScheduler().cancelTask(Maya.restartID);
Utils.restart();
ServerSettings.setPlayedGame(null);
Servers.connectAllToServer("Lobby01");
Bukkit.broadcastMessage("Alle würden jetzt auf die Lobby01 kommen");
}
time--;
}
}
}

View File

@ -0,0 +1,34 @@
package eu.univento.maya.game;
import eu.univento.core.api.Title;
import eu.univento.maya.Maya;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
/**
* @author joethei
* @version 0.1
*/
public class WarmupCounter extends BukkitRunnable{
int time = 10;
public void run() {
if(Maya.getStage() == GameStage.Warmup) {
for(Player players : Bukkit.getOnlinePlayers()) {
Title.sendTitle(players, 1, 10, 1, "§6" + time, "");
players.playSound(players.getEyeLocation(), Sound.ENTITY_ARROW_HIT, 1.0F, 1.0F);
}
if(time == 0) {
Maya.setStage(GameStage.InGame);
Maya.gameID = Maya.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(Maya.getInstance(), new GameCounter(), 20L, 20L);
Bukkit.getScheduler().cancelTask(Maya.warmupID);
}
time--;
}
return;
}
}

View File

@ -0,0 +1,60 @@
package eu.univento.maya.listener;
import eu.univento.core.api.Config;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.Spectator;
import eu.univento.maya.Maya;
import eu.univento.maya.game.GameStage;
import org.bukkit.GameMode;
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 PlayerEvents implements Listener{
@EventHandler
public void onJoin(PlayerJoinEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(Maya.getStage() == GameStage.Lobby) {
if(Maya.getPlayers().size() >= Maya.getMaxPlayers()) {
Spectator.add(p);
p.teleport(Config.readLocation("Maya.Spawn.Spectator"));
p.sendMessage("§cDu bist nun Zuschauer");
e.setJoinMessage(null);
return;
}
p.teleport(Config.readLocation("Maya.Spawn.Lobby"));
p.sendMessage("§cDu bist dem Spiel beigetreten");
e.setJoinMessage("§6Maya: " + p.getColor() + p.getDisplayName() + " §6ist dem Spiel beigetreten");
p.setGameMode(GameMode.ADVENTURE);
}else {
e.setJoinMessage(null);
Spectator.add(p);
p.teleport(Config.readLocation("Maya.Spawn.Spectator"));
p.sendMessage("§cDu bist nun Zuschauer");
}
}
@EventHandler
public void onQuit(PlayerQuitEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(Spectator.is(p)) {
Spectator.remove(p);
e.setQuitMessage(null);
}
if(Maya.getPlayers().contains(p)) {
Maya.getPlayers().remove(p);
e.setQuitMessage("§6Maya: " + p.getColor() + p.getDisplayName() + " §6hat das Spiel verlassen");
}
}
}

View File

@ -0,0 +1,29 @@
package eu.univento.maya.modules;
import eu.univento.core.api.map.MinecraftSchematic;
import eu.univento.maya.Maya;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import java.io.File;
import java.util.logging.Level;
/**
* @author joethei
* @version 0.1
*/
public class Modules {
private static void loadModule(Location loc, String name) {
File file = new File("plugins/Core/Maya/modules/", name + ".schematic");
MinecraftSchematic schematic = new MinecraftSchematic(file);
schematic.placeInWorld(loc);
}
public static void generate() {
int playercount = Maya.getPlayers().size();
loadModule(Bukkit.getWorld("world").getSpawnLocation(), "test");
Maya.log(Level.INFO, "Modul test wird generiert");
}
}

6
src/main/java/plugin.yml Normal file
View File

@ -0,0 +1,6 @@
main: eu.univento.maya.Maya
name: Maya
author: joethei
version: 0.1
description: Maya Minigame from univento.eu
website: http://univento.eu/games/maya