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 041 public PaperPluginCore(final JavaPlugin plugin, final PluginEngine engine, final TranslationProvider provider, 042 final CallbackProvider callbackProvider) { 043 044 this(plugin, engine, new PaperServerProvider(), provider, callbackProvider); 045 } 046 047 public PaperPluginCore(final JavaPlugin plugin, final PluginEngine engine, final ServerConnector connector, 048 final TranslationProvider provider, final CallbackProvider callbackProvider) { 049 050 super(engine, connector, new PaperLogProvider(plugin.getLogger()), provider, callbackProvider, Platform.PAPER, 051 Bukkit.getServer().getBukkitVersion().split("-")[0]); 052 053 setInstance(this); 054 this.plugin = plugin; 055 } 056 057 public static PaperPluginCore instance() { 058 059 return (PaperPluginCore)PluginCore.instance(); 060 } 061 062 @Override 063 protected void onLoad() { 064 065 this.directory = plugin.getDataFolder(); 066 067 super.onLoad(); 068 } 069 070 /** 071 * Used to enable the core. This should contain things that can't be initialized until after the 072 * server software is operational. 073 */ 074 @Override 075 protected void onEnable() { 076 077 super.onEnable(); 078 } 079 080 public JavaPlugin getPlugin() { 081 082 return plugin; 083 } 084}