2018-04-24 19:47:51 +03:00
|
|
|
package pw.kaboom.extras;
|
|
|
|
|
2019-07-24 04:50:19 +03:00
|
|
|
import java.util.Collections;
|
2018-05-04 16:59:39 +03:00
|
|
|
|
2020-01-04 23:17:55 +02:00
|
|
|
import com.comphenix.protocol.PacketType;
|
|
|
|
import com.comphenix.protocol.ProtocolLibrary;
|
|
|
|
import com.comphenix.protocol.events.ListenerPriority;
|
|
|
|
import com.comphenix.protocol.events.PacketAdapter;
|
|
|
|
import com.comphenix.protocol.events.PacketEvent;
|
2019-07-25 20:33:46 +03:00
|
|
|
import org.bukkit.block.BlockFace;
|
2018-04-24 19:47:51 +03:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2019-12-21 20:32:58 +02:00
|
|
|
import pw.kaboom.extras.commands.*;
|
2019-12-17 20:23:24 +02:00
|
|
|
import pw.kaboom.extras.modules.block.BlockCheck;
|
|
|
|
import pw.kaboom.extras.modules.block.BlockPhysics;
|
|
|
|
import pw.kaboom.extras.modules.entity.EntityExplosion;
|
|
|
|
import pw.kaboom.extras.modules.entity.EntityKnockback;
|
|
|
|
import pw.kaboom.extras.modules.entity.EntitySpawn;
|
|
|
|
import pw.kaboom.extras.modules.entity.EntityTeleport;
|
|
|
|
import pw.kaboom.extras.modules.player.PlayerChat;
|
|
|
|
import pw.kaboom.extras.modules.player.PlayerCommand;
|
|
|
|
import pw.kaboom.extras.modules.player.PlayerConnection;
|
|
|
|
import pw.kaboom.extras.modules.player.PlayerDamage;
|
|
|
|
import pw.kaboom.extras.modules.player.PlayerInteract;
|
|
|
|
import pw.kaboom.extras.modules.player.PlayerTeleport;
|
|
|
|
import pw.kaboom.extras.modules.server.ServerCommand;
|
|
|
|
import pw.kaboom.extras.modules.server.ServerPing;
|
2019-07-24 02:01:02 +03:00
|
|
|
|
2019-12-21 16:12:26 +02:00
|
|
|
public final class Main extends JavaPlugin {
|
2019-12-17 20:23:24 +02:00
|
|
|
@Override
|
2019-07-30 20:14:24 +03:00
|
|
|
public void onLoad() {
|
|
|
|
/* Fill lists */
|
2019-12-03 06:53:37 +02:00
|
|
|
Collections.addAll(
|
2019-12-17 20:23:24 +02:00
|
|
|
BlockPhysics.blockFaces,
|
2019-12-03 06:53:37 +02:00
|
|
|
BlockFace.NORTH,
|
|
|
|
BlockFace.SOUTH,
|
|
|
|
BlockFace.WEST,
|
|
|
|
BlockFace.EAST,
|
|
|
|
BlockFace.UP
|
|
|
|
);
|
2019-12-14 23:31:28 +02:00
|
|
|
|
|
|
|
/* Load missing config.yml defaults */
|
|
|
|
getConfig().options().copyDefaults(true);
|
|
|
|
saveConfig();
|
2019-07-30 20:14:24 +03:00
|
|
|
}
|
2018-12-19 22:10:03 +02:00
|
|
|
|
2019-12-17 20:23:24 +02:00
|
|
|
@Override
|
2019-07-30 20:14:24 +03:00
|
|
|
public void onEnable() {
|
|
|
|
/* Commands */
|
2020-02-26 22:20:13 +02:00
|
|
|
this.getCommand("broadcastvanilla").setExecutor(new CommandBroadcastVanilla());
|
2018-05-28 18:27:30 +03:00
|
|
|
this.getCommand("clearchat").setExecutor(new CommandClearChat());
|
|
|
|
this.getCommand("console").setExecutor(new CommandConsole());
|
|
|
|
this.getCommand("destroyentities").setExecutor(new CommandDestroyEntities());
|
|
|
|
this.getCommand("enchantall").setExecutor(new CommandEnchantAll());
|
|
|
|
this.getCommand("jumpscare").setExecutor(new CommandJumpscare());
|
2019-12-21 20:32:58 +02:00
|
|
|
this.getCommand("kaboom").setExecutor(new CommandKaboom());
|
2019-09-28 03:29:48 +03:00
|
|
|
this.getCommand("prefix").setExecutor(new CommandPrefix());
|
2019-07-16 15:56:19 +03:00
|
|
|
this.getCommand("pumpkin").setExecutor(new CommandPumpkin());
|
2019-10-15 03:03:27 +03:00
|
|
|
this.getCommand("serverinfo").setExecutor(new CommandServerInfo());
|
2019-09-28 03:29:48 +03:00
|
|
|
this.getCommand("skin").setExecutor(new CommandSkin());
|
2018-04-24 19:47:51 +03:00
|
|
|
this.getCommand("spawn").setExecutor(new CommandSpawn());
|
2019-07-16 15:56:19 +03:00
|
|
|
this.getCommand("spidey").setExecutor(new CommandSpidey());
|
2018-04-24 19:47:51 +03:00
|
|
|
this.getCommand("tellraw").setExecutor(new CommandTellraw());
|
2018-05-28 18:27:30 +03:00
|
|
|
this.getCommand("unloadchunks").setExecutor(new CommandUnloadChunks());
|
2019-09-28 03:29:48 +03:00
|
|
|
this.getCommand("username").setExecutor(new CommandUsername());
|
2018-04-24 19:47:51 +03:00
|
|
|
|
2020-01-04 23:17:55 +02:00
|
|
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
|
|
|
@Override
|
|
|
|
public void onPacketReceiving(PacketEvent event) {
|
|
|
|
final int maxInventorySize = 46;
|
|
|
|
if (event.getPacket().getIntegers().read(1) > maxInventorySize ||
|
|
|
|
event.getPacket().getIntegers().read(1) < 0) {
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-30 20:14:24 +03:00
|
|
|
/* Block-related modules */
|
2019-09-28 03:29:48 +03:00
|
|
|
this.getServer().getPluginManager().registerEvents(new BlockCheck(), this);
|
|
|
|
this.getServer().getPluginManager().registerEvents(new BlockPhysics(), this);
|
2019-07-30 20:14:24 +03:00
|
|
|
|
|
|
|
/* Entity-related modules */
|
|
|
|
this.getServer().getPluginManager().registerEvents(new EntityExplosion(), this);
|
|
|
|
this.getServer().getPluginManager().registerEvents(new EntityKnockback(), this);
|
|
|
|
this.getServer().getPluginManager().registerEvents(new EntitySpawn(), this);
|
2019-12-15 02:09:29 +02:00
|
|
|
this.getServer().getPluginManager().registerEvents(new EntityTeleport(), this);
|
2019-07-30 20:14:24 +03:00
|
|
|
|
|
|
|
/* Player-related modules */
|
2019-09-28 03:29:48 +03:00
|
|
|
this.getServer().getPluginManager().registerEvents(new PlayerChat(), this);
|
|
|
|
this.getServer().getPluginManager().registerEvents(new PlayerCommand(), this);
|
|
|
|
this.getServer().getPluginManager().registerEvents(new PlayerConnection(), this);
|
2019-07-30 20:14:24 +03:00
|
|
|
this.getServer().getPluginManager().registerEvents(new PlayerDamage(), this);
|
2019-09-28 03:29:48 +03:00
|
|
|
this.getServer().getPluginManager().registerEvents(new PlayerInteract(), this);
|
2019-12-15 02:09:29 +02:00
|
|
|
this.getServer().getPluginManager().registerEvents(new PlayerTeleport(), this);
|
2019-07-30 20:14:24 +03:00
|
|
|
|
|
|
|
/* Server-related modules */
|
2019-09-28 03:29:48 +03:00
|
|
|
this.getServer().getPluginManager().registerEvents(new ServerCommand(), this);
|
2019-07-30 20:14:24 +03:00
|
|
|
this.getServer().getPluginManager().registerEvents(new ServerPing(), this);
|
2018-04-24 19:47:51 +03:00
|
|
|
}
|
|
|
|
}
|