From c621048014ada4b03f1a6b5744a775ba4105ff04 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Thu, 29 Feb 2024 11:00:56 +0100 Subject: [PATCH] Removed old iterators --- .../tracer/record/TNTPrimedIterator15.java | 39 ---------------- .../tracer/record/TNTPrimedIterator18.java | 46 ------------------- 2 files changed, 85 deletions(-) delete mode 100644 BauSystem_15/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator15.java delete mode 100644 BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator15.java b/BauSystem_15/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator15.java deleted file mode 100644 index 36c53f40..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator15.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.bausystem.features.tracer.record; - -import net.minecraft.server.v1_15_R1.EntityTNTPrimed; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; -import org.bukkit.entity.TNTPrimed; - -import java.util.stream.Stream; - -public class TNTPrimedIterator15 implements TNTPrimedIterator { - - private static final CraftWorld WORLD = (CraftWorld) Bukkit.getWorlds().get(0); - - @Override - public Stream iterator() { - return WORLD.getHandle().entitiesById.values().stream() - .filter(EntityTNTPrimed.class::isInstance) - .map(entity -> (TNTPrimed) entity.getBukkitEntity()); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java b/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java deleted file mode 100644 index 0df69fb9..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.bausystem.features.tracer.record; - -import com.comphenix.tinyprotocol.Reflection; -import net.minecraft.server.level.WorldServer; -import net.minecraft.world.level.entity.LevelEntityGetter; -import org.bukkit.Bukkit; -import org.bukkit.entity.TNTPrimed; - -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -public class TNTPrimedIterator18 implements TNTPrimedIterator { - - private static final Reflection.MethodInvoker getWorld = Reflection.getMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle"); - private static final Reflection.MethodInvoker getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class); - private static final Reflection.MethodInvoker getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class); - private static final Reflection.MethodInvoker getBukkitEntity = Reflection.getTypedMethod(Reflection.getClass("{nms.world.entity}.Entity"), "getBukkitEntity", null); - - @Override - public Stream iterator() { - return StreamSupport.stream(((Iterable) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Bukkit.getWorlds().get(0))))).spliterator(), false) - .map(getBukkitEntity::invoke) - .filter(TNTPrimed.class::isInstance) - .map(TNTPrimed.class::cast); - } -} -