mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-27 09:55:36 -05:00
Add uncommitted changes
This commit is contained in:
parent
cad621f022
commit
edad9deb59
4 changed files with 52 additions and 58 deletions
|
@ -15,7 +15,6 @@ public class Main extends JavaPlugin {
|
|||
int fallingBlockCount;
|
||||
HashMap<UUID, Long> commandMillisList = new HashMap<>();
|
||||
HashMap<UUID, Long> interactMillisList = new HashMap<>();
|
||||
HashMap<String, PlayerProfile> playerProfile = new HashMap<>();
|
||||
HashSet<String> consoleCommandBlacklist = new HashSet<>();
|
||||
HashSet<BlockFace> faces = new HashSet<>();
|
||||
HashSet<Material> fallingBlockList = new HashSet<>();
|
||||
|
|
|
@ -25,6 +25,7 @@ class PlayerCommand implements Listener {
|
|||
final String command = event.getMessage();
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
final long millisDifference = System.currentTimeMillis() - main.commandMillisList.get(playerUuid);
|
||||
System.out.println("b " + command);
|
||||
|
||||
main.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
|
||||
|
@ -41,8 +42,11 @@ class PlayerCommand implements Listener {
|
|||
for (int i = 1; i < arr.length; i++) {
|
||||
stringBuilder.append(arr[i] + " ");
|
||||
}
|
||||
if (stringBuilder.toString().toLowerCase().contains("execute") ||
|
||||
stringBuilder.toString().toLowerCase().contains("sudo")) {
|
||||
if (stringBuilder.toString().toLowerCase().contains("run execute") ||
|
||||
stringBuilder.toString().toLowerCase().contains("run gamerule randomtickspeed") ||
|
||||
stringBuilder.toString().toLowerCase().contains("run particle") ||
|
||||
stringBuilder.toString().toLowerCase().contains("run save-off") ||
|
||||
stringBuilder.toString().toLowerCase().contains("run stop")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (("/minecraft:gamerule".equalsIgnoreCase(arr[0]) ||
|
||||
|
|
|
@ -45,38 +45,9 @@ class PlayerConnection implements Listener {
|
|||
|
||||
@EventHandler
|
||||
void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||
try {
|
||||
final URL skinUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + event.getName());
|
||||
final HttpsURLConnection premiumCheck = (HttpsURLConnection) skinUrl.openConnection();
|
||||
premiumCheck.setConnectTimeout(0);
|
||||
premiumCheck.setRequestMethod("HEAD");
|
||||
premiumCheck.setDefaultUseCaches(false);
|
||||
premiumCheck.setUseCaches(false);
|
||||
System.out.println(premiumCheck.getResponseCode());
|
||||
|
||||
if (premiumCheck.getResponseCode() == HttpsURLConnection.HTTP_OK) {
|
||||
final HttpsURLConnection skinConnection = (HttpsURLConnection) skinUrl.openConnection();
|
||||
skinConnection.setConnectTimeout(0);
|
||||
skinConnection.setDefaultUseCaches(false);
|
||||
skinConnection.setUseCaches(false);
|
||||
final InputStreamReader skinStream = new InputStreamReader(skinConnection.getInputStream());
|
||||
final JsonObject response = new JsonParser().parse(skinStream).getAsJsonObject();
|
||||
final String uuid = response.get("uuid").getAsString();
|
||||
final JsonObject rawSkin = response.getAsJsonObject("textures").getAsJsonObject("raw");
|
||||
final String texture = rawSkin.get("value").getAsString();
|
||||
final String signature = rawSkin.get("signature").getAsString();
|
||||
skinStream.close();
|
||||
skinConnection.disconnect();
|
||||
|
||||
final PlayerProfile textureProfile = event.getPlayerProfile();
|
||||
textureProfile.clearProperties();
|
||||
textureProfile.setProperty(new ProfileProperty("textures", texture, signature));
|
||||
|
||||
main.playerProfile.put(event.getName(), textureProfile);
|
||||
}
|
||||
|
||||
premiumCheck.disconnect();
|
||||
} catch (Exception exception) {
|
||||
if (event.getName().length() > 16) {
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username can't be longer than 16 characters");
|
||||
return;
|
||||
}
|
||||
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
|
@ -98,24 +69,6 @@ class PlayerConnection implements Listener {
|
|||
void onPlayerConnectionClose(final PlayerConnectionCloseEvent event) {
|
||||
main.commandMillisList.remove(event.getPlayerUniqueId());
|
||||
main.interactMillisList.remove(event.getPlayerUniqueId());
|
||||
|
||||
/*new BukkitRunnable() {
|
||||
public void run() {
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
try {
|
||||
chunk.getTileEntities(false);
|
||||
} catch (Exception exception) {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
}.runTask(main);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(main);*/
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -172,10 +125,47 @@ class PlayerConnection implements Listener {
|
|||
|
||||
event.allow();
|
||||
player.setOp(true);
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
try {
|
||||
player.setPlayerProfile(main.playerProfile.get(player.getName()));
|
||||
final URL skinUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + player.getName());
|
||||
final HttpsURLConnection premiumCheck = (HttpsURLConnection) skinUrl.openConnection();
|
||||
premiumCheck.setConnectTimeout(0);
|
||||
premiumCheck.setRequestMethod("HEAD");
|
||||
premiumCheck.setDefaultUseCaches(false);
|
||||
premiumCheck.setUseCaches(false);
|
||||
System.out.println(premiumCheck.getResponseCode());
|
||||
|
||||
if (premiumCheck.getResponseCode() == HttpsURLConnection.HTTP_OK) {
|
||||
final HttpsURLConnection skinConnection = (HttpsURLConnection) skinUrl.openConnection();
|
||||
skinConnection.setConnectTimeout(0);
|
||||
skinConnection.setDefaultUseCaches(false);
|
||||
skinConnection.setUseCaches(false);
|
||||
final InputStreamReader skinStream = new InputStreamReader(skinConnection.getInputStream());
|
||||
final JsonObject response = new JsonParser().parse(skinStream).getAsJsonObject();
|
||||
final String uuid = response.get("uuid").getAsString();
|
||||
final JsonObject rawSkin = response.getAsJsonObject("textures").getAsJsonObject("raw");
|
||||
final String texture = rawSkin.get("value").getAsString();
|
||||
final String signature = rawSkin.get("signature").getAsString();
|
||||
skinStream.close();
|
||||
skinConnection.disconnect();
|
||||
|
||||
final PlayerProfile textureProfile = player.getPlayerProfile();
|
||||
textureProfile.clearProperties();
|
||||
textureProfile.setProperty(new ProfileProperty("textures", texture, signature));
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
player.setPlayerProfile(textureProfile);
|
||||
}
|
||||
}.runTask(main);
|
||||
}
|
||||
|
||||
premiumCheck.disconnect();
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
main.playerProfile.remove(player.getName());
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ class ServerCommand implements Listener {
|
|||
void onServerCommand(ServerCommandEvent event) {
|
||||
final String[] arr = event.getCommand().split(" ");
|
||||
final String command = event.getCommand();
|
||||
System.out.println("a " + command);
|
||||
|
||||
if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
|
||||
event.setCancelled(true);
|
||||
|
|
Loading…
Reference in a new issue