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

View file

@ -1,16 +1,42 @@
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.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
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.inventory.ItemStack;
class CommandClearChat implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
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 {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
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 {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
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 {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
@ -98,11 +216,11 @@ class CommandPrefix implements CommandExecutor {
if (args.length == 0) {
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <prefix|off>");
} else if (args[0].equalsIgnoreCase("off")) {
main.getConfig().set(player.getName().toString(), null);
main.getConfig().set(player.getUniqueId().toString(), null);
main.saveConfig();
player.sendMessage("You no longer have a tag");
} else {
main.getConfig().set(player.getName().toString(), String.join(" ", args));
main.getConfig().set(player.getUniqueId().toString(), String.join(" ", args));
main.saveConfig();
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 {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;

View file

@ -1,11 +1,16 @@
package pw.kaboom.extras;
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import com.destroystokyo.paper.profile.PlayerProfile;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block;
@ -21,7 +26,12 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
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.BlockFadeEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
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.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
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.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerPreLoginEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -62,48 +74,16 @@ import com.sk89q.worldedit.event.extent.EditSessionEvent;
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe;
class EntityKiller extends BukkitRunnable {
class Tick extends BukkitRunnable {
public void run() {
double tps = Bukkit.getServer().getTPS()[0];
if (tps < 14) {
for (World world : Bukkit.getServer().getWorlds()) {
for (Chunk chunk : world.getLoadedChunks()) {
for (Entity e : chunk.getEntities()) {
if (e.getType().equals(EntityType.ARROW) ||
e.getType().equals(EntityType.ARROW) ||
e.getType().equals(EntityType.DRAGON_FIREBALL) ||
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()) {
WorldBorder worldborder = world.getWorldBorder();
if (worldborder.getSize() != 60000000) {
worldborder.setSize(60000000);
} else if (worldborder.getCenter().getX() != 0 || worldborder.getCenter().getZ() != 0) {
worldborder.setCenter(0, 0);
}
}
/*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();
}
}
}
}
}*/
}
}
@ -113,6 +93,25 @@ class Events implements Listener {
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
void onBlockBreakEvent(BlockBreakEvent event) {
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
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();
if (block.getWorld().getName().equals("world")) {
event.setCancelled(true);
@ -131,20 +179,23 @@ class Events implements Listener {
@EventHandler
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();
if (block.getWorld().getName().equals("world") || block.getType() == Material.SOIL) {
if (block.getWorld().getName().equals("world") ||
block.getType() == Material.SOIL) {
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
@ -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
void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
Block block = event.getBlock();
@ -176,29 +254,29 @@ class Events implements Listener {
void onEntityDamage(EntityDamageEvent event) {
Entity entity = event.getEntity();
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);
}
}
}
/*@EventHandler
@EventHandler
void onEntityExplode(EntityExplodeEvent event) {
Iterator<Block> iter = event.blockList().iterator();
while (iter.hasNext()) {
Block block = iter.next();
double x = block.getX();
double y = block.getY();
double z = block.getZ();
double spawnx = block.getWorld().getSpawnLocation().getX();
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)) {
iter.remove();
}
}
Entity entity = event.getEntity();
double tps = Bukkit.getServer().getTPS()[0];
event.setYield(0);
if (entity.getWorld().getName().equals("world")) {
event.blockList().clear();
}
}*/
if (tps < 14) {
event.setCancelled(true);
}
}
@EventHandler
void onEntitySpawn(EntitySpawnEvent event) {
@ -214,16 +292,6 @@ class Events implements Listener {
if (onChunk >= 50) {
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();
double tps = Bukkit.getServer().getTPS()[0];
if (entity.getWorld().getName().equals("world") || tps < 14) {
if (tps < 14) {
event.setCancelled(true);
} else if (event.getRadius() > 20) {
event.setRadius(20);
@ -240,7 +308,7 @@ class Events implements Listener {
}
@EventHandler
void onAreaEffectCloudEffect(LingeringPotionSplashEvent event) {
void onLingeringPotionSplash(LingeringPotionSplashEvent event) {
Entity entity = event.getEntity();
if (entity.getWorld().getName().equals("world")) {
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
void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
Player player = event.getPlayer();
@ -294,7 +343,7 @@ class Events implements Listener {
void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
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")) {
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);
}
if (world.equals("world")) {
/* if (world.equals("world")) {
p.unsetPermission("DoBlockImage.doblockimage");
p.unsetPermission("essentials.bigtree");
p.unsetPermission("essentials.tree");
p.unsetPermission("minecraft.command.blockdata");
@ -314,13 +364,14 @@ class Events implements Listener {
p.unsetPermission("minecraft.command.fill");
p.unsetPermission("minecraft.command.setblock");
} else {
p.setPermission("DoBlockImage.doblockimage", true);
p.setPermission("essentials.bigtree", true);
p.setPermission("essentials.tree", true);
p.setPermission("minecraft.command.blockdata", true);
p.setPermission("minecraft.command.clone", true);
p.setPermission("minecraft.command.fill", true);
p.setPermission("minecraft.command.setblock", true);
}
}*/
}
@EventHandler
@ -328,7 +379,7 @@ class Events implements Listener {
String arr[] = event.getMessage().split(" ");
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("/schem") ||
arr[0].toLowerCase().equals("/schematic") ||
@ -339,44 +390,55 @@ class Events implements Listener {
if (arr[1].toLowerCase().equals("delete")) {
event.setCancelled(true);
}
} else if (arr[0].toLowerCase().equals("/minecraft:particle") ||
} else */if (arr[0].toLowerCase().equals("/minecraft:particle") ||
arr[0].toLowerCase().equals("/particle")) {
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");
}
} 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())));
}
/*@EventHandler
void onPlayerHandshake(PlayerHandshakeEvent event) {
event.setFailed(true);
event.setServerHostname("0.0.0.0");
event.setSocketAddressHostname("0.0.0.0");
}*/
@EventHandler
void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
/*UUID uuid = "069a79f4-44e9-4726-a5be-fca90e38aaf5";*/
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);
if (!player.getWorld().getName().equals("world")) {
PermissionAttachment p = main.permissionList.get(player.getUniqueId());
p.setPermission("DoBlockImage.doblockimage", true);
p.setPermission("essentials.bigtree", true);
p.setPermission("essentials.tree", true);
p.setPermission("minecraft.command.blockdata", true);
p.setPermission("minecraft.command.clone", true);
p.setPermission("minecraft.command.fill", true);
p.setPermission("minecraft.command.setblock", true);
}
}*/
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();
main.enteredPortal.remove(player.getUniqueId());
main.enteredTitle.remove(player.getUniqueId());
player.removeAttachment(main.permissionList.get(player.getUniqueId()));
/*player.removeAttachment(main.permissionList.get(player.getUniqueId()));*/
}
@EventHandler
@ -519,18 +581,10 @@ class Events implements Listener {
if (arr[1].toLowerCase().equals("delete")) {
event.setCancelled(true);
}
} 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);
} else if (arr[0].toLowerCase().equals("minecraft:particle") ||
arr[0].toLowerCase().equals("particle")) {
if (arr[9] != null && Integer.parseInt(arr[9]) > 10) {
event.setCommand(String.join(" ", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8]) + " 10");
}
}
}

View file

@ -5,6 +5,13 @@ import java.util.HashMap;
import java.util.HashSet;
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.entity.Player;
@ -104,6 +111,7 @@ public class Main extends JavaPlugin {
"essentials:etp",
"essentials:etp2p",
"essentials:etpaall",
"essentials:etpall",
"essentials:etppos",
"essentials:etptoggle",
"essentials:eunban",
@ -154,6 +162,7 @@ public class Main extends JavaPlugin {
"essentials:tp",
"essentials:tp2p",
"essentials:tpaall",
"essentials:tpall",
"essentials:tppos",
"essentials:tptoggle",
"essentials:unban",
@ -174,6 +183,7 @@ public class Main extends JavaPlugin {
"minecraft:kill",
"minecraft:me",
"minecraft:say",
"minecraft:spreadplayers",
"minecraft:tell",
"minecraft:tellraw",
"minecraft:title",
@ -268,6 +278,7 @@ public class Main extends JavaPlugin {
"etp",
"etp2p",
"etpaall",
"etpall",
"etppos",
"etptoggle",
"eunban",
@ -311,6 +322,7 @@ public class Main extends JavaPlugin {
"spectator",
"spigot:spigot",
"spigot",
"spreadplayers",
"sudo",
"survival",
"survivalmode",
@ -319,11 +331,13 @@ public class Main extends JavaPlugin {
"teleport",
"tell",
"tempban",
"title",
"tjail",
"togglejail",
"tp",
"tp2p",
"tpaall",
"tpall",
"tppos",
"tptoggle",
"unban",
@ -338,26 +352,43 @@ public class Main extends JavaPlugin {
HashMap<UUID, Boolean> enteredPortal = new HashMap<UUID, Boolean>();
HashMap<UUID, Boolean> enteredTitle = new HashMap<UUID, Boolean>();
HashMap<UUID, PermissionAttachment> permissionList = new HashMap<UUID, PermissionAttachment>();
int physicscount = 0;
public void onEnable() {
getServer().createWorld(new WorldCreator("world_flatlands"));
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("flatlands").setExecutor(new CommandFlatlands());
this.getCommand("hub").setExecutor(new CommandHub());
this.getCommand("jumpscare").setExecutor(new CommandJumpscare());
this.getCommand("nether").setExecutor(new CommandNether());
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("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);
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
main: pw.kaboom.extras.Main
description: Plugin that adds extra functionality to the Kaboom.pw server.
depend: [ProtocolLib, WorldEdit]
version: ${project.version}
commands:
@ -11,23 +12,33 @@ commands:
console:
description: Broadcasts a message as the console
permission: extras.console
destroyentities:
description: Destroys all entities in every world
permission: extras.destroyentities
discord:
description: Join the Kaboom.pw Discord server
permission: extras.discord
enchantall:
description: Adds every enchantment to a held item
permission: extras.enchantall
end:
description: Moves your player to the End
description: Moves you to the End
permission: extras.end
flatlands:
description: Moves your player to the Flatlands
description: Moves you to the Flatlands
permission: extras.flatlands
hub:
description: Moves your player to the Hub
description: Moves you to the Hub
permission: extras.hub
jumpscare:
aliases: scare
description: Scares a player
permission: extras.jumpscare
nether:
description: Moves your player to the Nether
description: Moves you to the Nether
permission: extras.nether
overworld:
description: Moves your player to the Overworld
description: Moves you to the Overworld
permission: extras.overworld
prefix:
aliases: [rank, tag]
@ -39,6 +50,12 @@ commands:
tellraw:
description: Broadcasts raw text to the server
permission: extras.tellraw
unloadchunks:
description: Unloads all unused chunks
permission: extras.unloadchunks
username:
description: Changes your username on the server
permission: extras.username
vote:
description: Shows vote links for the server
permission: extras.vote