001package net.tnemc.plugincore.paper; 002/* 003 * The New Plugin Core 004 * Copyright (C) 2022 - 2024 Daniel "creatorfromhell" Vidmar 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU Affero General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU Affero General Public License for more details. 015 * 016 * You should have received a copy of the GNU Affero General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 */ 019 020import net.tnemc.plugincore.PluginCore; 021import net.tnemc.plugincore.core.Platform; 022import net.tnemc.plugincore.core.PluginEngine; 023import net.tnemc.plugincore.core.api.CallbackProvider; 024import net.tnemc.plugincore.core.compatibility.ServerConnector; 025import net.tnemc.plugincore.core.io.message.TranslationProvider; 026import net.tnemc.plugincore.paper.impl.PaperLogProvider; 027import net.tnemc.plugincore.paper.impl.PaperServerProvider; 028import org.bukkit.Bukkit; 029import org.bukkit.plugin.java.JavaPlugin; 030 031/** 032 * PaperPluginCore 033 * 034 * @author creatorfromhell 035 * @since 0.0.1.0 036 */ 037public class PaperPluginCore extends PluginCore { 038 039 private final JavaPlugin plugin; 040 public PaperPluginCore(final JavaPlugin plugin, final PluginEngine engine, final TranslationProvider provider, 041 final CallbackProvider callbackProvider) { 042 this(plugin, engine, new PaperServerProvider(), provider, callbackProvider); 043 } 044 045 public PaperPluginCore(final JavaPlugin plugin, final PluginEngine engine, final ServerConnector connector, 046 final TranslationProvider provider, final CallbackProvider callbackProvider) { 047 048 super(engine, connector, new PaperLogProvider(plugin.getLogger()), provider, callbackProvider, Platform.PAPER, 049 Bukkit.getServer().getBukkitVersion().split("-")[0]); 050 051 setInstance(this); 052 this.plugin = plugin; 053 } 054 055 /** 056 * Used to enable the core. This should contain things that can't be initialized until after the 057 * server software is operational. 058 */ 059 @Override 060 protected void onEnable() { 061 this.directory = plugin.getDataFolder(); 062 063 super.onEnable(); 064 } 065 066 public static PaperPluginCore instance() { 067 return (PaperPluginCore)PluginCore.instance(); 068 } 069 070 public JavaPlugin getPlugin() { 071 return plugin; 072 } 073}