added some antihack systems.
This commit is contained in:
parent
5f05f95ee8
commit
e48049a178
22
Core.iml
22
Core.iml
|
@ -20,16 +20,16 @@
|
||||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.8" level="project" />
|
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.8" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.9.2-R0.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.9.2-R0.1-SNAPSHOT" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9.2-R0.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9.2-R0.1-SNAPSHOT" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" 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" scope="PROVIDED" 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" scope="PROVIDED" 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: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" level="project" />
|
<orderEntry type="library" scope="PROVIDED" 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: com.google.code.gson:gson:2.2.4" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.9.2-R0.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.9.2-R0.1-SNAPSHOT" level="project" />
|
||||||
<orderEntry type="library" name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
1
pom.xml
1
pom.xml
|
@ -96,6 +96,7 @@
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package eu.univento.cloud.client;
|
||||||
|
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
|
||||||
|
public class CloudMessenger {
|
||||||
|
|
||||||
|
public static void sendModModeMessage(ModModePrefix prefix, String message) {
|
||||||
|
//TODO: add stuff + server
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendHackMessage(Hack hack, CustomPlayer player) {
|
||||||
|
//add function
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ModModePrefix {
|
||||||
|
HACK,
|
||||||
|
CMD,
|
||||||
|
AD,
|
||||||
|
ERROR;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.univento.core;
|
package eu.univento.core;
|
||||||
|
|
||||||
|
import eu.univento.core.antihack.AntiHack;
|
||||||
import eu.univento.core.api.Blackscreen;
|
import eu.univento.core.api.Blackscreen;
|
||||||
import eu.univento.core.api.Config;
|
import eu.univento.core.api.Config;
|
||||||
import eu.univento.core.api.database.MongoDB;
|
import eu.univento.core.api.database.MongoDB;
|
||||||
|
@ -32,7 +33,7 @@ public class Core extends JavaPlugin{
|
||||||
/**
|
/**
|
||||||
* plugin instance
|
* plugin instance
|
||||||
*/
|
*/
|
||||||
public static Core instance;
|
private static Core instance;
|
||||||
/**
|
/**
|
||||||
* @return plugin instance
|
* @return plugin instance
|
||||||
*/
|
*/
|
||||||
|
@ -106,6 +107,7 @@ public class Core extends JavaPlugin{
|
||||||
new Build(this, "build", "build", "b");
|
new Build(this, "build", "build", "b");
|
||||||
pm.registerEvents(new Blocks(), this);
|
pm.registerEvents(new Blocks(), this);
|
||||||
}
|
}
|
||||||
|
AntiHack.registerListeners();
|
||||||
|
|
||||||
new RunAs(this, "RunAs", "runas");
|
new RunAs(this, "RunAs", "runas");
|
||||||
new SystemInfo(this, "SystemInfo", "systeminfo");
|
new SystemInfo(this, "SystemInfo", "systeminfo");
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.univento.core.antihack;
|
||||||
|
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
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 org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class AntiHack implements Listener{
|
||||||
|
|
||||||
|
public static PacketInjector packetInjector = new PacketInjector();
|
||||||
|
|
||||||
|
public static void registerListeners() {
|
||||||
|
PluginManager pm = Bukkit.getPluginManager();
|
||||||
|
pm.registerEvents(new AntiHack(), Core.getInstance());
|
||||||
|
pm.registerEvents(new Glide(), Core.getInstance());
|
||||||
|
pm.registerEvents(new Fly(), Core.getInstance());
|
||||||
|
pm.registerEvents(new AutoClicker(), Core.getInstance());
|
||||||
|
pm.registerEvents(new Criticals(), Core.getInstance());
|
||||||
|
pm.registerEvents(new Reach(), Core.getInstance());
|
||||||
|
pm.registerEvents(new NoSlowDown(), Core.getInstance());
|
||||||
|
pm.registerEvents(new Regen(), Core.getInstance());
|
||||||
|
pm.registerEvents(new AutoRespawn(), Core.getInstance());
|
||||||
|
pm.registerEvents(new FastPlace(), Core.getInstance());
|
||||||
|
pm.registerEvents(new KillAura(), Core.getInstance());
|
||||||
|
|
||||||
|
for(Map.Entry<CustomPlayer, Integer> entry : AutoClicker.clicks.entrySet()) {
|
||||||
|
if(entry.getValue() > 16) {
|
||||||
|
CloudMessenger.sendHackMessage(Hack.AUTOCLICKER, entry.getKey());
|
||||||
|
entry.getKey().warn(Hack.AUTOCLICKER);
|
||||||
|
}
|
||||||
|
AutoClicker.clicks.remove(entry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
|
packetInjector.addPlayer(e.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package eu.univento.core.antihack;
|
||||||
|
|
||||||
|
public enum Hack {
|
||||||
|
//int represents warn points
|
||||||
|
CRITICALS(10),
|
||||||
|
AUTOCLICKER(10),
|
||||||
|
GLIDE(10),
|
||||||
|
REACH(10),
|
||||||
|
NOSLOWDOWN(10),
|
||||||
|
REGEN(10),
|
||||||
|
AUTORESPAWN(10),
|
||||||
|
FASTPLACE(10),
|
||||||
|
KILLAURA(10),
|
||||||
|
FLY(10);
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private Hack(int id) {
|
||||||
|
this.setId(id);
|
||||||
|
}
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class AutoClicker implements Listener {
|
||||||
|
|
||||||
|
public static HashMap<CustomPlayer, Integer> clicks = new HashMap<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onClick(PlayerInteractEvent e) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||||
|
if(e.getAction() == Action.LEFT_CLICK_AIR ||e.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
if(clicks.containsKey(p)) {
|
||||||
|
clicks.put(p, clicks.get(p) + 1);
|
||||||
|
}else{
|
||||||
|
clicks.put(p, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class AutoRespawn implements Listener {
|
||||||
|
|
||||||
|
private HashMap<CustomPlayer, Long> time = new HashMap<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDeath(PlayerDeathEvent e) {
|
||||||
|
time.put(CustomPlayer.getPlayer(e.getEntity()), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onRespawn(PlayerRespawnEvent e) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||||
|
if(time.containsKey(p)) {
|
||||||
|
if(System.currentTimeMillis() - time.get(p) <= 200L) {
|
||||||
|
CloudMessenger.sendHackMessage(Hack.AUTORESPAWN, p);
|
||||||
|
p.warn(Hack.AUTORESPAWN);
|
||||||
|
}
|
||||||
|
time.remove(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
import eu.univento.core.Core;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
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.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Criticals implements Listener {
|
||||||
|
|
||||||
|
private ArrayList<CustomPlayer> players = new ArrayList<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
|
||||||
|
if(e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
|
||||||
|
CustomPlayer damager = CustomPlayer.getPlayer((Player) e.getDamager());
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
|
||||||
|
if(!players.contains(p)) {
|
||||||
|
players.add(p);
|
||||||
|
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> players.remove(p), 5L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onMove(PlayerMoveEvent e) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||||
|
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
|
||||||
|
final double x1 = e.getFrom().getY();
|
||||||
|
final double x2 = p.getLocation().getY();
|
||||||
|
double fark = 0.0;
|
||||||
|
if (x1 > x2) {
|
||||||
|
fark = x1 - x2;
|
||||||
|
} else if (x2 > x1) {
|
||||||
|
fark = x2 - x1;
|
||||||
|
} else {
|
||||||
|
fark = 200.0;
|
||||||
|
}
|
||||||
|
if (!players.contains(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fark == 0.125 || fark == 1.0 || fark == 1.3 || fark == 0.6190840103302007 || fark == 0.4414162352399398 || fark == 200.0) {
|
||||||
|
CloudMessenger.sendHackMessage(Hack.CRITICALS, p);
|
||||||
|
p.warn(Hack.CRITICALS);
|
||||||
|
}
|
||||||
|
}, 6L);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class FastPlace implements Listener{
|
||||||
|
|
||||||
|
private HashMap<CustomPlayer, Long> time = new HashMap<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlace(BlockPlaceEvent e) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||||
|
if(time.containsKey(p)) {
|
||||||
|
if(System.currentTimeMillis() - time.get(p) <= 110L) {
|
||||||
|
CloudMessenger.sendHackMessage(Hack.FASTPLACE, p);
|
||||||
|
p.warn(Hack.FASTPLACE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
time.put(p, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
public class Fly implements Listener{
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFly(PlayerMoveEvent e) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||||
|
if(p.getGameMode() != GameMode.CREATIVE && e.getTo().getY() > e.getFrom().getY() + 1.5) {
|
||||||
|
CloudMessenger.sendHackMessage(Hack.FLY, p);
|
||||||
|
p.warn(Hack.FLY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
public class Glide implements Listener{
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onGlide(PlayerMoveEvent e) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||||
|
if(e.getTo().getY() - e.getFrom().getY() == -0.125 && e.getTo().clone().subtract(0.0, 1.0, 0.0).getBlock().getType().equals(Material.AIR)) {
|
||||||
|
CloudMessenger.sendHackMessage(Hack.GLIDE, p);
|
||||||
|
p.warn(Hack.GLIDE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import eu.univento.core.Core;
|
||||||
|
import eu.univento.core.api.fakeplayer.FakePlayer;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class KillAura implements Listener{
|
||||||
|
|
||||||
|
public static HashMap<Player, FakePlayer> players = new HashMap<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDamage(EntityDamageByEntityEvent e) {
|
||||||
|
if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
|
||||||
|
CustomPlayer damager = CustomPlayer.getPlayer((Player) e.getDamager());
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
|
||||||
|
FakePlayer fp = new FakePlayer(new GameProfile(UUID.randomUUID(), ""), false, p);
|
||||||
|
players.put(p, fp);
|
||||||
|
fp.spawn(p.getLocation().add((double) new Random().nextInt(2), 0.01, (double) new Random().nextInt(2)));
|
||||||
|
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
|
||||||
|
fp.removeTablist();
|
||||||
|
fp.despawn();
|
||||||
|
if(players.containsKey(p)) players.remove(p);
|
||||||
|
}, 5L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
|
||||||
|
public class NoSlowDown implements Listener{
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onShootBow(EntityShootBowEvent e) {
|
||||||
|
if(e.getEntity() instanceof Player) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
|
||||||
|
if(p.isSprinting()) {
|
||||||
|
CloudMessenger.sendHackMessage(Hack.NOSLOWDOWN, p);
|
||||||
|
p.warn(Hack.NOSLOWDOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFoodChange(FoodLevelChangeEvent e) {
|
||||||
|
if(e.getEntity() instanceof Player) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
|
||||||
|
if(e.getFoodLevel() > p.getFoodLevel() && p.isSprinting()) {
|
||||||
|
CloudMessenger.sendHackMessage(Hack.NOSLOWDOWN, p);
|
||||||
|
p.warn(Hack.NOSLOWDOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
|
public class Reach implements Listener{
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
|
||||||
|
if(e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
|
||||||
|
CustomPlayer damager = CustomPlayer.getPlayer((Player) e.getDamager());
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
|
||||||
|
if(damager.getLocation().distance(p.getLocation()) > 4.0) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
CloudMessenger.sendHackMessage(Hack.REACH, damager);
|
||||||
|
p.warn(Hack.REACH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockBreak(BlockBreakEvent e ) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||||
|
Block b = e.getBlock();
|
||||||
|
if(p.getLocation().distance(b.getLocation()) > 6.1) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
CloudMessenger.sendHackMessage(Hack.REACH, p);
|
||||||
|
p.warn(Hack.REACH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package eu.univento.core.antihack.modules;
|
||||||
|
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
import eu.univento.core.Core;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Regen implements Listener {
|
||||||
|
|
||||||
|
private ArrayList<CustomPlayer> a = new ArrayList<>();
|
||||||
|
private ArrayList<CustomPlayer> b = new ArrayList<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onRegainHealth(EntityRegainHealthEvent e) {
|
||||||
|
if (e.getEntity() instanceof Player) {
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
|
||||||
|
|
||||||
|
if (p.getFoodLevel() > 16 && e.getRegainReason() == EntityRegainHealthEvent.RegainReason.SATIATED) {
|
||||||
|
if (a.contains(p) && b.contains(p)) {
|
||||||
|
a.remove(p);
|
||||||
|
}
|
||||||
|
if (e.getAmount() > 1.0) {
|
||||||
|
p.setFoodLevel(0);
|
||||||
|
CloudMessenger.sendHackMessage(Hack.REGEN, p);
|
||||||
|
p.warn(Hack.REGEN);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!b.contains(p) && !a.contains(p)) {
|
||||||
|
a.add(p);
|
||||||
|
b.add(p);
|
||||||
|
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
|
||||||
|
if (!a.contains(p)) {
|
||||||
|
p.setFoodLevel(0);
|
||||||
|
b.remove(p);
|
||||||
|
CloudMessenger.sendHackMessage(Hack.REGEN, p);
|
||||||
|
p.warn(Hack.REGEN);
|
||||||
|
} else if (a.contains(p)) {
|
||||||
|
a.remove(p);
|
||||||
|
b.remove(p);
|
||||||
|
}
|
||||||
|
}, 10L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package eu.univento.core.antihack.utils;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import eu.univento.cloud.client.CloudMessenger;
|
||||||
|
import eu.univento.core.Core;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
|
import eu.univento.core.antihack.modules.KillAura;
|
||||||
|
import eu.univento.core.api.fakeplayer.FakePlayer;
|
||||||
|
import eu.univento.core.api.player.CustomPlayer;
|
||||||
|
import io.netty.channel.ChannelDuplexHandler;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.channel.ChannelPromise;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PacketHandler extends ChannelDuplexHandler {
|
||||||
|
private Player player;
|
||||||
|
private HashMap<Player, Integer> killAura = new HashMap<>();
|
||||||
|
private HashMap<Player, Integer> count = new HashMap<>();
|
||||||
|
private HashMap<Player, Long> inventory = new HashMap<>();
|
||||||
|
private ArrayList<Player> swing = new ArrayList<>();
|
||||||
|
|
||||||
|
public PacketHandler(final Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) throws Exception {
|
||||||
|
super.write(ctx, msg, promise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy(final FakePlayer fp, Player p) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
|
||||||
|
fp.removeTablist();
|
||||||
|
fp.despawn();
|
||||||
|
if (KillAura.players.containsKey(p)) {
|
||||||
|
KillAura.players.remove(p);
|
||||||
|
}
|
||||||
|
}, 5L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void channelRead(final ChannelHandlerContext c, final Object m) throws Exception {
|
||||||
|
if (m.getClass().getSimpleName().equalsIgnoreCase("PacketPlayInArmAnimation")) {
|
||||||
|
swing.add(player);
|
||||||
|
}
|
||||||
|
if (m.getClass().getSimpleName().equalsIgnoreCase("PacketPlayInUseEntity")) {
|
||||||
|
final int id = (int) Reflection.getFieldValue(m, "a");
|
||||||
|
if (Reflection.getFieldValue(m, "action").toString().equals("ATTACK") && KillAura.players.containsKey(player) && id == KillAura.players.get(player).getEntityID()) {
|
||||||
|
if (!killAura.containsKey(player)) {
|
||||||
|
final FakePlayer fp = new FakePlayer(new GameProfile(UUID.randomUUID(), ""), false, player);
|
||||||
|
KillAura.players.put(player, fp);
|
||||||
|
fp.spawn(player.getLocation().subtract((double) new Random().nextInt(2), 0.01, (double) new Random().nextInt(2)));
|
||||||
|
destroy(fp, player);
|
||||||
|
killAura.put(player, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (killAura.containsKey(player) && killAura.get(player) == 1) {
|
||||||
|
final FakePlayer fp = new FakePlayer(new GameProfile(UUID.randomUUID(), ""), false, player);
|
||||||
|
KillAura.players.put(player, fp);
|
||||||
|
fp.spawn(player.getLocation().subtract((double) new Random().nextInt(2), 0.01, (double) new Random().nextInt(2)));
|
||||||
|
destroy(fp, player);
|
||||||
|
killAura.put(player, 2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (count.get(player) < 4) {
|
||||||
|
count.put(player, count.get(player) + 1);
|
||||||
|
} else {
|
||||||
|
count.remove(player);
|
||||||
|
CustomPlayer p = CustomPlayer.getPlayer(player);
|
||||||
|
CloudMessenger.sendHackMessage(Hack.KILLAURA, p);
|
||||||
|
p.warn(Hack.KILLAURA);
|
||||||
|
}
|
||||||
|
killAura.remove(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m.getClass().getSimpleName().equalsIgnoreCase("PacketPlayInClientCommand")) {
|
||||||
|
final String s = Reflection.getFieldValue(m, "a").toString();
|
||||||
|
if (s.equals("OPEN_INVENTORY_ACHIEVEMENT")) {
|
||||||
|
inventory.put(player, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.channelRead(c, m);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
package eu.univento.core.antihack.utils;
|
||||||
|
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class PacketInjector {
|
||||||
|
|
||||||
|
private Field EntityPlayer_playerConnection;
|
||||||
|
private Class<?> PlayerConnection;
|
||||||
|
private Field PlayerConnection_networkManager;
|
||||||
|
private Class<?> NetworkManager;
|
||||||
|
private Field k;
|
||||||
|
private Field m;
|
||||||
|
|
||||||
|
public PacketInjector() {
|
||||||
|
try {
|
||||||
|
this.EntityPlayer_playerConnection = Reflection.getField(Reflection.getClass("{nms}.EntityPlayer"), "playerConnection");
|
||||||
|
this.PlayerConnection = Reflection.getClass("{nms}.PlayerConnection");
|
||||||
|
this.PlayerConnection_networkManager = Reflection.getField(this.PlayerConnection, "networkManager");
|
||||||
|
this.NetworkManager = Reflection.getClass("{nms}.NetworkManager");
|
||||||
|
Field[] fields2;
|
||||||
|
for (int length = (fields2 = this.NetworkManager.getFields()).length, i = 0; i < length; ++i) {
|
||||||
|
final Field fields = fields2[i];
|
||||||
|
if (fields.getType().equals(Channel.class)) {
|
||||||
|
this.k = fields;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.k == null) {
|
||||||
|
this.k = Reflection.getField(this.NetworkManager, "i");
|
||||||
|
}
|
||||||
|
this.m = Reflection.getField(this.NetworkManager, "m");
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayer(final Player p) {
|
||||||
|
try {
|
||||||
|
final Channel ch = this.getChannel(this.getNetworkManager(Reflection.getNmsPlayer(p)));
|
||||||
|
if (ch.pipeline().get("PacketInjector") == null) {
|
||||||
|
final PacketHandler h = new PacketHandler(p);
|
||||||
|
ch.pipeline().addBefore("packet_handler", "PacketInjector", h);
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayer(final Player p) {
|
||||||
|
try {
|
||||||
|
final Channel ch = this.getChannel(this.getNetworkManager(Reflection.getNmsPlayer(p)));
|
||||||
|
if (ch.pipeline().get("PacketInjector") != null) {
|
||||||
|
ch.pipeline().remove("PacketInjector");
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getNetworkManager(final Object ep) {
|
||||||
|
return Reflection.getFieldValue(this.PlayerConnection_networkManager, (Object) Reflection.getFieldValue(this.EntityPlayer_playerConnection, ep));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Channel getChannel(final Object networkManager) {
|
||||||
|
Channel ch = null;
|
||||||
|
try {
|
||||||
|
ch = Reflection.getFieldValue(this.k, networkManager);
|
||||||
|
} catch (Exception e) {
|
||||||
|
ch = Reflection.getFieldValue(this.m, networkManager);
|
||||||
|
}
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package eu.univento.core.antihack.utils;
|
||||||
|
|
||||||
|
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_9_R1.Packet;
|
||||||
|
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PacketReader {
|
||||||
|
|
||||||
|
Player player;
|
||||||
|
Channel channel;
|
||||||
|
|
||||||
|
public PacketReader(final Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inject() {
|
||||||
|
final CraftPlayer player = (CraftPlayer) this.player;
|
||||||
|
this.channel = player.getHandle().playerConnection.networkManager.channel;
|
||||||
|
this.channel.pipeline().addAfter("decoder", "PacketInjector", (ChannelHandler) new MessageToMessageDecoder<Packet<?>>() {
|
||||||
|
protected void decode(final ChannelHandlerContext arg0, final Packet<?> packet, final List<Object> arg2) throws Exception {
|
||||||
|
arg2.add(packet);
|
||||||
|
PacketReader.this.readPackets(packet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void uninject() {
|
||||||
|
if (this.channel.pipeline().get("PacketInjector") != null) {
|
||||||
|
this.channel.pipeline().remove("PacketInjector");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readPackets(final Packet<?> packet) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
package eu.univento.core.antihack.utils;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Reflection {
|
||||||
|
public static Class<?> getClass(final String classname) {
|
||||||
|
try {
|
||||||
|
final String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
|
final String path = classname.replace("{nms}", "net.minecraft.server." + version).replace("{nm}", "net.minecraft." + version).replace("{cb}", "org.bukkit.craftbukkit.." + version);
|
||||||
|
return Class.forName(path);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object getNmsPlayer(final Player p) throws Exception {
|
||||||
|
final Method getHandle = p.getClass().getMethod("getHandle", (Class<?>[]) new Class[0]);
|
||||||
|
return getHandle.invoke(p, new Object[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object getNmsScoreboard(final Scoreboard s) throws Exception {
|
||||||
|
final Method getHandle = s.getClass().getMethod("getHandle", (Class<?>[]) new Class[0]);
|
||||||
|
return getHandle.invoke(s, new Object[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object getFieldValue(final Object instance, final String fieldName) throws Exception {
|
||||||
|
final Field field = instance.getClass().getDeclaredField(fieldName);
|
||||||
|
field.setAccessible(true);
|
||||||
|
return field.get(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getFieldValue(final Field field, final Object obj) {
|
||||||
|
try {
|
||||||
|
return (T) field.get(obj);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Field getField(final Class<?> clazz, final String fieldName) throws Exception {
|
||||||
|
final Field field = clazz.getDeclaredField(fieldName);
|
||||||
|
field.setAccessible(true);
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setValue(final Object instance, final String field, final Object value) {
|
||||||
|
try {
|
||||||
|
final Field f = instance.getClass().getDeclaredField(field);
|
||||||
|
f.setAccessible(true);
|
||||||
|
f.set(instance, value);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendAllPacket(final Object packet) throws Exception {
|
||||||
|
for (final Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
final Object nmsPlayer = getNmsPlayer(p);
|
||||||
|
final Object connection = nmsPlayer.getClass().getField("playerConnection").get(nmsPlayer);
|
||||||
|
connection.getClass().getMethod("sendPacket", getClass("{nms}.Packet")).invoke(connection, packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendListPacket(final List<String> players, final Object packet) {
|
||||||
|
try {
|
||||||
|
for (final String name : players) {
|
||||||
|
final Object nmsPlayer = getNmsPlayer(Bukkit.getPlayer(name));
|
||||||
|
final Object connection = nmsPlayer.getClass().getField("playerConnection").get(nmsPlayer);
|
||||||
|
connection.getClass().getMethod("sendPacket", getClass("{nms}.Packet")).invoke(connection, packet);
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPlayerPacket(final Player p, final Object packet) throws Exception {
|
||||||
|
final Object nmsPlayer = getNmsPlayer(p);
|
||||||
|
final Object connection = nmsPlayer.getClass().getField("playerConnection").get(nmsPlayer);
|
||||||
|
connection.getClass().getMethod("sendPacket", getClass("{nms}.Packet")).invoke(connection, packet);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author joethei
|
* @author joethei
|
||||||
|
@ -54,6 +55,14 @@ public class FakePlayer {
|
||||||
//this.dataWatcher.a(6, 20F);
|
//this.dataWatcher.a(6, 20F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEntityID() {
|
||||||
|
return entityId;
|
||||||
|
}
|
||||||
|
|
||||||
private final BukkitRunnable tickTask = new BukkitRunnable() {
|
private final BukkitRunnable tickTask = new BukkitRunnable() {
|
||||||
|
|
||||||
private int ticksLiving = 0;
|
private int ticksLiving = 0;
|
||||||
|
@ -139,7 +148,6 @@ public class FakePlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawn(Location location) {
|
public void spawn(Location location) {
|
||||||
|
|
||||||
PacketPlayOutNamedEntitySpawn playerSpawn = new PacketPlayOutNamedEntitySpawn();
|
PacketPlayOutNamedEntitySpawn playerSpawn = new PacketPlayOutNamedEntitySpawn();
|
||||||
set(playerSpawn, "a", this.entityId);
|
set(playerSpawn, "a", this.entityId);
|
||||||
set(playerSpawn, "b", this.gameProfile.getId());
|
set(playerSpawn, "b", this.gameProfile.getId());
|
||||||
|
@ -152,7 +160,7 @@ public class FakePlayer {
|
||||||
set(playerSpawn, "i", this.dataWatcher);
|
set(playerSpawn, "i", this.dataWatcher);
|
||||||
|
|
||||||
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
||||||
set(playerInfo, "b", Arrays.asList(playerInfo.new PlayerInfoData(this.gameProfile, 0, WorldSettings.EnumGamemode.NOT_SET, new ChatComponentText(this.gameProfile.getName()))));
|
set(playerInfo, "b", Collections.singletonList(playerInfo.new PlayerInfoData(this.gameProfile, 0, WorldSettings.EnumGamemode.NOT_SET, new ChatComponentText(this.gameProfile.getName()))));
|
||||||
sendPackets(playerInfo, playerSpawn);
|
sendPackets(playerInfo, playerSpawn);
|
||||||
|
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
@ -165,7 +173,7 @@ public class FakePlayer {
|
||||||
|
|
||||||
public void despawn() {
|
public void despawn() {
|
||||||
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER);
|
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER);
|
||||||
set(playerInfo, "b", Arrays.asList(playerInfo.new PlayerInfoData(this.gameProfile, 0, null, null)));
|
set(playerInfo, "b", Collections.singletonList(playerInfo.new PlayerInfoData(this.gameProfile, 0, null, null)));
|
||||||
sendPackets(new PacketPlayOutEntityDestroy(this.entityId), playerInfo);
|
sendPackets(new PacketPlayOutEntityDestroy(this.entityId), playerInfo);
|
||||||
|
|
||||||
this.armorStand.remove();
|
this.armorStand.remove();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.mongodb.CursorType;
|
||||||
import com.mongodb.client.FindIterable;
|
import com.mongodb.client.FindIterable;
|
||||||
import com.mongodb.client.MongoCollection;
|
import com.mongodb.client.MongoCollection;
|
||||||
import eu.univento.core.Core;
|
import eu.univento.core.Core;
|
||||||
|
import eu.univento.core.antihack.Hack;
|
||||||
import eu.univento.core.api.Actionbar;
|
import eu.univento.core.api.Actionbar;
|
||||||
import eu.univento.core.api.Utils;
|
import eu.univento.core.api.Utils;
|
||||||
import eu.univento.core.api.database.MongoDB;
|
import eu.univento.core.api.database.MongoDB;
|
||||||
|
@ -14,9 +15,7 @@ import eu.univento.core.api.server.Game;
|
||||||
import eu.univento.core.api.server.Servers;
|
import eu.univento.core.api.server.Servers;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.minecraft.server.v1_9_R1.EnumParticle;
|
import net.minecraft.server.v1_9_R1.*;
|
||||||
import net.minecraft.server.v1_9_R1.PacketDataSerializer;
|
|
||||||
import net.minecraft.server.v1_9_R1.PacketPlayOutCustomPayload;
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
|
@ -96,9 +95,10 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertToDatabase() {
|
public void insertToDatabase() {
|
||||||
Document doc = new Document("uuid", getUniqueId());
|
Document doc = new Document("uuid", getUniqueId().toString());
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
|
|
||||||
|
doc.put("lastName", getName());
|
||||||
doc.put("rank", "Player");
|
doc.put("rank", "Player");
|
||||||
doc.put("firstLogin", date);
|
doc.put("firstLogin", date);
|
||||||
doc.put("lastLogin", date);
|
doc.put("lastLogin", date);
|
||||||
|
@ -138,7 +138,7 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPlayedBefore() {
|
public boolean hasPlayedBefore() {
|
||||||
FindIterable cursor = userCollection.find(new Document("uuid", getUniqueId()));
|
FindIterable cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
|
||||||
cursor.cursorType(CursorType.NonTailable);
|
cursor.cursorType(CursorType.NonTailable);
|
||||||
|
|
||||||
Object obj = cursor.first();
|
Object obj = cursor.first();
|
||||||
|
@ -349,7 +349,7 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<UUID> getFriends() {
|
public ArrayList<UUID> getFriends() {
|
||||||
FindIterable<Document> cursor = friendCollection.find(new Document("uuid", getUniqueId()));
|
FindIterable<Document> cursor = friendCollection.find(new Document("uuid", getUniqueId().toString()));
|
||||||
cursor.cursorType(CursorType.NonTailable);
|
cursor.cursorType(CursorType.NonTailable);
|
||||||
|
|
||||||
Document doc = cursor.first();
|
Document doc = cursor.first();
|
||||||
|
@ -359,7 +359,7 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFriends(ArrayList<UUID> friends) {
|
private void setFriends(ArrayList<UUID> friends) {
|
||||||
friendCollection.updateOne(new Document("uuid", getUniqueId()), new Document("$set", new Document("friends", friends)));
|
friendCollection.updateOne(new Document("uuid", getUniqueId().toString()), new Document("$set", new Document("friends", friends)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFriend(UUID uuid) {
|
public boolean isFriend(UUID uuid) {
|
||||||
|
@ -372,6 +372,10 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
setFriends(list);
|
setFriends(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void warn(Hack hack) {
|
||||||
|
//TODO: add actual function
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -438,7 +442,7 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
return getTeam(getRank());
|
return getTeam(getRank());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add function
|
//TODO: add function back in
|
||||||
public boolean isNicked() {
|
public boolean isNicked() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -545,11 +549,11 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInDatabase(String name, Object obj) {
|
private void setInDatabase(String name, Object obj) {
|
||||||
userCollection.updateOne(new Document("uuid", getUniqueId()), new Document("$set", new Document(name, obj)));
|
userCollection.updateOne(new Document("uuid", getUniqueId().toString()), new Document("$set", new Document(name, obj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getObjectFromDatbase(String name) {
|
private Object getObjectFromDatbase(String name) {
|
||||||
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId()));
|
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
|
||||||
cursor.cursorType(CursorType.NonTailable);
|
cursor.cursorType(CursorType.NonTailable);
|
||||||
|
|
||||||
Document doc = cursor.first();
|
Document doc = cursor.first();
|
||||||
|
@ -559,7 +563,7 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getIntegerFromDatabase(String name) {
|
private int getIntegerFromDatabase(String name) {
|
||||||
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId()));
|
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
|
||||||
cursor.cursorType(CursorType.NonTailable);
|
cursor.cursorType(CursorType.NonTailable);
|
||||||
|
|
||||||
Document doc = cursor.first();
|
Document doc = cursor.first();
|
||||||
|
@ -569,7 +573,7 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStringFromDatabase(String name) {
|
private String getStringFromDatabase(String name) {
|
||||||
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId()));
|
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
|
||||||
cursor.cursorType(CursorType.NonTailable);
|
cursor.cursorType(CursorType.NonTailable);
|
||||||
|
|
||||||
Document doc = cursor.first();
|
Document doc = cursor.first();
|
||||||
|
@ -579,7 +583,7 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date getDateFromDatabase(String name) {
|
private Date getDateFromDatabase(String name) {
|
||||||
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId()));
|
FindIterable<Document> cursor = userCollection.find(new Document("uuid", getUniqueId().toString()));
|
||||||
cursor.cursorType(CursorType.NonTailable);
|
cursor.cursorType(CursorType.NonTailable);
|
||||||
|
|
||||||
Document doc = cursor.first();
|
Document doc = cursor.first();
|
||||||
|
@ -596,10 +600,10 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
return (Map<String, Object>) getObjectFromDatbase(name);
|
return (Map<String, Object>) getObjectFromDatbase(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix(Ranks r) {
|
private String getPrefix(Ranks r) {
|
||||||
switch(r) {
|
switch(r) {
|
||||||
case Admin: return "§8[§4Admin§8]§4 ";
|
case Admin: return "§8[§4Admin§8]§4 ";
|
||||||
case SrDeveloper: return "§8[§3Dev+§8]§3 ";
|
case SrDeveloper: return "§8[§3SrDev§8]§3 ";
|
||||||
case Developer: return "§8[§3Dev§8]§3 ";
|
case Developer: return "§8[§3Dev§8]§3 ";
|
||||||
case SrModerator: return "§8[§cSrMod§8]§c ";
|
case SrModerator: return "§8[§cSrMod§8]§c ";
|
||||||
case HeadBuilder: return "§8[§aHead-Builder§8]§a ";
|
case HeadBuilder: return "§8[§aHead-Builder§8]§a ";
|
||||||
|
@ -613,7 +617,7 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSuffix(Ranks r) {
|
private String getSuffix(Ranks r) {
|
||||||
switch(r) {
|
switch(r) {
|
||||||
case Admin: return "§8 »§7 ";
|
case Admin: return "§8 »§7 ";
|
||||||
case SrDeveloper: return "§8 »§7";
|
case SrDeveloper: return "§8 »§7";
|
||||||
|
@ -630,7 +634,7 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColor(Ranks r) {
|
private String getColor(Ranks r) {
|
||||||
switch(r) {
|
switch(r) {
|
||||||
case Admin: return "§4";
|
case Admin: return "§4";
|
||||||
case SrDeveloper: return "§3";
|
case SrDeveloper: return "§3";
|
||||||
|
@ -662,33 +666,22 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Team getTeam(Ranks r) {
|
public Team getTeam(Ranks r) {
|
||||||
|
Scoreboard board = getScoreboard();
|
||||||
switch (r) {
|
switch (r) {
|
||||||
case Admin: return Admin;
|
case Admin: return board.getTeam("a");
|
||||||
case SrDeveloper: return SrDeveloper;
|
case SrDeveloper: return board.getTeam("b");
|
||||||
case Developer: return Developer;
|
case Developer: return board.getTeam("c");
|
||||||
case SrModerator: return SrModerator;
|
case SrModerator: return board.getTeam("d");
|
||||||
case HeadBuilder: return HeadBuilder;
|
case HeadBuilder: return board.getTeam("e");
|
||||||
case Moderator: return Moderator;
|
case Moderator: return board.getTeam("f");
|
||||||
case Builder: return Builder;
|
case Builder: return board.getTeam("g");
|
||||||
case Supporter: return Supporter;
|
case Supporter: return board.getTeam("h");
|
||||||
case Youtuber: return Youtuber;
|
case Youtuber: return board.getTeam("i");
|
||||||
case Premium: return Premium;
|
case Premium: return board.getTeam("j");
|
||||||
case Player: return Player;
|
case Player: return board.getTeam("k");
|
||||||
default: return Player;
|
default: return board.getTeam("k");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private Scoreboard board = getScoreboard();
|
|
||||||
private Team Admin = board.getTeam("a");
|
|
||||||
private Team SrDeveloper = board.getTeam("b");
|
|
||||||
private Team Developer = board.getTeam("c");
|
|
||||||
private Team SrModerator = board.getTeam("d");
|
|
||||||
private Team HeadBuilder = board.getTeam("e");
|
|
||||||
private Team Moderator = board.getTeam("f");
|
|
||||||
private Team Builder = board.getTeam("g");
|
|
||||||
private Team Supporter = board.getTeam("h");
|
|
||||||
private Team Youtuber = board.getTeam("i");
|
|
||||||
private Team Premium = board.getTeam("j");
|
|
||||||
private Team Player = board.getTeam("k");
|
|
||||||
|
|
||||||
public void initScoreboard() {
|
public void initScoreboard() {
|
||||||
Scoreboard board = getScoreboard();
|
Scoreboard board = getScoreboard();
|
||||||
|
@ -770,4 +763,11 @@ public class CustomPlayer extends CraftPlayer {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void crashClient() {
|
||||||
|
getHandle().playerConnection.sendPacket(new PacketPlayOutExplosion(9999999999D,
|
||||||
|
9999999999D, 9999999999D, 9999999999F,
|
||||||
|
new ArrayList<>(), new Vec3D(9999999999D,
|
||||||
|
9999999999D, 9999999999D)));
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue