mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-27 09:55:36 -05:00
A bunch of improvements
This commit is contained in:
parent
edb9b7389b
commit
79d4bae135
5 changed files with 239 additions and 211 deletions
23
pom.xml
23
pom.xml
|
@ -4,27 +4,12 @@
|
||||||
<artifactId>Extras</artifactId>
|
<artifactId>Extras</artifactId>
|
||||||
<version>master</version>
|
<version>master</version>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.destroystokyo.paper</groupId>
|
<groupId>com.destroystokyo.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.boydti</groupId>
|
|
||||||
<artifactId>fawe-api</artifactId>
|
|
||||||
<version>latest</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sk89q.worldedit</groupId>
|
|
||||||
<artifactId>worldedit-bukkit</artifactId>
|
|
||||||
<version>6.1.4-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
@ -32,14 +17,6 @@
|
||||||
<id>papermc</id>
|
<id>papermc</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>fawe</id>
|
|
||||||
<url>https://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>worldedit</id>
|
|
||||||
<url>https://maven.sk89q.com/repo/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -179,50 +179,58 @@ class CommandSkin implements CommandExecutor {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, final String[] args) {
|
||||||
Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <username>");
|
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <username>");
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(main, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(main, new Runnable() {
|
||||||
try {
|
public void run() {
|
||||||
String name = args[0];
|
try {
|
||||||
URL nameurl = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
|
final String name = args[0];
|
||||||
HttpURLConnection nameconnection = (HttpURLConnection) nameurl.openConnection();
|
URL nameurl = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
|
||||||
|
HttpURLConnection nameconnection = (HttpURLConnection) nameurl.openConnection();
|
||||||
|
|
||||||
if (nameconnection.getResponseCode() == 200) {
|
if (nameconnection.getResponseCode() == 200) {
|
||||||
InputStreamReader namestream = new InputStreamReader(nameconnection.getInputStream());
|
InputStreamReader namestream = new InputStreamReader(nameconnection.getInputStream());
|
||||||
String uuid = new JsonParser().parse(namestream).getAsJsonObject().get("id").getAsString();
|
String uuid = new JsonParser().parse(namestream).getAsJsonObject().get("id").getAsString();
|
||||||
URL uuidurl = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
|
URL uuidurl = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
|
||||||
HttpURLConnection uuidconnection = (HttpURLConnection) uuidurl.openConnection();
|
HttpURLConnection uuidconnection = (HttpURLConnection) uuidurl.openConnection();
|
||||||
|
|
||||||
if (uuidconnection.getResponseCode() == 200) {
|
if (uuidconnection.getResponseCode() == 200) {
|
||||||
InputStreamReader uuidstream = new InputStreamReader(uuidconnection.getInputStream());
|
InputStreamReader uuidstream = new InputStreamReader(uuidconnection.getInputStream());
|
||||||
JsonObject response = new JsonParser().parse(uuidstream).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
|
JsonObject response = new JsonParser().parse(uuidstream).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
|
||||||
String texture = response.get("value").getAsString();
|
final String texture = response.get("value").getAsString();
|
||||||
String signature = response.get("signature").getAsString();
|
final String signature = response.get("signature").getAsString();
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
|
||||||
PlayerProfile textureprofile = player.getPlayerProfile();
|
public void run() {
|
||||||
textureprofile.setProperty(new ProfileProperty("textures", texture, signature));
|
PlayerProfile textureprofile = player.getPlayerProfile();
|
||||||
player.setPlayerProfile(textureprofile);
|
textureprofile.setProperty(new ProfileProperty("textures", texture, signature));
|
||||||
player.sendMessage("Successfully set your skin to " + name + "'s");
|
player.setPlayerProfile(textureprofile);
|
||||||
});
|
player.sendMessage("Successfully set your skin to " + name + "'s");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
player.sendMessage("Failed to change skin. Try again later");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
uuidconnection.disconnect();
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
|
||||||
player.sendMessage("Failed to change skin. Try again later");
|
public void run() {
|
||||||
|
player.sendMessage("A player with that username doesn't exist");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
uuidconnection.disconnect();
|
nameconnection.disconnect();
|
||||||
} else {
|
} catch (Exception exception) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> {
|
exception.printStackTrace();
|
||||||
player.sendMessage("A player with that username doesn't exist");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
nameconnection.disconnect();
|
|
||||||
} catch (Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -235,7 +243,7 @@ class CommandSpawn implements CommandExecutor {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
World world = Bukkit.getWorld("world");
|
World world = Bukkit.getWorld("world");
|
||||||
player.teleport(new Location(world, 0.5, 100, 0.5));
|
player.teleport(world.getSpawnLocation());
|
||||||
player.sendMessage("Successfully moved to the spawn");
|
player.sendMessage("Successfully moved to the spawn");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,9 @@ package pw.kaboom.extras;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
|
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
|
||||||
import com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent;
|
import com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent;
|
||||||
|
@ -26,6 +27,7 @@ import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Container;
|
import org.bukkit.block.Container;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
@ -38,31 +40,29 @@ import org.bukkit.entity.Slime;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import org.bukkit.event.block.BlockExplodeEvent;
|
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
|
||||||
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;
|
||||||
import org.bukkit.event.block.BlockSpreadEvent;
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
|
||||||
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.EntityDeathEvent;
|
||||||
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.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
|
||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
|
||||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||||
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import org.bukkit.event.server.ServerCommandEvent;
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
|
|
||||||
|
@ -74,28 +74,13 @@ import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
|
class Tick extends BukkitRunnable {
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
|
||||||
|
|
||||||
class PasteSpawn extends BukkitRunnable {
|
|
||||||
Main main;
|
Main main;
|
||||||
PasteSpawn(Main main) {
|
Tick(Main main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
|
||||||
boolean allowUndo = false;
|
|
||||||
boolean noAir = false;
|
|
||||||
Vector position = new Vector(0, 100, 0);
|
|
||||||
EditSession editSession = ClipboardFormat.findByFile(main.spawnSchematic).load(main.spawnSchematic).paste(FaweAPI.getWorld("world"), position, allowUndo, !noAir, (Transform) null);
|
|
||||||
} catch (Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,11 +91,14 @@ class TickAsync extends BukkitRunnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
for (World world : Bukkit.getServer().getWorlds()) {
|
for (final World world : Bukkit.getServer().getWorlds()) {
|
||||||
WorldBorder worldborder = world.getWorldBorder();
|
WorldBorder worldborder = world.getWorldBorder();
|
||||||
|
|
||||||
if (worldborder.getSize() != 60000000) {
|
if (worldborder.getSize() != 60000000) {
|
||||||
worldborder.setSize(60000000);
|
worldborder.setSize(60000000);
|
||||||
} else if (worldborder.getCenter().getX() != 0 || worldborder.getCenter().getZ() != 0) {
|
}
|
||||||
|
|
||||||
|
if (worldborder.getCenter().getX() != 0 || worldborder.getCenter().getZ() != 0) {
|
||||||
worldborder.setCenter(0, 0);
|
worldborder.setCenter(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,47 +106,34 @@ class TickAsync extends BukkitRunnable {
|
||||||
world.setAutoSave(true);
|
world.setAutoSave(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entity entity : world.getEntities()) {
|
try {
|
||||||
if (entity instanceof LivingEntity) {
|
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||||
LivingEntity mob = (LivingEntity) entity;
|
try {
|
||||||
AttributeInstance followAttribute = mob.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
|
chunk.getTileEntities();
|
||||||
|
} catch (Exception e) {
|
||||||
if (followAttribute != null && followAttribute.getBaseValue() > 40) {
|
Bukkit.getScheduler().runTask(main, new Runnable() {
|
||||||
followAttribute.setBaseValue(32);
|
public void run() {
|
||||||
|
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Chunk chunk : world.getLoadedChunks()) {
|
try {
|
||||||
try {
|
for (LivingEntity mob : world.getLivingEntities()) {
|
||||||
int sizeCount = 0;
|
final AttributeInstance followAttribute = mob.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
|
||||||
for (BlockState block : chunk.getTileEntities()) {
|
|
||||||
if (block instanceof Container) {
|
|
||||||
Container container = (Container) block;
|
|
||||||
|
|
||||||
for (ItemStack item : container.getInventory().getContents()) {
|
if (followAttribute != null && followAttribute.getBaseValue() > 40) {
|
||||||
if (item != null) {
|
Bukkit.getScheduler().runTask(main, new Runnable() {
|
||||||
try {
|
public void run() {
|
||||||
sizeCount = sizeCount + item.toString().length();
|
followAttribute.setBaseValue(40);
|
||||||
|
|
||||||
if (sizeCount > 200000) {
|
|
||||||
for (BlockState chunkBlock : chunk.getTileEntities()) {
|
|
||||||
if (chunkBlock instanceof Container) {
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> {
|
|
||||||
chunkBlock.getBlock().getDrops().clear();
|
|
||||||
chunkBlock.getBlock().setType(Material.AIR);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,38 +159,40 @@ class Events implements Listener {
|
||||||
String prefix = ChatColor.translateAlternateColorCodes('&', "&8&l[&7&lDeOP&8&l]");
|
String prefix = ChatColor.translateAlternateColorCodes('&', "&8&l[&7&lDeOP&8&l]");
|
||||||
event.setFormat(prefix + ChatColor.GRAY + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + "%2$s");
|
event.setFormat(prefix + ChatColor.GRAY + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + "%2$s");
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setMessage(ChatColor.translateAlternateColorCodes('&', event.getMessage()));
|
event.setMessage(ChatColor.translateAlternateColorCodes('&', event.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
void onBlockExplode(BlockExplodeEvent event) {
|
|
||||||
double tps = Bukkit.getServer().getTPS()[0];
|
|
||||||
|
|
||||||
if (tps < 14) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
void onBlockFromTo(BlockFromToEvent event) {
|
|
||||||
Block block = event.getBlock();
|
|
||||||
|
|
||||||
if (block.getType() != Material.DRAGON_EGG ||
|
|
||||||
block.getType() != Material.LAVA ||
|
|
||||||
block.getType() != Material.STATIONARY_LAVA ||
|
|
||||||
block.getType() != Material.STATIONARY_WATER ||
|
|
||||||
block.getType() != Material.WATER) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockPhysics(BlockPhysicsEvent event) {
|
void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
World world = event.getBlock().getWorld();
|
||||||
|
int radius = 10;
|
||||||
|
int blockCount = 0;
|
||||||
|
|
||||||
if (block.getType() == Material.SOIL) {
|
for (int x = -radius; x < radius; x++) {
|
||||||
event.setCancelled(true);
|
for (int y = -radius; y < radius; y++) {
|
||||||
|
for (int z = -radius; z < radius; z++) {
|
||||||
|
if (blockCount < 15) {
|
||||||
|
Location blockLocation = new Location(world, block.getX() + x, block.getY() + y, block.getZ() + z);
|
||||||
|
Block coordBlock = world.getBlockAt(blockLocation);
|
||||||
|
|
||||||
|
if (coordBlock.getType() == block.getType()) {
|
||||||
|
blockCount++;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (block.getType() == Material.SOIL ||
|
||||||
|
blockCount == 15) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
System.out.println("test");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -223,6 +200,12 @@ class Events implements Listener {
|
||||||
if (event.getItemInHand().toString().length() > 3019) {
|
if (event.getItemInHand().toString().length() > 3019) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
event.getBlockPlaced().getState();
|
||||||
|
} catch (Exception e) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -251,13 +234,17 @@ class Events implements Listener {
|
||||||
int onChunk = 0;
|
int onChunk = 0;
|
||||||
|
|
||||||
for (Entity chunkEntity : chunkEntities) {
|
for (Entity chunkEntity : chunkEntities) {
|
||||||
if (onChunk < 50 && chunkEntity.getType() != EntityType.PLAYER) {
|
if (onChunk < 50) {
|
||||||
onChunk++;
|
if (chunkEntity.getType() != EntityType.PLAYER) {
|
||||||
|
onChunk++;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onChunk == 50 && !(entity instanceof LivingEntity) ||
|
if ((onChunk == 50 && !(entity instanceof LivingEntity)) ||
|
||||||
tps < 14 && entity.getType() == EntityType.PRIMED_TNT) {
|
(tps < 14 && entity.getType() == EntityType.PRIMED_TNT)) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,12 +259,14 @@ class Events implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onEntityDamage(EntityDamageEvent event) {
|
void onEntityDeath(EntityDeathEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (entity.getType() == EntityType.PLAYER) {
|
if (entity.getType() == EntityType.PLAYER) {
|
||||||
if (event.getCause() == DamageCause.VOID && entity.getLocation().getY() > -64 ||
|
if ((entity.getLastDamageCause().getCause() == DamageCause.VOID && entity.getLocation().getY() > -64) ||
|
||||||
event.getCause() == DamageCause.CUSTOM ||
|
entity.getLastDamageCause().getCause() == DamageCause.CUSTOM ||
|
||||||
event.getCause() == DamageCause.SUICIDE) {
|
entity.getLastDamageCause().getCause() == DamageCause.SUICIDE) {
|
||||||
|
((Player)entity).setHealth(20);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,9 +288,13 @@ class Events implements Listener {
|
||||||
int onChunk = 0;
|
int onChunk = 0;
|
||||||
|
|
||||||
for (Entity chunkEntity : chunkEntities) {
|
for (Entity chunkEntity : chunkEntities) {
|
||||||
if (onChunk < 50 && chunkEntity.getType() != EntityType.PLAYER) {
|
if (onChunk < 50) {
|
||||||
onChunk++;
|
if (chunkEntity.getType() != EntityType.PLAYER) {
|
||||||
|
onChunk++;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onChunk == 50 && entity.getType() != EntityType.PLAYER) {
|
if (onChunk == 50 && entity.getType() != EntityType.PLAYER) {
|
||||||
|
@ -381,36 +374,36 @@ class Events implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
void onLingeringPotionSplash(LingeringPotionSplashEvent event) {
|
|
||||||
Entity entity = event.getEntity();
|
|
||||||
double x = entity.getLocation().getX();
|
|
||||||
double z = entity.getLocation().getZ();
|
|
||||||
|
|
||||||
if (entity.getWorld().getName().equals("world")) {
|
|
||||||
if ((x > -20 && x < 20) && (z > -20 && z < 20)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
void onPotionSplash(PotionSplashEvent event) {
|
|
||||||
Entity entity = event.getEntity();
|
|
||||||
double x = entity.getLocation().getX();
|
|
||||||
double z = entity.getLocation().getZ();
|
|
||||||
|
|
||||||
if (entity.getWorld().getName().equals("world")) {
|
|
||||||
if ((x > -20 && x < 20) && (z > -20 && z < 20)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
String arr[] = event.getMessage().split(" ");
|
String arr[] = event.getMessage().split(" ");
|
||||||
|
UUID playerUUID = event.getPlayer().getUniqueId();
|
||||||
|
long millisDifference = System.currentTimeMillis() - main.commandMillisList.get(playerUUID);
|
||||||
|
|
||||||
|
if (millisDifference < 400) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
} else {
|
||||||
|
main.commandMillisList.put(playerUUID, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if (arr[0].toLowerCase().equals("/minecraft:blockdata") ||
|
||||||
|
arr[0].toLowerCase().equals("/blockdata")) {
|
||||||
|
if (arr[4] != null &&
|
||||||
|
!arr[4].equals("{}")) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(main, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
for (Chunk chunk : player.getWorld().getLoadedChunks()) {
|
||||||
|
try {
|
||||||
|
chunk.getTileEntities();
|
||||||
|
} catch (Exception e) {
|
||||||
|
player.getWorld().regenerateChunk(chunk.getX(), chunk.getZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1L);
|
||||||
|
}*/
|
||||||
if (arr[0].toLowerCase().equals("/minecraft:gamerule") ||
|
if (arr[0].toLowerCase().equals("/minecraft:gamerule") ||
|
||||||
arr[0].toLowerCase().equals("/gamerule")) {
|
arr[0].toLowerCase().equals("/gamerule")) {
|
||||||
if (arr[1] != null && arr[1].toLowerCase().equals("randomtickspeed")) {
|
if (arr[1] != null && arr[1].toLowerCase().equals("randomtickspeed")) {
|
||||||
|
@ -429,25 +422,45 @@ class Events implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerJoin(PlayerJoinEvent event) {
|
void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
UUID playerUUID = event.getPlayer().getUniqueId();
|
||||||
|
long millisDifference = System.currentTimeMillis() - main.interactMillisList.get(playerUUID);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(main, () -> {
|
if (millisDifference < 200) {
|
||||||
main.getSkin(player.getName(), player);
|
event.setCancelled(true);
|
||||||
|
} else {
|
||||||
|
main.interactMillisList.put(playerUUID, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(main, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
main.getSkin(player.getName(), player);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (ItemStack item : player.getInventory().getContents()) {
|
if (player.getInventory().getContents().length != 0) {
|
||||||
if (item != null) {
|
System.out.println("hm");
|
||||||
try {
|
for (ItemStack item : player.getInventory().getContents()) {
|
||||||
item.getItemMeta();
|
if (item != null) {
|
||||||
} catch (Exception e) {
|
try {
|
||||||
player.getInventory().remove(item);
|
item.getItemMeta();
|
||||||
|
} catch (Exception e) {
|
||||||
|
player.getInventory().remove(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main.commandMillisList.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
main.interactMillisList.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
player.sendTitle(ChatColor.GRAY + "" + ChatColor.BOLD + "Kaboom", "Free OP • Anarchy • Creative", 10, 160, 5);
|
player.sendTitle(ChatColor.GRAY + "Welcome to Kaboom!", "Free OP • Anarchy • Creative", 10, 160, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -465,27 +478,21 @@ class Events implements Listener {
|
||||||
event.disallow(Result.KICK_OTHER, "The server is throttled due to bot attacks. Please try logging in again.");
|
event.disallow(Result.KICK_OTHER, "The server is throttled due to bot attacks. Please try logging in again.");
|
||||||
main.onlineCount++;
|
main.onlineCount++;
|
||||||
}
|
}
|
||||||
|
} else if (!(event.getHostname().startsWith("play.kaboom.pw") &&
|
||||||
|
event.getHostname().endsWith(":64518"))) {
|
||||||
|
event.disallow(Result.KICK_OTHER, "You connected to the server using an outdated server address/IP.\nPlease use the following address/IP:\n\nkaboom.pw");
|
||||||
} else {
|
} else {
|
||||||
event.allow();
|
event.allow();
|
||||||
}
|
}
|
||||||
|
System.out.println("\"" + event.getHostname() + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerRespawn(PlayerRespawnEvent event) {
|
void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
World world = event.getRespawnLocation().getWorld();
|
|
||||||
if (world.getName().equals("world") && player.getBedSpawnLocation() == null) {
|
|
||||||
event.setRespawnLocation(new Location(world, 0.5, 100, 0.5));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
main.commandMillisList.remove(player.getUniqueId());
|
||||||
void onPlayerSpawnLocation(PlayerSpawnLocationEvent event) {
|
main.interactMillisList.remove(player.getUniqueId());
|
||||||
Player player = event.getPlayer();
|
|
||||||
World world = event.getSpawnLocation().getWorld();
|
|
||||||
if (!player.hasPlayedBefore()) {
|
|
||||||
event.setSpawnLocation(new Location(world, 0.5, 100, 0.5));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -494,9 +501,13 @@ class Events implements Listener {
|
||||||
int onChunk = 0;
|
int onChunk = 0;
|
||||||
|
|
||||||
for (Entity chunkEntity : chunkEntities) {
|
for (Entity chunkEntity : chunkEntities) {
|
||||||
if (onChunk < 50 && event.getType() != EntityType.PLAYER) {
|
if (onChunk < 50) {
|
||||||
onChunk++;
|
if (chunkEntity.getType() != EntityType.PLAYER) {
|
||||||
|
onChunk++;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onChunk == 50 && event.getType() != EntityType.PLAYER) {
|
if (onChunk == 50 && event.getType() != EntityType.PLAYER) {
|
||||||
|
@ -510,6 +521,24 @@ class Events implements Listener {
|
||||||
|
|
||||||
if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
|
if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
/* } else if (arr[0].toLowerCase().equals("minecraft:blockdata") ||
|
||||||
|
arr[0].toLowerCase().equals("blockdata")) {
|
||||||
|
if (arr[4] != null &&
|
||||||
|
!arr[4].equals("{}")) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(main, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
for (Chunk chunk : player.getWorld().getLoadedChunks()) {
|
||||||
|
try {
|
||||||
|
chunk.getTileEntities();
|
||||||
|
} catch (Exception e) {
|
||||||
|
player.getWorld().regenerateChunk(chunk.getX(), chunk.getZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1L);
|
||||||
|
}*/
|
||||||
} else if (arr[0].toLowerCase().equals("minecraft:gamerule") ||
|
} else if (arr[0].toLowerCase().equals("minecraft:gamerule") ||
|
||||||
arr[0].toLowerCase().equals("gamerule")) {
|
arr[0].toLowerCase().equals("gamerule")) {
|
||||||
if (arr[1] != null && arr[1].toLowerCase().equals("randomtickspeed")) {
|
if (arr[1] != null && arr[1].toLowerCase().equals("randomtickspeed")) {
|
||||||
|
@ -527,6 +556,15 @@ class Events implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
void onSignChange(SignChangeEvent event) {
|
||||||
|
try {
|
||||||
|
event.getLines();
|
||||||
|
} catch (Exception e) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onSpawnerSpawn(SpawnerSpawnEvent event) {
|
void onSpawnerSpawn(SpawnerSpawnEvent event) {
|
||||||
CreatureSpawner spawner = event.getSpawner();
|
CreatureSpawner spawner = event.getSpawner();
|
||||||
|
|
|
@ -5,7 +5,9 @@ import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||||
|
@ -23,7 +25,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class Main extends JavaPlugin {
|
public class Main extends JavaPlugin {
|
||||||
int onlineCount = 0;
|
int onlineCount = 0;
|
||||||
File spawnSchematic = new File("worlds/world/spawn.schematic");
|
HashMap<UUID, Long> commandMillisList = new HashMap<UUID, Long>();
|
||||||
|
HashMap<UUID, Long> interactMillisList = new HashMap<UUID, Long>();
|
||||||
HashSet<String> consoleCommandBlacklist = new HashSet<String>(Arrays.asList(new String[] {
|
HashSet<String> consoleCommandBlacklist = new HashSet<String>(Arrays.asList(new String[] {
|
||||||
"essentials:action",
|
"essentials:action",
|
||||||
"essentials:adventure",
|
"essentials:adventure",
|
||||||
|
@ -364,12 +367,12 @@ public class Main extends JavaPlugin {
|
||||||
this.getCommand("unloadchunks").setExecutor(new CommandUnloadChunks());
|
this.getCommand("unloadchunks").setExecutor(new CommandUnloadChunks());
|
||||||
this.getCommand("username").setExecutor(new CommandUsername(this));
|
this.getCommand("username").setExecutor(new CommandUsername(this));
|
||||||
|
|
||||||
new PasteSpawn(this).runTaskTimerAsynchronously(this, 0, 10);
|
new Tick(this).runTaskTimer(this, 0, 1);
|
||||||
new TickAsync(this).runTaskTimerAsynchronously(this, 0, 1);
|
new TickAsync(this).runTaskTimerAsynchronously(this, 0, 1);
|
||||||
this.getServer().getPluginManager().registerEvents(new Events(this), this);
|
this.getServer().getPluginManager().registerEvents(new Events(this), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSkin(String name, Player player) {
|
public void getSkin(String name, final Player player) {
|
||||||
try {
|
try {
|
||||||
URL nameurl = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
|
URL nameurl = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
|
||||||
HttpURLConnection nameconnection = (HttpURLConnection) nameurl.openConnection();
|
HttpURLConnection nameconnection = (HttpURLConnection) nameurl.openConnection();
|
||||||
|
@ -383,13 +386,16 @@ public class Main extends JavaPlugin {
|
||||||
if (uuidconnection.getResponseCode() == 200) {
|
if (uuidconnection.getResponseCode() == 200) {
|
||||||
InputStreamReader uuidstream = new InputStreamReader(uuidconnection.getInputStream());
|
InputStreamReader uuidstream = new InputStreamReader(uuidconnection.getInputStream());
|
||||||
JsonObject response = new JsonParser().parse(uuidstream).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
|
JsonObject response = new JsonParser().parse(uuidstream).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
|
||||||
String texture = response.get("value").getAsString();
|
final String texture = response.get("value").getAsString();
|
||||||
String signature = response.get("signature").getAsString();
|
final String signature = response.get("signature").getAsString();
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||||
PlayerProfile textureprofile = player.getPlayerProfile();
|
@Override
|
||||||
textureprofile.setProperty(new ProfileProperty("textures", texture, signature));
|
public void run() {
|
||||||
player.setPlayerProfile(textureprofile);
|
PlayerProfile textureprofile = player.getPlayerProfile();
|
||||||
|
textureprofile.setProperty(new ProfileProperty("textures", texture, signature));
|
||||||
|
player.setPlayerProfile(textureprofile);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
uuidconnection.disconnect();
|
uuidconnection.disconnect();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
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: [FastAsyncWorldEdit]
|
|
||||||
version: master
|
version: master
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
|
|
Loading…
Reference in a new issue