From 8cd9764e9df5f5e22988d2ecb92fcae2a0f3fc13 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 24 Feb 2023 17:01:29 +0100 Subject: [PATCH] Supress Recipe Discover popup --- .../core/RecipeDiscoverWrapper14.java | 30 +++++++++++++++++++ .../steamwar/core/RecipeDiscoverWrapper8.java | 24 +++++++++++++++ .../src/de/steamwar/core/Core.java | 24 ++++++++------- .../steamwar/core/RecipeDiscoverWrapper.java | 26 ++++++++++++++++ 4 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 SpigotCore_14/src/de/steamwar/core/RecipeDiscoverWrapper14.java create mode 100644 SpigotCore_8/src/de/steamwar/core/RecipeDiscoverWrapper8.java create mode 100644 SpigotCore_Main/src/de/steamwar/core/RecipeDiscoverWrapper.java diff --git a/SpigotCore_14/src/de/steamwar/core/RecipeDiscoverWrapper14.java b/SpigotCore_14/src/de/steamwar/core/RecipeDiscoverWrapper14.java new file mode 100644 index 0000000..93e050d --- /dev/null +++ b/SpigotCore_14/src/de/steamwar/core/RecipeDiscoverWrapper14.java @@ -0,0 +1,30 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerRecipeDiscoverEvent; + +public class RecipeDiscoverWrapper14 implements RecipeDiscoverWrapper { + @EventHandler + public void onRecipeDiscover(PlayerRecipeDiscoverEvent e) { + e.setCancelled(true); + } +} diff --git a/SpigotCore_8/src/de/steamwar/core/RecipeDiscoverWrapper8.java b/SpigotCore_8/src/de/steamwar/core/RecipeDiscoverWrapper8.java new file mode 100644 index 0000000..59faa4c --- /dev/null +++ b/SpigotCore_8/src/de/steamwar/core/RecipeDiscoverWrapper8.java @@ -0,0 +1,24 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +public class RecipeDiscoverWrapper8 implements RecipeDiscoverWrapper { + // Event not available pre flattening +} diff --git a/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore_Main/src/de/steamwar/core/Core.java index d1e6949..7d3a30d 100644 --- a/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -31,6 +31,7 @@ import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.internal.Statement; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; import java.io.BufferedReader; @@ -81,32 +82,33 @@ public class Core extends JavaPlugin{ return tabCompleter.apply(sender, s); } }); - Bukkit.getScheduler().runTaskTimer(this, TabCompletionCache::invalidateOldEntries, 20, 20); - Bukkit.getPluginManager().registerEvents(new CaseInsensitiveCommandsListener(), this); - Bukkit.getPluginManager().registerEvents(new PlayerJoinedEvent(), this); - Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this); - Bukkit.getPluginManager().registerEvents(new WorldLoadEvent(), this); - if(!Statement.productionDatabase()) { - Bukkit.getPluginManager().registerEvents(LocaleChangeWrapper.impl, this); + for(Listener listener : new Listener[]{new CaseInsensitiveCommandsListener(), new PlayerJoinedEvent(), new ChattingEvent(), new WorldLoadEvent(), RecipeDiscoverWrapper.impl}) { + getServer().getPluginManager().registerEvents(listener, this); } + if(!Statement.productionDatabase()) { + getServer().getPluginManager().registerEvents(LocaleChangeWrapper.impl, this); + } + getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver()); getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge"); + if(Core.getVersion() < 19) AuthlibInjector.inject(); - TinyProtocol.init(); + TinyProtocol.init(); new AntiNocom(); if(Core.getVersion() < 17 && Bukkit.getPluginManager().getPlugin("ViaVersion") != null) new PartialChunkFixer(); - Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SteamwarUser::clear, 72000, 72000); - Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SchematicNode::clear, 20L * 30, 20L * 30); - if(Core.getVersion() >= 19) new ServerDataHandler(); + Bukkit.getScheduler().runTaskTimer(this, TabCompletionCache::invalidateOldEntries, 20, 20); + Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SteamwarUser::clear, 72000, 72000); + Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SchematicNode::clear, 20L * 30, 20L * 30); + try { getLogger().log(Level.INFO, "Running on: " + new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("hostname").getInputStream())).readLine()); } catch (IOException e) { diff --git a/SpigotCore_Main/src/de/steamwar/core/RecipeDiscoverWrapper.java b/SpigotCore_Main/src/de/steamwar/core/RecipeDiscoverWrapper.java new file mode 100644 index 0000000..0d6b9da --- /dev/null +++ b/SpigotCore_Main/src/de/steamwar/core/RecipeDiscoverWrapper.java @@ -0,0 +1,26 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import org.bukkit.event.Listener; + +public interface RecipeDiscoverWrapper extends Listener { + RecipeDiscoverWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); +}