Latest changes

This commit is contained in:
mathias 2018-05-28 18:27:30 +03:00
parent 208fd3ea6b
commit e7420d9b6e
5 changed files with 436 additions and 144 deletions

12
pom.xml
View file

@ -20,6 +20,8 @@
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.boydti</groupId> <groupId>com.boydti</groupId>
@ -31,6 +33,11 @@
<artifactId>worldedit-bukkit</artifactId> <artifactId>worldedit-bukkit</artifactId>
<version>6.1.1-SNAPSHOT</version> <version>6.1.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>
@ -52,9 +59,14 @@
<enabled>true</enabled> <enabled>true</enabled>
</snapshots> </snapshots>
</repository> </repository>
<repository>
<id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/content/groups/public/</url>
</repository>
</repositories> </repositories>
<build> <build>
<finalName>${project.artifactId}</finalName>
<resources> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>

View file

@ -1,16 +1,42 @@
package pw.kaboom.extras; package pw.kaboom.extras;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import com.destroystokyo.paper.profile.PlayerProfile;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_12_R1.PacketPlayInClientCommand;
import net.minecraft.server.v1_12_R1.PacketPlayInClientCommand.EnumClientCommand;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_12_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
class CommandClearChat implements CommandExecutor { class CommandClearChat implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {
@ -33,6 +59,23 @@ class CommandConsole implements CommandExecutor {
} }
} }
class CommandDestroyEntities implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
for (World world : Bukkit.getServer().getWorlds()) {
for (Chunk chunk : world.getLoadedChunks()) {
for (Entity entity : chunk.getEntities()) {
if (!entity.getType().equals(EntityType.PLAYER)) {
entity.remove();
}
}
}
}
player.sendMessage("Successfully destroyed all entities in every world");
return true;
}
}
class CommandDiscord implements CommandExecutor { class CommandDiscord implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender; Player player = (Player)sender;
@ -42,6 +85,49 @@ class CommandDiscord implements CommandExecutor {
} }
} }
class CommandEnchantAll implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
ItemStack item = player.getItemInHand();
if (item.getType() == Material.AIR) {
player.sendMessage("Please hold an item in your hand to enchant it");
} else {
item.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 32767);
item.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 32767);
item.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 32767);
item.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 32767);
item.addUnsafeEnchantment(Enchantment.BINDING_CURSE, 32767);
item.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 32767);
item.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 32767);
item.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 32767);
item.addUnsafeEnchantment(Enchantment.DEPTH_STRIDER, 32767);
item.addUnsafeEnchantment(Enchantment.DIG_SPEED, 32767);
item.addUnsafeEnchantment(Enchantment.DURABILITY, 32767);
item.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 32767);
item.addUnsafeEnchantment(Enchantment.FROST_WALKER, 32767);
/*item.addUnsafeEnchantment(Enchantment.KNOCKBACK, 32767);*/
item.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 32767);
item.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 32767);
item.addUnsafeEnchantment(Enchantment.LUCK, 32767);
item.addUnsafeEnchantment(Enchantment.LURE, 32767);
item.addUnsafeEnchantment(Enchantment.MENDING, 32767);
item.addUnsafeEnchantment(Enchantment.OXYGEN, 32767);
item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 32767);
item.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 32767);
item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 32767);
item.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 32767);
item.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 32767);
item.addUnsafeEnchantment(Enchantment.SILK_TOUCH, 32767);
item.addUnsafeEnchantment(Enchantment.SWEEPING_EDGE, 32767);
item.addUnsafeEnchantment(Enchantment.THORNS, 32767);
item.addUnsafeEnchantment(Enchantment.VANISHING_CURSE, 32767);
item.addUnsafeEnchantment(Enchantment.WATER_WORKER, 32767);
player.sendMessage("I killed Tim.");
}
return true;
}
}
class CommandEnd implements CommandExecutor { class CommandEnd implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender; Player player = (Player)sender;
@ -69,6 +155,38 @@ class CommandHub implements CommandExecutor {
} }
} }
class CommandJumpscare implements CommandExecutor {
private void createJumpscare(Player player) {
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
for (int i = 0; i < 10; ++i) {
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMEN_SCREAM, 1, 0);
}
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
if (args.length == 0) {
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <player>");
} else {
if (args[0].equalsIgnoreCase("*") || args[0].equalsIgnoreCase("**")) {
for (Player p: Bukkit.getOnlinePlayers()) {
createJumpscare(p);
}
player.sendMessage("Successfully created jumpscare for every player");
} else {
Player target = Bukkit.getPlayer(args[0]);
if (target != null) {
createJumpscare(target);
player.sendMessage("Successfully created jumpscare for player \"" + target.getName() + "\"");
} else {
player.sendMessage("Player \"" + target.getName() + "\" not found");
}
}
}
return true;
}
}
class CommandNether implements CommandExecutor { class CommandNether implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender; Player player = (Player)sender;
@ -98,11 +216,11 @@ class CommandPrefix implements CommandExecutor {
if (args.length == 0) { if (args.length == 0) {
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <prefix|off>"); player.sendMessage(ChatColor.RED + "Usage: /" + label + " <prefix|off>");
} else if (args[0].equalsIgnoreCase("off")) { } else if (args[0].equalsIgnoreCase("off")) {
main.getConfig().set(player.getName().toString(), null); main.getConfig().set(player.getUniqueId().toString(), null);
main.saveConfig(); main.saveConfig();
player.sendMessage("You no longer have a tag"); player.sendMessage("You no longer have a tag");
} else { } else {
main.getConfig().set(player.getName().toString(), String.join(" ", args)); main.getConfig().set(player.getUniqueId().toString(), String.join(" ", args));
main.saveConfig(); main.saveConfig();
player.sendMessage("You now have the tag: " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args))); player.sendMessage("You now have the tag: " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
} }
@ -136,6 +254,66 @@ class CommandTellraw implements CommandExecutor {
} }
} }
class CommandUnloadChunks implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
for (World world : Bukkit.getServer().getWorlds()) {
for (Chunk chunk : world.getLoadedChunks()) {
chunk.unload(true);
}
}
player.sendMessage("Successfully unloaded unused chunks");
return true;
}
}
class CommandUsername implements CommandExecutor {
private void changeName(Player player, String name){
for (Player otherPlayer: Bukkit.getOnlinePlayers()){
((CraftPlayer)otherPlayer).getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, ((CraftPlayer)player).getHandle()));
try {
Field nameField = GameProfile.class.getDeclaredField("name");
nameField.setAccessible(true);
nameField.set(((CraftPlayer)player).getProfile(), name);
} catch (IllegalAccessException | NoSuchFieldException exception) {
exception.printStackTrace();
}
((CraftPlayer)otherPlayer).getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer)player).getHandle()));
if (otherPlayer.getUniqueId() != player.getUniqueId()) {
((CraftPlayer)otherPlayer).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(player.getEntityId()));
((CraftPlayer)otherPlayer).getHandle().playerConnection.sendPacket(new PacketPlayOutNamedEntitySpawn(((CraftPlayer)player).getHandle()));
}
}
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
if (args.length == 0) {
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <username>");
} else {
String namelong = ChatColor.translateAlternateColorCodes('&', String.join(" ", args));
String name = namelong.substring(0, Math.min(16, namelong.length()));
PlayerProfile profile = player.getPlayerProfile();
profile.setName(name);
profile.complete();
profile.clearProperties();
player.setPlayerProfile(profile);
/*Location location = player.getLocation();
/*changeName(player, name);
/*player.setHealth(0);
player.spigot().respawn();
player.teleport(location);
/*((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN));*/
player.sendMessage("Successfully set your username to \"" + name + "\"");
}
return true;
}
}
class CommandVote implements CommandExecutor { class CommandVote implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender; Player player = (Player)sender;

View file

@ -1,11 +1,16 @@
package pw.kaboom.extras; package pw.kaboom.extras;
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import com.destroystokyo.paper.profile.PlayerProfile;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -21,7 +26,12 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRedstoneEvent;
@ -29,6 +39,7 @@ import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.LingeringPotionSplashEvent; import org.bukkit.event.entity.LingeringPotionSplashEvent;
@ -37,6 +48,7 @@ import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerPreLoginEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -62,49 +74,17 @@ import com.sk89q.worldedit.event.extent.EditSessionEvent;
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority; import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
class EntityKiller extends BukkitRunnable { class Tick extends BukkitRunnable {
public void run() { public void run() {
double tps = Bukkit.getServer().getTPS()[0];
if (tps < 14) {
for (World world : Bukkit.getServer().getWorlds()) { for (World world : Bukkit.getServer().getWorlds()) {
for (Chunk chunk : world.getLoadedChunks()) { WorldBorder worldborder = world.getWorldBorder();
for (Entity e : chunk.getEntities()) { if (worldborder.getSize() != 60000000) {
if (e.getType().equals(EntityType.ARROW) || worldborder.setSize(60000000);
e.getType().equals(EntityType.ARROW) || } else if (worldborder.getCenter().getX() != 0 || worldborder.getCenter().getZ() != 0) {
e.getType().equals(EntityType.DRAGON_FIREBALL) || worldborder.setCenter(0, 0);
e.getType().equals(EntityType.DROPPED_ITEM) ||
e.getType().equals(EntityType.EGG) ||
e.getType().equals(EntityType.ENDER_CRYSTAL) ||
e.getType().equals(EntityType.ENDER_PEARL) ||
e.getType().equals(EntityType.ENDER_SIGNAL) ||
e.getType().equals(EntityType.EXPERIENCE_ORB) ||
e.getType().equals(EntityType.FIREBALL) ||
e.getType().equals(EntityType.FIREWORK) ||
e.getType().equals(EntityType.MINECART_TNT) ||
e.getType().equals(EntityType.PRIMED_TNT) ||
e.getType().equals(EntityType.SMALL_FIREBALL) ||
e.getType().equals(EntityType.SNOWBALL) ||
e.getType().equals(EntityType.SPECTRAL_ARROW) ||
e.getType().equals(EntityType.SPLASH_POTION) ||
e.getType().equals(EntityType.TIPPED_ARROW)) {
e.remove();
} }
} }
} }
}
}
/*for (World world : Bukkit.getServer().getWorlds()) {
for (Chunk chunk : world.getLoadedChunks()) {
for (Entity entity : chunk.getEntities()) {
if (entity.getWorld().getName().equals("world")) {
if (!entity.getType().equals(EntityType.PLAYER)) {
entity.remove();
}
}
}
}
}*/
}
} }
class Events implements Listener { class Events implements Listener {
@ -113,6 +93,25 @@ class Events implements Listener {
this.main = main; this.main = main;
} }
@EventHandler
void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage().substring(0, Math.min(256, event.getMessage().length()));
if (main.getConfig().getString(player.getUniqueId().toString()) != null) {
String prefix = ChatColor.translateAlternateColorCodes('&', main.getConfig().getString(player.getUniqueId().toString()));
event.setFormat(prefix + ChatColor.RESET + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', message));
} else {
if (event.getPlayer().isOp()) {
String prefix = ChatColor.translateAlternateColorCodes('&', "&4&l[&c&lOP&4&l]");
event.setFormat(prefix + ChatColor.RED + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', message));
} else {
String prefix = ChatColor.translateAlternateColorCodes('&', "&8&l[&7&lDeOP&8&l]");
event.setFormat(prefix + ChatColor.GRAY + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', message));
}
}
}
@EventHandler @EventHandler
void onBlockBreakEvent(BlockBreakEvent event) { void onBlockBreakEvent(BlockBreakEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
@ -121,8 +120,57 @@ class Events implements Listener {
} }
} }
@EventHandler
void onBlockBurnEvent(BlockBurnEvent event) {
Block block = event.getBlock();
if (block.getWorld().getName().equals("world")) {
event.setCancelled(true);
}
}
@EventHandler
void onBlockDamage(BlockDamageEvent event) {
Block block = event.getBlock();
if (block.getWorld().getName().equals("world")) {
event.setCancelled(true);
}
}
@EventHandler @EventHandler
void onBlockExplode(BlockExplodeEvent event) { void onBlockExplode(BlockExplodeEvent event) {
Block block = event.getBlock();
double tps = Bukkit.getServer().getTPS()[0];
event.setYield(0);
if (block.getWorld().getName().equals("world")) {
event.blockList().clear();
}
if (tps < 14) {
event.setCancelled(true);
}
}
@EventHandler
void onBlockFade(BlockFadeEvent event) {
Block block = event.getBlock();
if (block.getWorld().getName().equals("world")) {
event.setCancelled(true);
}
}
@EventHandler
void onBlockFromTo(BlockFromToEvent event) {
Block block = event.getBlock();
if (block.getWorld().getName().equals("world")) {
event.setCancelled(true);
}
}
@EventHandler
void onBlockGrow(BlockGrowEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
if (block.getWorld().getName().equals("world")) { if (block.getWorld().getName().equals("world")) {
event.setCancelled(true); event.setCancelled(true);
@ -131,20 +179,23 @@ class Events implements Listener {
@EventHandler @EventHandler
void onBlockPhysics(BlockPhysicsEvent event) { void onBlockPhysics(BlockPhysicsEvent event) {
/*double tps = Bukkit.getServer().getTPS()[0];
if (tps < 12) {
if (event.getBlock().getType() == Material.OBSERVER) {
Observer obs = (Observer) event.getBlock().getState().getData();
if (obs.isPowered()) {
event.getBlock().setType(Material.OBSERVER, true);
}
}
event.setCancelled(true);
}*/
Block block = event.getBlock(); Block block = event.getBlock();
if (block.getWorld().getName().equals("world") || block.getType() == Material.SOIL) { if (block.getWorld().getName().equals("world") ||
block.getType() == Material.SOIL) {
event.setCancelled(true); event.setCancelled(true);
} }
if (block.getType() == Material.LAVA ||
block.getType() == Material.STATIONARY_LAVA ||
block.getType() == Material.STATIONARY_WATER ||
block.getType() == Material.WATER) {
event.setCancelled(true);
/*if (main.physicscount == 5) {
main.physicscount = 0;
} else {
event.setCancelled(true);
main.physicscount = main.physicscount + 1;
}*/
}
} }
@EventHandler @EventHandler
@ -164,6 +215,33 @@ class Events implements Listener {
} }
} }
@EventHandler
void onEntityAddToWorld(EntityAddToWorldEvent event) {
Entity entity = event.getEntity();
Location entityLocation = entity.getLocation();
int onChunk = 0;
for (Entity chunkEntity : entityLocation.getWorld().getEntities()) {
if (entityLocation.getChunk().equals(chunkEntity.getLocation().getChunk())) {
onChunk++;
}
}
if (onChunk >= 50) {
entity.remove();
} else if (entity.getType().equals(EntityType.MAGMA_CUBE)) {
MagmaCube magmacube = (MagmaCube) event.getEntity();
if (magmacube.getSize() > 100) {
magmacube.setSize(100);
}
} else if (entity.getType().equals(EntityType.SLIME)) {
Slime slime = (Slime) event.getEntity();
if (slime.getSize() > 100) {
slime.setSize(100);
}
}
}
@EventHandler @EventHandler
void onEntityChangeBlockEvent(EntityChangeBlockEvent event) { void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
@ -176,29 +254,29 @@ class Events implements Listener {
void onEntityDamage(EntityDamageEvent event) { void onEntityDamage(EntityDamageEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity.getType().equals(EntityType.PLAYER)) { if (entity.getType().equals(EntityType.PLAYER)) {
if (event.getCause().equals(DamageCause.VOID) && entity.getLocation().getY() > -64) { if (event.getCause().equals(DamageCause.VOID) && entity.getLocation().getY() > -64 ||
event.getCause().equals(DamageCause.CUSTOM) ||
event.getCause().equals(DamageCause.SUICIDE)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
/*@EventHandler @EventHandler
void onEntityExplode(EntityExplodeEvent event) { void onEntityExplode(EntityExplodeEvent event) {
Iterator<Block> iter = event.blockList().iterator(); Entity entity = event.getEntity();
while (iter.hasNext()) { double tps = Bukkit.getServer().getTPS()[0];
Block block = iter.next();
double x = block.getX(); event.setYield(0);
double y = block.getY();
double z = block.getZ(); if (entity.getWorld().getName().equals("world")) {
double spawnx = block.getWorld().getSpawnLocation().getX(); event.blockList().clear();
double spawnz = block.getWorld().getSpawnLocation().getZ(); }
if (block.getWorld().getName().equals("world")) {
if ((x > spawnx - 50 && x < spawnx + 50) && (y > 0 && y < 9999) && (z > spawnz - 50 && z < spawnz + 50)) { if (tps < 14) {
iter.remove(); event.setCancelled(true);
} }
} }
}
}*/
@EventHandler @EventHandler
void onEntitySpawn(EntitySpawnEvent event) { void onEntitySpawn(EntitySpawnEvent event) {
@ -214,16 +292,6 @@ class Events implements Listener {
if (onChunk >= 50) { if (onChunk >= 50) {
event.setCancelled(true); event.setCancelled(true);
} else if (entity.getType().equals(EntityType.MAGMA_CUBE)) {
MagmaCube magmacube = (MagmaCube) event.getEntity();
if (magmacube.getSize() > 100) {
magmacube.setSize(100);
}
} else if (entity.getType().equals(EntityType.SLIME)) {
Slime slime = (Slime) event.getEntity();
if (slime.getSize() > 100) {
slime.setSize(100);
}
} }
} }
@ -232,7 +300,7 @@ class Events implements Listener {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
double tps = Bukkit.getServer().getTPS()[0]; double tps = Bukkit.getServer().getTPS()[0];
if (entity.getWorld().getName().equals("world") || tps < 14) { if (tps < 14) {
event.setCancelled(true); event.setCancelled(true);
} else if (event.getRadius() > 20) { } else if (event.getRadius() > 20) {
event.setRadius(20); event.setRadius(20);
@ -240,7 +308,7 @@ class Events implements Listener {
} }
@EventHandler @EventHandler
void onAreaEffectCloudEffect(LingeringPotionSplashEvent event) { void onLingeringPotionSplash(LingeringPotionSplashEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity.getWorld().getName().equals("world")) { if (entity.getWorld().getName().equals("world")) {
event.setCancelled(true); event.setCancelled(true);
@ -263,25 +331,6 @@ class Events implements Listener {
} }
} }
@EventHandler
void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage().substring(0, Math.min(256, event.getMessage().length()));
if (main.getConfig().getString(player.getName().toString()) != null) {
String prefix = ChatColor.translateAlternateColorCodes('&', main.getConfig().getString(player.getName().toString()));
event.setFormat(prefix + ChatColor.RESET + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', message));
} else {
if (event.getPlayer().isOp()) {
String prefix = ChatColor.translateAlternateColorCodes('&', "&4&l[&c&lOP&4&l]");
event.setFormat(prefix + ChatColor.RED + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', message));
} else {
String prefix = ChatColor.translateAlternateColorCodes('&', "&8&l[&7&lDeOP&8&l]");
event.setFormat(prefix + ChatColor.GRAY + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', message));
}
}
}
@EventHandler @EventHandler
void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -294,7 +343,7 @@ class Events implements Listener {
void onPlayerChangedWorld(PlayerChangedWorldEvent event) { void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
String world = player.getLocation().getWorld().getName(); String world = player.getLocation().getWorld().getName();
PermissionAttachment p = main.permissionList.get(player.getUniqueId()); /*PermissionAttachment p = main.permissionList.get(player.getUniqueId());*/
if (world.equals("world_the_end")) { if (world.equals("world_the_end")) {
player.sendTitle(ChatColor.GRAY + "The End", "Return to the hub by typing /hub in chat", 10, 160, 5); player.sendTitle(ChatColor.GRAY + "The End", "Return to the hub by typing /hub in chat", 10, 160, 5);
@ -306,7 +355,8 @@ class Events implements Listener {
player.sendTitle(ChatColor.DARK_GREEN + "Overworld", "Return to the hub by typing /hub in chat", 10, 160, 5); player.sendTitle(ChatColor.DARK_GREEN + "Overworld", "Return to the hub by typing /hub in chat", 10, 160, 5);
} }
if (world.equals("world")) { /* if (world.equals("world")) {
p.unsetPermission("DoBlockImage.doblockimage");
p.unsetPermission("essentials.bigtree"); p.unsetPermission("essentials.bigtree");
p.unsetPermission("essentials.tree"); p.unsetPermission("essentials.tree");
p.unsetPermission("minecraft.command.blockdata"); p.unsetPermission("minecraft.command.blockdata");
@ -314,13 +364,14 @@ class Events implements Listener {
p.unsetPermission("minecraft.command.fill"); p.unsetPermission("minecraft.command.fill");
p.unsetPermission("minecraft.command.setblock"); p.unsetPermission("minecraft.command.setblock");
} else { } else {
p.setPermission("DoBlockImage.doblockimage", true);
p.setPermission("essentials.bigtree", true); p.setPermission("essentials.bigtree", true);
p.setPermission("essentials.tree", true); p.setPermission("essentials.tree", true);
p.setPermission("minecraft.command.blockdata", true); p.setPermission("minecraft.command.blockdata", true);
p.setPermission("minecraft.command.clone", true); p.setPermission("minecraft.command.clone", true);
p.setPermission("minecraft.command.fill", true); p.setPermission("minecraft.command.fill", true);
p.setPermission("minecraft.command.setblock", true); p.setPermission("minecraft.command.setblock", true);
} }*/
} }
@EventHandler @EventHandler
@ -328,7 +379,7 @@ class Events implements Listener {
String arr[] = event.getMessage().split(" "); String arr[] = event.getMessage().split(" ");
String ar[] = event.getMessage().split(" ", 10); String ar[] = event.getMessage().split(" ", 10);
if (arr[0].toLowerCase().equals("//schem") || /*if (arr[0].toLowerCase().equals("//schem") ||
arr[0].toLowerCase().equals("//schematic") || arr[0].toLowerCase().equals("//schematic") ||
arr[0].toLowerCase().equals("/schem") || arr[0].toLowerCase().equals("/schem") ||
arr[0].toLowerCase().equals("/schematic") || arr[0].toLowerCase().equals("/schematic") ||
@ -339,44 +390,55 @@ class Events implements Listener {
if (arr[1].toLowerCase().equals("delete")) { if (arr[1].toLowerCase().equals("delete")) {
event.setCancelled(true); event.setCancelled(true);
} }
} else if (arr[0].toLowerCase().equals("/minecraft:particle") || } else */if (arr[0].toLowerCase().equals("/minecraft:particle") ||
arr[0].toLowerCase().equals("/particle")) { arr[0].toLowerCase().equals("/particle")) {
if (arr[9] != null && Integer.parseInt(arr[9]) > 10) { if (arr[9] != null && Integer.parseInt(arr[9]) > 10) {
event.setMessage(String.join(" ", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8]) + " 10"); event.setMessage(String.join(" ", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8]) + " 10");
} }
} else if (arr[0].toLowerCase().equals("/essentials:esudo") ||
arr[0].toLowerCase().equals("/essentials:sudo") ||
arr[0].toLowerCase().equals("/esudo") ||
arr[0].toLowerCase().equals("/sudo")) {
if (arr[2].toLowerCase().equals("ekill") ||
arr[2].toLowerCase().equals("essentials:ekill") ||
arr[2].toLowerCase().equals("essentials:esuicide") ||
arr[2].toLowerCase().equals("essentials:kill") ||
arr[2].toLowerCase().equals("essentials:suicide") ||
arr[2].toLowerCase().equals("esuicide") ||
arr[2].toLowerCase().equals("suicide")) {
event.setCancelled(true);
}
} }
event.setMessage(event.getMessage().substring(0, Math.min(256, event.getMessage().length()))); event.setMessage(event.getMessage().substring(0, Math.min(256, event.getMessage().length())));
} }
/*@EventHandler
void onPlayerHandshake(PlayerHandshakeEvent event) {
event.setFailed(true);
event.setServerHostname("0.0.0.0");
event.setSocketAddressHostname("0.0.0.0");
}*/
@EventHandler @EventHandler
void onPlayerJoin(PlayerJoinEvent event) { void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
/*UUID uuid = "069a79f4-44e9-4726-a5be-fca90e38aaf5";*/
player.setOp(true); player.setOp(true);
PermissionAttachment attachment = player.addAttachment(main); /*try {
HttpsURLConnection connection = (HttpsURLConnection) new URL(String.format("https://sessionserver.mojang.com/session/minecraft/profile/%s?unsigned=false", UUIDTypeAdapter.fromUUID(uuid))).openConnection();
if (connection.getResponseCode() == HttpsURLConnection.HTTP_OK) {
String reply = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();
String skin = reply.split("\"value\":\"")[1].split("\"")[0];
String signature = reply.split("\"signature\":\"")[1].split("\"")[0];
((CraftPlayer)player).getProfile().getProperties().put("textures", new Property("textures", skin, signature));
return true;
} else {
System.out.println("Connection could not be opened (Response code " + connection.getResponseCode() + ", " + connection.getResponseMessage() + ")");
}
} catch (IOException e) {
e.printStackTrace();
}*/
/*PermissionAttachment attachment = player.addAttachment(main);
main.permissionList.put(player.getUniqueId(), attachment); main.permissionList.put(player.getUniqueId(), attachment);
if (!player.getWorld().getName().equals("world")) { if (!player.getWorld().getName().equals("world")) {
PermissionAttachment p = main.permissionList.get(player.getUniqueId()); PermissionAttachment p = main.permissionList.get(player.getUniqueId());
p.setPermission("DoBlockImage.doblockimage", true);
p.setPermission("essentials.bigtree", true); p.setPermission("essentials.bigtree", true);
p.setPermission("essentials.tree", true); p.setPermission("essentials.tree", true);
p.setPermission("minecraft.command.blockdata", true); p.setPermission("minecraft.command.blockdata", true);
p.setPermission("minecraft.command.clone", true); p.setPermission("minecraft.command.clone", true);
p.setPermission("minecraft.command.fill", true); p.setPermission("minecraft.command.fill", true);
p.setPermission("minecraft.command.setblock", true); p.setPermission("minecraft.command.setblock", true);
} }*/
player.sendTitle(ChatColor.GRAY + "Kaboom.pw", "Free OP • Anarchy • Creative", 10, 160, 5); player.sendTitle(ChatColor.GRAY + "Kaboom.pw", "Free OP • Anarchy • Creative", 10, 160, 5);
} }
@ -478,7 +540,7 @@ class Events implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
main.enteredPortal.remove(player.getUniqueId()); main.enteredPortal.remove(player.getUniqueId());
main.enteredTitle.remove(player.getUniqueId()); main.enteredTitle.remove(player.getUniqueId());
player.removeAttachment(main.permissionList.get(player.getUniqueId())); /*player.removeAttachment(main.permissionList.get(player.getUniqueId()));*/
} }
@EventHandler @EventHandler
@ -519,18 +581,10 @@ class Events implements Listener {
if (arr[1].toLowerCase().equals("delete")) { if (arr[1].toLowerCase().equals("delete")) {
event.setCancelled(true); event.setCancelled(true);
} }
} else if (arr[0].toLowerCase().equals("essentials:esudo") || } else if (arr[0].toLowerCase().equals("minecraft:particle") ||
arr[0].toLowerCase().equals("essentials:sudo") || arr[0].toLowerCase().equals("particle")) {
arr[0].toLowerCase().equals("esudo") || if (arr[9] != null && Integer.parseInt(arr[9]) > 10) {
arr[0].toLowerCase().equals("sudo")) { event.setCommand(String.join(" ", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8]) + " 10");
if (arr[2].toLowerCase().equals("ekill") ||
arr[2].toLowerCase().equals("essentials:ekill") ||
arr[2].toLowerCase().equals("essentials:esuicide") ||
arr[2].toLowerCase().equals("essentials:kill") ||
arr[2].toLowerCase().equals("essentials:suicide") ||
arr[2].toLowerCase().equals("esuicide") ||
arr[2].toLowerCase().equals("suicide")) {
event.setCancelled(true);
} }
} }
} }

View file

@ -5,6 +5,13 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -104,6 +111,7 @@ public class Main extends JavaPlugin {
"essentials:etp", "essentials:etp",
"essentials:etp2p", "essentials:etp2p",
"essentials:etpaall", "essentials:etpaall",
"essentials:etpall",
"essentials:etppos", "essentials:etppos",
"essentials:etptoggle", "essentials:etptoggle",
"essentials:eunban", "essentials:eunban",
@ -154,6 +162,7 @@ public class Main extends JavaPlugin {
"essentials:tp", "essentials:tp",
"essentials:tp2p", "essentials:tp2p",
"essentials:tpaall", "essentials:tpaall",
"essentials:tpall",
"essentials:tppos", "essentials:tppos",
"essentials:tptoggle", "essentials:tptoggle",
"essentials:unban", "essentials:unban",
@ -174,6 +183,7 @@ public class Main extends JavaPlugin {
"minecraft:kill", "minecraft:kill",
"minecraft:me", "minecraft:me",
"minecraft:say", "minecraft:say",
"minecraft:spreadplayers",
"minecraft:tell", "minecraft:tell",
"minecraft:tellraw", "minecraft:tellraw",
"minecraft:title", "minecraft:title",
@ -268,6 +278,7 @@ public class Main extends JavaPlugin {
"etp", "etp",
"etp2p", "etp2p",
"etpaall", "etpaall",
"etpall",
"etppos", "etppos",
"etptoggle", "etptoggle",
"eunban", "eunban",
@ -311,6 +322,7 @@ public class Main extends JavaPlugin {
"spectator", "spectator",
"spigot:spigot", "spigot:spigot",
"spigot", "spigot",
"spreadplayers",
"sudo", "sudo",
"survival", "survival",
"survivalmode", "survivalmode",
@ -319,11 +331,13 @@ public class Main extends JavaPlugin {
"teleport", "teleport",
"tell", "tell",
"tempban", "tempban",
"title",
"tjail", "tjail",
"togglejail", "togglejail",
"tp", "tp",
"tp2p", "tp2p",
"tpaall", "tpaall",
"tpall",
"tppos", "tppos",
"tptoggle", "tptoggle",
"unban", "unban",
@ -338,26 +352,43 @@ public class Main extends JavaPlugin {
HashMap<UUID, Boolean> enteredPortal = new HashMap<UUID, Boolean>(); HashMap<UUID, Boolean> enteredPortal = new HashMap<UUID, Boolean>();
HashMap<UUID, Boolean> enteredTitle = new HashMap<UUID, Boolean>(); HashMap<UUID, Boolean> enteredTitle = new HashMap<UUID, Boolean>();
HashMap<UUID, PermissionAttachment> permissionList = new HashMap<UUID, PermissionAttachment>(); HashMap<UUID, PermissionAttachment> permissionList = new HashMap<UUID, PermissionAttachment>();
int physicscount = 0;
public void onEnable() { public void onEnable() {
getServer().createWorld(new WorldCreator("world_flatlands")); getServer().createWorld(new WorldCreator("world_flatlands"));
getServer().createWorld(new WorldCreator("world_overworld")); getServer().createWorld(new WorldCreator("world_overworld"));
this.getCommand("clearchat").setExecutor(new CommandClearChat());
this.getCommand("console").setExecutor(new CommandConsole());
this.getCommand("destroyentities").setExecutor(new CommandDestroyEntities());
this.getCommand("discord").setExecutor(new CommandDiscord());
this.getCommand("enchantall").setExecutor(new CommandEnchantAll());
this.getCommand("end").setExecutor(new CommandEnd()); this.getCommand("end").setExecutor(new CommandEnd());
this.getCommand("flatlands").setExecutor(new CommandFlatlands()); this.getCommand("flatlands").setExecutor(new CommandFlatlands());
this.getCommand("hub").setExecutor(new CommandHub()); this.getCommand("hub").setExecutor(new CommandHub());
this.getCommand("jumpscare").setExecutor(new CommandJumpscare());
this.getCommand("nether").setExecutor(new CommandNether()); this.getCommand("nether").setExecutor(new CommandNether());
this.getCommand("overworld").setExecutor(new CommandOverworld()); this.getCommand("overworld").setExecutor(new CommandOverworld());
this.getCommand("spawn").setExecutor(new CommandSpawn());
this.getCommand("console").setExecutor(new CommandConsole());
this.getCommand("vote").setExecutor(new CommandVote());
this.getCommand("discord").setExecutor(new CommandDiscord());
this.getCommand("clearchat").setExecutor(new CommandClearChat());
this.getCommand("tellraw").setExecutor(new CommandTellraw());
this.getCommand("prefix").setExecutor(new CommandPrefix(this)); this.getCommand("prefix").setExecutor(new CommandPrefix(this));
this.getCommand("spawn").setExecutor(new CommandSpawn());
this.getCommand("tellraw").setExecutor(new CommandTellraw());
this.getCommand("unloadchunks").setExecutor(new CommandUnloadChunks());
this.getCommand("username").setExecutor(new CommandUsername());
this.getCommand("vote").setExecutor(new CommandVote());
new EntityKiller().runTaskTimer(this, 0, 30); new Tick().runTaskTimer(this, 0, 1);
this.getServer().getPluginManager().registerEvents(new Events(this), this); this.getServer().getPluginManager().registerEvents(new Events(this), this);
WorldEdit.getInstance().getEventBus().register(new WorldEditEvent()); WorldEdit.getInstance().getEventBus().register(new WorldEditEvent());
/*ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, PacketType.Play.Server.BLOCK_CHANGE) {
@Override
public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer();
if (player.getWorld().getName().equals("world")) {
event.setCancelled(true);
}
}
});*/
} }
} }

View file

@ -1,6 +1,7 @@
name: Extras name: Extras
main: pw.kaboom.extras.Main main: pw.kaboom.extras.Main
description: Plugin that adds extra functionality to the Kaboom.pw server. description: Plugin that adds extra functionality to the Kaboom.pw server.
depend: [ProtocolLib, WorldEdit]
version: ${project.version} version: ${project.version}
commands: commands:
@ -11,23 +12,33 @@ commands:
console: console:
description: Broadcasts a message as the console description: Broadcasts a message as the console
permission: extras.console permission: extras.console
destroyentities:
description: Destroys all entities in every world
permission: extras.destroyentities
discord: discord:
description: Join the Kaboom.pw Discord server description: Join the Kaboom.pw Discord server
permission: extras.discord permission: extras.discord
enchantall:
description: Adds every enchantment to a held item
permission: extras.enchantall
end: end:
description: Moves your player to the End description: Moves you to the End
permission: extras.end permission: extras.end
flatlands: flatlands:
description: Moves your player to the Flatlands description: Moves you to the Flatlands
permission: extras.flatlands permission: extras.flatlands
hub: hub:
description: Moves your player to the Hub description: Moves you to the Hub
permission: extras.hub permission: extras.hub
jumpscare:
aliases: scare
description: Scares a player
permission: extras.jumpscare
nether: nether:
description: Moves your player to the Nether description: Moves you to the Nether
permission: extras.nether permission: extras.nether
overworld: overworld:
description: Moves your player to the Overworld description: Moves you to the Overworld
permission: extras.overworld permission: extras.overworld
prefix: prefix:
aliases: [rank, tag] aliases: [rank, tag]
@ -39,6 +50,12 @@ commands:
tellraw: tellraw:
description: Broadcasts raw text to the server description: Broadcasts raw text to the server
permission: extras.tellraw permission: extras.tellraw
unloadchunks:
description: Unloads all unused chunks
permission: extras.unloadchunks
username:
description: Changes your username on the server
permission: extras.username
vote: vote:
description: Shows vote links for the server description: Shows vote links for the server
permission: extras.vote permission: extras.vote