Minecraft 1.15.2

This commit is contained in:
mathiascode 2020-01-22 16:33:19 +02:00
parent 95a3cbd175
commit 66e3a3da01
8 changed files with 102 additions and 61 deletions

View file

@ -3,8 +3,6 @@ package pw.kaboom.extras.commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.block.BlockState;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View file

@ -8,8 +8,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import pw.kaboom.extras.Main;
import pw.kaboom.extras.helpers.SkinDownloader;
public final class CommandUsername implements CommandExecutor {

View file

@ -3,12 +3,12 @@ package pw.kaboom.extras.helpers;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import javax.net.ssl.HttpsURLConnection;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
@ -22,6 +22,7 @@ import pw.kaboom.extras.Main;
public final class SkinDownloader {
public static HashSet<UUID> skinInProgress = new HashSet<UUID>();
public static HashMap<UUID, PlayerProfile> skinProfiles = new HashMap<UUID, PlayerProfile>();
private HttpsURLConnection skinConnection;
private InputStreamReader skinStream;
@ -87,6 +88,20 @@ public final class SkinDownloader {
}.runTaskAsynchronously(JavaPlugin.getPlugin(Main.class));
}
public void fillJoinProfile(final PlayerProfile profile, final String name, final UUID uuid) {
try {
fetchSkinData(name);
profile.setProperty(new ProfileProperty("textures", texture, signature));
skinProfiles.put(uuid, profile);
} catch (Exception exception) {
try {
skinStream.close();
skinConnection.disconnect();
} catch (Exception ignored) {
}
}
}
private void fetchSkinData(final String playerName) throws IOException {
final URL skinUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + playerName);
skinConnection = (HttpsURLConnection) skinUrl.openConnection();
@ -101,4 +116,12 @@ public final class SkinDownloader {
skinStream.close();
skinConnection.disconnect();
}
public static PlayerProfile getProfile(final UUID uuid) {
return skinProfiles.get(uuid);
}
public static void removeProfile(final UUID uuid) {
skinProfiles.remove(uuid);
}
}

View file

@ -5,7 +5,6 @@ import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

View file

@ -7,15 +7,7 @@ import org.bukkit.World;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Slime;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
@ -28,6 +20,7 @@ import com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason;
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
import com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent;
import org.bukkit.event.weather.LightningStrikeEvent;
public class EntitySpawn implements Listener {
private void applyEntityChanges(Entity entity) {
@ -172,8 +165,13 @@ public class EntitySpawn implements Listener {
private void limitSpawner(CreatureSpawner spawner) {
if (spawner.getSpawnedType() == EntityType.MINECART_MOB_SPAWNER) {
spawner.setSpawnedType(EntityType.MINECART);
} else if (spawner.getSpawnedType() == EntityType.FALLING_BLOCK &&
spawner.getDelay() > 100) {
}
System.out.println(spawner.getDelay());
System.out.println(spawner.getSpawnCount());
System.out.println(spawner.getSpawnRange());
if (spawner.getDelay() > 100) {
spawner.setMaxSpawnDelay(100);
spawner.setDelay(100);
spawner.update();
@ -253,6 +251,28 @@ public class EntitySpawn implements Listener {
applyEntityChanges(entity);
}
@EventHandler
void onLightningStrike(LightningStrikeEvent event) {
final LightningStrike lightning = event.getLightning();
final double X = lightning.getLocation().getX();
final double Y = lightning.getLocation().getY();
final double Z = lightning.getLocation().getZ();
if (isOutsideBoundaries(X, Y, Z)) {
event.setCancelled(true);
return;
}
final EntityType entityType = lightning.getType();
final Chunk chunk = lightning.getChunk();
final World world = lightning.getWorld();
final boolean isAddToWorldEvent = false;
if (checkEntityLimits(entityType, chunk, world, isAddToWorldEvent)) {
event.setCancelled(true);
}
}
@EventHandler
void onPreCreatureSpawn(PreCreatureSpawnEvent event) {
final EntityType mobType = event.getType();

View file

@ -2,39 +2,31 @@ package pw.kaboom.extras.modules.player;
import com.destroystokyo.paper.event.profile.PreLookupProfileEvent;
import com.destroystokyo.paper.profile.PlayerProfile;
import com.destroystokyo.paper.profile.ProfileProperty;
import com.google.common.base.Charsets;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import pw.kaboom.extras.Main;
import pw.kaboom.extras.helpers.SkinDownloader;
import javax.net.ssl.HttpsURLConnection;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.UUID;
public final class PlayerConnection implements Listener {
private PlayerProfile profile;
private String texture;
private String signature;
private long connectionMillis;
private final File configFile = new File("spigot.yml");
private final FileConfiguration spigotConfig = YamlConfiguration.loadConfiguration(configFile);
private final ConfigurationSection configSection = spigotConfig.getConfigurationSection("commands");
/*public static boolean isIllegalItem(ItemStack item) {
//try {
@ -62,11 +54,10 @@ public final class PlayerConnection implements Listener {
}
try {
profile = event.getPlayerProfile();
profile.clearProperties();
final PlayerProfile profile = event.getPlayerProfile();
fetchSkinData(event.getName());
profile.setProperty(new ProfileProperty("textures", texture, signature));
SkinDownloader skinDownloader = new SkinDownloader();
skinDownloader.fillJoinProfile(profile, event.getName(), event.getUniqueId());
} catch (Exception ignored) {
}
}
@ -81,17 +72,18 @@ public final class PlayerConnection implements Listener {
}
}*/
@EventHandler
/*@EventHandler
void onPlayerCommandSend(final PlayerCommandSendEvent event) {
if (event.getPlayer().isOnline()) {
event.getCommands().clear();
}
}
}*/
@EventHandler
void onPlayerCommandSend2(final PreLookupProfileEvent event) {
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
event.setUUID(offlineUUID);
void onPlayerCommandSend2(final PlayerStatisticIncrementEvent event) {
//if (event.getPlayer().isOnline()) {
event.setCancelled(true);
//}
}
@EventHandler
@ -128,8 +120,28 @@ public final class PlayerConnection implements Listener {
&& event.getHostname().endsWith(":25565")) {
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");
return;
} else if (System.currentTimeMillis() - connectionMillis < 2000) {
if (!configSection.getString("tab-complete").equals("-1")) {
configSection.set("tab-complete", -1);
try {
spigotConfig.save(configFile);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spigot reload");
} catch (IOException ignored) {
}
}
} else if (configSection.getString("tab-complete").equals("-1")) {
configSection.set("tab-complete", 0);
try {
spigotConfig.save(configFile);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spigot reload");
} catch (IOException ignored) {
}
}
connectionMillis = System.currentTimeMillis();
if (!JavaPlugin.getPlugin(Main.class).getConfig().getBoolean("enableJoinRestrictions")) {
event.allow();
}
@ -142,8 +154,8 @@ public final class PlayerConnection implements Listener {
final Player player = event.getPlayer();
try {
player.setPlayerProfile(profile);
profile = null;
player.setPlayerProfile(SkinDownloader.getProfile(player.getUniqueId()));
SkinDownloader.removeProfile(player.getUniqueId());
} catch (Exception ignored) {
}
@ -153,7 +165,6 @@ public final class PlayerConnection implements Listener {
}
}
@SuppressWarnings("deprecation")
@EventHandler
void onPlayerQuit(PlayerQuitEvent event) {
PlayerCommand.commandMillisList.remove(event.getPlayer().getUniqueId());
@ -178,18 +189,9 @@ public final class PlayerConnection implements Listener {
}*/
}
private void fetchSkinData(final String playerName) throws IOException {
final URL skinUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + playerName);
HttpsURLConnection skinConnection = (HttpsURLConnection) skinUrl.openConnection();
skinConnection.setConnectTimeout(0);
InputStreamReader skinStream = new InputStreamReader(skinConnection.getInputStream());
final JsonObject responseJson = new JsonParser().parse(skinStream).getAsJsonObject();
final JsonObject rawSkin = responseJson.getAsJsonObject("textures").getAsJsonObject("raw");
texture = rawSkin.get("value").getAsString();
signature = rawSkin.get("signature").getAsString();
skinStream.close();
skinConnection.disconnect();
@EventHandler
void onPreLookupProfile(final PreLookupProfileEvent event) {
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
event.setUUID(offlineUUID);
}
}

View file

@ -44,6 +44,7 @@ public final class PlayerDamage implements Listener {
}
}
@SuppressWarnings("deprecation")
@EventHandler
void onFoodLevelChange(final FoodLevelChangeEvent event) {
final HumanEntity player = event.getEntity();

View file

@ -9,11 +9,11 @@ public final class ServerPing implements Listener {
@EventHandler
void onServerListPing(final PaperServerListPingEvent event) {
if (event.getClient().getProtocolVersion() == -1) {
final int protocol = 573;
final int protocol = 578;
event.setProtocolVersion(protocol);
} else {
event.setProtocolVersion(event.getClient().getProtocolVersion());
}
event.setVersion("1.15.1");
event.setVersion("1.15.2");
}
}