first commit
This commit is contained in:
commit
0f3b8cb9a0
|
@ -0,0 +1,48 @@
|
|||
<?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.bukkit:craftbukkit:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit: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" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:17.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" 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: org.spigotmc:spigot-api:1.10-R0.1-SNAPSHOT" 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" scope="PROVIDED" />
|
||||
<orderEntry type="module" module-name="CloudCommons" scope="PROVIDED" />
|
||||
<orderEntry type="module" module-name="Commons" scope="PROVIDED" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.8" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:mongo-java-driver:3.2.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:mongodb-driver-async:3.2.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:mongodb-driver-core:3.2.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:bson:3.2.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb.morphia:morphia:1.2.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:2.2.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.thoughtworks.proxytoys:proxytoys:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.zaxxer:HikariCP:2.4.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.16" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-all:4.0.36.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: joda-time:joda-time:2.9.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.theholywaffle:teamspeak3-api:1.0.14-SNAPSHOT" level="project" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
-->
|
||||
|
||||
<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>WoolGet</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Univento.eu WoolGet 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.woolget.WoolGet</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.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<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>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -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>
|
|
@ -0,0 +1,112 @@
|
|||
package eu.univento.woolget;
|
||||
|
||||
import eu.univento.cloud.commons.server.ServerType;
|
||||
import eu.univento.core.api.map.Map;
|
||||
import eu.univento.core.api.map.MapDatabase;
|
||||
import eu.univento.core.api.map.MapVoting;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import eu.univento.woolget.commands.SetPositions;
|
||||
import eu.univento.woolget.game.GameStage;
|
||||
import eu.univento.woolget.game.LobbyCounter;
|
||||
import eu.univento.woolget.listeners.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class WoolGet extends JavaPlugin{
|
||||
|
||||
private static WoolGet instance;
|
||||
public static WoolGet getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static Logger logger = Bukkit.getLogger();
|
||||
|
||||
public static void log(Level level, String msg) {
|
||||
if(ServerSettings.isDebug())
|
||||
logger.log(level, "[" + getInstance().getDescription().getName() + "]" + msg);
|
||||
}
|
||||
|
||||
public static int lobbyID;
|
||||
public static int warmupID;
|
||||
public static int gameID;
|
||||
public static int restartID;
|
||||
|
||||
public static int getMinPlayers() {
|
||||
return 2;
|
||||
}
|
||||
public static int getMaxPlayers() {
|
||||
return 12;
|
||||
}
|
||||
|
||||
private static GameStage gameStage;
|
||||
public static GameStage getGameStage() {
|
||||
return gameStage;
|
||||
}
|
||||
public static void setGameStage(GameStage gameStage) {
|
||||
WoolGet.gameStage = gameStage;
|
||||
ServerSettings.setGameState(gameStage.toString());
|
||||
}
|
||||
|
||||
private static ArrayList<CustomPlayer> players = new ArrayList<>();
|
||||
public static ArrayList<CustomPlayer> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
private static MapVoting voting;
|
||||
public static MapVoting getVoting() {
|
||||
return voting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
instance = this;
|
||||
setGameStage(GameStage.Lobby);
|
||||
ServerSettings.setGame(true);
|
||||
ServerSettings.setServerType(ServerType.GAME_WOOLGET);
|
||||
ServerSettings.setGameMode(GameMode.ADVENTURE);
|
||||
|
||||
voting = new MapVoting("Map Voting");
|
||||
for(Map map : MapDatabase.getAllMaps(ServerType.GAME_WOOLGET)) {
|
||||
voting.addMap(map);
|
||||
}
|
||||
voting.setVotingMaps();
|
||||
voting.registerListener(this);
|
||||
|
||||
pm.registerEvents(new Inventorys(), this);
|
||||
pm.registerEvents(new JoinQuit(), this);
|
||||
pm.registerEvents(new Blocks(), this);
|
||||
pm.registerEvents(new PlayerEvents(), this);
|
||||
pm.registerEvents(new ChestManager(), this);
|
||||
|
||||
new SetPositions(this, "setpositions", "sets all positions", "setpos");
|
||||
|
||||
ChestManager.fillLists();
|
||||
|
||||
log(Level.INFO, "Plugin started");
|
||||
|
||||
lobbyID = getServer().getScheduler().scheduleSyncRepeatingTask(getInstance(), new LobbyCounter(), 20L, 20L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
world.getEntities().forEach(Entity::remove);
|
||||
}
|
||||
log(Level.INFO, "Plugin stopped");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.commands;
|
||||
|
||||
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.core.api.player.Rank;
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class SetPositions extends AutoCommand<WoolGet> {
|
||||
|
||||
|
||||
public SetPositions(WoolGet 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());
|
||||
if(p.isAllowed(Rank.SrDeveloper)) {
|
||||
if(args.length == 1) {
|
||||
Config.write("Strive." + args[0], p.getLocation());
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Lobby_SET_LOCATION());
|
||||
}else {
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Lobby_SET_LOCATION_USAGE());
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(p.getMessages().NO_PERMS());
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.game;
|
||||
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import eu.univento.woolget.utils.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
|
||||
/**
|
||||
* runnable for game counter
|
||||
* @author joethei
|
||||
* @version 0.2
|
||||
*/
|
||||
public class GameCounter extends BukkitRunnable{
|
||||
|
||||
private int time = 0;
|
||||
private int maxTime = 1000;
|
||||
|
||||
public void run() {
|
||||
if(WoolGet.getGameStage() == GameStage.Game) {
|
||||
if(WoolGet.getPlayers().size() <= 1) {
|
||||
Utils.endGame(WoolGet.getGameStage());
|
||||
}
|
||||
if(time == maxTime) {
|
||||
WoolGet.setGameStage(GameStage.Restart);
|
||||
WoolGet.restartID = WoolGet.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(WoolGet.getInstance(), new RestartCounter(), 20L, 20L);
|
||||
Bukkit.getScheduler().cancelTask(WoolGet.gameID);
|
||||
}
|
||||
time++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.game;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public enum GameStage {
|
||||
|
||||
Lobby(0),
|
||||
Warmup(1),
|
||||
Game(2),
|
||||
Restart(3);
|
||||
|
||||
private int id;
|
||||
private GameStage(int id) {
|
||||
this.setId(id);
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.game;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.game.Team;
|
||||
import eu.univento.core.api.game.TeamManager;
|
||||
import eu.univento.core.api.map.Map;
|
||||
import eu.univento.core.api.map.MapDownloader;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.schematic.Cuboid;
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import eu.univento.woolget.listeners.Blocks;
|
||||
import eu.univento.woolget.listeners.PlayerEvents;
|
||||
import eu.univento.woolget.utils.TeamChooser;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* runnable for lobby counter
|
||||
* @author joethei
|
||||
* @version 0.2
|
||||
*/
|
||||
public class LobbyCounter extends BukkitRunnable{
|
||||
|
||||
private int time = 60;
|
||||
|
||||
public void run() {
|
||||
if(WoolGet.getGameStage() == GameStage.Lobby && Bukkit.getOnlinePlayers().size() >= WoolGet.getMinPlayers()) {
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.setLevel(time);
|
||||
if(time == 30) {
|
||||
players.playSound(players.getEyeLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 1.0F);
|
||||
}
|
||||
if(time <= 10) {
|
||||
players.playSound(players.getEyeLocation(), Sound.ENTITY_ARROW_HIT, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
if(time == 10) {
|
||||
Map map = WoolGet.getVoting().getWinningMap();
|
||||
Bukkit.broadcastMessage("Das Voting ist beendet, gewonnen hat " + map.getName());
|
||||
for(CustomPlayer players : Core.getOnlinePlayers())
|
||||
players.getInventory().clear();
|
||||
World world = MapDownloader.loadMap(map);
|
||||
assert world != null;
|
||||
world.setPVP(true);
|
||||
world.setDifficulty(Difficulty.PEACEFUL);
|
||||
world.setAutoSave(false);
|
||||
}
|
||||
|
||||
if(time == 0) {
|
||||
TeamManager.addTeam(new Team("blue", "§9"));
|
||||
TeamManager.addTeam(new Team("yellow", "§e"));
|
||||
Blocks.setTeams();
|
||||
PlayerEvents.setTeams();
|
||||
|
||||
Map map = WoolGet.getVoting().getWinningMap();
|
||||
Cuboid blue = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Blue.MinPos"), Config.readLocation("Strive." + map.getName() + ".Blue.MaxPos"));
|
||||
Cuboid yellow = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Yellow.MinPos"), Config.readLocation("Strive." + map.getName() + ".Yellow.MaxPos"));
|
||||
|
||||
TeamChooser.addToTeams();
|
||||
|
||||
WoolGet.setGameStage(GameStage.Warmup);
|
||||
WoolGet.warmupID = WoolGet.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(WoolGet.getInstance(), new WarmupCounter(), 20L, 20L);
|
||||
Bukkit.getScheduler().cancelTask(WoolGet.lobbyID);
|
||||
|
||||
for(CustomPlayer players : WoolGet.getPlayers()) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(players);
|
||||
Team teamBlue = TeamManager.getTeam("blue");
|
||||
Team teamYellow = TeamManager.getTeam("yellow");
|
||||
|
||||
teamBlue.getScoreboardTeam().setOption(org.bukkit.scoreboard.Team.Option.NAME_TAG_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.FOR_OWN_TEAM);
|
||||
teamYellow.getScoreboardTeam().setOption(org.bukkit.scoreboard.Team.Option.NAME_TAG_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.FOR_OWN_TEAM);
|
||||
|
||||
players.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||
|
||||
players.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
if(teamBlue.isPlayer(p)) {
|
||||
p.teleport(blue.getRandomLocation());
|
||||
p.sendMessage("§aDu bist in Team Blau");
|
||||
|
||||
ItemStack item = new ItemStack(Material.WOOL, 1, (short) 11);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("§9Dein Block");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
p.getInventory().clear();
|
||||
p.getInventory().addItem(item);
|
||||
}
|
||||
if(teamYellow.isPlayer(p)) {
|
||||
p.teleport(yellow.getRandomLocation());
|
||||
p.sendMessage("§aDu bist in Team Gelb");
|
||||
|
||||
ItemStack item = new ItemStack(Material.WOOL, 1, (short) 4);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("§eDein Block");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
p.getInventory().clear();
|
||||
p.getInventory().addItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
time--;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.game;
|
||||
|
||||
import eu.univento.core.api.server.Servers;
|
||||
import eu.univento.core.api.Utils;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import eu.univento.woolget.WoolGet;
|
||||
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(WoolGet.getGameStage() == GameStage.Restart) {
|
||||
|
||||
Bukkit.broadcastMessage("§6Server startet neu in " + time + " Sekunden");
|
||||
|
||||
if(time == 0) {
|
||||
Bukkit.getScheduler().cancelTask(WoolGet.restartID);
|
||||
Utils.restart();
|
||||
ServerSettings.setPlayedGame(null);
|
||||
Servers.connectAllToServer("Lobby01");
|
||||
}
|
||||
time--;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.game;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.game.TeamManager;
|
||||
import eu.univento.core.api.schematic.Cuboid;
|
||||
import eu.univento.core.api.map.Map;
|
||||
import eu.univento.core.api.player.Spectator;
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import eu.univento.woolget.listeners.Blocks;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
class WarmupCounter extends BukkitRunnable{
|
||||
|
||||
private int time = 60;
|
||||
|
||||
private ArrayList<Location> usedLocations = new ArrayList<>();
|
||||
|
||||
public void run() {
|
||||
if(WoolGet.getGameStage() == GameStage.Warmup) {
|
||||
if(time == 60) {
|
||||
Map map = WoolGet.getVoting().getWinningMap();
|
||||
Cuboid blue = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Blue.MinPos"), Config.readLocation("Strive." + map.getName() + ".Blue.MaxPos"));
|
||||
Cuboid yellow = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Yellow.MinPos"), Config.readLocation("Strive." + map.getName() + ".Yellow.MaxPos"));
|
||||
|
||||
for (int i = 0; i <= 25; i++) {
|
||||
Location blueChest = blue.getRandomLocation();
|
||||
Location yellowChest = yellow.getRandomLocation();
|
||||
if (isSafeLocation(blueChest) && !usedLocations.contains(blueChest)) {
|
||||
blueChest.getBlock().setType(Material.CHEST);
|
||||
usedLocations.add(blueChest);
|
||||
} else i--;
|
||||
if (isSafeLocation(yellowChest) && !usedLocations.contains(yellowChest)) {
|
||||
yellowChest.getBlock().setType(Material.CHEST);
|
||||
|
||||
usedLocations.add(yellowChest);
|
||||
} else i--;
|
||||
}
|
||||
blue.getRandomLocation().getBlock().setType(Material.ENCHANTMENT_TABLE);
|
||||
yellow.getRandomLocation().getBlock().setType(Material.ENCHANTMENT_TABLE);
|
||||
}
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.setLevel(time);
|
||||
}
|
||||
if(time == 0) {
|
||||
WoolGet.setGameStage(GameStage.Game);
|
||||
WoolGet.gameID = WoolGet.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(WoolGet.getInstance(), new GameCounter(), 20L, 20L);
|
||||
Bukkit.getScheduler().cancelTask(WoolGet.warmupID);
|
||||
|
||||
WoolGet.getPlayers().stream().filter(players -> !Blocks.placedBlocksBlue.containsKey(players) || !Blocks.placedBlocksYellow.containsKey(players)).forEach(players -> {
|
||||
WoolGet.getPlayers().remove(players);
|
||||
Spectator.add(players);
|
||||
TeamManager.getTeam(players).removePlayer(players);
|
||||
Bukkit.broadcastMessage(players.getDisplayName() + "hat seinen Block nicht platziert");
|
||||
});
|
||||
}
|
||||
time--;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSafeLocation(Location loc) {
|
||||
return loc.getBlock().getType() != Material.WATER && loc.getBlock().getType() != Material.STATIONARY_WATER;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.listeners;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.game.Team;
|
||||
import eu.univento.core.api.game.TeamManager;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import eu.univento.woolget.game.GameCounter;
|
||||
import eu.univento.woolget.game.GameStage;
|
||||
import eu.univento.woolget.game.RestartCounter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Blocks implements Listener{
|
||||
|
||||
public static HashMap<CustomPlayer, Location> placedBlocksBlue = new HashMap<>();
|
||||
public static HashMap<CustomPlayer,Location> placedBlocksYellow = new HashMap<>();
|
||||
private static Team teamBlue;
|
||||
private static Team teamYellow;
|
||||
|
||||
private boolean blue;
|
||||
private boolean yellow;
|
||||
|
||||
public static void setTeams() {
|
||||
teamBlue = TeamManager.getTeam("blue");
|
||||
teamYellow = TeamManager.getTeam("yellow");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
if(WoolGet.getGameStage() == GameStage.Warmup && e.getBlock().getType() == Material.WOOL) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
Bukkit.broadcastMessage(p.getDisplayName() + " hat seinen Block platziert");
|
||||
if (teamBlue.isPlayer(p)) {
|
||||
placedBlocksBlue.put(p, e.getBlock().getLocation());
|
||||
if(teamBlue.getPlayers().size() == placedBlocksBlue.size()) {
|
||||
blue = true;
|
||||
Bukkit.broadcastMessage("Team Blau hat alle Blöcke platziert");
|
||||
}
|
||||
}
|
||||
if (teamYellow.isPlayer(p)) {
|
||||
placedBlocksYellow.put(p, e.getBlock().getLocation());
|
||||
if(teamYellow.getPlayers().size() == placedBlocksYellow.size()) {
|
||||
yellow = true;
|
||||
Bukkit.broadcastMessage("Team Gelb hat alle Blöcke platziert");
|
||||
}
|
||||
}
|
||||
if(blue && yellow) {
|
||||
WoolGet.setGameStage(GameStage.Game);
|
||||
WoolGet.gameID = Bukkit.getScheduler().scheduleSyncRepeatingTask(WoolGet.getInstance(), new GameCounter(), 20L, 20L);
|
||||
for(CustomPlayer players : Core.getOnlinePlayers()) {
|
||||
players.setExp(0.0F);
|
||||
}
|
||||
Bukkit.getScheduler().cancelTask(WoolGet.warmupID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
e.setCancelled(true);
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(WoolGet.getGameStage() == GameStage.Game && e.getBlock().getType() == Material.WOOL) {
|
||||
if(placedBlocksBlue.containsValue(e.getBlock().getLocation())) {
|
||||
CustomPlayer t = getKeyByValue(placedBlocksBlue, e.getBlock().getLocation());
|
||||
if(TeamManager.getTeam(p) != TeamManager.getTeam(t)) {
|
||||
Bukkit.broadcastMessage(p.getDisplayName() + " hat den Block von " + t.getDisplayName() + " abgebaut");
|
||||
e.getBlock().setType(Material.AIR);
|
||||
TNTPrimed tnt = e.getBlock().getWorld().spawn(e.getBlock().getLocation(), TNTPrimed.class);
|
||||
tnt.setFuseTicks(100);
|
||||
tnt.setGlowing(true);
|
||||
tnt.setCustomName(t.getDisplayName());
|
||||
tnt.setCustomNameVisible(true);
|
||||
placedBlocksBlue.remove(t);
|
||||
if(placedBlocksBlue.size() == 0) {
|
||||
Bukkit.broadcastMessage("Team Gelb hat gewonnen");
|
||||
WoolGet.setGameStage(GameStage.Restart);
|
||||
WoolGet.restartID = WoolGet.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(WoolGet.getInstance(), new RestartCounter(), 20L, 20L);
|
||||
Bukkit.getScheduler().cancelTask(WoolGet.gameID);
|
||||
}
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(placedBlocksYellow.containsValue(e.getBlock().getLocation())) {
|
||||
CustomPlayer t = getKeyByValue(placedBlocksYellow, e.getBlock().getLocation());
|
||||
if(TeamManager.getTeam(p) != TeamManager.getTeam(t)) {
|
||||
Bukkit.broadcastMessage(p.getDisplayName() + " hat den Block von " + t.getDisplayName() + " abgebaut");
|
||||
e.getBlock().setType(Material.AIR);
|
||||
TNTPrimed tnt = e.getBlock().getWorld().spawn(e.getBlock().getLocation(), TNTPrimed.class);
|
||||
tnt.setFuseTicks(100);
|
||||
tnt.setGlowing(true);
|
||||
tnt.setCustomName(t.getDisplayName());
|
||||
tnt.setCustomNameVisible(true);
|
||||
placedBlocksYellow.remove(t);
|
||||
if(placedBlocksYellow.size() == 0) {
|
||||
Bukkit.broadcastMessage("Team Blau hat gewonnen");
|
||||
WoolGet.setGameStage(GameStage.Restart);
|
||||
WoolGet.restartID = WoolGet.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(WoolGet.getInstance(), new RestartCounter(), 20L, 20L);
|
||||
Bukkit.getScheduler().cancelTask(WoolGet.gameID);
|
||||
}
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}if(WoolGet.getGameStage() == GameStage.Warmup || WoolGet.getGameStage() == GameStage.Game) {
|
||||
e.getBlock().getDrops().clear();
|
||||
if(teamBlue.isPlayer(p)) e.getBlock().getDrops().add(new ItemStack(Material.STAINED_GLASS, 1, (short) 11));
|
||||
if(teamYellow.isPlayer(p)) e.getBlock().getDrops().add(new ItemStack(Material.STAINED_GLASS, 1, (short) 4));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onArmorStandManipulate(PlayerArmorStandManipulateEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
private CustomPlayer getKeyByValue(HashMap<CustomPlayer, Location> map, Location value) {
|
||||
for(Map.Entry<CustomPlayer, Location> entry : map.entrySet()) {
|
||||
if(entry.getValue().equals(value)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent e) {
|
||||
for(Block b : e.blockList()) {
|
||||
float x = -5.0F + (float) (Math.random() * 11.0D);
|
||||
float y = -6.0F + (float) (Math.random() * 12.0D);
|
||||
float z = -7.0F + (float) (Math.random() * 13.0D);
|
||||
|
||||
FallingBlock fall = b.getWorld().spawnFallingBlock(b.getLocation(), b.getType(), b.getData());
|
||||
fall.setDropItem(false);
|
||||
fall.setVelocity(new Vector(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package eu.univento.woolget.listeners;
|
||||
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class ChestManager implements Listener {
|
||||
|
||||
private HashMap<Location, Inventory> chests = new HashMap<>();
|
||||
private static ArrayList<ItemStack> normalChest = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> rareChest = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> epicChest = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> incredibleChest = new ArrayList<>();
|
||||
|
||||
public static void fillLists() {
|
||||
//fillng normal chest items
|
||||
normalChest.add(new ItemStack(Material.LEATHER_BOOTS));
|
||||
normalChest.add(new ItemStack(Material.LEATHER_CHESTPLATE));
|
||||
normalChest.add(new ItemStack(Material.WOOD_SWORD));
|
||||
normalChest.add(new ItemStack(Material.LEATHER_BOOTS));
|
||||
normalChest.add(new ItemStack(Material.LEATHER_HELMET));
|
||||
normalChest.add(new ItemStack(Material.WHEAT));
|
||||
normalChest.add(new ItemStack(Material.CHAINMAIL_BOOTS));
|
||||
normalChest.add(new ItemStack(Material.STONE_AXE));
|
||||
normalChest.add(new ItemStack(Material.CHAINMAIL_HELMET));
|
||||
normalChest.add(new ItemStack(Material.WOOD_AXE));
|
||||
normalChest.add(new ItemStack(Material.MELON));
|
||||
normalChest.add(new ItemStack(Material.PORK));
|
||||
normalChest.add(new ItemStack(Material.ARROW));
|
||||
normalChest.add(new ItemStack(Material.APPLE));
|
||||
normalChest.add(new ItemStack(Material.BREAD));
|
||||
normalChest.add(new ItemStack(Material.SNOW_BALL));
|
||||
normalChest.add(new ItemStack(Material.GOLD_HELMET));
|
||||
normalChest.add(new ItemStack(Material.GOLD_BOOTS));
|
||||
normalChest.add(new ItemStack(Material.GOLD_SWORD));
|
||||
normalChest.add(new ItemStack(Material.RAW_BEEF));
|
||||
normalChest.add(new ItemStack(Material.RAW_CHICKEN));
|
||||
|
||||
//filling rare chests
|
||||
rareChest.add(new ItemStack(Material.BOW));
|
||||
rareChest.add(new ItemStack(Material.IRON_AXE));
|
||||
rareChest.add(new ItemStack(Material.GRILLED_PORK));
|
||||
rareChest.add(new ItemStack(Material.CAKE));
|
||||
rareChest.add(new ItemStack(Material.COOKED_BEEF));
|
||||
rareChest.add(new ItemStack(Material.STONE_SWORD));
|
||||
rareChest.add(new ItemStack(Material.FLINT_AND_STEEL));
|
||||
rareChest.add(new ItemStack(Material.FISHING_ROD));
|
||||
rareChest.add(new ItemStack(Material.COOKED_CHICKEN));
|
||||
rareChest.add(new ItemStack(Material.IRON_HELMET));
|
||||
rareChest.add(new ItemStack(Material.IRON_BOOTS));
|
||||
rareChest.add(new ItemStack(Material.CHAINMAIL_LEGGINGS));
|
||||
rareChest.add(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
|
||||
rareChest.add(new ItemStack(Material.WEB));
|
||||
rareChest.add(new ItemStack(Material.SHIELD));
|
||||
rareChest.add(new ItemStack(Material.PUMPKIN_PIE));
|
||||
rareChest.add(new ItemStack(Material.STICK));
|
||||
rareChest.add(new ItemStack(Material.IRON_INGOT));
|
||||
rareChest.add(new ItemStack(Material.GOLD_LEGGINGS));
|
||||
rareChest.add(new ItemStack(Material.GOLD_CHESTPLATE));
|
||||
|
||||
//filling epic chests
|
||||
epicChest.add(new ItemStack(Material.IRON_CHESTPLATE));
|
||||
epicChest.add(new ItemStack(Material.IRON_LEGGINGS));
|
||||
epicChest.add(new ItemStack(Material.IRON_SWORD));
|
||||
epicChest.add(new ItemStack(Material.GOLDEN_APPLE));
|
||||
epicChest.add(new ItemStack(Material.DIAMOND));
|
||||
epicChest.add(new ItemStack(Material.WOOD));
|
||||
epicChest.add(new ItemStack(Material.DIAMOND_AXE));
|
||||
|
||||
//filling incredible chests
|
||||
incredibleChest.add(new ItemStack(Material.DIAMOND_SWORD));
|
||||
incredibleChest.add(new ItemStack(Material.DIAMOND_CHESTPLATE));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if(e.getClickedBlock().getType() == Material.CHEST) {
|
||||
e.setCancelled(true);
|
||||
if(chests.containsKey(e.getClickedBlock().getLocation())) {
|
||||
p.openInventory(chests.get(e.getClickedBlock().getLocation()));
|
||||
}else{
|
||||
Random random = new Random();
|
||||
float r = random.nextFloat();
|
||||
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
if(r == 0.5F) list = normalChest;
|
||||
if(r == 0.3F) list = rareChest;
|
||||
if(r == 0.1F) list = epicChest;
|
||||
if(r == 0.1F) list = incredibleChest;
|
||||
|
||||
Inventory inv = Bukkit.createInventory(null, InventoryType.CHEST);
|
||||
|
||||
for(int i = 0; i <= 1; i++) {
|
||||
int slot = new Random().nextInt(27);
|
||||
int item = new Random().nextInt(list.size());
|
||||
|
||||
inv.setItem(slot, list.get(item));
|
||||
|
||||
}
|
||||
chests.put(e.getClickedBlock().getLocation(), inv);
|
||||
p.openInventory(inv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.listeners;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import eu.univento.woolget.game.GameStage;
|
||||
import eu.univento.woolget.utils.Shop;
|
||||
import eu.univento.woolget.utils.TeamChooser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Inventorys implements Listener{
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if(e.getItem() != null) {
|
||||
if (e.getItem().getType() == Material.PAPER && WoolGet.getGameStage() == GameStage.Lobby) {
|
||||
p.openInventory(WoolGet.getVoting().getInventory(p));
|
||||
}
|
||||
if (e.getItem().getType() == Material.NETHER_STAR && WoolGet.getGameStage() == GameStage.Lobby) {
|
||||
p.connectToServer("Lobby01");
|
||||
}
|
||||
if (e.getItem().getType() == Material.WOOL && WoolGet.getGameStage() == GameStage.Lobby) {
|
||||
p.openInventory(TeamChooser.getInventory(p));
|
||||
}
|
||||
if (e.getItem().getType() == Material.GOLD_INGOT && WoolGet.getGameStage() == GameStage.Game) {
|
||||
if (Shop.mobileShop().contains(p)) p.openInventory(Shop.getInventory(p));
|
||||
}
|
||||
}
|
||||
if(e.getClickedBlock() != null) {
|
||||
if(e.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && (WoolGet.getGameStage() == GameStage.Game || WoolGet.getGameStage() == GameStage.Warmup)) {
|
||||
e.setCancelled(true);
|
||||
Random random = new Random();
|
||||
int r = random.nextInt(8);
|
||||
|
||||
ItemStack mine = new ItemStack(Material.STONE_PLATE);
|
||||
ItemStack ender = new ItemStack(Material.ENDER_PEARL);
|
||||
ItemStack switcher = new ItemStack(Material.SNOW_BALL);
|
||||
ItemStack grenade = new ItemStack(Material.FIREBALL);
|
||||
ItemStack tracker = new ItemStack(Material.COMPASS);
|
||||
ItemStack spawn = new ItemStack(Material.EYE_OF_ENDER);
|
||||
ItemStack c4 = new ItemStack(Material.TNT);
|
||||
ItemStack spreader = new ItemStack(Material.BEACON);
|
||||
|
||||
ItemStack item = null;
|
||||
if (r == 0) item = mine;
|
||||
if (r == 1) item = ender;
|
||||
if (r == 2) item = switcher;
|
||||
if (r == 3) item = grenade;
|
||||
if (r == 4) item = tracker;
|
||||
if (r == 5) item = spawn;
|
||||
if (r == 6) item = c4;
|
||||
if (r == 7) item = spreader;
|
||||
|
||||
p.getInventory().addItem(item);
|
||||
Block block = e.getClickedBlock();
|
||||
block.setType(Material.ENDER_PORTAL_FRAME);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(WoolGet.getInstance(), () -> block.setType(Material.ENCHANTMENT_TABLE), 100L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
if(e.getWhoClicked() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
|
||||
if(e.getInventory().getName().equals(TeamChooser.getInventory(p).getName())) {
|
||||
if (e.getCurrentItem().getType() == Material.WOOL && WoolGet.getGameStage() == GameStage.Lobby) {
|
||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals("§9blue")) {
|
||||
p.getInventory().getItem(1).setDurability((short) 11);
|
||||
TeamChooser.addToTeam("blue", p);
|
||||
p.closeInventory();
|
||||
}
|
||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals("§eyellow")) {
|
||||
p.getInventory().getItem(1).setDurability((short) 4);
|
||||
TeamChooser.addToTeam("yellow", p);
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryMove(InventoryMoveItemEvent e) {
|
||||
if(WoolGet.getGameStage() == GameStage.Lobby) e.setCancelled(true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.listeners;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.game.TeamManager;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Spectator;
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import eu.univento.woolget.game.GameStage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.5
|
||||
*/
|
||||
public class JoinQuit implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
|
||||
if(WoolGet.getGameStage() == GameStage.Lobby) {
|
||||
|
||||
ItemStack voting = new ItemStack(Material.PAPER);
|
||||
ItemMeta votingMeta = voting.getItemMeta();
|
||||
votingMeta.setDisplayName("§aMap Voting");
|
||||
voting.setItemMeta(votingMeta);
|
||||
|
||||
ItemStack team = new ItemStack(Material.WOOL);
|
||||
ItemMeta teamMeta = team.getItemMeta();
|
||||
teamMeta.setDisplayName("§aTeam wählen");
|
||||
team.setItemMeta(teamMeta);
|
||||
|
||||
ItemStack lobby = new ItemStack(Material.NETHER_STAR);
|
||||
ItemMeta lobbyMeta = lobby.getItemMeta();
|
||||
lobbyMeta.setDisplayName("§6zur Lobby");
|
||||
lobby.setItemMeta(lobbyMeta);
|
||||
|
||||
p.getInventory().clear();
|
||||
p.getInventory().setItem(0, voting);
|
||||
p.getInventory().setItem(1, team);
|
||||
p.getInventory().setItem(8, lobby);
|
||||
|
||||
p.setLevel(0);
|
||||
|
||||
e.setJoinMessage(p.getMessages().PREFIX() + p.getColor() + p.getDisplayName() + " §6hat das Spiel betreteten");
|
||||
WoolGet.getPlayers().add(p);
|
||||
p.teleport(Config.readLocation("Strive.Spawn"));
|
||||
}
|
||||
if(WoolGet.getGameStage() == GameStage.Warmup) {
|
||||
e.setJoinMessage(null);
|
||||
Spectator.add(p);
|
||||
p.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||
}
|
||||
if(WoolGet.getGameStage() == GameStage.Game) {
|
||||
e.setJoinMessage(null);
|
||||
Spectator.add(p);
|
||||
p.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||
}
|
||||
if(WoolGet.getGameStage() == GameStage.Restart) {
|
||||
e.setJoinMessage(null);
|
||||
Spectator.add(p);
|
||||
p.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(WoolGet.getGameStage() == GameStage.Lobby) {
|
||||
if(WoolGet.getPlayers().contains(p)) {
|
||||
e.setQuitMessage(p.getMessages().PREFIX() + p.getColor() + p.getDisplayName() + " §chat die Lobby verlassen");
|
||||
}else{
|
||||
e.setQuitMessage(null);
|
||||
}
|
||||
}
|
||||
if(WoolGet.getGameStage() == GameStage.Warmup) {
|
||||
if(WoolGet.getPlayers().contains(p)) {
|
||||
e.setQuitMessage(p.getMessages().PREFIX() + p.getColor() + p.getDisplayName() + " §chat das Spiel verlassen");
|
||||
}else{
|
||||
e.setQuitMessage(null);
|
||||
}
|
||||
}
|
||||
if(WoolGet.getGameStage() == GameStage.Game) {
|
||||
if(WoolGet.getPlayers().contains(p)) {
|
||||
e.setQuitMessage(p.getMessages().PREFIX() + p.getColor() + p.getDisplayName() + " §chat das Spiel verlassen");
|
||||
}else{
|
||||
e.setQuitMessage(null);
|
||||
}
|
||||
}
|
||||
if(WoolGet.getGameStage() == GameStage.Restart) {
|
||||
if(WoolGet.getPlayers().contains(p)) {
|
||||
e.setQuitMessage(p.getMessages().PREFIX() + p.getColor() + p.getDisplayName() + " §chat den Server verlassen");
|
||||
}else{
|
||||
e.setQuitMessage(null);
|
||||
}
|
||||
}
|
||||
if(WoolGet.getPlayers().contains(p)) {
|
||||
WoolGet.getPlayers().remove(p);
|
||||
}
|
||||
if(Spectator.is(p)) {
|
||||
Spectator.remove(p);
|
||||
}
|
||||
if(TeamManager.getTeam(p) != null) {
|
||||
TeamManager.getTeam(p).removePlayer(p);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(PlayerLoginEvent e) {
|
||||
if(WoolGet.getGameStage() == GameStage.Lobby && WoolGet.getPlayers().size() >= WoolGet.getMaxPlayers()) {
|
||||
e.disallow(PlayerLoginEvent.Result.KICK_FULL, "§cDas Spiel ist voll");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,258 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.listeners;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.game.Team;
|
||||
import eu.univento.core.api.game.TeamManager;
|
||||
import eu.univento.core.api.schematic.Cuboid;
|
||||
import eu.univento.core.api.map.Map;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.server.Game;
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import eu.univento.woolget.game.GameStage;
|
||||
import eu.univento.woolget.utils.Shop;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class PlayerEvents implements Listener {
|
||||
|
||||
private Game game = Game.WoolGet;
|
||||
private static Team blue;
|
||||
private static Team yellow;
|
||||
|
||||
public static void setTeams() {
|
||||
blue = TeamManager.getTeam("blue");
|
||||
yellow = TeamManager.getTeam("yellow");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getEntity());
|
||||
if (Shop.mobileShop().contains(p)) Shop.mobileShop().remove(p);
|
||||
if (WoolGet.getGameStage() == GameStage.Game) {
|
||||
if (p.getKiller() != null) {
|
||||
CustomPlayer killer = CustomPlayer.getPlayer(p.getKiller());
|
||||
e.setDeathMessage(p.getDisplayName() + " wurde von " + killer.getDisplayName() + " gebasht");
|
||||
e.getDrops().clear();
|
||||
e.setDroppedExp(0);
|
||||
p.getStatistics(game).addDeath();
|
||||
killer.getStatistics(game).addKill();
|
||||
} else {
|
||||
e.setDeathMessage(p.getDisplayName() + " ist nun tot");
|
||||
}
|
||||
} else {
|
||||
e.setDeathMessage(null);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (WoolGet.getGameStage() == GameStage.Game || WoolGet.getGameStage() == GameStage.Warmup) {
|
||||
Map map = WoolGet.getVoting().getWinningMap();
|
||||
if (blue.isPlayer(p)) {
|
||||
Cuboid cb = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Blue.MinPos"), Config.readLocation("Strive." + map.getName() + ".Blue.MaxPos"));
|
||||
e.setRespawnLocation(cb.getRandomLocation());
|
||||
}
|
||||
if (yellow.isPlayer(p)) {
|
||||
Cuboid cb = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Yellow.MinPos"), Config.readLocation("Strive." + map.getName() + ".Yellow.MaxPos"));
|
||||
e.setRespawnLocation(cb.getRandomLocation());
|
||||
}
|
||||
} else {
|
||||
e.setRespawnLocation(Config.readLocation("Strive.Spawn"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityInteract(PlayerInteractEntityEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (e.getRightClicked() instanceof Villager) {
|
||||
e.setCancelled(true);
|
||||
p.openInventory(Shop.getInventory(p));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (WoolGet.getGameStage() == GameStage.Warmup) {
|
||||
Map map = WoolGet.getVoting().getWinningMap();
|
||||
if (blue.isPlayer(p)) {
|
||||
Cuboid cb = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Blue.MinPos"), Config.readLocation("Strive." + map.getName() + ".Blue.MaxPos"));
|
||||
if (!cb.containsLocation(p.getLocation())) {
|
||||
p.setVelocity(p.getLocation().getDirection().multiply(-2).setY(0.2F));
|
||||
}
|
||||
}
|
||||
if (yellow.isPlayer(p)) {
|
||||
Cuboid cb = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Yellow.MinPos"), Config.readLocation("Strive." + map.getName() + ".Yellow.MaxPos"));
|
||||
if (!cb.containsLocation(p.getLocation())) {
|
||||
p.setVelocity(p.getLocation().getDirection().multiply(-2).setY(0.2F));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(WoolGet.getGameStage() == GameStage.Lobby) {
|
||||
if(p.getEyeLocation().getBlock().getType() == Material.WATER || p.getEyeLocation().getBlock().getType() == Material.STATIONARY_WATER) {
|
||||
p.teleport(Config.readLocation("Strive.Spawn"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@EventHandler
|
||||
public void onRodLand(ProjectileHitEvent e) {
|
||||
if (e.getEntityType() == EntityType.FISHING_HOOK) {
|
||||
Bukkit.getWorld(e.getEntity().getWorld().getName()).getNearbyEntities(e.getEntity().getLocation(), 2.0, 2.0, 2.0).stream().filter(entity -> entity instanceof Player).forEach(entity -> {
|
||||
FishHook hock = (FishHook) e.getEntity();
|
||||
Player rodder = (Player) hock.getShooter();
|
||||
Player player = (Player) entity;
|
||||
player.damage(1.0);
|
||||
player.getLocation().add(0.0D, 1.0D, 0.0D);
|
||||
player.setVelocity(rodder.getLocation().getDirection().multiply(0.3D));
|
||||
e.getEntity().remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if (WoolGet.getGameStage() == GameStage.Game) {
|
||||
Map map = WoolGet.getVoting().getWinningMap();
|
||||
Cuboid yellow = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Blue.MinPos"), Config.readLocation("Strive." + map.getName() + ".Blue.MaxPos"));
|
||||
Cuboid blue = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Blue.MinPos"), Config.readLocation("Strive." + map.getName() + ".Blue.MaxPos"));
|
||||
if (e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.STONE_PLATE) {
|
||||
e.getClickedBlock().getWorld().createExplosion(e.getClickedBlock().getLocation(), 0.0F);
|
||||
e.getClickedBlock().setType(Material.AIR);
|
||||
p.damage(5.0D);
|
||||
}
|
||||
if (e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.IRON_PLATE) {
|
||||
if (PlayerEvents.blue.isPlayer(p)) p.teleport(blue.getRandomLocation());
|
||||
if (PlayerEvents.yellow.isPlayer(p)) p.teleport(yellow.getRandomLocation());
|
||||
e.getClickedBlock().setType(Material.AIR);
|
||||
}
|
||||
if (e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.WOOD_PLATE) {
|
||||
e.getClickedBlock().setType(Material.AIR);
|
||||
e.getClickedBlock().getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.GRASS);
|
||||
e.getClickedBlock().getWorld().generateTree(e.getClickedBlock().getLocation(), TreeType.BIRCH);
|
||||
}
|
||||
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (p.getItemInHand().getType() == Material.FIREBALL) {
|
||||
Item grenade = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.FIREBALL));
|
||||
grenade.setPickupDelay(4);
|
||||
grenade.setVelocity(p.getEyeLocation().getDirection().multiply(1.5));
|
||||
p.getInventory().remove(p.getItemInHand());
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
if (grenade.isOnGround()) {
|
||||
grenade.getLocation().getWorld().createExplosion(grenade.getLocation(), 0.0F);
|
||||
grenade.getWorld().getLivingEntities().stream().filter(entity -> entity.getLocation().distance(grenade.getLocation()) <= 1.5D).forEach(entity -> {
|
||||
entity.damage(2.0D);
|
||||
entity.sendMessage("Kabum");
|
||||
});
|
||||
grenade.remove();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(WoolGet.getInstance(), 2L, 2L);
|
||||
}
|
||||
}
|
||||
if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||
if (p.getItemInHand().getType() == Material.COMPASS) {
|
||||
p.sendMessage("Neues Ziel gesetzt.");
|
||||
getAreaBlocks(p.getLocation(), 15).stream().filter(loc -> loc.getBlock().getType() == Material.WOOL).forEach(p::setCompassTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemPickup(PlayerPickupItemEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(WoolGet.getGameStage() == GameStage.Warmup || WoolGet.getGameStage() == GameStage.Game) {
|
||||
ItemStack item = e.getItem().getItemStack();
|
||||
if(item.getType() == Material.FIREBALL) {
|
||||
e.getItem().remove();
|
||||
e.setCancelled(true);
|
||||
p.getWorld().createExplosion(p.getLocation(), 0.0F);
|
||||
p.damage(3.0D);
|
||||
}
|
||||
}else{
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemDrop(PlayerDropItemEvent e) {
|
||||
if(WoolGet.getGameStage() == GameStage.Lobby) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageByEntityEvent e) {
|
||||
if (e.getEntity() instanceof Player && e.getDamager() instanceof Snowball && WoolGet.getGameStage() == GameStage.Game) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getEntity().getName());
|
||||
Snowball snowball = (Snowball) e.getDamager();
|
||||
if (snowball.getShooter() instanceof Player) {
|
||||
CustomPlayer shooter = CustomPlayer.getPlayer(((Player) snowball.getShooter()).getName());
|
||||
if (TeamManager.getTeam(p) != TeamManager.getTeam(shooter)) {
|
||||
Location pLoc = p.getLocation().clone();
|
||||
Location shooterLoc = shooter.getLocation().clone();
|
||||
p.teleport(shooterLoc);
|
||||
shooter.teleport(pLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTramp(PlayerInteractEvent e) {
|
||||
if(e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.SOIL) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent e) {
|
||||
if (e.getEntity() instanceof Villager) e.setCancelled(true);
|
||||
if(e.getEntity() instanceof Player && WoolGet.getGameStage() != GameStage.Game) e.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
private static List<Location> getAreaBlocks(Location loc, int radius) {
|
||||
World w = loc.getWorld();
|
||||
double xCord = loc.getX();
|
||||
double YCord = loc.getY();
|
||||
double zCord = loc.getZ();
|
||||
|
||||
List<Location> tempList = new ArrayList<>();
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
for (int y = -radius; y <= radius; y++) {
|
||||
tempList.add(new Location(w, xCord + x, YCord + y, zCord + z));
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempList;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.utils;
|
||||
|
||||
import eu.univento.core.api.game.TeamManager;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Shop {
|
||||
|
||||
private static HashMap<CustomPlayer, Integer> coins = new HashMap<>();
|
||||
public static HashMap<CustomPlayer, Integer> getCoins() {
|
||||
return coins;
|
||||
}
|
||||
|
||||
public static ArrayList<CustomPlayer> mobileShop() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public static void updateInventory(CustomPlayer p) {
|
||||
if(p.getInventory().getItem(8) != null) {
|
||||
ItemMeta meta = p.getInventory().getItem(8).getItemMeta();
|
||||
meta.setDisplayName(coins.get(p) + " Coins");
|
||||
p.getInventory().getItem(8).setItemMeta(meta);
|
||||
}else{
|
||||
ItemStack item = new ItemStack(Material.GOLD_INGOT);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(coins.get(p) + " Coins");
|
||||
item.setItemMeta(meta);
|
||||
p.getInventory().setItem(8, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Inventory getInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "Shop");
|
||||
|
||||
ItemStack weapons = new ItemStack(Material.IRON_SWORD);
|
||||
ItemMeta weaponsMeta = weapons.getItemMeta();
|
||||
weaponsMeta.setDisplayName("Waffen");
|
||||
weapons.setItemMeta(weaponsMeta);
|
||||
|
||||
ItemStack build = new ItemStack(Material.GLASS, (short) 6);
|
||||
ItemMeta buildMeta = build.getItemMeta();
|
||||
buildMeta.setDisplayName("Baumaterial");
|
||||
build.setItemMeta(buildMeta);
|
||||
|
||||
ItemStack food = new ItemStack(Material.BREAD);
|
||||
ItemMeta foodMeta = food.getItemMeta();
|
||||
foodMeta.setDisplayName("Nahrungsmittel");
|
||||
food.setItemMeta(foodMeta);
|
||||
|
||||
ItemStack special = new ItemStack(Material.WOOD_PLATE);
|
||||
ItemMeta specialMeta = special.getItemMeta();
|
||||
specialMeta.setDisplayName("Special");
|
||||
special.setItemMeta(specialMeta);
|
||||
|
||||
inv.setItem(1, weapons);
|
||||
inv.setItem(3, build);
|
||||
inv.setItem(5, food);
|
||||
inv.setItem(7, special);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static Inventory getWeaponsInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "Waffen");
|
||||
|
||||
ItemStack swords = new ItemStack(Material.STONE_SWORD);
|
||||
ItemMeta swordsMeta = swords.getItemMeta();
|
||||
swordsMeta.setDisplayName("Schwerter");
|
||||
swords.setItemMeta(swordsMeta);
|
||||
|
||||
ItemStack bows = new ItemStack(Material.BOW);
|
||||
ItemMeta bowsMeta = bows.getItemMeta();
|
||||
bowsMeta.setDisplayName("Bögen");
|
||||
bows.setItemMeta(bowsMeta);
|
||||
|
||||
ItemStack armor = new ItemStack(Material.GOLD_CHESTPLATE);
|
||||
ItemMeta armorMeta = armor.getItemMeta();
|
||||
armorMeta.setDisplayName("Rüstung");
|
||||
armor.setItemMeta(armorMeta);
|
||||
|
||||
ItemStack other = new ItemStack(Material.SHIELD);
|
||||
ItemMeta otherMeta = other.getItemMeta();
|
||||
otherMeta.setDisplayName("Anderes");
|
||||
other.setItemMeta(otherMeta);
|
||||
|
||||
inv.setItem(1, swords);
|
||||
inv.setItem(3, bows);
|
||||
inv.setItem(5, armor);
|
||||
inv.setItem(7, other);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static Inventory getSwordInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "Schwerter");
|
||||
|
||||
ItemStack wood = new ItemStack(Material.WOOD_SWORD);
|
||||
ItemStack gold = new ItemStack(Material.GOLD_SWORD);
|
||||
ItemStack stone = new ItemStack(Material.STONE_SWORD);
|
||||
ItemStack iron = new ItemStack(Material.IRON_SWORD);
|
||||
ItemStack diamond = new ItemStack(Material.DIAMOND_SWORD);
|
||||
|
||||
inv.setItem(0, wood);
|
||||
inv.setItem(1, gold);
|
||||
inv.setItem(2, stone);
|
||||
inv.setItem(3, iron);
|
||||
inv.setItem(4, diamond);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static Inventory getBowInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "Bögen");
|
||||
|
||||
ItemStack normal = new ItemStack(Material.BOW);
|
||||
|
||||
inv.setItem(4, normal);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static Inventory getArmorInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "Rüstung");
|
||||
|
||||
ItemStack leather = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
ItemMeta leatherMeta = leather.getItemMeta();
|
||||
leatherMeta.setDisplayName("Leder");
|
||||
leather.setItemMeta(leatherMeta);
|
||||
|
||||
ItemStack gold = new ItemStack(Material.GOLD_CHESTPLATE);
|
||||
ItemMeta goldMeta = gold.getItemMeta();
|
||||
goldMeta.setDisplayName("Gold");
|
||||
gold.setItemMeta(goldMeta);
|
||||
|
||||
ItemStack chain = new ItemStack(Material.CHAINMAIL_CHESTPLATE);
|
||||
ItemMeta chainMeta = chain.getItemMeta();
|
||||
chainMeta.setDisplayName("Kette");
|
||||
chain.setItemMeta(chainMeta);
|
||||
|
||||
ItemStack iron = new ItemStack(Material.IRON_CHESTPLATE);
|
||||
ItemMeta ironMeta = iron.getItemMeta();
|
||||
ironMeta.setDisplayName("Eisen");
|
||||
iron.setItemMeta(ironMeta);
|
||||
|
||||
ItemStack diamond = new ItemStack(Material.DIAMOND_CHESTPLATE);
|
||||
ItemMeta diamondMeta = diamond.getItemMeta();
|
||||
diamondMeta.setDisplayName("Diamand");
|
||||
diamond.setItemMeta(diamondMeta);
|
||||
|
||||
inv.setItem(0, leather);
|
||||
inv.setItem(1, gold);
|
||||
inv.setItem(2, chain);
|
||||
inv.setItem(3, iron);
|
||||
inv.setItem(4, diamond);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static Inventory getOtherInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "Anderes");
|
||||
|
||||
ItemStack rod = new ItemStack(Material.FISHING_ROD);
|
||||
ItemStack arrow = new ItemStack(Material.ARROW);
|
||||
ItemStack shield = new ItemStack(Material.SHIELD);
|
||||
|
||||
inv.setItem(0, rod);
|
||||
inv.setItem(4, arrow);
|
||||
inv.setItem(8, shield);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static Inventory getBuildInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "Baumaterial");
|
||||
short color = 0;
|
||||
|
||||
if(TeamManager.getTeam(p).getName().equals("blue")) color = 11;
|
||||
if(TeamManager.getTeam(p).getName().equals("yellow")) color = 4;
|
||||
|
||||
ItemStack glass = new ItemStack(Material.STAINED_GLASS, color);
|
||||
ItemStack clay = new ItemStack(Material.STAINED_CLAY, color);
|
||||
|
||||
ItemStack wood = new ItemStack(Material.WOOD_PICKAXE);
|
||||
ItemStack gold = new ItemStack(Material.GOLD_PICKAXE);
|
||||
ItemStack stone = new ItemStack(Material.STONE_PICKAXE);
|
||||
ItemStack iron = new ItemStack(Material.IRON_PICKAXE);
|
||||
ItemStack diamond = new ItemStack(Material.DIAMOND_PICKAXE);
|
||||
|
||||
inv.setItem(0, glass);
|
||||
inv.setItem(1, clay);
|
||||
inv.setItem(2, wood);
|
||||
inv.setItem(3, gold);
|
||||
inv.setItem(4, stone);
|
||||
inv.setItem(5, iron);
|
||||
inv.setItem(6, diamond);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static Inventory getFoodInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "Nahrungsmittel");
|
||||
|
||||
ItemStack apple = new ItemStack(Material.APPLE);
|
||||
ItemStack bread = new ItemStack(Material.BREAD);
|
||||
ItemStack steak = new ItemStack(Material.COOKED_BEEF);
|
||||
ItemStack golden = new ItemStack(Material.GOLDEN_APPLE);
|
||||
|
||||
inv.setItem(0, apple);
|
||||
inv.setItem(1, bread);
|
||||
inv.setItem(2, steak);
|
||||
inv.setItem(3, golden);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static Inventory getSpecialInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "Spezial");
|
||||
|
||||
ItemStack c4 = new ItemStack(Material.WOOD_PLATE);
|
||||
ItemMeta c4Meta = c4.getItemMeta();
|
||||
c4Meta.setDisplayName("C4");
|
||||
c4.setItemMeta(c4Meta);
|
||||
|
||||
ItemStack mine = new ItemStack(Material.STONE_PLATE);
|
||||
ItemMeta mineMeta = mine.getItemMeta();
|
||||
mineMeta.setDisplayName("Miene");
|
||||
mine.setItemMeta(mineMeta);
|
||||
|
||||
ItemStack compass = new ItemStack(Material.COMPASS);
|
||||
ItemStack snowball = new ItemStack(Material.SNOW_BALL);
|
||||
ItemStack portal = new ItemStack(Material.PORTAL);
|
||||
|
||||
ItemStack grenade = new ItemStack(Material.FIREBALL);
|
||||
ItemMeta grenadeMeta = grenade.getItemMeta();
|
||||
grenadeMeta.setDisplayName("Granate");
|
||||
grenade.setItemMeta(grenadeMeta);
|
||||
|
||||
ItemStack shop = new ItemStack(Material.GOLD_INGOT);
|
||||
ItemMeta shopMeta = shop.getItemMeta();
|
||||
shopMeta.setDisplayName("mobiler Shop");
|
||||
shop.setItemMeta(shopMeta);
|
||||
|
||||
inv.setItem(0, c4);
|
||||
inv.setItem(1, mine);
|
||||
inv.setItem(2, compass);
|
||||
inv.setItem(3, snowball);
|
||||
inv.setItem(4, portal);
|
||||
inv.setItem(5, grenade);
|
||||
inv.setItem(6, shop);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.utils;
|
||||
|
||||
import eu.univento.core.api.game.TeamManager;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class TeamChooser {
|
||||
|
||||
private static ArrayList<CustomPlayer> blue = new ArrayList<>();
|
||||
private static ArrayList<CustomPlayer> yellow = new ArrayList<>();
|
||||
|
||||
|
||||
public static Inventory getInventory(CustomPlayer p) {
|
||||
Inventory inv = Bukkit.createInventory(p, 9, "§6Team wählen");
|
||||
|
||||
ItemStack blue = new ItemStack(Material.WOOL, 1, (short) 11);
|
||||
ItemMeta blueMeta = blue.getItemMeta();
|
||||
blueMeta.setDisplayName("§9blue");
|
||||
blue.setItemMeta(blueMeta);
|
||||
|
||||
ItemStack yellow = new ItemStack(Material.WOOL, 1, (short) 4);
|
||||
ItemMeta yellowMeta = yellow.getItemMeta();
|
||||
yellowMeta.setDisplayName("§eyellow");
|
||||
yellow.setItemMeta(yellowMeta);
|
||||
|
||||
inv.setItem(2, blue);
|
||||
inv.setItem(5, yellow);
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static void addToTeam(String name, CustomPlayer p) {
|
||||
if (blue.contains(p)) blue.remove(p);
|
||||
if (yellow.contains(p)) yellow.remove(p);
|
||||
if (name.equalsIgnoreCase("blue")) blue.add(p);
|
||||
if (name.equalsIgnoreCase("yellow")) yellow.add(p);
|
||||
}
|
||||
|
||||
public static void addToTeams() {
|
||||
for (CustomPlayer p : blue) {
|
||||
TeamManager.getTeam("blue").addPlayer(p);
|
||||
}
|
||||
for (CustomPlayer p : yellow) {
|
||||
TeamManager.getTeam("yellow").addPlayer(p);
|
||||
}
|
||||
WoolGet.getPlayers().stream().filter(p -> TeamManager.getTeam(p) == null).forEachOrdered(p -> {
|
||||
if (TeamManager.getTeam("blue").getPlayers().size() > TeamManager.getTeam("yellow").getPlayers().size()) {
|
||||
TeamManager.getTeam("yellow").addPlayer(p);
|
||||
}
|
||||
if (TeamManager.getTeam("yellow").getPlayers().size() > TeamManager.getTeam("blue").getPlayers().size()) {
|
||||
TeamManager.getTeam("blue").addPlayer(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) univento.eu 2016. Any attempt to use these program(s) without permission may result in a penalty of up to 1.000€
|
||||
*/
|
||||
|
||||
package eu.univento.woolget.utils;
|
||||
|
||||
import eu.univento.woolget.WoolGet;
|
||||
import eu.univento.woolget.game.GameStage;
|
||||
import eu.univento.woolget.game.RestartCounter;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Utils {
|
||||
|
||||
public static void endGame(GameStage stage) {
|
||||
WoolGet.setGameStage(GameStage.Restart);
|
||||
WoolGet.restartID = WoolGet.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(WoolGet.getInstance(), new RestartCounter(), 20L, 20L);
|
||||
Bukkit.getScheduler().cancelTask(getSchedulerId(stage));
|
||||
}
|
||||
|
||||
private static int getSchedulerId(GameStage gameStage) {
|
||||
switch (gameStage) {
|
||||
case Lobby: return WoolGet.lobbyID;
|
||||
case Warmup: return WoolGet.warmupID;
|
||||
case Game: return WoolGet.gameID;
|
||||
case Restart: return WoolGet.restartID;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
main: eu.univento.woolget.WoolGet
|
||||
name: WoolGet
|
||||
author: joethei
|
||||
version: 0.1
|
||||
description: first minigame on univento.eu
|
||||
website: http://univento.eu/woolget
|
||||
depend: [Core]
|
Loading…
Reference in New Issue