mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-23 16:08:18 -05:00
Push wip
This commit is contained in:
parent
eb77c8e47a
commit
f4a175bfa7
2 changed files with 59 additions and 41 deletions
|
@ -55,6 +55,8 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||||
|
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -165,6 +167,12 @@ class Events implements Listener {
|
||||||
event.setMessage(ChatColor.translateAlternateColorCodes('&', event.getMessage()));
|
event.setMessage(ChatColor.translateAlternateColorCodes('&', event.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||||
|
main.commandMillisList.put(event.getUniqueId(), System.currentTimeMillis());
|
||||||
|
main.interactMillisList.put(event.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockPhysics(BlockPhysicsEvent event) {
|
void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
@ -418,6 +426,21 @@ class Events implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*@EventHandler
|
||||||
|
void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
int length = 0;
|
||||||
|
for (ItemStack itemStack : event.getClickedInventory().getContents()) {
|
||||||
|
if (itemStack != null) {
|
||||||
|
length = length + itemStack.toString().length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("inventory");
|
||||||
|
System.out.println(length);
|
||||||
|
if (length > 100000) {
|
||||||
|
event.getClickedInventory().clear();
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onItemSpawn(ItemSpawnEvent event) {
|
void onItemSpawn(ItemSpawnEvent event) {
|
||||||
ItemStack item = event.getEntity().getItemStack();
|
ItemStack item = event.getEntity().getItemStack();
|
||||||
|
@ -491,30 +514,9 @@ class Events implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerJoin(PlayerJoinEvent event) {
|
void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(main, new Runnable() {
|
player.getInventory().clear();
|
||||||
public void run() {
|
|
||||||
main.getSkin(player.getName(), player);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (player.getInventory().getContents().length != 0) {
|
|
||||||
System.out.println("hm");
|
|
||||||
for (ItemStack item : player.getInventory().getContents()) {
|
|
||||||
if (item != null) {
|
|
||||||
try {
|
|
||||||
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.sendTitle(ChatColor.GRAY + "Welcome to Kaboom!", "Free OP • Anarchy • Creative", 10, 160, 5);
|
player.sendTitle(ChatColor.GRAY + "Welcome to Kaboom!", "Free OP • Anarchy • Creative", 10, 160, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,6 +527,8 @@ class Events implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerLogin(PlayerLoginEvent event) {
|
void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Bukkit.getOnlinePlayers().size() > 30) {
|
if (Bukkit.getOnlinePlayers().size() > 30) {
|
||||||
if (main.onlineCount == 5) {
|
if (main.onlineCount == 5) {
|
||||||
event.allow();
|
event.allow();
|
||||||
|
@ -533,13 +537,20 @@ 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") &&
|
/*} else if (!(event.getHostname().startsWith("play.kaboom.pw") &&
|
||||||
event.getHostname().endsWith(":64518"))) {
|
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");
|
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() + "\"");
|
|
||||||
|
player.setOp(true);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(main, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
main.getSkin(player.getName(), player);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
|
@ -3,11 +3,11 @@ package pw.kaboom.extras;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||||
|
@ -453,22 +453,28 @@ public class Main extends JavaPlugin {
|
||||||
|
|
||||||
public void getSkin(String name, final 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();
|
HttpsURLConnection nameConnection = (HttpsURLConnection) nameUrl.openConnection();
|
||||||
|
|
||||||
if (nameconnection.getResponseCode() == 200) {
|
if (nameConnection.getResponseCode() == HttpsURLConnection.HTTP_OK) {
|
||||||
InputStreamReader namestream = new InputStreamReader(nameconnection.getInputStream());
|
System.out.println("ok");
|
||||||
String uuid = new JsonParser().parse(namestream).getAsJsonObject().get("id").getAsString();
|
InputStreamReader nameStream = new InputStreamReader(nameConnection.getInputStream());
|
||||||
URL uuidurl = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
|
String uuid = new JsonParser().parse(nameStream).getAsJsonObject().get("id").getAsString();
|
||||||
HttpURLConnection uuidconnection = (HttpURLConnection) uuidurl.openConnection();
|
nameStream.close();
|
||||||
|
nameConnection.disconnect();
|
||||||
|
|
||||||
if (uuidconnection.getResponseCode() == 200) {
|
URL uuidUrl = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
|
||||||
InputStreamReader uuidstream = new InputStreamReader(uuidconnection.getInputStream());
|
HttpsURLConnection uuidConnection = (HttpsURLConnection) uuidUrl.openConnection();
|
||||||
JsonObject response = new JsonParser().parse(uuidstream).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
|
|
||||||
|
if (uuidConnection.getResponseCode() == HttpsURLConnection.HTTP_OK) {
|
||||||
|
InputStreamReader uuidStream = new InputStreamReader(uuidConnection.getInputStream());
|
||||||
|
JsonObject response = new JsonParser().parse(uuidStream).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
|
||||||
final String texture = response.get("value").getAsString();
|
final String texture = response.get("value").getAsString();
|
||||||
final String signature = response.get("signature").getAsString();
|
final String signature = response.get("signature").getAsString();
|
||||||
|
uuidStream.close();
|
||||||
|
uuidConnection.disconnect();
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
Bukkit.getScheduler().runTask(this, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PlayerProfile textureprofile = player.getPlayerProfile();
|
PlayerProfile textureprofile = player.getPlayerProfile();
|
||||||
|
@ -476,12 +482,13 @@ public class Main extends JavaPlugin {
|
||||||
player.setPlayerProfile(textureprofile);
|
player.setPlayerProfile(textureprofile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
uuidConnection.disconnect();
|
||||||
}
|
}
|
||||||
uuidconnection.disconnect();
|
} else {
|
||||||
|
nameConnection.disconnect();
|
||||||
}
|
}
|
||||||
nameconnection.disconnect();
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue