+ added first test mission

+ testing EntityModifier
This commit is contained in:
Johannes Theiner 2016-10-11 23:55:49 +02:00
parent e630ea2e6d
commit dfdea0762b
10 changed files with 166 additions and 83 deletions

View File

@ -9,28 +9,44 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<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: org.spigotmc:spigot-api:1.10.2-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" 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: 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="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.10-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.10.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.bukkit:craftbukkit:1.10.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="Core" />
<orderEntry type="module" module-name="CloudCommons" />
<orderEntry type="module-library">
<library name="Maven: eu.the5zig.mod:mod:1.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/../Core/local-maven-repo/The5zigMod.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<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: io.netty:netty-all:4.0.36.Final" 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.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" />
<orderEntry type="library" name="Maven: com.github.theholywaffle:teamspeak3-api:1.0.14-SNAPSHOT" 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: net.gpedro.integrations.slack:slack-webhook:1.2.1" level="project" />
</component>
</module>

22
pom.xml
View File

@ -4,7 +4,7 @@
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>
<groupId>eu.univento</groupId>
<artifactId>Lobby</artifactId>
<version>1.0-SNAPSHOT</version>
@ -57,28 +57,32 @@
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.10-R0.1-SNAPSHOT</version>
<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-R0.1-SNAPSHOT</version>
<version>1.10.2-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>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -1,10 +1,10 @@
package eu.univento.lobby;
import java.util.logging.Level;
import java.util.logging.Logger;
import eu.univento.core.Core;
import eu.univento.core.api.pet.NMSHandler;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.lobby.commands.DropItem;
import eu.univento.lobby.commands.Setloc;
import eu.univento.lobby.listeners.*;
import eu.univento.lobby.utils.PetManager;
import eu.univento.lobby.utils.StatusSignManager;
@ -15,8 +15,8 @@ import org.bukkit.World;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import eu.univento.lobby.commands.DropItem;
import eu.univento.lobby.commands.Setloc;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* main class...
@ -55,8 +55,7 @@ public class Lobby extends JavaPlugin{
@Override
public void onEnable() {
instance = this;
PluginManager pm = Bukkit.getPluginManager();
ServerSettings.setLobby(true);
PluginManager pm = Bukkit.getPluginManager();;
pm.registerEvents(new Jumppads(), this);
pm.registerEvents(new JoinQuit(), this);
pm.registerEvents(new MenuEvents(), this);
@ -82,11 +81,12 @@ public class Lobby extends JavaPlugin{
w.setDifficulty(Difficulty.PEACEFUL);
}
ServerSettings.setGameMode(GameMode.ADVENTURE);
ServerSettings.setLobby(true);
ServerSettings.setLobby();
StatusSignManager.loadSigns();
StatusSignManager.updateSigns();
NMSHandler.registerEnties();
log(Level.INFO, " Plugin ver." + getDescription().getVersion() + " gestartet");
Core.getInstance().registerPlugin(this);
log(Level.INFO, " Plugin ver." + getDescription().getVersion() + " gestartet");
}

View File

@ -1,15 +1,22 @@
package eu.univento.lobby.listeners;
import eu.univento.core.api.Title;
import eu.univento.core.api.Config;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import eu.univento.lobby.story.missions.StartMission;
import eu.univento.lobby.utils.CustomMapRenderer;
import eu.univento.lobby.utils.PetManager;
import eu.univento.lobby.utils.Pets;
import eu.univento.lobby.utils.Scoreboards;
import net.minecraft.server.v1_10_R1.EnumParticle;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Skull;
import org.bukkit.entity.*;
import org.bukkit.entity.Creature;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
@ -25,15 +32,9 @@ import org.bukkit.event.player.*;
import org.bukkit.event.server.MapInitializeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.StructureGrowEvent;
import eu.univento.core.api.Config;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import org.bukkit.util.Vector;
import java.util.Set;
/**
* some short events
*
@ -166,9 +167,8 @@ public class Events implements Listener {
*/
@EventHandler
public void onBlockIgnite(BlockIgniteEvent e) {
if (e.getCause() == IgniteCause.SPREAD) {
if (e.getCause() == IgniteCause.SPREAD)
e.setCancelled(true);
}
}
/**
@ -196,21 +196,6 @@ public class Events implements Listener {
if (e.getClickedBlock().getType() == Material.SPRUCE_DOOR) e.setCancelled(true);
if (e.getClickedBlock().getType() == Material.WOOD_DOOR) e.setCancelled(true);
if (e.getClickedBlock().getType() == Material.WOODEN_DOOR) e.setCancelled(true);
if (e.getClickedBlock().getType() == Material.BEDROCK) {
p.setPlayerWeather(WeatherType.DOWNFALL);
p.setPlayerTime(15000, true);
p.sendBlockChange(e.getClickedBlock().getLocation(), Material.TNT, (byte) 0);
p.getWorld().strikeLightning(p.getTargetBlock((Set<Material>) null, 500).getLocation());
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), () -> p.getWorld().strikeLightning(p.getTargetBlock((Set<Material>) null, 500).getLocation()), 5 * 20L);
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), () -> {
p.resetPlayerWeather();
p.resetPlayerTime();
p.sendBlockChange(e.getClickedBlock().getLocation(), Material.BEDROCK, (byte) 0);
p.getWorld().strikeLightning(p.getTargetBlock((Set<Material>) null, 500).getLocation());
}, 10 * 20L);
}
if (e.getClickedBlock().getType() == Material.SKULL) {
Skull skull = (Skull) e.getClickedBlock().getState();
if (skull.getOwner().equals("MHF_Chest")) {
@ -218,14 +203,16 @@ public class Events implements Listener {
p.playParticle(skull.getLocation().add(0.5D, 1.5D, 0.5D), EnumParticle.ENCHANTMENT_TABLE, 0.3F, 500);
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), () -> {
p.playParticle(skull.getLocation().add(0.5D, 0.0D, 0.5D), EnumParticle.SPELL_WITCH, 0.4F, 500);
Title.sendTitle(p, 10, 50, 10, "§eDu hast ein Versteck gefunden", "§6Name hier einfügen");
p.addCoins(100);
p.sendTitle(10, 50, 10, "§eDu hast ein Versteck gefunden", "§6Name hier einfügen");
p.getDatabasePlayer().addCoins(100);
Scoreboards.updateScoreboard(p);
}, 3 * 20L);
}
}
if(e.getClickedBlock().getType() == Material.STONE_BUTTON) {
new StartMission(p);
}
}
}
/**
@ -240,9 +227,8 @@ public class Events implements Listener {
@EventHandler
public void onHangingBreak(HangingBreakByEntityEvent e) {
if (e.getEntity() instanceof ItemFrame) {
if (e.getEntity() instanceof ItemFrame)
e.setCancelled(true);
}
}
@EventHandler
@ -264,13 +250,9 @@ public class Events implements Listener {
public void onChat(AsyncPlayerChatEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
for (CustomPlayer players : PlayerHider.getSilentlobby()) {
e.getRecipients().remove(players);
}
for (CustomPlayer players : PlayerHider.getSilentlobby()) e.getRecipients().remove(players);
if (PlayerHider.getSilentlobby().contains(p)) {
e.setCancelled(true);
}
if (PlayerHider.getSilentlobby().contains(p)) e.setCancelled(true);
}
@EventHandler
@ -279,9 +261,15 @@ public class Events implements Listener {
if (PetManager.hasPet(p)) {
new Pets().followPlayer((Creature) PetManager.getPet(p), p, 1.4);
}
if ((p.getLocation().getBlock().getType() == Material.STATIONARY_WATER) && (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.STATIONARY_WATER) && (p.getVehicle() == null) && (p.getGameMode() != GameMode.CREATIVE) && (!p.isFlying())) {
if ((p.getLocation().getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getVehicle() == null) && (p.getGameMode() != GameMode.CREATIVE)
&& (!p.isFlying())) {
p.setGliding(true);
}else{
}
if ((p.getLocation().getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getVehicle() == null)) {
p.setGliding(false);
}
//only for debugging purposes
@ -291,6 +279,28 @@ public class Events implements Listener {
}
}
@EventHandler
public void onEntityToggleGlideEvent(EntityToggleGlideEvent e) {
if(e.getEntity() instanceof Player) {
final CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER) {
p.setVelocity(new Vector(p.getLocation().getDirection().getX() * 1, 1 * -1.0, p.getLocation().getDirection().getZ() * 0.1));
e.setCancelled(true);
}
if(p.isSneaking()) {
e.setCancelled(true);
}
}
}
@EventHandler
public void onToogleSneak(PlayerToggleSneakEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(!p.isSneaking()) {
p.setGliding(true);
}
}
@EventHandler
public void onEntityBlockChange(EntityChangeBlockEvent e) {
e.setCancelled(true);

View File

@ -1,7 +1,9 @@
package eu.univento.lobby.listeners;
import java.util.ArrayList;
import eu.univento.commons.player.Rank;
import eu.univento.core.api.Config;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
@ -15,10 +17,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
import eu.univento.core.api.Config;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.Rank;
import eu.univento.lobby.Lobby;
import java.util.ArrayList;
/**
* fun for player
@ -68,7 +67,7 @@ public class Jumppads implements Listener{
}
if(block.getType() == Material.DIAMOND_BLOCK) {
if(p.isAllowed(Rank.Premium)) {
if(p.getDatabasePlayer().isAllowed(Rank.Premium)) {
if(!flyPremium.contains(p)) {
Vector v = p.getLocation().getDirection().multiply(1D).setY(3D);
p.setVelocity(v);

View File

@ -1,8 +1,8 @@
package eu.univento.lobby.listeners;
import eu.univento.commons.player.Rank;
import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.Rank;
import eu.univento.lobby.utils.StatusSign;
import eu.univento.lobby.utils.StatusSignManager;
import org.bukkit.Material;
@ -22,7 +22,7 @@ public class StatusSigns implements Listener{
@EventHandler
public void onSignChange(SignChangeEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(e.getLine(0).equals("[join]") && p.isAllowed(Rank.Developer)) {
if(e.getLine(0).equals("[join]") && p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) {
StatusSignManager.addSign(e.getLine(1), e.getBlock().getLocation());
Messages msgs = new Messages(p);
p.sendMessage(msgs.Lobby_SET_SIGN());

View File

@ -0,0 +1,34 @@
package eu.univento.lobby.story.events;
import eu.univento.core.api.entity.EntityModifier;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.story.StoryMission;
import eu.univento.lobby.Lobby;
import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
/**
* @author joethei
* @version 0.1
*/
public class StartMissionEvents implements Listener{
private StoryMission mission;
public StartMissionEvents(StoryMission mission) {
this.mission = mission;
mission.registerEvent(this);
}
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
p.sendMessage("Hallo du da");
EntityModifier.Builder modifier = new EntityModifier(p.getWorld().spawnEntity(p.getLocation(), EntityType.CREEPER)).modify();
modifier.setNoAI(true).followPlayer(p, 1.0F);
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), modifier::die, 10 * 20L);
}
}

View File

@ -0,0 +1,20 @@
package eu.univento.lobby.story.missions;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.story.StoryMission;
import eu.univento.core.api.story.StoryMissions;
import eu.univento.lobby.story.events.StartMissionEvents;
/**
* @author joethei
* @version 0.1
*/
public class StartMission extends StoryMission{
public StartMission(CustomPlayer player) {
super(StoryMissions.START, player);
player.sendMessage("Hallo los geht die Mission");
new StartMissionEvents(this);
}
}

View File

@ -18,8 +18,8 @@ public class CustomMapRenderer extends MapRenderer{
public void render(MapView mapView, MapCanvas mapCanvas, Player player) {
CustomPlayer p = CustomPlayer.getPlayer(player);
mapCanvas.drawText(1, 10, MinecraftFont.Font, "Hallo " + p.getName());
mapCanvas.drawText(1, 20, MinecraftFont.Font, "Du bist ein " + p.getRank().name());
mapCanvas.drawText(1, 30, MinecraftFont.Font, p.getFirstLogin().toString());
mapCanvas.drawText(1, 40, MinecraftFont.Font, "Sprache " + p.getLanguage());
mapCanvas.drawText(1, 20, MinecraftFont.Font, "Du bist ein " + p.getDatabasePlayer().getRank().name());
mapCanvas.drawText(1, 30, MinecraftFont.Font, p.getDatabasePlayer().getFirstLogin().toString());
mapCanvas.drawText(1, 40, MinecraftFont.Font, "Sprache " + p.getDatabasePlayer().getLanguage());
}
}

View File

@ -28,7 +28,7 @@ public class Scoreboards {
Score coinsMsg = obj.getScore(msgs.LobbyBoard_COINS());
coinsMsg.setScore(12);
Score coins = obj.getScore("§7" + p.getCoins());
Score coins = obj.getScore("§7" + p.getDatabasePlayer().getCoins());
coins.setScore(11);
Score empty1 = obj.getScore(" ");
@ -37,7 +37,7 @@ public class Scoreboards {
Score foundMsg = obj.getScore(msgs.LobbyBoard_FOUND_SECRETS());
foundMsg.setScore(9);
Score found = obj.getScore("§7" + p.getSecrets());
Score found = obj.getScore("§7" + p.getDatabasePlayer().getSecrets());
found.setScore(8);
Score empty2 = obj.getScore(" ");