^ changed up player nicking system again, mabye it works now

+ added a few things for NPCs
+ added BowAimbot Detection
This commit is contained in:
Johannes Theiner 2016-10-28 23:50:06 +02:00
parent 4f79661aa9
commit 40e4190fcf
31 changed files with 523 additions and 422 deletions

View File

@ -11,6 +11,7 @@
</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: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
@ -24,10 +25,7 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.10-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.10.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.bukkit:craftbukkit:1.10.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="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="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: com.zaxxer:HikariCP:2.4.5" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.16" level="project" />
@ -38,6 +36,7 @@
<orderEntry type="library" name="Maven: com.github.theholywaffle:teamspeak3-api:1.0.14-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: net.gpedro.integrations.slack:slack-webhook:1.2.1" level="project" />
<orderEntry type="module-library">
<library name="Maven: eu.the5zig.mod:mod:1.0">
<CLASSES>

View File

@ -56,6 +56,12 @@
</repositories>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
@ -75,7 +81,7 @@
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>CloudCommons</artifactId>
<artifactId>Commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>

View File

@ -199,6 +199,7 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler {
" \n" +
" \n" +
"\n"), 0L);
/*
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
for (Plugin plugin : pm.getPlugins()) {
if (!plugin.getName().equalsIgnoreCase("WorldEdit") && !plugin.getName().equalsIgnoreCase("VoxelSniper") && !registeredPlugins.contains(plugin.getName())) {
@ -207,6 +208,7 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler {
}
}
}, 5L);
*/
this.injection = new NettyInjection(this, this.getName());
this.injection.addHandler("TIMEOUT", new NettyInjection.PacketHandler() {
public Object onPacketIn(Player sender, Channel channel, Object packet) {
@ -222,11 +224,13 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler {
return packet;
}
});
/*
commons.getSecurityHandler().isValidServer(getServer().getIp(), aBoolean -> {
if(!aBoolean) {
getServer().shutdown();
}
});
*/
Bukkit.getScheduler().runTask(this, new TPS());
debugManager = new DebugManager();
}

View File

@ -1,10 +1,10 @@
package eu.univento.core.antihack;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.antihack.modules.*;
import eu.univento.core.antihack.utils.PacketInjector;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.WarnReason;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -28,11 +28,15 @@ public class AntiHack implements Listener{
pm.registerEvents(new Regen(), Core.getInstance());
pm.registerEvents(new AutoRespawn(), Core.getInstance());
pm.registerEvents(new FastPlace(), Core.getInstance());
pm.registerEvents(new AutoSoup(), Core.getInstance());
pm.registerEvents(new Nuker(), Core.getInstance());
pm.registerEvents(new SelfHit(), Core.getInstance());
pm.registerEvents(new BowAimbot(), Core.getInstance());
//pm.registerEvents(new KillAura(), Core.getInstance());
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getInstance(), () -> {
for(Map.Entry<CustomPlayer, Integer> entry : AutoClicker.clicks.entrySet()) {
if(entry.getValue() > 16) {
if(entry.getValue() > 25) {
//TODO: change to real warn reason
entry.getKey().warn(WarnReason.SPAM, null, "https://players.univento.eu/" + entry.getKey().getUniqueId().toString() + "/hacks");
}

View File

@ -1,7 +1,7 @@
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.WarnReason;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;

View File

@ -1,5 +1,6 @@
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -16,8 +17,9 @@ public class AutoSoup implements Listener{
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) {
if(p.getInventory().getViewers().contains(p)) {
p.closeInventory();
p.warn(WarnReason.SPAM, null, "");
}
}
}

View File

@ -0,0 +1,84 @@
package eu.univento.core.antihack.modules;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import java.util.HashMap;
import static jdk.nashorn.internal.objects.NativeMath.log;
/**
* @author joethei
* @version 0.1
*/
public class BowAimbot implements Listener {
private HashMap<CustomPlayer, Integer> totalShots = new HashMap<>();
private HashMap<CustomPlayer, Integer> totalHits = new HashMap<>();
private int getTotalShots(CustomPlayer p){
if(!(totalShots.containsKey(p))){
totalShots.put(p, 0);
}
return totalShots.get(p);
}
private int getTotalHits(CustomPlayer p){
if(!(totalHits.containsKey(p))){
totalHits.put(p, 0);
}
return totalHits.get(p);
}
private int getHitRatio(CustomPlayer p){
int shots = getTotalShots(p);
int hits = getTotalHits(p);
return (hits / shots) * 100;
}
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event){
if(event.getDamager() instanceof Arrow){
Arrow arrow = (Arrow) event.getDamager();
if(arrow.getShooter() instanceof Player){
CustomPlayer p = CustomPlayer.getPlayer((Player) arrow.getShooter());
int hits = getTotalHits(p) + 1;
totalHits.put(p, hits);
if(hits >= 10){
int ratio = getHitRatio(p);
if(ratio >= 80){
log(p, ratio + "% hits");
}
}
}
}
}
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event){
if(event.getEntity() instanceof Arrow){
Arrow arrow = (Arrow) event.getEntity();
if(arrow.getShooter() instanceof Player){
CustomPlayer p = CustomPlayer.getPlayer((Player) arrow.getShooter());
totalShots.put(p, getTotalShots(p) + 1);
}
}
}
}

View File

@ -1,8 +1,8 @@
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.WarnReason;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View File

@ -1,7 +1,7 @@
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.WarnReason;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;

View File

@ -1,7 +1,7 @@
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.WarnReason;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
@ -12,7 +12,7 @@ import java.util.LinkedHashMap;
* @author joethei
* @version 0.1
*/
class Nuker implements Listener {
public class Nuker implements Listener {
private final LinkedHashMap<CustomPlayer, Long> last = new LinkedHashMap<>();
private final LinkedHashMap<CustomPlayer, Integer> blocks = new LinkedHashMap<>();

View File

@ -1,8 +1,8 @@
package eu.univento.core.antihack.modules;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.WarnReason;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View File

@ -1,11 +1,11 @@
package eu.univento.core.antihack.utils;
import com.mojang.authlib.GameProfile;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.antihack.modules.KillAura;
import eu.univento.core.api.fakeplayer.FakePlayer;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.WarnReason;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;

View File

@ -83,16 +83,16 @@ public class AnvilGUI {
return close;
}
public void setWillClose(){
this.close = true;
public void setWillClose(boolean close){
this.close = close;
}
public boolean getWillDestroy(){
return destroy;
}
public void setWillDestroy(){
this.destroy = true;
public void setWillDestroy(boolean destroy){
this.destroy = destroy;
}
}
@ -178,8 +178,8 @@ public class AnvilGUI {
return player;
}
public void setSlot(ItemStack item){
items.put(AnvilSlot.INPUT_LEFT, item);
public void setSlot(AnvilSlot slot, ItemStack item){
items.put(slot, item);
}
public void open(){

View File

@ -0,0 +1,153 @@
package eu.univento.core.api.npc;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import eu.univento.commons.player.uuid.UUIDFetcher;
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 org.bukkit.Bukkit;
import org.bukkit.Location;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.UUID;
/**
* @author joethei
* @version 0.1
*/
@Data
public class NPC{
private int entityID;
private Location location;
private static GameProfile gameProfile;
private DataWatcher dataWatcher;
public NPC(String name, Location location) {
this.location = location;
dataWatcher = new DataWatcher(null);
gameProfile = new GameProfile(UUID.randomUUID(), name);
entityID = (int) (Math.ceil(Math.random() * 1000) + 2000);
Bukkit.getScheduler().scheduleAsyncDelayedTask(Core.getInstance(), () -> {
try {
gameProfile = GameProfileBuilder.fetch(UUIDFetcher.getRequest(name));
} catch (IOException e) {
e.printStackTrace();
}
}, 20L);
}
public void spawn() {
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
setField(packet, "a", entityID);
setField(packet, "b", gameProfile.getId());
setField(packet, "c", location.getX());
setField(packet, "d", location.getY());
setField(packet, "e", location.getZ());
setField(packet, "f", location.getYaw());
setField(packet, "g", location.getPitch());
setField(packet, "h", dataWatcher);
for(CustomPlayer player : Core.getOnlinePlayers()) player.sendPacket(packet);
}
public void setSkin(String value, String signature) {
gameProfile.getProperties().put("textures", new Property("textures", value, signature));
}
public void remove() {
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(entityID);
for(CustomPlayer player : Core.getOnlinePlayers()) player.sendPacket(packet);
}
private void addToTablist() {
}
private void removeFromTablist() {
}
private void setField(Object instance, String field, Object value) {
try {
Field f = instance.getClass().getDeclaredField(field);
f.setAccessible(true);
f.set(instance, value);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
/*
int entityID;
Location location;
GameProfile gameprofile;
public NPC(String name,Location location){
entityID = (int)Math.ceil(Math.random() * 1000) + 2000;
gameprofile = new GameProfile(UUID.randomUUID(), name);
this.location = location;
}
public void spawn(){
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
setValue(packet, "a", entityID);
setValue(packet, "b", gameprofile.getId());
setValue(packet, "c", (int)MathHelper.floor(location.getX() * 32.0D));
setValue(packet, "d", (int)MathHelper.floor(location.getY() * 32.0D));
setValue(packet, "e", (int)MathHelper.floor(location.getZ() * 32.0D));
setValue(packet, "f", (byte) ((int) (location.getYaw() * 256.0F / 360.0F)));
setValue(packet, "g", (byte) ((int) (location.getPitch() * 256.0F / 360.0F)));
setValue(packet, "h", 0);
DataWatcher w = new DataWatcher(null);
w.a(6,(float)20);
w.a(10,(byte)127);
setValue(packet, "i", w);
addToTablist();
sendPacket(packet);
}
public void destroy(){
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[] {entityID});
rmvFromTablist();
sendPacket(packet);
}
public void addToTablist(){
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
PacketPlayOutPlayerInfo.PlayerInfoData data = packet.new PlayerInfoData(gameprofile, 1, EnumGamemode.NOT_SET, CraftChatMessage.fromString(gameprofile.getName())[0]);
@SuppressWarnings("unchecked")
List<PacketPlayOutPlayerInfo.PlayerInfoData> players = (List<PacketPlayOutPlayerInfo.PlayerInfoData>) getValue(packet, "b");
players.add(data);
setValue(packet, "a", PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
setValue(packet, "b", players);
sendPacket(packet);
}
public void rmvFromTablist(){
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
PacketPlayOutPlayerInfo.PlayerInfoData data = packet.new PlayerInfoData(gameprofile, 1, EnumGamemode.NOT_SET, CraftChatMessage.fromString(gameprofile.getName())[0]);
@SuppressWarnings("unchecked")
List<PacketPlayOutPlayerInfo.PlayerInfoData> players = (List<PacketPlayOutPlayerInfo.PlayerInfoData>) getValue(packet, "b");
players.add(data);
setValue(packet, "a", PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER);
setValue(packet, "b", players);
sendPacket(packet);
}
*/
}

View File

@ -0,0 +1,33 @@
package eu.univento.core.api.npc.datawatcher;
/**
* @author ingrim4, joethei
* @version 1.0
*/
public enum EnumDataWatcher {
ENTITY_BITMASK_00("Entity", "ay"),//
ENTITY_AIR_01("Entity", "az"),//AIR
ENTITY_NAME_02("Entity", "aA"),//CUSTOM_NAME
ENTITY_NAME_VISIBLE_03("Entity", "aB"),//CUSTOM_NAME_VISIBLE
ENTITY_SILENT_04("Entity", "aC"),//SILENT
LIVING_HAND_05("EntityLiving", "as"),
LIVING_HEALTH_06("EntityLiving", "HEALTH"),
LIVING_POTION_COLOR_07("EntityLiving", "f"),
LIVING_POTION_AMBIENT_08("EntityLiving", "g"),
LIVING_ARROWS_09("EntityLiving", "h"),
HUMAN_ABSORTION_10("EntityHuman", ""),
HUMAN_SCORE_11("EntityHuman", ""),
HUMAN_SKIN_12("EntityHuman", ""),
HUMAN_HAND_13("EntityHuman", "");
EnumDataWatcher(String owner, String field) {
}
public Object getObject() {
return null;
}
}

View File

@ -0,0 +1,49 @@
package eu.univento.core.api.npc.datawatcher;
import eu.univento.core.api.utils.reflection.IReflection;
/**
* @author ingrim4, joethei
* @version 1.0
*/
public class NullDataWatcher {
private static final Class<?> CLASS_DATAWATCHER = IReflection.getClass(IReflection.ServerPacket.MINECRAFT_PACKAGE, "DataWatcher");
private static final IReflection.ConstructorAccessor CONSTRUCTOR_DATAWATCHER_ENTITY = IReflection.getConstructor(CLASS_DATAWATCHER, IReflection.getClass(IReflection.ServerPacket.MINECRAFT_PACKAGE, "Entity"));
private static final Class<?> CLASS_DATAWATCHER_OBJECT = IReflection.getClass(IReflection.ServerPacket.MINECRAFT_PACKAGE, "DataWatcherObject");
private static final Class<?> CLASS_DATAWATCHER_ITEM = IReflection.getClass(IReflection.ServerPacket.MINECRAFT_PACKAGE, "DataWatcher$Item");
private static final IReflection.MethodAccessor METHOD_DATAWATCHER_ITEM_SETDATA = IReflection.getMethod(CLASS_DATAWATCHER_ITEM, "a", Object.class);
private static final IReflection.MethodAccessor METHOD_DATAWATCHER_REGISTER = IReflection.getMethod(CLASS_DATAWATCHER, "register", CLASS_DATAWATCHER_OBJECT, Object.class);
private static final IReflection.MethodAccessor METHOD_DATAWATCHER_GETITEM = IReflection.getMethod(CLASS_DATAWATCHER, "c", CLASS_DATAWATCHER_OBJECT, Object.class);
private static final IReflection.MethodAccessor METHOD_DATAWATCHER_C = IReflection.getMethod(CLASS_DATAWATCHER, "c");
private final Object dataWatcher;
public NullDataWatcher() {
this.dataWatcher = CONSTRUCTOR_DATAWATCHER_ENTITY.newInstance(new Object[]{null});
}
public NullDataWatcher add(EnumDataWatcher dataWatcher, Object value) {
METHOD_DATAWATCHER_REGISTER.invoke(this.dataWatcher, dataWatcher.getObject(), value);
return this;
}
public NullDataWatcher update(EnumDataWatcher dataWatcher, Object value) {
Object item = METHOD_DATAWATCHER_GETITEM.invoke(this.dataWatcher, dataWatcher.getObject());
METHOD_DATAWATCHER_ITEM_SETDATA.invoke(item, value);
return this;
}
public Object toPacket() {
return METHOD_DATAWATCHER_C.invoke(this.dataWatcher);
}
public Object toNMS() {
return this.dataWatcher;
}
}

View File

@ -1,10 +1,10 @@
package eu.univento.core.api.player;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mongodb.BasicDBObject;
import eu.univento.commons.player.DatabasePlayer;
import eu.univento.commons.player.Rank;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.api.Hologram;
import eu.univento.core.api.Utils;
@ -14,12 +14,9 @@ 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 eu.univento.core.api.utils.GameProfileBuilder;
import eu.univento.core.api.utils.UUIDFetcher;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_10_R1.*;
import org.bson.Document;
import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.World;
@ -33,8 +30,9 @@ 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.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
@ -48,16 +46,20 @@ public class CustomPlayer extends CraftPlayer {
private static final HashMap<UUID, CustomPlayer> PLAYERS = new HashMap<>();
private static final Map<UUID, NickedPlayer> nickedPlayers = new HashMap<>();
private final Player PLAYER;
private final DatabasePlayer DATABASE_PLAYER;
private boolean openInventory;
private final GameProfile gameProfile;
private CustomPlayer(Player player) {
super((CraftServer) Bukkit.getServer(), ((CraftPlayer) player).getHandle());
DATABASE_PLAYER = new DatabasePlayer(Core.getCommons(), player.getUniqueId());
PLAYERS.put(player.getUniqueId(), this);
PLAYER = player;
gameProfile = ((CraftPlayer) player).getProfile();
}
public void onLeave() {
@ -95,12 +97,11 @@ public class CustomPlayer extends CraftPlayer {
}
}
public static CustomPlayer getPlayer(Player player) {
return getPlayer(player.getUniqueId());
}
public Player getPLAYER() {
public Player getPlayer() {
return PLAYER;
}
@ -142,13 +143,7 @@ public class CustomPlayer extends CraftPlayer {
}
public void warn(WarnReason reason, CustomPlayer warner, String proof) {
Document doc = new Document("uuid", getUniqueId().toString());
doc.put("reason", reason.name());
doc.put("warner", warner.getUniqueId().toString());
doc.put("date", new Date());
doc.put("proof", proof);
DATABASE_PLAYER.getWarnCollection().insertOne(doc);
DATABASE_PLAYER.warn(reason, warner.getUniqueId(), proof);
}
public boolean hasEmptyInventory() {
@ -168,18 +163,11 @@ public class CustomPlayer extends CraftPlayer {
this.openInventory = openInventory;
}
/*
@Deprecated
public void sendActionBar(String text) {
IChatBaseComponent cbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + text + "\"}");
PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc, (byte) 2);
sendPacket(ppoc);
}
*/
public void sendActionBar(String text) {
//spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(text));
}
public void sendTitle(int fadeIn, int stay, int fadeOut, String title, String subtitle) {
PacketPlayOutTitle packetPlayOutTimes = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TIMES, null, fadeIn, stay, fadeOut);
@ -206,8 +194,8 @@ public class CustomPlayer extends CraftPlayer {
return bar;
}
public Hologram sendHologram(Location location, String... text) {
Hologram hologram = new Hologram(text, location);
public Hologram sendHologram(ItemStack item, Location location, String... text) {
Hologram hologram = new Hologram(item, text, location);
hologram.showPlayer(this);
return hologram;
}
@ -238,6 +226,56 @@ public class CustomPlayer extends CraftPlayer {
}
}
public void setNickName(String name) {
if(name.length() > 16) {
sendMessage("Disguised name can only be less the 16 characters.");
return;
}
if(nickedPlayers.containsKey(getUniqueId())) {
sendMessage("You are already disguised!");
return;
}
if(Bukkit.getOnlinePlayers().stream().filter(p -> p.getName().equals(name)).count() != 0) {
sendMessage("The name you chose is online.");
return;
}
nickedPlayers.put(getUniqueId(), new NickedPlayer(this, name));
setGameProfile(name, new GameProfile(getUniqueId(), name));
}
private void setGameProfile(String name, GameProfile profile) {
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, getHandle()));
setDisplayName(name);
setPlayerListName(name);
try {
Field gp2 = getHandle().getClass().getSuperclass().getDeclaredField("bT");
gp2.setAccessible(true);
gp2.set(getHandle(), profile);
gp2.setAccessible(false);
} catch (Exception e) {
e.printStackTrace();
removeNickName();
return;
}
Core.getOnlinePlayers().stream().filter(p -> p.getUniqueId() != getUniqueId()).forEach(p -> {
p.sendPacket(new PacketPlayOutEntityDestroy(getEntityId()));
p.sendPacket(new PacketPlayOutNamedEntitySpawn(getHandle()));
Bukkit.getServer().getScheduler().runTask(Core.getInstance(), () -> p.hidePlayer(this));
Bukkit.getServer().getScheduler().runTaskLater(Core.getInstance(), () -> p.showPlayer(this), 5);
});
}
public void removeNickName() {
if(isNicked()) {
nickedPlayers.remove(getUniqueId());
setGameProfile(getName(), gameProfile);
}
}
public boolean isNicked() {
return nickedPlayers.containsKey(getUniqueId());
}
public void addExperience(int experience) {
DATABASE_PLAYER.setExperience(DATABASE_PLAYER.getExperience() + experience);
setExp(0F);
@ -283,71 +321,6 @@ public class CustomPlayer extends CraftPlayer {
return new Messages(this);
}
@Deprecated
private void loadSkin(String name) {
//Skin skin = new Skin(UUIDFetcher.getUUID(name).toString());
GameProfile skin;
GameProfile gp = getProfile();
try {
skin = GameProfileBuilder.fetch(UUIDFetcher.getUUID(name));
Collection<Property> properties = skin.getProperties().get("textures");
gp.getProperties().removeAll("textures");
gp.getProperties().putAll("textures", properties);
PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(getEntityId());
sendPacket(destroy);
PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, getHandle());
sendPacket(remove);
setHealth(0.0D);
new BukkitRunnable() {
@Override
public void run() {
PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, getHandle());
sendPacket(add);
PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(getHandle());
Core.getOnlinePlayers().stream().filter(player -> !player.getName().equals(getName())).forEach(player -> sendPacket(spawn));
}
}.runTaskLater(Core.getInstance(), 4);
} catch (IOException e) {
e.printStackTrace();
Core.getCommons().getLoggingHandler().getCore().error("Mojang Skin Server offline");
sendMessage("§cSkin Server sind offline");
}
}
@Deprecated
public void removeNick() {
setNick(getName());
}
@Deprecated
public void setNick(String name) {
setDisplayName(name);
Field nameField = getField(GameProfile.class, "name");
try {
assert nameField != null;
nameField.setAccessible(true);
nameField.set(getProfile(), name);
PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(getEntityId());
sendPacket(destroy);
PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, getHandle());
sendPacket(remove);
new BukkitRunnable() {
@Override
public void run() {
PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, getHandle());
sendPacket(add);
PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(getHandle());
Core.getOnlinePlayers().stream().filter(players -> !players.equals(this)).forEach(players -> players.sendPacket(spawn));
}
}.runTaskLater(Core.getInstance(), 4);
loadSkin(name);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
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);
@ -478,7 +451,7 @@ public class CustomPlayer extends CraftPlayer {
* @param time time in seconds
*/
public void setItemCooldown(ItemStack item, int time) {
sendPacket(new PacketPlayOutSetCooldown(item.getItem(), time));
sendPacket(new PacketPlayOutSetCooldown(CraftItemStack.asNMSCopy(item).getItem(), time));
}
}

View File

@ -1,26 +0,0 @@
package eu.univento.core.api.player;
import eu.univento.core.api.utils.UUIDFetcher;
import java.util.UUID;
/**
* @author joethei
* @version 0.1
*/
public class FriendObject {
private UUID uuid;
public FriendObject(UUID uuid) {
this.uuid = uuid;
}
public UUID getUuid() {
return uuid;
}
public String getName() {
return UUIDFetcher.getName(uuid);
}
}

View File

@ -0,0 +1,28 @@
package eu.univento.core.api.player;
import com.mojang.authlib.GameProfile;
import lombok.Data;
import java.util.UUID;
/**
* @author joethei
* @version 0.1
*/
@Data
public class NickedPlayer {
private CustomPlayer player;
private String name;
private UUID uuid;
private GameProfile gameProfile;
public NickedPlayer(CustomPlayer player, String name) {
this.player = player;
this.name = name;
this.uuid = player.getUniqueId();
}
}

View File

@ -1,26 +0,0 @@
package eu.univento.core.api.player;
/**
* @author joethei
* @version 0.1
*/
public enum WarnReason {
ADVERTISEMENT("Advertisement", 10),
SPAM("Spamming", 10);
private String name;
private int value;
WarnReason(String name, int value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public int getValue() {
return value;
}
}

View File

@ -1,5 +1,7 @@
package eu.univento.core.api.server;
import eu.univento.commons.server.ServerType;
/**
* @author joethei
* @version 0.1

View File

@ -59,7 +59,7 @@ public class IReflection {
return null;
}
private static ConstructorAccessor getConstructor(Class<?> clazz, Class<?>... parameterTypes) {
public static ConstructorAccessor getConstructor(Class<?> clazz, Class<?>... parameterTypes) {
Class<?>[] p = DataType.convertToPrimitive(parameterTypes);
for (Constructor<?> c : clazz.getDeclaredConstructors())
if (DataType.equalsArray(DataType.convertToPrimitive(c.getParameterTypes()), p)) {
@ -143,14 +143,11 @@ public class IReflection {
return new FieldAccessor<T>() {
@Override
@SuppressWarnings("unchecked")
public T get(Object target) {
try {
return (T) field.get(target);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Cannot use reflection.", e);
} catch (IllegalArgumentException e) {
throw e;
}
}
@ -160,8 +157,6 @@ public class IReflection {
field.set(target, value);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Cannot use reflection.", e);
} catch (IllegalArgumentException e) {
throw e;
}
}

View File

@ -1,238 +0,0 @@
package eu.univento.core.api.utils.reflection;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
/**
* A class containing static utility methods and caches which are intended as reflective conveniences.
* Unless otherwise noted, upon failure methods will return {@code null}.
*/
final class Reflection {
private static String _versionString;
private Reflection() {
}
/**
* Gets the version string from the package name of the CraftBukkit server implementation.
* This is needed to bypass the JAR package name changing on each update.
*
* @return The version string of the OBC and NMS packages, <em>including the trailing dot</em>.
*/
private synchronized static String getVersion() {
if (_versionString == null) {
if (Bukkit.getServer() == null) {
// The server hasn't started, static initializer call?
return null;
}
String name = Bukkit.getServer().getClass().getPackage().getName();
_versionString = name.substring(name.lastIndexOf('.') + 1) + ".";
}
return _versionString;
}
/**
* Stores loaded classes from the {@code net.minecraft.server} package.
*/
private static final Map<String, Class<?>> _loadedNMSClasses = new HashMap<>();
/**
* Stores loaded classes from the {@code org.bukkit.craftbukkit} package (and subpackages).
*/
private static final Map<String, Class<?>> _loadedOBCClasses = new HashMap<>();
/**
* Gets a {@link Class} object representing a type contained within the {@code net.minecraft.server} versioned package.
* The class instances returned by this method are cached, such that no lookup will be done twice (unless multiple threads are accessing this method simultaneously).
*
* @param className The name of the class, excluding the package, within NMS.
* @return The class instance representing the specified NMS class, or {@code null} if it could not be loaded.
*/
public synchronized static Class<?> getNMSClass(String className) {
if (_loadedNMSClasses.containsKey(className)) {
return _loadedNMSClasses.get(className);
}
String fullName = "net.minecraft.server." + getVersion() + className;
Class<?> clazz;
try {
clazz = Class.forName(fullName);
} catch (Exception e) {
e.printStackTrace();
_loadedNMSClasses.put(className, null);
return null;
}
_loadedNMSClasses.put(className, clazz);
return clazz;
}
public synchronized static Class<?> getCTBClass(String className) {
if (_loadedNMSClasses.containsKey(className)) {
return _loadedNMSClasses.get(className);
}
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
Class<?> clazz;
try {
clazz = Class.forName(fullName);
} catch (Exception e) {
e.printStackTrace();
_loadedNMSClasses.put(className, null);
return null;
}
_loadedNMSClasses.put(className, clazz);
return clazz;
}
/**
* Gets a {@link Class} object representing a type contained within the {@code org.bukkit.craftbukkit} versioned package.
* The class instances returned by this method are cached, such that no lookup will be done twice (unless multiple threads are accessing this method simultaneously).
*
* @param className The name of the class, excluding the package, within OBC. This name may contain a subpackage name, such as {@code inventory.CraftItemStack}.
* @return The class instance representing the specified OBC class, or {@code null} if it could not be loaded.
*/
public synchronized static Class<?> getOBCClass(String className) {
if (_loadedOBCClasses.containsKey(className)) {
return _loadedOBCClasses.get(className);
}
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
Class<?> clazz;
try {
clazz = Class.forName(fullName);
} catch (Exception e) {
e.printStackTrace();
_loadedOBCClasses.put(className, null);
return null;
}
_loadedOBCClasses.put(className, clazz);
return clazz;
}
/**
* Attempts to get the NMS handle of a CraftBukkit object.
* <p>
* The only match currently attempted by this method is a retrieval by using a parameterless {@code getHandle()} method implemented by the runtime type of the specified object.
* </p>
*
* @param obj The object for which to retrieve an NMS handle.
* @return The NMS handle of the specified object, or {@code null} if it could not be retrieved using {@code getHandle()}.
*/
public synchronized static Object getHandle(Object obj) {
try {
return getMethod(obj.getClass(), "getHandle").invoke(obj);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private static final Map<Class<?>, Map<String, Field>> _loadedFields = new HashMap<>();
/**
* Retrieves a {@link Field} instance declared by the specified class with the specified name.
* Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field
* returned will be an instance or static field.
* <p>
* A global caching mechanism within this class is used to store fields. Combined with synchronization, this guarantees that
* no field will be reflectively looked up twice.
* </p>
* <p>
* If a field is deemed suitable for return, {@link Field#setAccessible(boolean) setAccessible} will be invoked with an argument of {@code true} before it is returned.
* This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance.
* </p>
*
* @param clazz The class which contains the field to retrieve.
* @param name The declared name of the field in the class.
* @return A field object with the specified name declared by the specified class.
* @see Class#getDeclaredField(String)
*/
public synchronized static Field getField(Class<?> clazz, String name) {
Map<String, Field> loaded;
if (!_loadedFields.containsKey(clazz)) {
loaded = new HashMap<>();
_loadedFields.put(clazz, loaded);
} else {
loaded = _loadedFields.get(clazz);
}
if (loaded.containsKey(name)) {
// If the field is loaded (or cached as not existing), return the relevant value, which might be null
return loaded.get(name);
}
try {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
loaded.put(name, field);
return field;
} catch (Exception e) {
// Error loading
e.printStackTrace();
// Cache field as not existing
loaded.put(name, null);
return null;
}
}
/**
* Contains loaded methods in a cache.
* The map maps [types to maps of [method names to maps of [parameter types to method instances]]].
*/
private static final Map<Class<?>, Map<String, Map<ArrayWrapper<Class<?>>, Method>>> _loadedMethods = new HashMap<>();
/**
* Retrieves a {@link Method} instance declared by the specified class with the specified name and argument types.
* Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field
* returned will be an instance or static field.
* <p>
* A global caching mechanism within this class is used to store method. Combined with synchronization, this guarantees that
* no method will be reflectively looked up twice.
* </p>
* <p>
* If a method is deemed suitable for return, {@link Method#setAccessible(boolean) setAccessible} will be invoked with an argument of {@code true} before it is returned.
* This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance.
* </p>
* <p>
* This method does <em>not</em> search superclasses of the specified type for methods with the specified signature.
* Callers wishing this behavior should use {@link Class#getDeclaredMethod(String, Class...)}.
*
* @param clazz The class which contains the method to retrieve.
* @param name The declared name of the method in the class.
* @param args The formal argument types of the method.
* @return A method object with the specified name declared by the specified class.
*/
private synchronized static Method getMethod(Class<?> clazz, String name,
Class<?>... args) {
if (!_loadedMethods.containsKey(clazz)) {
_loadedMethods.put(clazz, new HashMap<>());
}
Map<String, Map<ArrayWrapper<Class<?>>, Method>> loadedMethodNames = _loadedMethods.get(clazz);
if (!loadedMethodNames.containsKey(name)) {
loadedMethodNames.put(name, new HashMap<>());
}
Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name);
ArrayWrapper<Class<?>> wrappedArg = new ArrayWrapper<>(args);
if (loadedSignatures.containsKey(wrappedArg)) {
return loadedSignatures.get(wrappedArg);
}
for (Method m : clazz.getMethods())
if (m.getName().equals(name) && Arrays.equals(args, m.getParameterTypes())) {
m.setAccessible(true);
loadedSignatures.put(wrappedArg, m);
return m;
}
loadedSignatures.put(wrappedArg, null);
return null;
}
}

View File

@ -40,14 +40,14 @@ public class Nick extends AutoCommand<Core>{
p.getDatabasePlayer().getSettings().setNickStatus(false);
p.getScoreboard().getTeam(p.getDatabasePlayer().getRank().getTeam()).addEntry(p.getDisplayName());
p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_OFF());
p.removeNick();
p.removeNickName();
}else {
p.getScoreboard().getTeam(p.getDatabasePlayer().getRank().getTeam()).removeEntry(p.getDisplayName());
p.getDatabasePlayer().getSettings().setNickStatus(true);
p.getScoreboard().getTeam(p.getDatabasePlayer().getRank().getTeam()).addEntry(p.getDisplayName());
p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_ON());
String nick = NickName.getRandomNick();
p.setNick(nick);
p.setNickName(nick);
//Core.getDebugManager().sendOverlay("der Nick ist " + nick);
}
}else {

View File

@ -1,6 +1,7 @@
package eu.univento.core.commands;
import eu.univento.commons.player.Rank;
import eu.univento.commons.player.language.MessageConstant;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.languages.Messages;
@ -35,13 +36,13 @@ public class Timeout extends AutoCommand<Core> {
Core.getTimeout().add(p);
}
} else {
p.sendMessage(p.getDatabasePlayer().getMessage("Command.not_online"));
p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NOT_ONLINE));
}
} else {
p.sendMessage("Nicht genug Argumente");
}
} else {
p.sendMessage(p.getDatabasePlayer().getMessage("Command.no_perms"));
p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NO_PERMS));
}
} else {
sender.sendMessage(Messages.Console.NOT_A_PLAYER);

View File

@ -1,12 +1,12 @@
package eu.univento.core.listeners;
import eu.univento.commons.player.Rank;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.api.blocks.MiniBlock;
import eu.univento.core.api.customitems.swords.BestSwordEver;
import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.WarnReason;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.core.api.shop.ShopItem;
import eu.univento.core.api.shop.ShopMenu;

View File

@ -1,6 +1,7 @@
package eu.univento.core.listeners;
import eu.univento.commons.player.Rank;
import eu.univento.commons.player.language.MessageConstant;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Bukkit;
@ -29,7 +30,7 @@ public class Commands implements Listener{
String cmd = e.getMessage().split(" ")[0];
HelpTopic topic = Bukkit.getServer().getHelpMap().getHelpTopic(cmd);
if (topic == null) {
p.sendMessage(p.getDatabasePlayer().getMessage("Command.not_found"));
p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NOT_FOUND));
e.setCancelled(true);
}
}
@ -44,7 +45,7 @@ public class Commands implements Listener{
Bukkit.spigot().restart();
}, 100L);
}else {
p.sendMessage(p.getDatabasePlayer().getMessage("Command.no_perms"));
p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NO_PERMS));
}
}
}

View File

@ -1,25 +1,34 @@
package eu.univento.core.listeners;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.SpectateManager;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.core.commands.Vanish;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.util.Vector;
/**
* some basic events
*
* @author joethei
* @version 0.2
*/
public class Events implements Listener{
public class Events implements Listener {
@EventHandler
public void onServerListPing(ServerListPingEvent e) {
if(ServerSettings.isGame()) e.setMotd(ServerSettings.getServerType().toString() + ";" + ServerSettings.getGameState());
e.setMotd(ServerSettings.getServerType().name() + ";" + (ServerSettings.isGame() ? ServerSettings.getGameState() : ""));
}
@EventHandler
@ -31,10 +40,54 @@ public class Events implements Listener{
@EventHandler
public void onMove(PlayerMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(p.getLocation().getY() <= 0) {
if (p.getLocation().getY() <= 0) {
p.setVelocity(new Vector().setY(10.0D).multiply(1.0D));
p.setGliding(true);
}
}
@EventHandler
public void onEntityTarget(EntityTargetEvent e) {
if (e.isCancelled()) return;
final Entity entity = e.getEntity();
final Entity target = e.getTarget();
if (!(target instanceof Player)) return;
CustomPlayer p = CustomPlayer.getPlayer((Player) target);
if (Vanish.getPlayers().contains(p) || SpectateManager.contains(p)) {
if (entity instanceof Tameable) {
e.setTarget(null);
}
if (entity instanceof ExperienceOrb) {
repellExpOrb((Player) target, (ExperienceOrb) entity);
e.setCancelled(true);
e.setTarget(null);
}
}
}
private void repellExpOrb(Player player, ExperienceOrb orb) {
final Location pLoc = player.getLocation();
final Location oLoc = orb.getLocation();
final Vector dir = oLoc.toVector().subtract(pLoc.toVector());
final double dx = Math.abs(dir.getX());
final double dz = Math.abs(dir.getZ());
if ((dx == 0.0) && (dz == 0.0)) {
// Special case probably never happens
dir.setX(0.001);
}
if ((dx < 3.0) && (dz < 3.0)) {
final Vector nDir = dir.normalize();
final Vector newV = nDir.clone().multiply(0.3);
newV.setY(0);
orb.setVelocity(newV);
if ((dx < 1.0) && (dz < 1.0)) {
// maybe oLoc
orb.teleport(oLoc.clone().add(nDir.multiply(1.0)), PlayerTeleportEvent.TeleportCause.PLUGIN);
}
if ((dx < 0.5) && (dz < 0.5)) {
orb.remove();
}
}
}
}

View File

@ -37,6 +37,9 @@ public class JoinQuit implements Listener {
@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);
@ -77,7 +80,7 @@ public class JoinQuit implements Listener {
p.initScoreboard();
p.sendTabHeaderAndFooter(p.getMessages().Core_TAB_TITLE() + Bukkit.getServerName(), p.getMessages().TAB_PREFIX());
if (p.getDatabasePlayer().getSettings().isNicked() && !ServerSettings.isLobby()) {
p.setNick(NickName.getRandomNick());
p.setNickName(NickName.getRandomNick());
}
for (CustomPlayer player : Core.getOnlinePlayers()) {
p.getScoreboard().getTeam(player.getDatabasePlayer().getRank().getTeam()).addEntry(player.getDisplayName());
@ -118,7 +121,7 @@ public class JoinQuit implements Listener {
if (Build.getPlayers().containsKey(p))
Build.getPlayers().remove(p);
if (p.getDatabasePlayer().getSettings().isNicked() && !ServerSettings.isLobby()) {
p.removeNick();
p.removeNickName();
}
for (Team team : p.getScoreboard().getTeams()) {
team.removeEntry(p.getDisplayName());

View File

@ -2,9 +2,9 @@ package eu.univento.core.listeners;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import eu.univento.commons.player.warn.WarnReason;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.WarnReason;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
@ -24,7 +24,7 @@ public class PluginMessenger implements PluginMessageListener {
e.printStackTrace();
}
Core.getCommons().getLoggingHandler().getCore().info(p.getName() + " hat WDL installiert. Version : " + version);
p.sendMessage(p.getDatabasePlayer().getMessage("Prefix") + p.getDatabasePlayer().getMessage("Hack.WorldDownloader"));
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));
@ -32,7 +32,7 @@ public class PluginMessenger implements PluginMessageListener {
if (channel.equals("PERMISSIONSREPL") && new String(data).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().getMessage("Prefix") + p.getDatabasePlayer().getMessage("Hack.WorldDownloader"));
p.sendMessage(p.getDatabasePlayer().getLanguage().getWord("Prefix") + p.getDatabasePlayer().getLanguage().getWord("Hack.WorldDownloader"));
}
if(channel.equals("5zig_Set")) {
try {

View File

@ -1,5 +1,6 @@
package eu.univento.core.listeners;
import eu.univento.commons.player.language.MessageConstant;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.SpectateManager;
import eu.univento.core.api.player.Spectator;
@ -59,7 +60,7 @@ public class SpectatorEvents implements Listener{
public void onInventoryClick(InventoryClickEvent e) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked());
if(SpectateManager.contains(p)) {
if (e.getInventory().getName().equals(p.getDatabasePlayer().getMessage("Game.Menu.SpectateMenu"))) {
if (e.getInventory().getName().equals(p.getDatabasePlayer().getLanguage().getWord("Game.Menu.SpectateMenu"))) {
if(e.getCurrentItem().getType() == Material.SKULL_ITEM) {
SkullMeta meta = (SkullMeta) e.getCurrentItem().getItemMeta();
CustomPlayer player = CustomPlayer.getPlayer(meta.getOwner());
@ -70,7 +71,7 @@ public class SpectatorEvents implements Listener{
p.closeInventory();
spectator.spectate(player);
}else{
p.sendMessage(p.getDatabasePlayer().getMessage("Not_online"));
p.sendMessage(p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NOT_ONLINE));
}
}
}