+ added Debug Manager

+ added GameTimer
+ added Story Mission
This commit is contained in:
Johannes Theiner 2016-10-11 23:20:58 +02:00
parent d1bb61b3ab
commit 93d263d063
27 changed files with 351 additions and 98 deletions

View File

@ -23,25 +23,29 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" 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.10-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" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.10.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit: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="CloudCommons" /> <orderEntry type="module" module-name="CloudCommons" />
<orderEntry type="library" name="Maven: net.gpedro.integrations.slack:slack-webhook:1.2.1" level="project" />
<orderEntry type="module" module-name="Commons" /> <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.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: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: 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: 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: 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: 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: 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: 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: 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="module-library">
<library name="Maven: eu.the5zig.mod:mod:1.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/local-maven-repo/The5zigMod.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component> </component>
</module> </module>

Binary file not shown.

13
pom.xml
View File

@ -72,13 +72,24 @@
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>craftbukkit</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version> <version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>eu.univento</groupId> <groupId>eu.univento</groupId>
<artifactId>CloudCommons</artifactId> <artifactId>CloudCommons</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.the5zig.mod</groupId>
<artifactId>mod</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/local-maven-repo/The5zigMod.jar</systemPath>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -4,6 +4,7 @@ import eu.univento.commons.Commons;
import eu.univento.commons.server.TPS; import eu.univento.commons.server.TPS;
import eu.univento.core.antihack.AntiHack; import eu.univento.core.antihack.AntiHack;
import eu.univento.core.api.Config; import eu.univento.core.api.Config;
import eu.univento.core.api.debug.DebugManager;
import eu.univento.core.api.effects.Blackscreen; import eu.univento.core.api.effects.Blackscreen;
import eu.univento.core.api.events.MoveEventFilter; import eu.univento.core.api.events.MoveEventFilter;
import eu.univento.core.api.items.InventoryManager; import eu.univento.core.api.items.InventoryManager;
@ -13,6 +14,8 @@ import eu.univento.core.api.server.ServerSettings;
import eu.univento.core.api.utils.NettyInjection; import eu.univento.core.api.utils.NettyInjection;
import eu.univento.core.commands.*; import eu.univento.core.commands.*;
import eu.univento.core.listeners.*; import eu.univento.core.listeners.*;
import io.netty.channel.Channel;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -20,7 +23,6 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException; import java.io.IOException;
import java.nio.channels.Channel;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -80,10 +82,13 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler {
public static void broadcast(String key) { public static void broadcast(String key) {
for (CustomPlayer players : getOnlinePlayers()) { for (CustomPlayer players : getOnlinePlayers()) {
players.sendMessage(players.getDatabasePlayer().getMessage(key)); players.sendMessage(players.getDatabasePlayer().getLanguage().getWord(key));
} }
} }
@Getter
private static DebugManager debugManager;
/* /*
@Override @Override
public void onLoad() { public void onLoad() {
@ -205,10 +210,17 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler {
this.injection = new NettyInjection(this, this.getName()); this.injection = new NettyInjection(this, this.getName());
this.injection.addHandler("TIMEOUT", new NettyInjection.PacketHandler() { this.injection.addHandler("TIMEOUT", new NettyInjection.PacketHandler() {
public Object onPacketIn(Player sender, Channel channel, Object packet) { public Object onPacketIn(Player sender, Channel channel, Object packet) {
getCommons().getLoggingHandler().getCore().info("PacketIN: " + sender.getName() + " | " + channel + " | " + packet);
if (timeout.contains(CustomPlayer.getPlayer(sender))) if (timeout.contains(CustomPlayer.getPlayer(sender)))
return null; return null;
return packet; return packet;
} }
@Override
public Object onPacketOut(Player target, Channel channel, Object packet) {
getCommons().getLoggingHandler().getCore().info("PacketOUT: " + target.getName() + " | " + channel + " | " + packet);
return packet;
}
}); });
commons.getSecurityHandler().isValidServer(getServer().getIp(), aBoolean -> { commons.getSecurityHandler().isValidServer(getServer().getIp(), aBoolean -> {
if(!aBoolean) { if(!aBoolean) {
@ -216,6 +228,7 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler {
} }
}); });
Bukkit.getScheduler().runTask(this, new TPS()); Bukkit.getScheduler().runTask(this, new TPS());
debugManager = new DebugManager();
} }
@Override @Override

View File

@ -17,6 +17,7 @@ public class AntiHack implements Listener{
private static final PacketInjector packetInjector = new PacketInjector(); private static final PacketInjector packetInjector = new PacketInjector();
//TODO: add nofication system
public static void registerListeners() { public static void registerListeners() {
PluginManager pm = Bukkit.getPluginManager(); PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new AntiHack(), Core.getInstance()); pm.registerEvents(new AntiHack(), Core.getInstance());
@ -24,7 +25,6 @@ public class AntiHack implements Listener{
pm.registerEvents(new AutoClicker(), Core.getInstance()); pm.registerEvents(new AutoClicker(), Core.getInstance());
pm.registerEvents(new Criticals(), Core.getInstance()); pm.registerEvents(new Criticals(), Core.getInstance());
pm.registerEvents(new Reach(), Core.getInstance()); pm.registerEvents(new Reach(), Core.getInstance());
pm.registerEvents(new NoSlowDown(), Core.getInstance());
pm.registerEvents(new Regen(), Core.getInstance()); pm.registerEvents(new Regen(), Core.getInstance());
pm.registerEvents(new AutoRespawn(), Core.getInstance()); pm.registerEvents(new AutoRespawn(), Core.getInstance());
pm.registerEvents(new FastPlace(), Core.getInstance()); pm.registerEvents(new FastPlace(), Core.getInstance());

View File

@ -0,0 +1,24 @@
package eu.univento.core.antihack.modules;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
/**
* @author joethei
* @version 0.1
*/
public class AutoSoup implements Listener{
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
if(e.getEntity() instanceof Player && e.getDamager() instanceof Player) {
CustomPlayer p = (CustomPlayer) e.getDamager();
if(p.getInventory().getViewers().size() < 0) {
p.closeInventory();
}
}
}
}

View File

@ -1,11 +1,15 @@
package eu.univento.core.antihack.modules; package eu.univento.core.antihack.modules;
import eu.univento.core.api.events.MoveEventFilter;
import eu.univento.core.api.player.CustomPlayer; import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
public class Movement implements Listener{ public class Movement implements Listener{
@ -43,4 +47,40 @@ public class Movement implements Listener{
p.sendMessage("Du hast Glide an"); p.sendMessage("Du hast Glide an");
} }
} }
@EventHandler
public void onShootBow(EntityShootBowEvent e) {
if(e.getEntity() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(p.isSprinting()) {
e.setCancelled(true);
p.damage(2.0D);
p.setArrowsInBody(p.getArrowsInBody() + 50);
p.sendMessage("Du hast NoSlowDown an");
}
}
}
@EventHandler
public void onFoodChange(FoodLevelChangeEvent e) {
if(e.getEntity() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(e.getFoodLevel() > p.getFoodLevel() && p.isSprinting()) {
e.setCancelled(true);
e.setFoodLevel(0);
p.sendMessage("Du hast NoSlowDown an");
}
}
}
@EventHandler
public void onMoveByBlock(MoveEventFilter.PlayerBlockMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
double distance = e.getTo().getY() - e.getFrom().getY();
if(distance >= 0.9D) {
e.setCancelled(true);
p.teleport(e.getFrom());
p.sendMessage("Du hast Step an");
}
}
} }

View File

@ -1,36 +0,0 @@
package eu.univento.core.antihack.modules;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
public class NoSlowDown implements Listener{
@EventHandler
public void onShootBow(EntityShootBowEvent e) {
if(e.getEntity() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(p.isSprinting()) {
e.setCancelled(true);
p.damage(2.0D);
p.setArrowsInBody(p.getArrowsInBody() + 50);
p.sendMessage("Du hast NoSlowDown an");
}
}
}
@EventHandler
public void onFoodChange(FoodLevelChangeEvent e) {
if(e.getEntity() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(e.getFoodLevel() > p.getFoodLevel() && p.isSprinting()) {
e.setCancelled(true);
e.setFoodLevel(0);
p.sendMessage("Du hast NoSlowDown an");
}
}
}
}

View File

@ -0,0 +1,26 @@
package eu.univento.core.antihack.modules;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
/**
* @author joethei
* @version 0.1
*/
public class SelfHit implements Listener {
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
if(!e.isCancelled() && e.getEntity() instanceof Player && e.getDamager() instanceof Player) {
CustomPlayer p = (CustomPlayer) e.getEntity();
CustomPlayer damager = (CustomPlayer) e.getDamager();
if(damager.equals(p)) {
e.setCancelled(true);
e.setDamage(0.0D);
}
}
}
}

View File

@ -0,0 +1,46 @@
package eu.univento.core.api.debug;
import eu.the5zig.mod.server.The5zigMod;
import eu.the5zig.mod.server.api.ModUser;
import eu.univento.commons.player.Rank;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
/**
* @author joethei
* @version 0.1
*/
public class DebugManager {
private boolean enabled;
public DebugManager() {
Plugin plugin = Bukkit.getPluginManager().getPlugin("The5zigMod");
if(plugin.isEnabled()) {
this.enabled = true;
}
}
public void sendStat(String stat, String score) {
if(enabled) {
for(ModUser user : The5zigMod.getInstance().getUserManager().getOnlineModUsers()) {
CustomPlayer player = CustomPlayer.getPlayer(user.getPlayer());
if(player.getDatabasePlayer().isAllowed(Rank.JrDeveloper)) {
user.getStatsManager().getStat(stat).setScore(score);
}
}
}
}
public void sendOverlay(String overlay) {
if(enabled) {
for(ModUser user : The5zigMod.getInstance().getUserManager().getOnlineModUsers()) {
CustomPlayer player = CustomPlayer.getPlayer(user.getPlayer());
if(player.getDatabasePlayer().isAllowed(Rank.JrDeveloper)) {
user.sendOverlay(overlay);
}
}
}
}
}

View File

@ -1,5 +1,6 @@
package eu.univento.core.api.entity; package eu.univento.core.api.entity;
import eu.univento.core.Core;
import net.minecraft.server.v1_10_R1.EntityLiving; import net.minecraft.server.v1_10_R1.EntityLiving;
import net.minecraft.server.v1_10_R1.NBTTagCompound; import net.minecraft.server.v1_10_R1.NBTTagCompound;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -21,18 +22,17 @@ public class EntityModifier {
private static CraftEntity craftentity; private static CraftEntity craftentity;
private static net.minecraft.server.v1_10_R1.Entity entityS; private static net.minecraft.server.v1_10_R1.Entity entityS;
private static int scheduler; private static int scheduler;
private static Plugin plugin; private static Plugin plugin = Core.getInstance();
private static Player player = null; private static Player player = null;
private static float Speed; private static float Speed;
public EntityModifier(org.bukkit.entity.Entity entity, Plugin plugin) { public EntityModifier(org.bukkit.entity.Entity entity) {
EntityModifier.entity = entity; EntityModifier.entity = entity;
craftentity = (CraftEntity) entity; craftentity = (CraftEntity) entity;
entityS = craftentity.getHandle(); entityS = craftentity.getHandle();
EntityModifier.plugin = plugin;
} }
public static Builder modify() { public Builder modify() {
return new Builder(); return new Builder();
} }
@ -48,7 +48,7 @@ public class EntityModifier {
return this; return this;
} }
public Builder playEffekt(EntityEffect entityeffect) { public Builder playEffect(EntityEffect entityeffect) {
EntityModifier.entity.playEffect(entityeffect); EntityModifier.entity.playEffect(entityeffect);
return this; return this;
} }
@ -75,9 +75,7 @@ public class EntityModifier {
public Builder setYawPitch(float yaw, float pitch) { public Builder setYawPitch(float yaw, float pitch) {
Location loc = EntityModifier.entity.getLocation().clone(); Location loc = EntityModifier.entity.getLocation().clone();
teleport( teleport(new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ(), yaw, pitch));
new Location(loc.getWorld(), loc.getX(), loc.getY(),
loc.getZ(), yaw, pitch));
return this; return this;
} }
@ -102,8 +100,7 @@ public class EntityModifier {
public Builder setInvulnerable(boolean invulnerable) { public Builder setInvulnerable(boolean invulnerable) {
try { try {
Field invulnerableField = net.minecraft.server.v1_10_R1.Entity.class Field invulnerableField = net.minecraft.server.v1_10_R1.Entity.class.getDeclaredField("invulnerable");
.getDeclaredField("invulnerable");
invulnerableField.setAccessible(true); invulnerableField.setAccessible(true);
invulnerableField.setBoolean(EntityModifier.entityS, invulnerable); invulnerableField.setBoolean(EntityModifier.entityS, invulnerable);
} catch (Exception ex) { } catch (Exception ex) {
@ -159,10 +156,7 @@ public class EntityModifier {
} }
public Builder walkToLocation(Location location, float speed) { public Builder walkToLocation(Location location, float speed) {
((CraftCreature) EntityModifier.entity) ((CraftCreature) EntityModifier.entity).getHandle().getNavigation().a(location.getX(), location.getY(), location.getZ(), speed);
.getHandle()
.getNavigation()
.a(location.getX(), location.getY(), location.getZ(), speed);
return this; return this;
} }
@ -171,20 +165,13 @@ public class EntityModifier {
EntityModifier.Speed = speed; EntityModifier.Speed = speed;
EntityModifier.scheduler = Bukkit.getScheduler().scheduleSyncRepeatingTask(EntityModifier.plugin, EntityModifier.scheduler = Bukkit.getScheduler().scheduleSyncRepeatingTask(EntityModifier.plugin,
() -> { () -> {
double distance = EntityModifier.entity.getLocation().distance( double distance = EntityModifier.entity.getLocation().distance(EntityModifier.player.getLocation());
EntityModifier.player.getLocation());
if (distance < 11.0D) { if (distance < 11.0D) {
float speed1 = EntityModifier.Speed; float speed1 = EntityModifier.Speed;
if (distance < 3.0D) { if (distance < 3.0D) {
speed1 = 0.0F; speed1 = 0.0F;
} }
((CraftCreature) EntityModifier.entity) ((CraftCreature) EntityModifier.entity).getHandle().getNavigation().a(EntityModifier.player.getLocation().getX(),EntityModifier.player.getLocation().getY(),EntityModifier.player.getLocation().getZ(), speed1);
.getHandle()
.getNavigation()
.a(EntityModifier.player.getLocation().getX(),
EntityModifier.player.getLocation().getY(),
EntityModifier.player.getLocation().getZ(),
speed1);
} else if (EntityModifier.player.isOnGround()) { } else if (EntityModifier.player.isOnGround()) {
EntityModifier.entity.teleport(EntityModifier.player); EntityModifier.entity.teleport(EntityModifier.player);
} }

View File

@ -0,0 +1,51 @@
package eu.univento.core.api.game;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
/**
* @author joethei
* @version 0.1
*/
public class GameTimer extends BukkitRunnable{
private Plugin plugin;
private int time;
private int minPlayers;
private GameTimer following;
public GameTimer(Plugin plugin, GameTimer following, int time, int minPlayers) {
this.plugin = plugin;
this.following = following;
this.time = time;
this.minPlayers = minPlayers;
runTaskTimer(plugin, 20L, 20L);
}
@Override
public void run() {
if(PlayerManager.size() >= minPlayers) {
time--;
}
if(time == 0) {
if(PlayerManager.size() > minPlayers) {
this.cancel();
following.run();
}else {
this.cancel();
//TODO: reset timer
this.run();
}
}
}
public int getTime() {
return time;
}
public int getMinPlayers() {
return minPlayers;
}
}

View File

@ -13,7 +13,6 @@ public class PlayerManager {
private static final List<CustomPlayer> players = new LinkedList<>(); private static final List<CustomPlayer> players = new LinkedList<>();
public static List<CustomPlayer> getPlayers() { public static List<CustomPlayer> getPlayers() {
return players; return players;
} }

View File

@ -8,7 +8,7 @@ import java.util.ArrayList;
* @author joethei * @author joethei
* @version 0.1 * @version 0.1
*/ */
class TeamManager { public class TeamManager {
private static final ArrayList<Team> teams = new ArrayList<>(); private static final ArrayList<Team> teams = new ArrayList<>();

View File

@ -58,10 +58,12 @@ public class InventoryManager implements Listener{
public void onInventoryClick(InventoryClickEvent e) { public void onInventoryClick(InventoryClickEvent e) {
int i = 0; int i = 0;
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked()); CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked());
for(ClickInventory inventory : inventoryList) { if(e.getInventory() instanceof ClickInventory) {
if(inventory.getPlayer() == p) for(ClickInventory inventory : inventoryList) {
inventory.onInventoryClick(e); if(inventory.getPlayer() == p)
inventory.onInventoryClick(e);
if(i++ == 1) break; if(i++ == 1) break;
}
} }
} }

View File

@ -1,6 +1,6 @@
package eu.univento.core.api.map; package eu.univento.core.api.map;
import eu.univento.cloud.commons.server.ServerType; import eu.univento.commons.server.ServerType;
import eu.univento.core.Core; import eu.univento.core.Core;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -18,13 +18,11 @@ import eu.univento.core.api.utils.GameProfileBuilder;
import eu.univento.core.api.utils.UUIDFetcher; import eu.univento.core.api.utils.UUIDFetcher;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_10_R1.*; import net.minecraft.server.v1_10_R1.*;
import net.minecraft.server.v1_10_R1.World;
import org.bson.Document; import org.bson.Document;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance; import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier; import org.bukkit.attribute.AttributeModifier;
@ -46,7 +44,7 @@ import java.io.ObjectOutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.*;
public class CustomPlayer extends CraftPlayer{ public class CustomPlayer extends CraftPlayer {
private static final HashMap<UUID, CustomPlayer> PLAYERS = new HashMap<>(); private static final HashMap<UUID, CustomPlayer> PLAYERS = new HashMap<>();
@ -180,7 +178,7 @@ public class CustomPlayer extends CraftPlayer{
*/ */
public void sendActionBar(String text) { public void sendActionBar(String text) {
spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(text)); //spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(text));
} }
public void sendTitle(int fadeIn, int stay, int fadeOut, String title, String subtitle) { public void sendTitle(int fadeIn, int stay, int fadeOut, String title, String subtitle) {
@ -326,6 +324,8 @@ public class CustomPlayer extends CraftPlayer{
setDisplayName(name); setDisplayName(name);
Field nameField = getField(GameProfile.class, "name"); Field nameField = getField(GameProfile.class, "name");
try { try {
assert nameField != null;
nameField.setAccessible(true);
nameField.set(getProfile(), name); nameField.set(getProfile(), name);
PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(getEntityId()); PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(getEntityId());
sendPacket(destroy); sendPacket(destroy);
@ -349,8 +349,8 @@ public class CustomPlayer extends CraftPlayer{
} }
public void strikeLightning(Location loc) { public void strikeLightning(Location loc) {
World nmsWorld = ((CraftWorld) loc.getWorld()).getHandle(); World nmsWorld = (World) ((CraftWorld) loc.getWorld()).getHandle();
EntityLightning lightning = new EntityLightning(nmsWorld, loc.getX(), loc.getY(), loc.getZ(), true); EntityLightning lightning = new EntityLightning((net.minecraft.server.v1_10_R1.World) nmsWorld, loc.getX(), loc.getY(), loc.getZ(), true);
sendPacket(new PacketPlayOutSpawnEntityWeather(lightning)); sendPacket(new PacketPlayOutSpawnEntityWeather(lightning));
playSound(loc, Sound.ENTITY_LIGHTNING_IMPACT, 20.0F, 1.0F); playSound(loc, Sound.ENTITY_LIGHTNING_IMPACT, 20.0F, 1.0F);
playSound(loc, Sound.ENTITY_LIGHTNING_THUNDER, 20.0F, 1.0F); playSound(loc, Sound.ENTITY_LIGHTNING_THUNDER, 20.0F, 1.0F);
@ -360,11 +360,6 @@ public class CustomPlayer extends CraftPlayer{
Blackscreen.setBlack(PLAYER, seconds); Blackscreen.setBlack(PLAYER, seconds);
} }
@Override
public boolean isOnline() {
return DATABASE_PLAYER.isOnline();
}
public void setStoryResourcePack() { public void setStoryResourcePack() {
setResourcePack("http://univento.eu/storyPack.zip"); setResourcePack("http://univento.eu/storyPack.zip");
} }

View File

@ -18,11 +18,11 @@ public class SpectateManager {
return null; return null;
} }
public static void add(Spectator spectator) { static void add(Spectator spectator) {
if(!spectators.contains(spectator)) spectators.add(spectator); if(!spectators.contains(spectator)) spectators.add(spectator);
} }
public static void remove(Spectator spectator) { static void remove(Spectator spectator) {
if(spectators.contains(spectator)) spectators.remove(spectator); if(spectators.contains(spectator)) spectators.remove(spectator);
} }

View File

@ -1,5 +1,6 @@
package eu.univento.core.api.player; package eu.univento.core.api.player;
import eu.univento.commons.player.language.MessageConstant;
import eu.univento.core.Core; import eu.univento.core.Core;
import eu.univento.core.api.game.PlayerManager; import eu.univento.core.api.game.PlayerManager;
import eu.univento.core.api.items.ItemBuilder; import eu.univento.core.api.items.ItemBuilder;
@ -51,7 +52,7 @@ public class Spectator {
} }
public void openPlayerListInventory() { public void openPlayerListInventory() {
ScrollingInventory inventory = new ScrollingInventory(player, player.getDatabasePlayer().getMessage("Game.Menu.SpectatorMenu")); ScrollingInventory inventory = new ScrollingInventory(player, player.getDatabasePlayer().getLanguage().getMessage(MessageConstant.GAME_SPECTATE_MENU));
for(CustomPlayer players : PlayerManager.getPlayers()) { for(CustomPlayer players : PlayerManager.getPlayers()) {
inventory.addItem(new ItemBuilder(Material.SKULL_ITEM).durability((short) 3).skullOwner(players.getDisplayName()).name(players.getDisplayName()).make()); inventory.addItem(new ItemBuilder(Material.SKULL_ITEM).durability((short) 3).skullOwner(players.getDisplayName()).name(players.getDisplayName()).make());
} }

View File

@ -1,5 +1,7 @@
package eu.univento.core.api.server; package eu.univento.core.api.server;
import eu.univento.commons.server.ServerType;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**

View File

@ -1,6 +1,6 @@
package eu.univento.core.api.server; package eu.univento.core.api.server;
import eu.univento.cloud.commons.server.ServerType; import eu.univento.commons.server.ServerType;
import eu.univento.core.Core; import eu.univento.core.Core;
import eu.univento.core.commands.Build; import eu.univento.core.commands.Build;
import eu.univento.core.listeners.Blocks; import eu.univento.core.listeners.Blocks;

View File

@ -1,6 +1,6 @@
package eu.univento.core.api.shop; package eu.univento.core.api.shop;
import eu.univento.cloud.commons.server.ServerType; import eu.univento.commons.server.ServerType;
/** /**
* @author joethei * @author joethei

View File

@ -0,0 +1,51 @@
package eu.univento.core.api.story;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import lombok.Data;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginManager;
import java.util.List;
/**
* @author joethei
* @version 0.1
*/
@Data
public class StoryMission{
private PluginManager pluginManager;
private List<Listener> listeners;
private StoryMissions mission;
private CustomPlayer player;
public StoryMission(StoryMissions mission, CustomPlayer player) {
this.mission = mission;
this.player = player;
this.pluginManager = Bukkit.getPluginManager();
player.getDatabasePlayer().setInDatabase("mission", mission.getId());
setStatus(StoryMissionStatus.RUNNING);
}
public void registerEvent(Listener listener) {
listeners.add(listener);
pluginManager.registerEvents(listener, Core.getInstance());
}
public boolean unregisterEvent(Listener listener) {
HandlerList.unregisterAll(listener);
return listeners.contains(listener) && listeners.remove(listener);
}
public void unregisterEvents() {
listeners.forEach(HandlerList::unregisterAll);
}
public void setStatus(StoryMissionStatus status) {
player.getDatabasePlayer().setInDatabase("missionStatus", status.name());
}
}

View File

@ -0,0 +1,11 @@
package eu.univento.core.api.story;
/**
* @author joethei
* @version 0.1
*/
public enum StoryMissionStatus {
RUNNING,
DONE,
}

View File

@ -0,0 +1,23 @@
package eu.univento.core.api.story;
import lombok.Getter;
/**
* @author joethei
* @version 0.1
*/
public enum StoryMissions {
START(1, "Story.Mission.Start");
@Getter
private int id;
@Getter
private String name;
StoryMissions(int id, String name) {
this.id = id;
this.name = name;
}
}

View File

@ -46,7 +46,9 @@ public class Nick extends AutoCommand<Core>{
p.getDatabasePlayer().getSettings().setNickStatus(true); p.getDatabasePlayer().getSettings().setNickStatus(true);
p.getScoreboard().getTeam(p.getDatabasePlayer().getRank().getTeam()).addEntry(p.getDisplayName()); p.getScoreboard().getTeam(p.getDatabasePlayer().getRank().getTeam()).addEntry(p.getDisplayName());
p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_ON()); p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_ON());
p.setNick(NickName.getRandomNick()); String nick = NickName.getRandomNick();
p.setNick(nick);
//Core.getDebugManager().sendOverlay("der Nick ist " + nick);
} }
}else { }else {
p.sendMessage(msgs.NO_PERMS()); p.sendMessage(msgs.NO_PERMS());

View File

@ -1,5 +1,6 @@
package eu.univento.core.listeners; package eu.univento.core.listeners;
import eu.univento.commons.player.language.MessageConstant;
import eu.univento.core.Core; import eu.univento.core.Core;
import eu.univento.core.api.Utils; import eu.univento.core.api.Utils;
import eu.univento.core.api.player.*; import eu.univento.core.api.player.*;
@ -102,11 +103,11 @@ public class JoinQuit implements Listener {
loading.remove(p); loading.remove(p);
} }
if(e.getStatus() == PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD) { if(e.getStatus() == PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD) {
p.sendMessage(p.getDatabasePlayer().getMessage("Pack.failed_download")); p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.PACK_FAILED_DOWNLOAD));
Bukkit.getScheduler().runTaskLaterAsynchronously(Core.getInstance(), p::setStoryResourcePack, 10 * 20L); Bukkit.getScheduler().runTaskLaterAsynchronously(Core.getInstance(), p::setStoryResourcePack, 10 * 20L);
} }
if(e.getStatus() == PlayerResourcePackStatusEvent.Status.DECLINED) { if(e.getStatus() == PlayerResourcePackStatusEvent.Status.DECLINED) {
p.sendMessage(p.getDatabasePlayer().getMessage("Pack.declined")); p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.PACK_DECLINED));
Bukkit.getScheduler().runTaskLaterAsynchronously(Core.getInstance(), p::setStoryResourcePack, 10 * 20L); Bukkit.getScheduler().runTaskLaterAsynchronously(Core.getInstance(), p::setStoryResourcePack, 10 * 20L);
} }
} }