mirror of
https://github.com/kaboomserver/extras.git
synced 2024-10-31 16:59:24 +00:00
Move lists
This commit is contained in:
parent
ca17239065
commit
91a1b47054
|
@ -1,7 +1,6 @@
|
|||
package pw.kaboom.extras;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -11,11 +10,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
static int fallingBlockCount;
|
||||
static HashSet<UUID> skinInProgress = new HashSet<>();
|
||||
static HashSet<UUID> usernameInProgress = new HashSet<>();
|
||||
static HashMap<UUID, Long> commandMillisList = new HashMap<>();
|
||||
static HashMap<UUID, Long> interactMillisList = new HashMap<>();
|
||||
|
||||
static HashSet<String> consoleCommandBlacklist = new HashSet<>();
|
||||
static HashSet<BlockFace> faces = new HashSet<>();
|
||||
|
||||
|
@ -408,7 +404,6 @@ public class Main extends JavaPlugin {
|
|||
|
||||
/* Block-related modules */
|
||||
this.getServer().getPluginManager().registerEvents(new BlockCheck(), this);
|
||||
/*new TileEntityCheck(this).runTaskTimerAsynchronously(this, 0, 400);*/
|
||||
this.getServer().getPluginManager().registerEvents(new BlockPhysics(), this);
|
||||
|
||||
/* Entity-related modules */
|
||||
|
|
|
@ -18,7 +18,7 @@ class CommandUsername implements CommandExecutor {
|
|||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <username>");
|
||||
} else if (!Main.usernameInProgress.contains(player.getUniqueId())) {
|
||||
} else if (!Main.skinInProgress.contains(player.getUniqueId())) {
|
||||
final String nameColor = ChatColor.translateAlternateColorCodes('&', String.join(" ", args));
|
||||
final String name = nameColor.substring(0, Math.min(16, nameColor.length()));
|
||||
final boolean shouldChangeUsername = true;
|
||||
|
|
|
@ -21,7 +21,7 @@ class SkinDownloader {
|
|||
private String signature;
|
||||
|
||||
public void applySkin(Player player, String name, boolean shouldChangeName, boolean shouldSendMessage) {
|
||||
Main.usernameInProgress.add(player.getUniqueId());
|
||||
Main.skinInProgress.add(player.getUniqueId());
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
|
@ -39,7 +39,7 @@ class SkinDownloader {
|
|||
}
|
||||
} else if (!shouldChangeName && shouldSendMessage) {
|
||||
player.sendMessage("A player with that username doesn't exist");
|
||||
Main.usernameInProgress.remove(player.getUniqueId());
|
||||
Main.skinInProgress.remove(player.getUniqueId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class SkinDownloader {
|
|||
player.sendMessage("Successfully set your username to \"" + name + "\"");
|
||||
}
|
||||
}
|
||||
Main.usernameInProgress.remove(player.getUniqueId());
|
||||
Main.skinInProgress.remove(player.getUniqueId());
|
||||
}
|
||||
}.runTask(JavaPlugin.getPlugin(Main.class));
|
||||
}
|
||||
|
|
|
@ -89,15 +89,17 @@ class BlockPhysics implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
int fallingBlockCount;
|
||||
|
||||
@EventHandler
|
||||
void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
if (event.getEntityType() == EntityType.FALLING_BLOCK &&
|
||||
event.getTo() == Material.AIR) {
|
||||
Main.fallingBlockCount++;
|
||||
fallingBlockCount++;
|
||||
|
||||
if (Main.fallingBlockCount == 10) {
|
||||
if (fallingBlockCount == 10) {
|
||||
event.setCancelled(true);
|
||||
Main.fallingBlockCount = 0;
|
||||
fallingBlockCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,15 +23,15 @@ class PlayerChat implements Listener {
|
|||
final Player player = event.getPlayer();
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (Main.commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - Main.commandMillisList.get(playerUuid);
|
||||
if (PlayerCommand.commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - PlayerCommand.commandMillisList.get(playerUuid);
|
||||
|
||||
if (millisDifference < 5) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Main.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
PlayerCommand.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pw.kaboom.extras;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -17,21 +18,23 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
class PlayerCommand implements Listener {
|
||||
static HashMap<UUID, Long> commandMillisList = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
final String[] arr = event.getMessage().split(" ");
|
||||
final String command = event.getMessage();
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (Main.commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - Main.commandMillisList.get(playerUuid);
|
||||
if (commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - commandMillisList.get(playerUuid);
|
||||
|
||||
if (millisDifference < 75) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Main.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
|
|
|
@ -42,9 +42,9 @@ class PlayerConnection implements Listener {
|
|||
|
||||
@EventHandler
|
||||
void onPlayerConnectionClose(final PlayerConnectionCloseEvent event) {
|
||||
Main.commandMillisList.remove(event.getPlayerUniqueId());
|
||||
Main.interactMillisList.remove(event.getPlayerUniqueId());
|
||||
Main.usernameInProgress.remove(event.getPlayerUniqueId());
|
||||
PlayerCommand.commandMillisList.remove(event.getPlayerUniqueId());
|
||||
PlayerInteract.interactMillisList.remove(event.getPlayerUniqueId());
|
||||
Main.skinInProgress.remove(event.getPlayerUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pw.kaboom.extras;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -10,19 +11,21 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
class PlayerInteract implements Listener {
|
||||
static HashMap<UUID, Long> interactMillisList = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
void onPlayerInteract(PlayerInteractEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (Main.interactMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - Main.interactMillisList.get(playerUuid);
|
||||
if (interactMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - interactMillisList.get(playerUuid);
|
||||
|
||||
if (millisDifference < 150) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Main.interactMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
interactMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue