mirror of
https://github.com/kaboomserver/extras.git
synced 2025-02-11 11:40:19 +00: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;
|
int fallingBlockCount;
|
||||||
HashMap<UUID, Long> commandMillisList = new HashMap<>();
|
HashMap<UUID, Long> commandMillisList = new HashMap<>();
|
||||||
HashMap<UUID, Long> interactMillisList = new HashMap<>();
|
HashMap<UUID, Long> interactMillisList = new HashMap<>();
|
||||||
HashMap<String, PlayerProfile> playerProfile = new HashMap<>();
|
|
||||||
HashSet<String> consoleCommandBlacklist = new HashSet<>();
|
HashSet<String> consoleCommandBlacklist = new HashSet<>();
|
||||||
HashSet<BlockFace> faces = new HashSet<>();
|
HashSet<BlockFace> faces = new HashSet<>();
|
||||||
HashSet<Material> fallingBlockList = new HashSet<>();
|
HashSet<Material> fallingBlockList = new HashSet<>();
|
||||||
|
|
|
@ -25,6 +25,7 @@ class PlayerCommand implements Listener {
|
||||||
final String command = event.getMessage();
|
final String command = event.getMessage();
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
final long millisDifference = System.currentTimeMillis() - main.commandMillisList.get(playerUuid);
|
final long millisDifference = System.currentTimeMillis() - main.commandMillisList.get(playerUuid);
|
||||||
|
System.out.println("b " + command);
|
||||||
|
|
||||||
main.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
main.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||||
|
|
||||||
|
@ -41,8 +42,11 @@ class PlayerCommand implements Listener {
|
||||||
for (int i = 1; i < arr.length; i++) {
|
for (int i = 1; i < arr.length; i++) {
|
||||||
stringBuilder.append(arr[i] + " ");
|
stringBuilder.append(arr[i] + " ");
|
||||||
}
|
}
|
||||||
if (stringBuilder.toString().toLowerCase().contains("execute") ||
|
if (stringBuilder.toString().toLowerCase().contains("run execute") ||
|
||||||
stringBuilder.toString().toLowerCase().contains("sudo")) {
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (("/minecraft:gamerule".equalsIgnoreCase(arr[0]) ||
|
} else if (("/minecraft:gamerule".equalsIgnoreCase(arr[0]) ||
|
||||||
|
|
|
@ -45,38 +45,9 @@ class PlayerConnection implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||||
try {
|
if (event.getName().length() > 16) {
|
||||||
final URL skinUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + event.getName());
|
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username can't be longer than 16 characters");
|
||||||
final HttpsURLConnection premiumCheck = (HttpsURLConnection) skinUrl.openConnection();
|
return;
|
||||||
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) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final World world : Bukkit.getWorlds()) {
|
for (final World world : Bukkit.getWorlds()) {
|
||||||
|
@ -98,24 +69,6 @@ class PlayerConnection implements Listener {
|
||||||
void onPlayerConnectionClose(final PlayerConnectionCloseEvent event) {
|
void onPlayerConnectionClose(final PlayerConnectionCloseEvent event) {
|
||||||
main.commandMillisList.remove(event.getPlayerUniqueId());
|
main.commandMillisList.remove(event.getPlayerUniqueId());
|
||||||
main.interactMillisList.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
|
@EventHandler
|
||||||
|
@ -172,10 +125,47 @@ class PlayerConnection implements Listener {
|
||||||
|
|
||||||
event.allow();
|
event.allow();
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
try {
|
|
||||||
player.setPlayerProfile(main.playerProfile.get(player.getName()));
|
new BukkitRunnable() {
|
||||||
} catch (Exception exception) {
|
public void run() {
|
||||||
}
|
try {
|
||||||
main.playerProfile.remove(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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(main);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ class ServerCommand implements Listener {
|
||||||
void onServerCommand(ServerCommandEvent event) {
|
void onServerCommand(ServerCommandEvent event) {
|
||||||
final String[] arr = event.getCommand().split(" ");
|
final String[] arr = event.getCommand().split(" ");
|
||||||
final String command = event.getCommand();
|
final String command = event.getCommand();
|
||||||
|
System.out.println("a " + command);
|
||||||
|
|
||||||
if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
|
if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
Loading…
Reference in a new issue