2016-04-13 05:52:53 +02:00
|
|
|
package eu.univento.core;
|
|
|
|
|
2016-08-03 00:15:45 +02:00
|
|
|
import eu.univento.commons.Commons;
|
|
|
|
import eu.univento.commons.server.TPS;
|
2016-04-13 05:52:53 +02:00
|
|
|
import eu.univento.core.api.Config;
|
2016-07-28 20:17:25 +02:00
|
|
|
import eu.univento.core.api.effects.Blackscreen;
|
2016-04-13 05:52:53 +02:00
|
|
|
import eu.univento.core.api.events.MoveEventFilter;
|
2016-09-19 17:21:39 +02:00
|
|
|
import eu.univento.core.api.items.InventoryManager;
|
2016-04-13 05:52:53 +02:00
|
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
|
|
import eu.univento.core.api.server.ServerSettings;
|
2017-04-15 13:00:58 +02:00
|
|
|
import eu.univento.core.api.update.PluginUpdater;
|
2016-07-28 20:17:25 +02:00
|
|
|
import eu.univento.core.api.utils.NettyInjection;
|
2016-04-13 05:52:53 +02:00
|
|
|
import eu.univento.core.commands.*;
|
|
|
|
import eu.univento.core.listeners.*;
|
2016-12-06 19:47:49 +01:00
|
|
|
import lombok.Getter;
|
2016-04-13 05:52:53 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.entity.Player;
|
2016-07-28 20:17:25 +02:00
|
|
|
import org.bukkit.plugin.Plugin;
|
2016-04-13 05:52:53 +02:00
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
2016-07-28 20:17:25 +02:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
2016-04-13 05:52:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* main class
|
2016-07-28 20:17:25 +02:00
|
|
|
*
|
2016-04-13 05:52:53 +02:00
|
|
|
* @author joethei
|
|
|
|
* @version 1.0
|
|
|
|
*/
|
2016-07-28 20:17:25 +02:00
|
|
|
public class Core extends JavaPlugin implements NettyInjection.PacketHandler {
|
|
|
|
|
2016-12-06 19:47:49 +01:00
|
|
|
@Getter
|
2016-07-28 20:17:25 +02:00
|
|
|
private static Core instance;
|
2016-12-06 19:47:49 +01:00
|
|
|
@Getter
|
2016-08-03 00:15:45 +02:00
|
|
|
private static Commons commons;
|
|
|
|
|
2016-07-28 20:17:25 +02:00
|
|
|
private ArrayList<String> registeredPlugins = new ArrayList<>();
|
|
|
|
|
|
|
|
public void registerPlugin(Plugin plugin) {
|
|
|
|
registeredPlugins.add(plugin.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void unregisterPlugin(Plugin plugin) {
|
|
|
|
if (registeredPlugins.contains(plugin.getName())) registeredPlugins.remove(plugin.getName());
|
2016-04-13 05:52:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-03 00:15:45 +02:00
|
|
|
public static String getNMSVersion() {
|
|
|
|
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
|
|
|
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
|
|
|
}
|
|
|
|
|
2016-07-28 20:17:25 +02:00
|
|
|
private NettyInjection injection;
|
2016-08-03 00:15:45 +02:00
|
|
|
private static List<CustomPlayer> timeout = new LinkedList<>();
|
2016-07-28 20:17:25 +02:00
|
|
|
public static List<CustomPlayer> getTimeout() {
|
|
|
|
return timeout;
|
2016-07-09 13:14:19 +02:00
|
|
|
}
|
|
|
|
|
2016-07-28 20:17:25 +02:00
|
|
|
public static Collection<CustomPlayer> getOnlinePlayers() {
|
|
|
|
Collection<CustomPlayer> list = new LinkedList<>();
|
|
|
|
for (Player players : Bukkit.getOnlinePlayers()) {
|
2016-04-13 05:52:53 +02:00
|
|
|
CustomPlayer p = CustomPlayer.getPlayer(players);
|
|
|
|
list.add(p);
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2016-07-28 20:17:25 +02:00
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
2016-08-03 00:15:45 +02:00
|
|
|
commons = new Commons();
|
|
|
|
registerPlugin(this);
|
|
|
|
commons.getLoggingHandler().getCore().info("\n" +
|
2016-06-25 15:42:06 +02:00
|
|
|
"\n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" _ _ _ \n" +
|
|
|
|
" | | | | (_) \n" +
|
|
|
|
" ___ ___ _ ____ _____ _ __ ___| |_ __ _ _ __| |_ _ _ __ __ _ \n" +
|
|
|
|
"/ __|/ _ \\ '__\\ \\ / / _ \\ '__| / __| __/ _` | '__| __| | '_ \\ / _` |\n" +
|
|
|
|
"\\__ \\ __/ | \\ V / __/ | \\__ \\ || (_| | | | |_| | | | | (_| |\n" +
|
|
|
|
"|___/\\___|_| \\_/ \\___|_| |___/\\__\\__,_|_| \\__|_|_| |_|\\__, |\n" +
|
|
|
|
" __/ |\n" +
|
|
|
|
" |___/ \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
"\n");
|
2016-07-28 20:17:25 +02:00
|
|
|
try {
|
|
|
|
Config.writeDefault();
|
2016-12-06 19:47:49 +01:00
|
|
|
} catch (IOException e) {
|
2016-07-28 20:17:25 +02:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
instance = this;
|
|
|
|
PluginManager pm = Bukkit.getPluginManager();
|
|
|
|
pm.registerEvents(new Commands(), this);
|
|
|
|
pm.registerEvents(new JoinQuit(), this);
|
|
|
|
pm.registerEvents(new Chat(), this);
|
|
|
|
pm.registerEvents(new Events(), this);
|
|
|
|
pm.registerEvents(new WeaponEvents(), this);
|
|
|
|
pm.registerEvents(new SpectatorEvents(), this);
|
|
|
|
pm.registerEvents(new MoveEventFilter(getServer()), this);
|
2016-09-19 17:21:39 +02:00
|
|
|
pm.registerEvents(new InventoryManager(), this);
|
2016-07-28 20:17:25 +02:00
|
|
|
|
|
|
|
if (ServerSettings.isGame()) {
|
|
|
|
new Fix(this, "fix", "fix your self or other players");
|
|
|
|
new Nick(this, "nick", "nick/unnick your self");
|
|
|
|
}
|
2017-04-15 13:00:58 +02:00
|
|
|
//AntiHack.registerListeners();
|
2016-07-28 20:17:25 +02:00
|
|
|
|
2016-12-06 19:47:49 +01:00
|
|
|
new RunAs(this, "RunAs", "run commands as other players");
|
2016-07-28 20:17:25 +02:00
|
|
|
new SystemInfo(this, "SystemInfo", "gives info about the server system");
|
|
|
|
new Vanish(this, "vanish", "vanish/unvanish your self");
|
|
|
|
new GameMode(this, "gamemode", "sets your gamemode", "gm");
|
|
|
|
new SetRank(this, "setrank", "sets the rank for other players", "sr");
|
|
|
|
new GlobalMute(this, "globalmute", "mutes the server");
|
|
|
|
new ChatClear(this, "chatclear", "clears the chat", "cc");
|
|
|
|
new Timeout(this, "timeout", "timeout other players");
|
2017-04-08 21:20:12 +02:00
|
|
|
new Hologram(this, "hologram", "manages holograms");
|
2016-07-28 20:17:25 +02:00
|
|
|
|
|
|
|
PluginMessenger pluginMessenger = new PluginMessenger();
|
|
|
|
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "5zig_Set");
|
|
|
|
Bukkit.getMessenger().registerIncomingPluginChannel(this, "5zig_Set", pluginMessenger);
|
|
|
|
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "LABYMOD");
|
|
|
|
Bukkit.getMessenger().registerIncomingPluginChannel(this, "WDL|INIT", pluginMessenger);
|
|
|
|
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "WDL|CONTROL");
|
|
|
|
Bukkit.getMessenger().registerIncomingPluginChannel(this, "WDL|REQUEST", pluginMessenger);
|
|
|
|
Bukkit.getMessenger().registerIncomingPluginChannel(this, "PERMISSIONSREPL", pluginMessenger);
|
|
|
|
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "schematica");
|
|
|
|
|
|
|
|
Blackscreen.setupUtil(getInstance());
|
2016-08-03 00:15:45 +02:00
|
|
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> commons.getLoggingHandler().getCore().info("\n" +
|
2016-06-25 15:42:06 +02:00
|
|
|
"\n" +
|
|
|
|
"\n" +
|
|
|
|
" _ _ \n" +
|
|
|
|
" | (_) \n" +
|
|
|
|
" ___ ___ _ ____ _____ _ __ ___ _ __ | |_ _ __ ___ \n" +
|
|
|
|
"/ __|/ _ \\ '__\\ \\ / / _ \\ '__| / _ \\| '_ \\| | | '_ \\ / _ \\\n" +
|
|
|
|
"\\__ \\ __/ | \\ V / __/ | | (_) | | | | | | | | | __/\n" +
|
|
|
|
"|___/\\___|_| \\_/ \\___|_| \\___/|_| |_|_|_|_| |_|\\___|\n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
"\n"), 0L);
|
2016-10-28 23:50:06 +02:00
|
|
|
/*
|
2016-07-28 20:17:25 +02:00
|
|
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
|
|
|
|
for (Plugin plugin : pm.getPlugins()) {
|
|
|
|
if (!plugin.getName().equalsIgnoreCase("WorldEdit") && !plugin.getName().equalsIgnoreCase("VoxelSniper") && !registeredPlugins.contains(plugin.getName())) {
|
2016-08-03 00:15:45 +02:00
|
|
|
commons.getLoggingHandler().getCore().warn("§cDas Plugin " + plugin.getName() + " ist nicht für den Server zugelassen.");
|
|
|
|
getServer().shutdown();
|
2016-07-28 20:17:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 5L);
|
2017-04-15 13:00:58 +02:00
|
|
|
|
2016-12-06 19:47:49 +01:00
|
|
|
this.injection = new NettyInjection(this, this.getName());
|
2016-07-28 20:17:25 +02:00
|
|
|
this.injection.addHandler("TIMEOUT", new NettyInjection.PacketHandler() {
|
|
|
|
public Object onPacketIn(Player sender, Channel channel, Object packet) {
|
2016-10-11 23:20:58 +02:00
|
|
|
getCommons().getLoggingHandler().getCore().info("PacketIN: " + sender.getName() + " | " + channel + " | " + packet);
|
2016-07-28 20:17:25 +02:00
|
|
|
if (timeout.contains(CustomPlayer.getPlayer(sender)))
|
|
|
|
return null;
|
|
|
|
return packet;
|
|
|
|
}
|
2016-10-11 23:20:58 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object onPacketOut(Player target, Channel channel, Object packet) {
|
|
|
|
getCommons().getLoggingHandler().getCore().info("PacketOUT: " + target.getName() + " | " + channel + " | " + packet);
|
|
|
|
return packet;
|
|
|
|
}
|
2016-07-28 20:17:25 +02:00
|
|
|
});
|
2017-04-15 13:00:58 +02:00
|
|
|
|
2016-08-03 00:15:45 +02:00
|
|
|
commons.getSecurityHandler().isValidServer(getServer().getIp(), aBoolean -> {
|
|
|
|
if(!aBoolean) {
|
|
|
|
getServer().shutdown();
|
|
|
|
}
|
|
|
|
});
|
2016-10-28 23:50:06 +02:00
|
|
|
*/
|
2016-08-03 00:15:45 +02:00
|
|
|
Bukkit.getScheduler().runTask(this, new TPS());
|
2016-07-28 20:17:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
2016-08-03 00:15:45 +02:00
|
|
|
commons.shutdown();
|
2016-07-28 20:17:25 +02:00
|
|
|
Bukkit.getMessenger().unregisterIncomingPluginChannel(this);
|
|
|
|
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this);
|
2016-05-08 10:45:34 +02:00
|
|
|
|
2017-04-15 13:00:58 +02:00
|
|
|
//this.injection.disable();
|
2016-07-28 20:17:25 +02:00
|
|
|
|
2016-08-03 00:15:45 +02:00
|
|
|
commons.getLoggingHandler().getCore().info("\n" +
|
2016-06-25 15:42:06 +02:00
|
|
|
"\n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" _ _ _ \n" +
|
|
|
|
" | | | | | | \n" +
|
|
|
|
" ___ ___ _ ____ _____ _ __ ___| |__ _ _| |_ __| | _____ ___ __ \n" +
|
|
|
|
"/ __|/ _ \\ '__\\ \\ / / _ \\ '__| / __| '_ \\| | | | __/ _` |/ _ \\ \\ /\\ / / '_ \\ \n" +
|
|
|
|
"\\__ \\ __/ | \\ V / __/ | \\__ \\ | | | |_| | || (_| | (_) \\ V V /| | | |\n" +
|
|
|
|
"|___/\\___|_| \\_/ \\___|_| |___/_| |_|\\__,_|\\__\\__,_|\\___/ \\_/\\_/ |_| |_|\n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
" \n" +
|
|
|
|
"\nd");
|
2017-04-15 13:00:58 +02:00
|
|
|
new PluginUpdater("Core").update();
|
2016-07-28 20:17:25 +02:00
|
|
|
}
|
2016-04-13 05:52:53 +02:00
|
|
|
|
|
|
|
}
|