+ 1.11 Update

+ pathfinding
+ method to send centered text
This commit is contained in:
Johannes Theiner 2016-11-24 19:52:24 +01:00
parent 40e4190fcf
commit 1e6b3e3b6d
69 changed files with 977 additions and 359 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<module com.demonwav.mcdev.MinecraftModuleTypes="PAPER_MODULE_TYPE" 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" />
@ -11,40 +11,33 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.14.8" 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: com.destroystokyo.paper:paper-api:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" 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.yaml:snakeyaml:1.17" 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="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-all:5.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="Commons" />
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.2.2" 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: com.github.TheHolyWaffle:TeamSpeak-3-Java-API:v1.0.13" 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" />
<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>
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.10" level="project" />
</component>
</module>

Binary file not shown.

30
pom.xml
View File

@ -50,34 +50,35 @@
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
<id>univentoEU</id>
<url>http://dev.joethei.de:8081/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.8</version>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
@ -85,16 +86,9 @@
<version>1.0-SNAPSHOT</version>
</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>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
</dependency>
</dependencies>

View File

@ -4,7 +4,6 @@ import eu.univento.commons.Commons;
import eu.univento.commons.server.TPS;
import eu.univento.core.antihack.AntiHack;
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.events.MoveEventFilter;
import eu.univento.core.api.items.InventoryManager;
@ -15,7 +14,6 @@ import eu.univento.core.api.utils.NettyInjection;
import eu.univento.core.commands.*;
import eu.univento.core.listeners.*;
import io.netty.channel.Channel;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -86,9 +84,6 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler {
}
}
@Getter
private static DebugManager debugManager;
/*
@Override
public void onLoad() {
@ -232,7 +227,6 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler {
});
*/
Bukkit.getScheduler().runTask(this, new TPS());
debugManager = new DebugManager();
}
@Override

View File

@ -4,8 +4,8 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.minecraft.server.v1_10_R1.Packet;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import net.minecraft.server.v1_11_R1.Packet;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.List;

View File

@ -2,14 +2,14 @@ package eu.univento.core.api;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import net.minecraft.server.v1_10_R1.EntityArmorStand;
import net.minecraft.server.v1_10_R1.EnumHand;
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_11_R1.EntityArmorStand;
import net.minecraft.server.v1_11_R1.EnumHand;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_11_R1.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;

View File

@ -8,7 +8,22 @@ import org.bukkit.DyeColor;
*/
public enum BannerColor {
BLACK('0', DyeColor.BLACK), BLUE('1', DyeColor.BLUE), BROWN('g', DyeColor.BROWN), CYAN('3', DyeColor.CYAN), GRAY('8', DyeColor.GRAY), GREEN('2', DyeColor.GREEN), LIGHT_BLUE('b', DyeColor.LIGHT_BLUE), LIME('a', DyeColor.LIME), MAGENTA('c', DyeColor.MAGENTA), ORANGE('6', DyeColor.ORANGE), PINK('d', DyeColor.PINK), PURPLE('5', DyeColor.PURPLE), RED('4', DyeColor.RED), SILVER('7', DyeColor.SILVER), WHITE('f', DyeColor.WHITE), YELLOW('e', DyeColor.YELLOW);
BLACK('0', DyeColor.BLACK),
BLUE('1', DyeColor.BLUE),
BROWN('g', DyeColor.BROWN),
CYAN('3', DyeColor.CYAN),
GRAY('8', DyeColor.GRAY),
GREEN('2', DyeColor.GREEN),
LIGHT_BLUE('b', DyeColor.LIGHT_BLUE),
LIME('a', DyeColor.LIME),
MAGENTA('c', DyeColor.MAGENTA),
ORANGE('6', DyeColor.ORANGE),
PINK('d', DyeColor.PINK),
PURPLE('5', DyeColor.PURPLE),
RED('4', DyeColor.RED),
SILVER('7', DyeColor.SILVER),
WHITE('f', DyeColor.WHITE),
YELLOW('e', DyeColor.YELLOW);
private char colorCode;
private DyeColor color;

View File

@ -0,0 +1,139 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.chat;
/**
* @author SirSpoodles
* @version 1.0
*/
public enum DefaultFontInfo {
A('A', 5),
a('a', 5),
B('B', 5),
b('b', 5),
C('C', 5),
c('c', 5),
D('D', 5),
d('d', 5),
E('E', 5),
e('e', 5),
F('F', 5),
f('f', 4),
G('G', 5),
g('g', 5),
H('H', 5),
h('h', 5),
I('I', 3),
i('i', 1),
J('J', 5),
j('j', 5),
K('K', 5),
k('k', 4),
L('L', 5),
l('l', 1),
M('M', 5),
m('m', 5),
N('N', 5),
n('n', 5),
O('O', 5),
o('o', 5),
P('P', 5),
p('p', 5),
Q('Q', 5),
q('q', 5),
R('R', 5),
r('r', 5),
S('S', 5),
s('s', 5),
T('T', 5),
t('t', 4),
U('U', 5),
u('u', 5),
V('V', 5),
v('v', 5),
W('W', 5),
w('w', 5),
X('X', 5),
x('x', 5),
Y('Y', 5),
y('y', 5),
Z('Z', 5),
z('z', 5),
NUM_1('1', 5),
NUM_2('2', 5),
NUM_3('3', 5),
NUM_4('4', 5),
NUM_5('5', 5),
NUM_6('6', 5),
NUM_7('7', 5),
NUM_8('8', 5),
NUM_9('9', 5),
NUM_0('0', 5),
EXCLAMATION_POINT('!', 1),
AT_SYMBOL('@', 6),
NUM_SIGN('#', 5),
DOLLAR_SIGN('$', 5),
PERCENT('%', 5),
UP_ARROW('^', 5),
AMPERSAND('&', 5),
ASTERISK('*', 5),
LEFT_PARENTHESIS('(', 4),
RIGHT_PERENTHESIS(')', 4),
MINUS('-', 5),
UNDERSCORE('_', 5),
PLUS_SIGN('+', 5),
EQUALS_SIGN('=', 5),
LEFT_CURL_BRACE('{', 4),
RIGHT_CURL_BRACE('}', 4),
LEFT_BRACKET('[', 3),
RIGHT_BRACKET(']', 3),
COLON(':', 1),
SEMI_COLON(';', 1),
DOUBLE_QUOTE('"', 3),
SINGLE_QUOTE('\'', 1),
LEFT_ARROW('<', 4),
RIGHT_ARROW('>', 4),
QUESTION_MARK('?', 5),
SLASH('/', 5),
BACK_SLASH('\\', 5),
LINE('|', 1),
TILDE('~', 5),
TICK('`', 2),
PERIOD('.', 1),
COMMA(',', 1),
SPACE(' ', 3),
DEFAULT('a', 4);
private char character;
private int length;
DefaultFontInfo(char character, int length) {
this.character = character;
this.length = length;
}
public char getCharacter() {
return this.character;
}
public int getLength() {
return this.length;
}
public int getBoldLength() {
if (this == DefaultFontInfo.SPACE) return this.getLength();
return this.length + 1;
}
public static DefaultFontInfo getDefaultFontInfo(char c) {
for (DefaultFontInfo dFI : DefaultFontInfo.values()) {
if (dFI.getCharacter() == c) return dFI;
}
return DefaultFontInfo.DEFAULT;
}
}

View File

@ -1,6 +1,5 @@
package eu.univento.core.api.customitems.swords;
import eu.univento.core.api.customitems.swords.CustomSwordManager;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.inventory.ItemStack;

View File

@ -1,46 +0,0 @@
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,10 +1,10 @@
package eu.univento.core.api.effects;
import eu.univento.core.Core;
import net.minecraft.server.v1_10_R1.EnumParticle;
import net.minecraft.server.v1_10_R1.PacketPlayOutWorldParticles;
import net.minecraft.server.v1_11_R1.EnumParticle;
import net.minecraft.server.v1_11_R1.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
/**

View File

@ -1,13 +1,13 @@
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.NBTTagCompound;
import net.minecraft.server.v1_11_R1.EntityLiving;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
import org.bukkit.Bukkit;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -20,7 +20,7 @@ import java.lang.reflect.Field;
public class EntityModifier {
private static org.bukkit.entity.Entity entity;
private static CraftEntity craftentity;
private static net.minecraft.server.v1_10_R1.Entity entityS;
private static net.minecraft.server.v1_11_R1.Entity entityS;
private static int scheduler;
private static Plugin plugin = Core.getInstance();
private static Player player = null;
@ -100,7 +100,7 @@ public class EntityModifier {
public Builder setInvulnerable(boolean invulnerable) {
try {
Field invulnerableField = net.minecraft.server.v1_10_R1.Entity.class.getDeclaredField("invulnerable");
Field invulnerableField = net.minecraft.server.v1_11_R1.Entity.class.getDeclaredField("invulnerable");
invulnerableField.setAccessible(true);
invulnerableField.setBoolean(EntityModifier.entityS, invulnerable);
} catch (Exception ex) {

View File

@ -0,0 +1,323 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.entity.pathfinding;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.material.Gate;
import java.util.*;
/**
* @author Adamk11s
* @version 1.0
*/
public class AStar {
private final int sx, sy, sz, ex, ey, ez;
private final World w;
private PathingResult result;
private HashMap<String, Tile> open = new HashMap<>();
private HashMap<String, Tile> closed = new HashMap<>();
private void addToOpenList(Tile t, boolean modify) {
if (open.containsKey(t.getUID())) {
if (modify) {
open.put(t.getUID(), t);
}
} else {
open.put(t.getUID(), t);
}
}
private void addToClosedList(Tile t) {
if (!closed.containsKey(t.getUID())) {
closed.put(t.getUID(), t);
}
}
private final int range;
private final String endUID;
public AStar(Location start, Location end, int range) throws InvalidPathException {
boolean s = true, e = true;
if (!(s = this.isLocationWalkable(start)) || !(e = this.isLocationWalkable(end))) {
throw new InvalidPathException(s, e);
}
this.w = start.getWorld();
this.sx = start.getBlockX();
this.sy = start.getBlockY();
this.sz = start.getBlockZ();
this.ex = end.getBlockX();
this.ey = end.getBlockY();
this.ez = end.getBlockZ();
this.range = range;
short sh = 0;
Tile t = new Tile(sh, sh, sh, null);
t.calculateBoth(sx, sy, sz, ex, ey, ez, true);
this.open.put(t.getUID(), t);
this.processAdjacentTiles(t);
StringBuilder b = new StringBuilder();
b.append(ex - sx).append(ey - sy).append(ez - sz);
this.endUID = b.toString();
}
public Location getEndLocation() {
return new Location(w, ex, ey, ez);
}
public PathingResult getPathingResult() {
return this.result;
}
boolean checkOnce = false;
private int abs(int i) {
return (i < 0 ? -i : i);
}
public ArrayList<Tile> iterate() {
if (!checkOnce) {
// invert the boolean flag
checkOnce ^= true;
if((abs(sx - ex) > range) || (abs(sy - ey) > range) || (abs(sz - ez) > range)){
this.result = PathingResult.NO_PATH;
return null;//jump out
}
}
// while not at end
Tile current = null;
while (canContinue()) {
// get lowest F cost square on open list
current = this.getLowestFTile();
// process tiles
this.processAdjacentTiles(current);
}
if (this.result != PathingResult.SUCCESS) {
return null;
} else {
// path found
LinkedList<Tile> routeTrace = new LinkedList<>();
Tile parent;
routeTrace.add(current);
assert current != null;
while ((parent = current.getParent()) != null) {
routeTrace.add(parent);
current = parent;
}
Collections.reverse(routeTrace);
return new ArrayList<>(routeTrace);
}
}
private boolean canContinue() {
// check if open list is empty, if it is no path has been found
if (open.size() == 0) {
this.result = PathingResult.NO_PATH;
return false;
} else {
if (closed.containsKey(this.endUID)) {
this.result = PathingResult.SUCCESS;
return false;
} else {
return true;
}
}
}
private Tile getLowestFTile() {
double f = 0;
Tile drop = null;
// get lowest F cost square
for (Tile t : open.values()) {
if (f == 0) {
t.calculateBoth(sx, sy, sz, ex, ey, ez, true);
f = t.getF();
drop = t;
} else {
t.calculateBoth(sx, sy, sz, ex, ey, ez, true);
double posF = t.getF();
if (posF < f) {
f = posF;
drop = t;
}
}
}
// drop from open list and add to closed
assert drop != null;
this.open.remove(drop.getUID());
this.addToClosedList(drop);
return drop;
}
private boolean isOnClosedList(Tile t) {
return closed.containsKey(t.getUID());
}
// pass in the current tile as the parent
private void processAdjacentTiles(Tile current) {
// set of possible walk to locations adjacent to current tile
HashSet<Tile> possible = new HashSet<>(26);
for (byte x = -1; x <= 1; x++) {
for (byte y = -1; y <= 1; y++) {
for (byte z = -1; z <= 1; z++) {
if (x == 0 && y == 0 && z == 0) {
continue;// don't check current square
}
Tile t = new Tile((short) (current.getX() + x), (short) (current.getY() + y), (short) (current.getZ() + z), current);
if (!t.isInRange(this.range)) {
// if block is out of bounds continue
continue;
}
if (x != 0 && z != 0 && (y == 0 || y == 1)) {
// check to stop jumping through diagonal blocks
Tile xOff = new Tile((short) (current.getX() + x), (short) (current.getY() + y), current.getZ(), current), zOff = new Tile(current.getX(),
(short) (current.getY() + y), (short) (current.getZ() + z), current);
if (!this.isTileWalkable(xOff) && !this.isTileWalkable(zOff)) {
continue;
}
}
if (this.isOnClosedList(t)) {
// ignore tile
continue;
}
// only process the tile if it can be walked on
if (this.isTileWalkable(t)) {
t.calculateBoth(sx, sy, sz, ex, ey, ez, true);
possible.add(t);
}
}
}
}
for (Tile t : possible) {
// get the reference of the object in the array
Tile openRef;
if ((openRef = this.isOnOpenList(t)) == null) {
// not on open list, so add
this.addToOpenList(t, false);
} else {
// is on open list, check if path to that square is better using
// G cost
if (t.getG() < openRef.getG()) {
// if current path is better, change parent
openRef.setParent(current);
// force updates of F, G and H values.
openRef.calculateBoth(sx, sy, sz, ex, ey, ez, true);
}
}
}
}
private Tile isOnOpenList(Tile t) {
return (open.containsKey(t.getUID()) ? open.get(t.getUID()) : null);
/*
* for (Tile o : open) { if (o.equals(t)) { return o; } } return null;
*/
}
private boolean isTileWalkable(Tile t) {
Location l = new Location(w, (sx + t.getX()), (sy + t.getY()), (sz + t.getZ()));
Block b = l.getBlock();
int i = b.getTypeId();
// lava, fire, wheat and ladders cannot be walked on, and of course air
// 85, 107 and 113 stops npcs climbing fences and fence gates
if (i != 10 && i != 11 && i != 51 && i != 59 && i != 65 && i != 0 && i != 85 && i != 107 && i != 113 && !canBlockBeWalkedThrough(i)) {
// make sure the blocks above are air
if (b.getRelative(0, 1, 0).getTypeId() == 107) {
// fench gate check, if closed continue
Gate g = new Gate(b.getRelative(0, 1, 0).getData());
return (g.isOpen() && (b.getRelative(0, 2, 0).getTypeId() == 0));
}
return (canBlockBeWalkedThrough(b.getRelative(0, 1, 0).getTypeId()) && b.getRelative(0, 2, 0).getTypeId() == 0);
} else {
return false;
}
}
private boolean isLocationWalkable(Location l) {
Block b = l.getBlock();
int i = b.getTypeId();
if (i != 10 && i != 11 && i != 51 && i != 59 && i != 65 && i != 0 && !canBlockBeWalkedThrough(i)) {
// make sure the blocks above are air or can be walked through
return (canBlockBeWalkedThrough(b.getRelative(0, 1, 0).getTypeId()) && b.getRelative(0, 2, 0).getTypeId() == 0);
} else {
return false;
}
}
private boolean canBlockBeWalkedThrough(int id) {
return (id == 0 || id == 6 || id == 50 || id == 63 || id == 30 || id == 31 || id == 32 || id == 37 || id == 38 || id == 39 || id == 40 || id == 55 || id == 66 || id == 75
|| id == 76 || id == 78);
}
public class InvalidPathException extends Exception {
private final boolean s, e;
public InvalidPathException(boolean s, boolean e) {
this.s = s;
this.e = e;
}
public String getErrorReason() {
StringBuilder sb = new StringBuilder();
if (!s) {
sb.append("Start Location was air. ");
}
if (!e) {
sb.append("End Location was air.");
}
return sb.toString();
}
public boolean isStartNotSolid() {
return (!s);
}
public boolean isEndNotSolid() {
return (!e);
}
}
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.entity.pathfinding;
/**
* @author joethei
* @version 1.0
*/
public enum PathingResult {
SUCCESS(0),
NO_PATH(-1);
private final int ec;
PathingResult(int ec){
this.ec = ec;
}
public int getEndCode(){
return this.ec;
}
}

View File

@ -0,0 +1,156 @@
/*
* Copyright (c) 2016 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.entity.pathfinding;
import org.bukkit.Location;
/**
* @author Adamk11s
* @version 1.0
*/
public class Tile {
// as offset from starting point
private final short x, y, z;
private double g = -1, h = -1;
private Tile parent = null;
private final String uid;
public Tile(short x, short y, short z, Tile parent) {
this.x = x;
this.y = y;
this.z = z;
this.parent = parent;
StringBuilder b = new StringBuilder();
b.append(x);
b.append(y);
b.append(z);
uid = b.toString();
}
public boolean isInRange(int range){
return ((range - abs(x) >= 0) && (range - abs(y) >= 0) && (range - abs(z) >= 0));
}
public void setParent(Tile parent) {
this.parent = parent;
}
public Location getLocation(Location start) {
return new Location(start.getWorld(), start.getBlockX() + x, start.getBlockY() + y, start.getBlockZ() + z);
}
public Tile getParent() {
return this.parent;
}
public short getX() {
return x;
}
public int getX(Location i) {
return (i.getBlockX() + x);
}
public short getY() {
return y;
}
public int getY(Location i) {
return (i.getBlockY() + y);
}
public short getZ() {
return z;
}
public int getZ(Location i) {
return (i.getBlockZ() + z);
}
public String getUID() {
return this.uid;
}
public boolean equals(Tile t) {
return (t.getX() == x && t.getY() == y && t.getZ() == z);
}
public void calculateBoth(int sx, int sy, int sz, int ex, int ey, int ez, boolean update) {
this.calculateG(sx, sy, sz, update);
this.calculateH(sx, sy, sz, ex, ey, ez, update);
}
public void calculateH(int sx, int sy, int sz, int ex, int ey, int ez, boolean update) {
// only update if h hasn't been calculated or if forced
if ((!update && h == -1) || update) {
int hx = sx + x, hy = sy + y, hz = sz + z;
this.h = this.getEuclideanDistance(hx, hy, hz, ex, ey, ez);
}
}
// G = the movement cost to move from the starting point A to a given square
// on the grid, following the path generated to get there.
public void calculateG(int sx, int sy, int sz, boolean update) {
if ((!update && g == -1) || update) {
// only update if g hasn't been calculated or if forced
Tile currentParent = this.getParent(), currentTile = this;
int gCost = 0;
// follow path back to start
while ((currentParent = currentTile.getParent()) != null) {
int dx = currentTile.getX() - currentParent.getX(), dy = currentTile.getY() - currentParent.getY(), dz = currentTile.getZ() - currentParent.getZ();
dx = abs(dx);
dy = abs(dy);
dz = abs(dz);
if (dx == 1 && dy == 1 && dz == 1) {
gCost += 1.7;
} else if (((dx == 1 || dz == 1) && dy == 1) || ((dx == 1 || dz == 1) && dy == 0)) {
gCost += 1.4;
} else {
gCost += 1.0;
}
// move backwards a tile
currentTile = currentParent;
}
this.g = gCost;
}
}
public double getG() {
return g;
}
public double getH() {
return h;
}
public double getF() {
// f = h + g
return (h + g);
}
private double getEuclideanDistance(int sx, int sy, int sz, int ex, int ey, int ez) {
double dx = sx - ex, dy = sy - ey, dz = sz - ez;
return Math.sqrt((dx * dx) + (dy * dy) + (dz * dz));
}
private int abs(int i) {
return (i < 0 ? -i : i);
}
}

View File

@ -2,9 +2,9 @@ package eu.univento.core.api.fakeplayer;
import com.mojang.authlib.GameProfile;
import eu.univento.core.Core;
import net.minecraft.server.v1_10_R1.*;
import net.minecraft.server.v1_11_R1.*;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;

View File

@ -1,9 +1,9 @@
package eu.univento.core.api.gui;
import eu.univento.core.Core;
import net.minecraft.server.v1_10_R1.*;
import net.minecraft.server.v1_11_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;

View File

@ -1,9 +1,9 @@
package eu.univento.core.api.gui;
import eu.univento.core.api.player.CustomPlayer;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.EntityPlayer;
import net.minecraft.server.v1_10_R1.PacketPlayOutOpenSignEditor;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.PacketPlayOutOpenSignEditor;
/**
* @author joethei

View File

@ -3,11 +3,11 @@ package eu.univento.core.api.gui;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.minecraft.server.v1_10_R1.NetworkManager;
import net.minecraft.server.v1_10_R1.Packet;
import net.minecraft.server.v1_10_R1.PacketPlayInUpdateSign;
import net.minecraft.server.v1_11_R1.NetworkManager;
import net.minecraft.server.v1_11_R1.Packet;
import net.minecraft.server.v1_11_R1.PacketPlayInUpdateSign;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;

View File

@ -34,8 +34,7 @@ public class ItemBuilder {
/**
* Init item chainable via given Material parameter.
*
* @param itemType
* the {@link Material} to initiate the instance with.
* @param itemType the {@link Material} to initiate the instance with.
*
* @since 1.0
*/
@ -47,8 +46,7 @@ public class ItemBuilder {
/**
* Init item chainable via given ItemStack parameter.
*
* @param itemStack
* the {@link ItemStack} to initialize the instance with.
* @param itemStack the {@link ItemStack} to initialize the instance with.
*
* @since 1.0
*/
@ -70,8 +68,7 @@ public class ItemBuilder {
/**
* Changes the Material type of the {@link ItemStack}
*
* @param material
* the new {@link Material} to set for the ItemStack.
* @param material the new {@link Material} to set for the ItemStack.
*
* @return the current instance for chainable application.
* @since 1.0
@ -84,8 +81,7 @@ public class ItemBuilder {
/**
* Changes the {@link ItemStack}s size.
*
* @param itemAmt
* the new Integer count of the ItemStack.
* @param itemAmt the new Integer count of the ItemStack.
*
* @return the current instance for chainable application.
* @since 1.0
@ -98,8 +94,7 @@ public class ItemBuilder {
/**
* Changes the {@link ItemStack}s display name.
*
* @param name
* the new String for the ItemStack's display name to be set to.
* @param name the new String for the ItemStack's display name to be set to.
*
* @return the current instance for chainable application.
* @since 1.0
@ -113,8 +108,7 @@ public class ItemBuilder {
/**
* Adds a line of lore to the {@link ItemStack}
*
* @param lore
* String you want to add to the ItemStack's lore.
* @param lore String you want to add to the ItemStack's lore.
*
* @return the current instance for chainable application.
* @since 1.0
@ -131,8 +125,7 @@ public class ItemBuilder {
/**
* Clears the {@link ItemStack}s lore and replaces it with the defined String array.
*
* @param lores
* String array you want to set the ItemStack's lore to.
* @param lores String array you want to set the ItemStack's lore to.
*
* @return the current instance for chainable application.
* @since 1.0
@ -146,17 +139,6 @@ public class ItemBuilder {
return this;
}
/**
* Changes the durability of the current {@link ItemStack}
*
* @return the current instance for chainable application.
* @since 1.0
*/
public ItemBuilder durability(){
make().setDurability((short) 3);
return this;
}
public ItemBuilder durability(short durability) {
make().setDurability(durability);
return this;
@ -165,8 +147,7 @@ public class ItemBuilder {
/**
* Changes the data value of the {@link ItemStack}
*
* @param data
* the new int data value (parsed as byte) to set the ItemStack's durability to.
* @param data the new int data value (parsed as byte) to set the ItemStack's durability to.
*
* @return the current instance for chainable application.
* @since 1.0
@ -180,11 +161,9 @@ public class ItemBuilder {
/**
* Adds and UnsafeEnchantment to the {@link ItemStack} with a defined level int value.
*
* @param enchantment
* the {@link Enchantment} to add to the ItemStack.
* @param enchantment the {@link Enchantment} to add to the ItemStack.
*
* @param level
* the int amount that the Enchantment's level will be set to.
* @param level the int amount that the Enchantment's level will be set to.
*
* @return the current instance for chainable application.
* @since 1.0
@ -197,8 +176,7 @@ public class ItemBuilder {
/**
* Adds and UnsafeEnchantment to the {@link} with a level int value of 1.
*
* @param enchantment
* the {@link Enchantment} to add to the ItemStack.
* @param enchantment the {@link Enchantment} to add to the ItemStack.
*
* @return the current instance for chainable application.
* @since 1.0
@ -211,11 +189,9 @@ public class ItemBuilder {
/**
* Clears all {@link Enchantment}s from the current {@link ItemStack} then adds the defined array of Enchantments to the ItemStack.
*
* @param enchantments
* the Enchantment array to replace any current enchantments applied on the ItemStack.
* @param enchantments the Enchantment array to replace any current enchantments applied on the ItemStack.
*
* @param level
* the int level value for all Enchantments to be set to.
* @param level the int level value for all Enchantments to be set to.
*
* @return the current instance for chainable application.
* @since 1.0
@ -231,8 +207,7 @@ public class ItemBuilder {
/**
* Clears all {@link Enchantment}s from the current {@link ItemStack} then adds the defined array of Enchantments to the ItemStack with a level int value of 1.
*
* @param enchantments
* the Enchantment array to replace any current enchantments applied on the ItemStack.
* @param enchantments the Enchantment array to replace any current enchantments applied on the ItemStack.
*
* @return the current instance for chainable application.
* @since 1.0
@ -248,8 +223,7 @@ public class ItemBuilder {
/**
* Clears the defined {@link Enchantment} from the {@link ItemStack}
*
* @param enchantment
* the Enchantment to remove from the ItemStack.
* @param enchantment the Enchantment to remove from the ItemStack.
*
* @return the current instance for chainable application.
* @since 1.0
@ -278,8 +252,7 @@ public class ItemBuilder {
/**
* Clears the defined {@link String} of lore from the {@link ItemStack}
*
* @param lore
* the String to be removed from the ItemStack.
* @param lore the String to be removed from the ItemStack.
*
* @return the current instance for chainable application.
* @since 1.0
@ -307,8 +280,7 @@ public class ItemBuilder {
/**
* Sets the {@link Color} of any LEATHER_ARMOR {@link Material} types of the {@link ItemStack}
*
* @param color
* the Color to set the LEATHER_ARMOR ItemStack to.
* @param color the Color to set the LEATHER_ARMOR ItemStack to.
*
* @return the current instance for chainable application.
* @since 1.0
@ -346,8 +318,7 @@ public class ItemBuilder {
/**
* Sets the skullOwner {@link SkullMeta} of the current SKULL_ITEM {@link Material} type {@link ItemStack}
*
* @param name
* the {@link String} value to set the SkullOwner meta to for the SKULL_ITEM Material type ItemStack.
* @param name the {@link String} value to set the SkullOwner meta to for the SKULL_ITEM Material type ItemStack.
*
* @return the current instance for chainable application
* @since 1.0

View File

@ -7,9 +7,9 @@ import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.utils.GameProfileBuilder;
import lombok.Data;
import net.minecraft.server.v1_10_R1.DataWatcher;
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_10_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_11_R1.DataWatcher;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn;
import org.bukkit.Bukkit;
import org.bukkit.Location;

View File

@ -1,10 +1,14 @@
package eu.univento.core.api.npc.datawatcher;
import lombok.Getter;
/**
* @author ingrim4, joethei
* @version 1.0
*/
public enum EnumDataWatcher {
enum EnumDataWatcher {
//TODO: fix field
ENTITY_BITMASK_00("Entity", "ay"),//
ENTITY_AIR_01("Entity", "az"),//AIR
@ -23,8 +27,14 @@ public enum EnumDataWatcher {
HUMAN_SKIN_12("EntityHuman", ""),
HUMAN_HAND_13("EntityHuman", "");
EnumDataWatcher(String owner, String field) {
@Getter
private String owner;
@Getter
private String field;
EnumDataWatcher(String owner, String field) {
this.owner = owner;
this.field = field;
}
public Object getObject() {

View File

@ -1,9 +1,9 @@
package eu.univento.core.api.pet;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.World;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.World;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.CreatureSpawnEvent;

View File

@ -1,7 +1,7 @@
package eu.univento.core.api.pet;
import net.minecraft.server.v1_10_R1.EntityInsentient;
import net.minecraft.server.v1_10_R1.EntityTypes;
import net.minecraft.server.v1_11_R1.EntityInsentient;
import net.minecraft.server.v1_11_R1.EntityTypes;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

View File

@ -2,9 +2,9 @@ package eu.univento.core.api.pet;
import eu.univento.core.api.pet.custom.CustomCreeper;
import eu.univento.core.api.pet.custom.CustomPig;
import net.minecraft.server.v1_10_R1.EntityCreeper;
import net.minecraft.server.v1_10_R1.EntityInsentient;
import net.minecraft.server.v1_10_R1.EntityPig;
import net.minecraft.server.v1_11_R1.EntityCreeper;
import net.minecraft.server.v1_11_R1.EntityInsentient;
import net.minecraft.server.v1_11_R1.EntityPig;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;

View File

@ -1,7 +1,7 @@
package eu.univento.core.api.pet.custom;
import eu.univento.core.api.pet.PetManager;
import net.minecraft.server.v1_10_R1.*;
import net.minecraft.server.v1_11_R1.*;
/**
* @author joethei

View File

@ -1,7 +1,7 @@
package eu.univento.core.api.pet.custom;
import eu.univento.core.api.pet.PetManager;
import net.minecraft.server.v1_10_R1.*;
import net.minecraft.server.v1_11_R1.*;
/**
* @author joethei

View File

@ -2,10 +2,7 @@ package eu.univento.core.api.player;
public class BetterPvP {
public BetterPvP() {
}
public String getCodeString() {
public static String getCodeString() {
String toReturn = "§c §r§5 §r§1 §r§f";
String code = String.valueOf(getCodeToSend());
int size = code.length();
@ -16,7 +13,7 @@ public class BetterPvP {
return toReturn;
}
private int getCodeToSend() {
private static int getCodeToSend() {
int code = 0;
code |= 0;
int armourStatusMask = 2;

View File

@ -8,15 +8,15 @@ import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.api.Hologram;
import eu.univento.core.api.Utils;
import eu.univento.core.api.chat.DefaultFontInfo;
import eu.univento.core.api.effects.Blackscreen;
import eu.univento.core.api.effects.Effects;
import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.core.api.server.Servers;
import eu.univento.core.api.shop.ShopItem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_10_R1.*;
import net.minecraft.server.v1_11_R1.*;
import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.World;
@ -27,16 +27,17 @@ import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.lang.reflect.Field;
@ -139,7 +140,15 @@ public class CustomPlayer extends CraftPlayer {
}
public void connectToServer(String server) {
Servers.connectServer(PLAYER, server);
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Connect");
out.writeUTF(server);
} catch (IOException el) {
el.printStackTrace();
}
sendPluginMessage(Core.getInstance(), "BungeeCord", b.toByteArray());
}
public void warn(WarnReason reason, CustomPlayer warner, String proof) {
@ -321,9 +330,45 @@ public class CustomPlayer extends CraftPlayer {
return new Messages(this);
}
public void sendCentredMessage(Player player, String message) {
if(message == null || message.equals("")) {
player.sendMessage("");
return;
}
message = ChatColor.translateAlternateColorCodes('&', message);
int messagePxSize = 0;
boolean previousCode = false;
boolean isBold = false;
for(char c : message.toCharArray()){
if(c == '§'){
previousCode = true;
}else if(previousCode){
previousCode = false;
isBold = c == 'l' || c == 'L';
}else{
DefaultFontInfo dFI = DefaultFontInfo.getDefaultFontInfo(c);
messagePxSize += isBold ? dFI.getBoldLength() : dFI.getLength();
messagePxSize++;
}
}
int CENTER_PX = 154;
int halvedMessageSize = messagePxSize / 2;
int toCompensate = CENTER_PX - halvedMessageSize;
int spaceLength = DefaultFontInfo.SPACE.getLength() + 1;
int compensated = 0;
StringBuilder sb = new StringBuilder();
while(compensated < toCompensate){
sb.append(" ");
compensated += spaceLength;
}
sendMessage(sb.toString() + message);
}
public void strikeLightning(Location loc) {
World nmsWorld = (World) ((CraftWorld) loc.getWorld()).getHandle();
EntityLightning lightning = new EntityLightning((net.minecraft.server.v1_10_R1.World) nmsWorld, loc.getX(), loc.getY(), loc.getZ(), true);
EntityLightning lightning = new EntityLightning((net.minecraft.server.v1_11_R1.World) nmsWorld, loc.getX(), loc.getY(), loc.getZ(), true);
sendPacket(new PacketPlayOutSpawnEntityWeather(lightning));
playSound(loc, Sound.ENTITY_LIGHTNING_IMPACT, 20.0F, 1.0F);
playSound(loc, Sound.ENTITY_LIGHTNING_THUNDER, 20.0F, 1.0F);
@ -429,7 +474,7 @@ public class CustomPlayer extends CraftPlayer {
if(loc.getBlock().getType() != Material.CHEST) return;
byte dataByte = (open) ? (byte) 1 : 0;
BlockPosition position = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
PacketPlayOutBlockAction blockActionPacket = new PacketPlayOutBlockAction(position, net.minecraft.server.v1_10_R1.Block.getById(loc.getBlock().getTypeId()), (byte) 1, dataByte);
PacketPlayOutBlockAction blockActionPacket = new PacketPlayOutBlockAction(position, net.minecraft.server.v1_11_R1.Block.getById(loc.getBlock().getTypeId()), (byte) 1, dataByte);
sendPacket(blockActionPacket);
}

View File

@ -8,11 +8,16 @@ import java.util.Random;
* @author joethei
* @version 1.1
*/
public class NickName {
/**
/**
* gets random Nickname
* @return String
*/
//FIXME: change to users from ban list
@Deprecated
public static String getRandomNick() {
ArrayList<String> names = new ArrayList<>();
names.add("GommeHD");

View File

@ -11,7 +11,7 @@ import java.util.stream.Collectors;
/**
* @author desht (Original code), KingFaris10 (Editor of code)
* @version 0.1
* @version 1.0
*/
public class Cuboid implements Cloneable, ConfigurationSerializable, Iterable<Block> {
@ -66,7 +66,7 @@ public class Cuboid implements Cloneable, ConfigurationSerializable, Iterable<Bl
}
public boolean containsLocation(Location location) {
return location != null && location.getWorld().getName().equals(this.worldName) && location.toVector().isInAABB(this.minimumPoint, this.maximumPoint);
return location != null && (location.getWorld().getName().equals(this.worldName) || location.toVector().isInAABB(this.minimumPoint, this.maximumPoint));
}
public boolean containsVector(Vector vector) {

View File

@ -13,7 +13,7 @@ import java.util.stream.Collectors;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class Schematic {

View File

@ -9,7 +9,7 @@ import java.util.Map;
/**
* @author joethei
* @version 0.1
* @version 0.5
*/
public class SchematicManager {

View File

@ -4,7 +4,7 @@ import eu.univento.commons.server.ServerType;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
class GameInfo {

View File

@ -9,6 +9,16 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
/**
* @author TheTinySpider
* Idea from: sebasju1234
*
* @version 1.0
*
* Status names and other information can be found at:
* [url]http://minecraft.gamepedia.com/User_talk:Oxguy3/Minecraft.net_API[/url]
*/
public enum MojangService {
@ -21,14 +31,6 @@ public enum MojangService {
SKINS("Skin ServerPinger", "skins.minecraft.net"),
MAIN_WEBSITE("Main Site", "minecraft.net");
/*
* @Author TheTinySpider
* Idea from: sebasju1234
*
* Status names and other information can be found at:
* [url]http://minecraft.gamepedia.com/User_talk:Oxguy3/Minecraft.net_API[/url]
*/
private final String name;
private final String serviceURL;
private final JSONParser jsonParser = new JSONParser();

View File

@ -12,6 +12,8 @@ import java.sql.SQLException;
*/
class ServerDatabase {
//TODO: cache results and use mongodb
static String getIP(String name) {
MySQL sql = Core.getCommons().getDatabaseManager().getMySQL();
try {

View File

@ -6,7 +6,7 @@ import java.util.regex.Pattern;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class ServerInfo {

View File

@ -1,44 +0,0 @@
package eu.univento.core.api.server;
import eu.univento.core.Core;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
/**
* sends player to other bungeecord servers
* @author joethei
* @version 1.0
*/
public class Servers {
/**
* sends player to server
* @param p player
* @param server name of server
*/
public static void connectServer(Player p, String server) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Connect");
out.writeUTF(server);
} catch (IOException el) {
el.printStackTrace();
}
p.sendPluginMessage(Core.getInstance(), "BungeeCord", b.toByteArray());
}
/**
* connects all player to server
* @param server name of server
*/
public static void connectAllToServer(String server) {
for (Player all : Bukkit.getOnlinePlayers())
connectServer(all, server);
}
}

View File

@ -2,7 +2,7 @@ package eu.univento.core.api.shop;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public enum PayType {
//TODO: change to real pay type names.

View File

@ -4,7 +4,7 @@ import eu.univento.commons.server.ServerType;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
enum ShopCategory {

View File

@ -5,7 +5,7 @@ import org.bukkit.inventory.ItemStack;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public enum ShopItem {

View File

@ -15,7 +15,7 @@ import java.util.List;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class ShopMenu implements Listener{

View File

@ -14,7 +14,7 @@ import org.bukkit.plugin.Plugin;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
class ShopEntity implements Listener{

View File

@ -7,7 +7,7 @@ import org.bukkit.plugin.Plugin;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class ShopIronGolem extends ShopEntity{

View File

@ -8,7 +8,7 @@ import org.bukkit.plugin.Plugin;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class ShopVillager extends ShopEntity {

View File

@ -12,7 +12,7 @@ import java.util.List;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
@Data

View File

@ -2,7 +2,7 @@ package eu.univento.core.api.story;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public enum StoryMissionStatus {

View File

@ -4,7 +4,7 @@ import lombok.Getter;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public enum StoryMissions {

View File

@ -1,7 +1,6 @@
package eu.univento.core.api.utils;
public enum Direction
{
public enum Direction {
NORTH(1, 0),
SOUTH(-1, 0),
EAST(0, 1),

View File

@ -57,7 +57,7 @@ public class GameProfileBuilder {
cache.put(uuid, new CachedProfile(result));
return result;
} else {
if (!false && cache.containsKey(uuid)) {
if (cache.containsKey(uuid)) {
return cache.get(uuid).profile;
}
JsonObject error = (JsonObject) new JsonParser().parse(new BufferedReader(new InputStreamReader(connection.getErrorStream())).readLine());

View File

@ -9,7 +9,7 @@ import java.lang.reflect.InvocationTargetException;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class Lamps {

View File

@ -6,8 +6,12 @@ import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
final class Maths
{
/**
* @author joethei
* @version 1.0
*/
final class Maths {
public static final float nanoToSec = 1.0E-009F;
public static final float FLOAT_ROUNDING_ERROR = 1.0E-006F;
public static final float PI = 3.141593F;

View File

@ -119,7 +119,7 @@ public class NettyInjection {
Bukkit.getOnlinePlayers().forEach(this::inject);
}
private final void registerGlobalChannel() {
private void registerGlobalChannel() {
Object server = NettyInjection.FIELD_CRAFTSERVER_MINECRAFTSERVER.get(Bukkit.getServer());
Object connection = NettyInjection.FIELD_MINECRAFTSERVER_SERVERCONNECTION.get(server);
List<Object> channelFuture = (List<Object>) FIELD_SERVERCONNECTION_CHANNELFUTURE.get(connection);
@ -132,7 +132,7 @@ public class NettyInjection {
}
}
private final void unregisterGlobalChannel() {
private void unregisterGlobalChannel() {
for (Channel global : this.globalChannel) {
final ChannelPipeline pipe = global.pipeline();
global.eventLoop().execute(() -> pipe.remove("NettyInjectionGlobal"));
@ -148,15 +148,15 @@ public class NettyInjection {
this.handlerList.remove(name);
}
public final void inject(Player player) {
private void inject(Player player) {
this.injectChannel(this.getChannel(player)).player = player;
}
public final void uninject(Player player) {
private void uninject(Player player) {
this.uninjectChannel(this.getChannel(player));
}
private final Channel getChannel(Player player) {
private Channel getChannel(Player player) {
Channel channel = this.playerChannel.get(player.getName());
if (channel == null) {
channel = FIELD_NETWORKMANAGER_CHANNEL.get(FIELD_PLAYERCONNECTION_NETWORKMANAGER.get(FIELD_ENTITYPLAYER_PLAYERCONNECTION.get(FIELD_CRAFTPLAYER_ENTITY.get(player))));
@ -165,7 +165,7 @@ public class NettyInjection {
return channel;
}
private final PacketInjection injectChannel(Channel channel) {
private PacketInjection injectChannel(Channel channel) {
try {
PacketInjection handel = (PacketInjection) channel.pipeline().get(this.handlerName);
if (handel == null) {
@ -178,7 +178,7 @@ public class NettyInjection {
}
}
private final void uninjectChannel(Channel channel) {
private void uninjectChannel(Channel channel) {
Object handel = channel.pipeline().get(this.handlerName);
if (handel != null)
channel.pipeline().remove(this.handlerName);
@ -196,6 +196,7 @@ public class NettyInjection {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
assert CLASS_PACKERLOGININSTART != null;
if (CLASS_PACKERLOGININSTART.isInstance(msg))
NettyInjection.this.playerChannel.put(FIELD_GAMEPROFILE_NAME.get(FIELD_PACKERLOGININSTART_GAMEPROFILE.get(msg)), ctx.channel());
for (PacketHandler handel : NettyInjection.this.handlerList.values()) {

View File

@ -4,8 +4,7 @@ import java.util.NavigableMap;
import java.util.Random;
import java.util.TreeMap;
class RandomCollection<E>
{
class RandomCollection<E> {
private final NavigableMap<Double, E> map = new TreeMap<>();
private final Random random;
private double total = 0.0D;

View File

@ -1,5 +1,9 @@
package eu.univento.core.api.utils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.util.UUIDTypeAdapter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
@ -11,12 +15,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.util.UUIDTypeAdapter;
/**
* @author Jofkos
* @version 1.0
*/
public class UUIDFetcher{

View File

@ -2,44 +2,44 @@ package eu.univento.core.api.utils;
import org.bukkit.util.Vector;
final class Vectors
{
private static Vector rotateAroundAxisX(Vector v, double angle)
{
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double y = v.getY() * cos - v.getZ() * sin;
double z = v.getY() * sin + v.getZ() * cos;
return v.setY(y).setZ(z);
}
/**
* @author joethei
* @version 1.0
*/
private static Vector rotateAroundAxisY(Vector v, double angle)
{
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double x = v.getX() * cos + v.getZ() * sin;
double z = v.getX() * -sin + v.getZ() * cos;
return v.setX(x).setZ(z);
}
final class Vectors {
private static Vector rotateAroundAxisX(Vector v, double angle) {
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double y = v.getY() * cos - v.getZ() * sin;
double z = v.getY() * sin + v.getZ() * cos;
return v.setY(y).setZ(z);
}
private static Vector rotateAroundAxisZ(Vector v, double angle)
{
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double x = v.getX() * cos - v.getY() * sin;
double y = v.getX() * sin + v.getY() * cos;
return v.setX(x).setY(y);
}
private static Vector rotateAroundAxisY(Vector v, double angle) {
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double x = v.getX() * cos + v.getZ() * sin;
double z = v.getX() * -sin + v.getZ() * cos;
return v.setX(x).setZ(z);
}
public static Vector rotateVector(Vector v, double angleX, double angleY, double angleZ)
{
rotateAroundAxisX(v, angleX);
rotateAroundAxisY(v, angleY);
rotateAroundAxisZ(v, angleZ);
return v;
}
private static Vector rotateAroundAxisZ(Vector v, double angle) {
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double x = v.getX() * cos - v.getY() * sin;
double y = v.getX() * sin + v.getY() * cos;
return v.setX(x).setY(y);
}
public static double angleToXAxis(Vector vector) {
return Math.atan2(vector.getX(), vector.getY());
}
public static Vector rotateVector(Vector v, double angleX, double angleY, double angleZ) {
rotateAroundAxisX(v, angleX);
rotateAroundAxisY(v, angleY);
rotateAroundAxisZ(v, angleZ);
return v;
}
public static double angleToXAxis(Vector vector) {
return Math.atan2(vector.getX(), vector.getY());
}
}

View File

@ -28,7 +28,6 @@ public class Nick extends AutoCommand<Core>{
super(plugin, command, description, aliases);
}
@SuppressWarnings("deprecation")
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if(sender instanceof Player) {

View File

@ -17,6 +17,7 @@ import java.util.stream.Collectors;
* @author joethei
* @version 1.0
*/
public class SetRank extends AutoCommand<Core>{
public SetRank(Core plugin, String command, String description, String... aliases) {

View File

@ -27,6 +27,7 @@ public class SystemInfo extends AutoCommand<Core>{
* @param description describes the commons
* @param aliases aliases of commons
*/
public SystemInfo(Core plugin, String command, String description, String... aliases) {
super(plugin, command, description, aliases);
}

View File

@ -16,6 +16,7 @@ import java.util.List;
* @author joethei
* @version 0.1
*/
public class Timeout extends AutoCommand<Core> {
public Timeout(Core plugin, String command, String description, String... aliases) {

View File

@ -17,6 +17,7 @@ import java.util.List;
* @author joethei
* @version 1.0
*/
public class Vanish extends AutoCommand<Core>{
/**

View File

@ -14,6 +14,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
* @author joethei
* @version 1.0
*/
public class Blocks implements Listener{
/**

View File

@ -34,6 +34,7 @@ import java.util.Map;
* @author joethei
* @version 1.0
*/
public class Chat implements Listener {
private List<CustomPlayer> players = new LinkedList<>();

View File

@ -16,6 +16,7 @@ import org.bukkit.help.HelpTopic;
* @author joethei
* @version 1.0
*/
public class Commands implements Listener{

View File

@ -22,8 +22,9 @@ import org.bukkit.util.Vector;
* some basic events
*
* @author joethei
* @version 0.2
* @version 1.0
*/
public class Events implements Listener {
@EventHandler
@ -43,6 +44,7 @@ public class Events implements Listener {
if (p.getLocation().getY() <= 0) {
p.setVelocity(new Vector().setY(10.0D).multiply(1.0D));
p.setGliding(true);
}
}
@ -90,4 +92,5 @@ public class Events implements Listener {
}
}
}
}

View File

@ -12,10 +12,7 @@ import org.bukkit.entity.Player;
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.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
import org.bukkit.event.player.*;
import org.bukkit.scoreboard.Team;
import java.io.ByteArrayOutputStream;
@ -34,13 +31,17 @@ public class JoinQuit implements Listener {
private List<CustomPlayer> firstJoin = new LinkedList<>();
private List<CustomPlayer> loading = new LinkedList<>();
@EventHandler
public void onPreLogin(AsyncPlayerPreLoginEvent e) {
if(!Core.getCommons().getSecurityHandler().isValidServer(e.getAddress().getHostAddress())) {
e.setKickMessage("Im sorry, you can only join from our official IP: play.univento.eu");
e.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_BANNED);
}
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(!p.hasPlayedBefore()) {
}
for (Player players : Bukkit.getOnlinePlayers()) {
CustomPlayer player = CustomPlayer.getPlayer(players);
if (Vanish.getPlayers().contains(player))
@ -64,7 +65,7 @@ public class JoinQuit implements Listener {
labyModFeatures.put(LabyMod.EXTRAS, false);
p.setLabyModFeatures(labyModFeatures);
p.sendMessage(new BetterPvP().getCodeString());
p.sendMessage(BetterPvP.getCodeString());
//disable code for minimap mod
p.sendMessage("§A§n§t§i§M§i§n§i§m§a§p");
@ -90,7 +91,6 @@ public class JoinQuit implements Listener {
//p.setStoryResourcePack();
loading.add(p);
}
@EventHandler

View File

@ -6,6 +6,7 @@ import org.bukkit.event.Listener;
* @author joethei
* @version 0.1
*/
public class NPCEvents implements Listener {
}

View File

@ -10,11 +10,27 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
import java.io.UnsupportedEncodingException;
/**
* @author joethei
* @version 1.0
*/
public class PluginMessenger implements PluginMessageListener {
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] data) {
CustomPlayer p = CustomPlayer.getPlayer(player);
String string = null;
try {
string = new String (data, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
assert string != null;
if(string.endsWith("squidhq")) {
p.warn(WarnReason.SPAM, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/hacks");
}
if (channel.equals("WDL|INIT")) {
String version = null;
if(data.length == 0) version = "vor 1.8d";
@ -27,41 +43,47 @@ public class PluginMessenger implements PluginMessageListener {
p.sendMessage(p.getDatabasePlayer().getLanguage().getWord("Prefix") + p.getDatabasePlayer().getLanguage().getWord("Hack.WorldDownloader"));
}
if(channel.equals("WDL|CONTROL")) {
p.sendPluginMessage(Core.getInstance(), "WDL|CONTROL", createWDLPacket(0, false, false, false, false));
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeInt(1);
output.writeBoolean(false);
output.writeInt(0);
output.writeBoolean(false);
output.writeBoolean(false);
output.writeBoolean(false);
output.writeBoolean(false);
p.sendPluginMessage(Core.getInstance(), "WDL|CONTROL", output.toByteArray());
}
if (channel.equals("PERMISSIONSREPL") && new String(data).contains("mod.worlddownloader")) {
if (channel.equals("PERMISSIONSREPL") && string.contains("mod.worlddownloader")) {
//TODO: change to real warn reason
p.warn(WarnReason.SPAM, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/hacks");
p.sendMessage(p.getDatabasePlayer().getLanguage().getWord("Prefix") + p.getDatabasePlayer().getLanguage().getWord("Hack.WorldDownloader"));
}
if(channel.equals("5zig_Set")) {
try {
String version = new String(data, "UTF-8");
Core.getCommons().getLoggingHandler().getCore().info(p.getName() + " hat den 5zig Mod Version : " + version);
//https://gist.github.com/5zig/35e0854504edda418f4b shows why
ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
dataOutput.writeByte(0x01 | 0x02 | 0x02 | 0x04 | 0x08 | 0x010);
p.sendPluginMessage(Core.getInstance(), "5zig_Set", dataOutput.toByteArray());
p.sendPluginMessage(Core.getInstance(), "5zig_Set", new byte[]{0x01 | 0x02 | 0x04 | 0x08 | 0x10});
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//https://gist.github.com/5zig/35e0854504edda418f4b shows why its done that way
ByteArrayDataOutput output1 = ByteStreams.newDataOutput();
output1.write(0x01);
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output1.toByteArray());
ByteArrayDataOutput output2 = ByteStreams.newDataOutput();
output2.write(0x02);
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output2.toByteArray());
ByteArrayDataOutput output3 = ByteStreams.newDataOutput();
output3.write(0x04);
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output3.toByteArray());
ByteArrayDataOutput output4 = ByteStreams.newDataOutput();
output4.write(0x08);
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output4.toByteArray());
ByteArrayDataOutput output5 = ByteStreams.newDataOutput();
output5.write(0x10);
p.sendPluginMessage(Core.getInstance(), "5zig_Set", output5.toByteArray());
}
}
//TODO:
private byte[] createWDLPacket(int saveRadius, boolean cacheChunks, boolean saveEntities, boolean saveTileEntities, boolean saveContainers) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeInt(1);
output.writeBoolean(cacheChunks);
output.writeInt(saveRadius);
output.writeBoolean(saveEntities);
output.writeBoolean(saveTileEntities);
output.writeBoolean(saveContainers);
output.writeBoolean(false);
return output.toByteArray();
}
}

View File

@ -10,7 +10,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
/**
* @author joethei
* @version 0.1
* @version 1.0
*/
public class WeaponEvents implements Listener {