Commits vergleichen
9 Commits
master
...
BetterSche
Autor | SHA1 | Datum | |
---|---|---|---|
|
b17cd9acda | ||
|
42f8a044a4 | ||
|
176ee5e0cf | ||
|
fb4d803d92 | ||
|
c36e6f5d43 | ||
|
6fedbac3f9 | ||
|
7494b8abea | ||
|
3eeca6c349 | ||
|
91abbc25fc |
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,7 +1,5 @@
|
||||
# Build files
|
||||
# Package Files
|
||||
*.jar
|
||||
**/bin
|
||||
**/build
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
@ -12,10 +10,6 @@ steamwar.properties
|
||||
# IntelliJ IDEA
|
||||
.idea
|
||||
*.iml
|
||||
plugin.yml
|
||||
|
||||
# Other
|
||||
lib
|
||||
|
||||
#linkage
|
||||
LinkageUtils.java
|
@ -27,8 +27,8 @@ version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class DetonatorEntity15 extends EntityFallingBlock implements AbstractDetonatorEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
private final Vector position;
|
||||
private int references = 0;
|
||||
|
||||
public DetonatorEntity15(World world, Vector position) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.RED_STAINED_GLASS.getBlockData());
|
||||
this.position = position;
|
||||
|
||||
this.h(true);
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (references++ > 0)
|
||||
return;
|
||||
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.getCombinedId(Blocks.RED_STAINED_GLASS.getBlockData()), ZERO);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||
playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && --references > 0)
|
||||
return false;
|
||||
|
||||
sendDestroy(player);
|
||||
die();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntity(Player player) {
|
||||
display(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntityDestroy(Player player) {
|
||||
hide(player, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
||||
import de.steamwar.bausystem.shared.BaseEntity15;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SimulatorEntity15 extends BaseEntity15 implements AbstractSimulatorEntity {
|
||||
|
||||
private boolean printed = false;
|
||||
|
||||
public SimulatorEntity15(World world, Vector position, boolean highlight) {
|
||||
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
||||
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (printed) return;
|
||||
printed = true;
|
||||
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector position) {
|
||||
this.position = position;
|
||||
setPosition(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!printed) return false;
|
||||
printed = false;
|
||||
|
||||
|
||||
sendEntityDestroy(player);
|
||||
die();
|
||||
return true;
|
||||
}
|
||||
}
|
73
BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java
Normale Datei
73
BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java
Normale Datei
@ -0,0 +1,73 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
|
||||
import de.steamwar.bausystem.shared.BaseEntity15;
|
||||
import de.steamwar.bausystem.shared.ReferenceCounter;
|
||||
import net.minecraft.server.v1_15_R1.ChatComponentText;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TraceEntity15 extends BaseEntity15 implements AbstractTraceEntity {
|
||||
|
||||
private boolean exploded = false;
|
||||
private ReferenceCounter referenceCounter = new ReferenceCounter();
|
||||
|
||||
public TraceEntity15(World world, Vector position, boolean tnt) {
|
||||
super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS);
|
||||
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player, boolean exploded, int ticks) {
|
||||
if (ticks != -1) {
|
||||
this.setCustomNameVisible(true);
|
||||
this.setCustomName(new ChatComponentText(ticks + ""));
|
||||
}
|
||||
if (!this.exploded && exploded) {
|
||||
this.setCustomNameVisible(true);
|
||||
this.setCustomName(new ChatComponentText("Bumm"));
|
||||
this.exploded = true;
|
||||
if (referenceCounter.increment() > 0) {
|
||||
sendEntityDestroy(player);
|
||||
}
|
||||
} else if (referenceCounter.increment() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && referenceCounter.decrement() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendEntityDestroy(player);
|
||||
die();
|
||||
return true;
|
||||
}
|
||||
}
|
80
BauSystem_15/src/de/steamwar/bausystem/entities/WarpEntity15.java
Normale Datei
80
BauSystem_15/src/de/steamwar/bausystem/entities/WarpEntity15.java
Normale Datei
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
|
||||
import de.steamwar.bausystem.shared.BaseArmorStand15;
|
||||
import net.minecraft.server.v1_15_R1.ChatComponentText;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_15_R1.PlayerConnection;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class WarpEntity15 extends BaseArmorStand15 implements AbstractWarpEntity {
|
||||
|
||||
public WarpEntity15(World world, Vector position, String name) {
|
||||
super(world, position);
|
||||
setInvisible(true);
|
||||
setSmall(true);
|
||||
setName(name);
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.setCustomNameVisible(true);
|
||||
this.setCustomName(new ChatComponentText(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player) {
|
||||
sendEntityDestroy(player);
|
||||
die();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMetaData(Player player) {
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Player player, Vector position) {
|
||||
setPositionRaw(position.getX(), position.getY(), position.getZ());
|
||||
PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityTeleport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getPosition() {
|
||||
return new Vector(locX(), locY(), locZ());
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* 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
|
||||
@ -17,18 +17,14 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.killchecker;
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Cuboid {
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private double dx;
|
||||
private double dy;
|
||||
private double dz;
|
||||
public class SimulatorPreview15 implements SimulatorPreview {
|
||||
|
||||
@Override
|
||||
public Record simulate(TNTSimulator tntSimulator) {
|
||||
return new Record(null);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<TNTPrimed> iterator() {
|
||||
return WORLD.getHandle().entitiesById.values().stream()
|
||||
.filter(EntityTNTPrimed.class::isInstance)
|
||||
.map(entity -> (TNTPrimed) entity.getBukkitEntity());
|
||||
}
|
||||
}
|
56
BauSystem_15/src/de/steamwar/bausystem/shared/BaseArmorStand15.java
Normale Datei
56
BauSystem_15/src/de/steamwar/bausystem/shared/BaseArmorStand15.java
Normale Datei
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.shared;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BaseArmorStand15 extends EntityArmorStand implements AbstractEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
|
||||
protected Vector position;
|
||||
|
||||
public BaseArmorStand15(World world, Vector position) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ());
|
||||
|
||||
this.position = position;
|
||||
setNoGravity(true);
|
||||
ticksLived = -12000;
|
||||
}
|
||||
|
||||
public void sendEntity(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.ARMOR_STAND, 0, ZERO);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||
playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
public void sendEntityDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
}
|
||||
}
|
60
BauSystem_15/src/de/steamwar/bausystem/shared/BaseEntity15.java
Normale Datei
60
BauSystem_15/src/de/steamwar/bausystem/shared/BaseEntity15.java
Normale Datei
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.shared;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BaseEntity15 extends EntityFallingBlock implements AbstractEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
|
||||
private final IBlockData iBlockData;
|
||||
protected Vector position;
|
||||
|
||||
public BaseEntity15(World world, Vector position, Material blockType) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState());
|
||||
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
|
||||
this.position = position;
|
||||
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
}
|
||||
|
||||
public void sendEntity(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.getCombinedId(iBlockData), ZERO);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||
playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
public void sendEntityDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
}
|
||||
}
|
@ -37,11 +37,14 @@ import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.bausystem.region.Color;
|
||||
import de.steamwar.bausystem.region.PasteOptions;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -57,12 +60,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
@ -106,55 +104,61 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
|
||||
private static final WorldEditPlugin WORLDEDIT_PLUGIN = Objects.requireNonNull((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
||||
private static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
|
||||
@Override
|
||||
public void setSelection(Player p, Point minPoint, Point maxPoint) {
|
||||
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toBlockVector3(minPoint), toBlockVector3(maxPoint)));
|
||||
}
|
||||
|
||||
private static final BaseBlock WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock WOOL2 = Objects.requireNonNull(BlockTypes.YELLOW_WOOL).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock CLAY = Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock CLAY2 = Objects.requireNonNull(BlockTypes.YELLOW_TERRACOTTA).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock GLAZED = Objects.requireNonNull(BlockTypes.PINK_GLAZED_TERRACOTTA).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock GLASS = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock GLASS2 = Objects.requireNonNull(BlockTypes.YELLOW_STAINED_GLASS).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock GLASS_PANE = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock GLASS_PANE2 = Objects.requireNonNull(BlockTypes.YELLOW_STAINED_GLASS_PANE).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock CONCRETE = Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock CONCRETE2 = Objects.requireNonNull(BlockTypes.YELLOW_CONCRETE).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock CONCRETE_POWDER = Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock CARPET = Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock();
|
||||
|
||||
@Override
|
||||
public Clipboard loadSchematic(File file) {
|
||||
public EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
|
||||
Clipboard clipboard;
|
||||
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
|
||||
clipboard = reader.read();
|
||||
} catch (NullPointerException | IOException e) {
|
||||
throw new SecurityException("Bausystem schematic not found", e);
|
||||
}
|
||||
return clipboard;
|
||||
|
||||
EditSession editSession = paste(clipboard, pastePoint, pasteOptions);
|
||||
return editSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditSession paste(PasteBuilder pasteBuilder) {
|
||||
public EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
|
||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||
Clipboard clipboard = pasteBuilder.getClipboard();
|
||||
if (pasteOptions.getColor() != Color.YELLOW) {
|
||||
changeColor(clipboard, pasteOptions.getColor());
|
||||
}
|
||||
if (pasteOptions.isOnlyColors()) {
|
||||
Set<String> blocks = new HashSet<>();
|
||||
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_wool");
|
||||
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_terracotta");
|
||||
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_glazed_terracotta");
|
||||
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_stained_glass");
|
||||
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_stained_glass_pane");
|
||||
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_concrete");
|
||||
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_concrete_powder");
|
||||
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_carpet");
|
||||
|
||||
if (!pasteBuilder.getMappers().isEmpty()) {
|
||||
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
|
||||
for (int x = 0; x < clipboard.getDimensions().getX(); x++) {
|
||||
for (int y = 0; y < clipboard.getDimensions().getY(); y++) {
|
||||
for (int z = 0; z < clipboard.getDimensions().getZ(); z++) {
|
||||
BlockVector3 pos = minimum.add(x, y, z);
|
||||
pasteBuilder.getMappers().forEach(mapper -> mapper.accept(clipboard, pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AtomicReference<BlockVector3> pastePoint = new AtomicReference<>();
|
||||
if (!pasteBuilder.getPredicates().isEmpty()) {
|
||||
e.setMask(new Mask() {
|
||||
@Override
|
||||
public boolean test(BlockVector3 blockVector3) {
|
||||
BaseBlock block = clipboard.getFullBlock(blockVector3.subtract(pastePoint.get()).add(clipboard.getRegion().getMinimumPoint()));
|
||||
String blockName = block.getBlockType().toString().toLowerCase();
|
||||
for (BiPredicate<BaseBlock, String> predicate : pasteBuilder.getPredicates()) {
|
||||
if (!predicate.test(block, blockName)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Mask copy() {
|
||||
return this;
|
||||
BaseBlock block = clipboard.getFullBlock(blockVector3);
|
||||
String blockName = block.toString().toLowerCase();
|
||||
return blocks.contains(blockName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -162,28 +166,31 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Mask copy() {
|
||||
return this;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||
BlockVector3 dimensions = clipboard.getDimensions();
|
||||
BlockVector3 v = BlockVector3.at(pasteBuilder.getPastPoint().getX(), pasteBuilder.getPastPoint().getY(), pasteBuilder.getPastPoint().getZ());
|
||||
BlockVector3 v = BlockVector3.at(pastePoint.getX(), pastePoint.getY(), pastePoint.getZ());
|
||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
if (pasteBuilder.isRotate()) {
|
||||
if (pasteOptions.isRotate()) {
|
||||
ch.setTransform(new AffineTransform().rotateY(180));
|
||||
v = v.add(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset.multiply(-1, 1, -1)).subtract(0, 0, 1);
|
||||
} else {
|
||||
v = v.subtract(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset);
|
||||
}
|
||||
pastePoint.set(v);
|
||||
|
||||
if (pasteBuilder.isReset()) {
|
||||
e.setBlocks(new CuboidRegion(toBlockVector3(pasteBuilder.getMinPoint()), toBlockVector3(pasteBuilder.getMaxPoint())), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
|
||||
if (pasteBuilder.getWaterLevel() != 0) {
|
||||
e.setBlocks(new CuboidRegion(toBlockVector3(pasteBuilder.getMinPoint()), toBlockVector3(pasteBuilder.getMaxPoint()).withY(pasteBuilder.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
|
||||
if (pasteOptions.isReset()) {
|
||||
e.setBlocks((Region) new CuboidRegion(toBlockVector3(pasteOptions.getMinPoint()), toBlockVector3(pasteOptions.getMaxPoint())), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
|
||||
if (pasteOptions.getWaterLevel() != 0) {
|
||||
e.setBlocks((Region) new CuboidRegion(toBlockVector3(pasteOptions.getMinPoint()), toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
|
||||
}
|
||||
}
|
||||
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteBuilder.isIgnoreAir()).build());
|
||||
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build());
|
||||
return e;
|
||||
} catch (WorldEditException e) {
|
||||
throw new SecurityException(e.getMessage(), e);
|
||||
@ -191,7 +198,56 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint) {
|
||||
public void changeColor(Clipboard clipboard, Color color) throws WorldEditException {
|
||||
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
|
||||
BaseBlock wool = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock();
|
||||
BaseBlock clay = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock();
|
||||
BaseBlock glazed = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_glazed_terracotta")).getDefaultState().toBaseBlock();
|
||||
BaseBlock glass = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_stained_glass")).getDefaultState().toBaseBlock();
|
||||
BaseBlock glassPane = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_stained_glass_pane")).getDefaultState().toBaseBlock();
|
||||
BaseBlock carpet = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock();
|
||||
BaseBlock concrete = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_concrete")).getDefaultState().toBaseBlock();
|
||||
BaseBlock concretePowder = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_concrete_powder")).getDefaultState().toBaseBlock();
|
||||
|
||||
for (int x = 0; x < clipboard.getDimensions().getX(); x++) {
|
||||
for (int y = 0; y < clipboard.getDimensions().getY(); y++) {
|
||||
for (int z = 0; z < clipboard.getDimensions().getZ(); z++) {
|
||||
BlockVector3 pos = minimum.add(x, y, z);
|
||||
BaseBlock block = clipboard.getFullBlock(pos);
|
||||
if (block.equals(WOOL)) {
|
||||
clipboard.setBlock(pos, wool);
|
||||
} else if (block.equals(WOOL2)) {
|
||||
clipboard.setBlock(pos, wool);
|
||||
} else if (block.equals(CLAY)) {
|
||||
clipboard.setBlock(pos, clay);
|
||||
} else if (block.equals(CLAY2)) {
|
||||
clipboard.setBlock(pos, clay);
|
||||
} else if (block.equals(GLAZED)) {
|
||||
clipboard.setBlock(pos, glazed);
|
||||
} else if (block.equals(GLASS)) {
|
||||
clipboard.setBlock(pos, glass);
|
||||
} else if (block.equals(GLASS2)) {
|
||||
clipboard.setBlock(pos, glass);
|
||||
} else if (block.equals(GLASS_PANE)) {
|
||||
clipboard.setBlock(pos, glassPane);
|
||||
} else if (block.equals(GLASS_PANE2)) {
|
||||
clipboard.setBlock(pos, glassPane);
|
||||
} else if (block.equals(CARPET)) {
|
||||
clipboard.setBlock(pos, carpet);
|
||||
} else if (block.equals(CONCRETE)) {
|
||||
clipboard.setBlock(pos, concrete);
|
||||
} else if (block.equals(CONCRETE2)) {
|
||||
clipboard.setBlock(pos, concrete);
|
||||
} else if (block.equals(CONCRETE_POWDER)) {
|
||||
clipboard.setBlock(pos, concretePowder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean backup(Point minPoint, Point maxPoint, File file) {
|
||||
BukkitWorld bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
CuboidRegion region = new CuboidRegion(bukkitWorld, toBlockVector3(minPoint), toBlockVector3(maxPoint));
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||
@ -204,21 +260,12 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
copy.setCopyingBiomes(false);
|
||||
|
||||
Operations.complete(copy);
|
||||
clipboard.setOrigin(toBlockVector3(copyPoint));
|
||||
return clipboard;
|
||||
} catch (WorldEditException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean backup(Point minPoint, Point maxPoint, File file) {
|
||||
Clipboard clipboard = copy(minPoint, maxPoint, minPoint);
|
||||
try (ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream(file))) {
|
||||
writer.write(clipboard);
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
} catch (WorldEditException | IOException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
@ -240,4 +287,19 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
|
||||
return ((Waterlogged) data).isWaterlogged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getTraceShowMaterial() {
|
||||
return Material.LIME_CONCRETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getTraceHideMaterial() {
|
||||
return Material.RED_CONCRETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getTraceXZMaterial() {
|
||||
return Material.QUARTZ_SLAB;
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,20 @@
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.bausystem.entities.DetonatorEntity15;
|
||||
import de.steamwar.bausystem.entities.SimulatorEntity15;
|
||||
import de.steamwar.bausystem.entities.TraceEntity15;
|
||||
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
||||
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
|
||||
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
|
||||
import de.steamwar.bausystem.entities.WarpEntity15;
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
@ -32,6 +41,7 @@ import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -63,6 +73,38 @@ public class NMSWrapper15 implements NMSWrapper {
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(LongSupplier longSupplier) {
|
||||
SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong();
|
||||
}
|
||||
|
||||
private static final List<Packet<?>> packets = new ArrayList<>();
|
||||
private static final Vec3D noMotion = new Vec3D(0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void createTickCache(World world) {
|
||||
packets.clear();
|
||||
world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> {
|
||||
packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion));
|
||||
packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle()));
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
net.minecraft.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle();
|
||||
packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTickPackets() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
for (Packet<?> p : packets) {
|
||||
connection.sendPacket(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final Reflection.FieldAccessor<Integer> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, int.class, 0);
|
||||
|
||||
@Override
|
||||
@ -120,6 +162,26 @@ public class NMSWrapper15 implements NMSWrapper {
|
||||
return invalid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractWarpEntity createWarp(World world, Vector position, String name) {
|
||||
return new WarpEntity15(world, position, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) {
|
||||
return new SimulatorEntity15(world, tntPosition, highlight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDetonatorEntity constructDetonator(World world, Vector position) {
|
||||
return new DetonatorEntity15(world, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) {
|
||||
return new TraceEntity15(world, tntPosition, tnt);
|
||||
}
|
||||
|
||||
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
||||
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class PlaceItemWrapper15 implements PlaceItemWrapper {
|
||||
|
||||
public PlaceItemWrapper15() {
|
||||
for (Material material : Material.values()) {
|
||||
if (!material.isBlock()) continue;
|
||||
if (material.isLegacy()) continue;
|
||||
|
||||
String nonWall = material.name().replace("_WALL_", "").replace("WALL_", "").replace("_WALL", "");
|
||||
try {
|
||||
Material nonWallMaterial = Material.valueOf(nonWall);
|
||||
if (nonWallMaterial != material && nonWallMaterial.isItem() && !nonWallMaterial.isBlock()) {
|
||||
BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL.put(nonWallMaterial, material);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
ITEM_MATERIAL_TO_BLOCK_MATERIAL.put(Material.REDSTONE, Material.REDSTONE_WIRE);
|
||||
}
|
||||
}
|
@ -19,12 +19,9 @@
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.bausystem.utils.PlayerMovementWrapper;
|
||||
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntity;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityTeleport;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -40,20 +37,4 @@ public class PlayerMovementWrapper15 implements PlayerMovementWrapper {
|
||||
entityPlayer.setLocation(packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0), packetPlayInFlying.a(0F), packetPlayInFlying.b(0F));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertToOut(Player player, Object object) {
|
||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||
Object packet = Reflection.newInstance(teleportPacket);
|
||||
teleportEntity.set(packet, player.getEntityId());
|
||||
teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0));
|
||||
if (Float.isNaN(packetPlayInFlying.a(Float.NaN))) {
|
||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||
} else {
|
||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.a(0.0F)));
|
||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.b(0.0F)));
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
33
BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java
Normale Datei
33
BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java
Normale Datei
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
|
||||
public class ProtocolWrapper15 implements ProtocolWrapper {
|
||||
|
||||
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, NoClipCommand.playerInfoPacket, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent);
|
||||
@Override
|
||||
public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) {
|
||||
return playerInfoDataConstructor.invoke(packet, profile, 0, mode, null);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
public class TickListener15 implements TickListener {
|
||||
}
|
@ -27,8 +27,8 @@ version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class DetonatorEntity18 extends EntityFallingBlock implements AbstractDetonatorEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
private final Vector position;
|
||||
private int references = 0;
|
||||
|
||||
public DetonatorEntity18(World world, Vector position) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.du.n());
|
||||
this.position = position;
|
||||
|
||||
this.h(true);
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ae();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (references++ > 0)
|
||||
return;
|
||||
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(Blocks.du.n()), ZERO);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true);
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && --references > 0)
|
||||
return false;
|
||||
|
||||
sendDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntity(Player player) {
|
||||
display(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntityDestroy(Player player) {
|
||||
hide(player, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
||||
import de.steamwar.bausystem.shared.BaseEntity18;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulatorEntity {
|
||||
|
||||
private boolean printed = false;
|
||||
|
||||
public SimulatorEntity18(World world, Vector position, boolean highlight) {
|
||||
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ae();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (printed) return;
|
||||
printed = true;
|
||||
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector position) {
|
||||
this.position = position;
|
||||
e(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!printed) return false;
|
||||
printed = false;
|
||||
|
||||
sendEntityDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
}
|
73
BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java
Normale Datei
73
BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java
Normale Datei
@ -0,0 +1,73 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
|
||||
import de.steamwar.bausystem.shared.BaseEntity18;
|
||||
import de.steamwar.bausystem.shared.ReferenceCounter;
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TraceEntity18 extends BaseEntity18 implements AbstractTraceEntity {
|
||||
|
||||
private boolean exploded = false;
|
||||
private ReferenceCounter referenceCounter = new ReferenceCounter();
|
||||
|
||||
public TraceEntity18(World world, Vector position, boolean tnt) {
|
||||
super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS);
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player, boolean exploded, int ticks) {
|
||||
if (ticks != -1) {
|
||||
this.n(true);
|
||||
this.a(new ChatComponentText(ticks + ""));
|
||||
}
|
||||
if (!this.exploded && exploded) {
|
||||
this.n(true);
|
||||
this.a(new ChatComponentText("Bumm"));
|
||||
this.exploded = true;
|
||||
if (referenceCounter.increment() > 0) {
|
||||
sendEntityDestroy(player);
|
||||
}
|
||||
} else if (referenceCounter.increment() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && referenceCounter.decrement() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendEntityDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
}
|
80
BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java
Normale Datei
80
BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java
Normale Datei
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
|
||||
import de.steamwar.bausystem.shared.BaseArmorStand18;
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class WarpEntity18 extends BaseArmorStand18 implements AbstractWarpEntity {
|
||||
|
||||
public WarpEntity18(World world, Vector position, String name) {
|
||||
super(world, position);
|
||||
this.j(true);
|
||||
this.a(true);
|
||||
setName(name);
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.n(true);
|
||||
this.a(new ChatComponentText(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player) {
|
||||
sendEntityDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMetaData(Player player) {
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Player player, Vector position) {
|
||||
setPosRaw(position.getX(), position.getY(), position.getZ(), false);
|
||||
PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this);
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityTeleport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getPosition() {
|
||||
return new Vector(dc(), de(), di());
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tracer.record;
|
||||
|
||||
import net.minecraft.world.entity.item.EntityTNTPrimed;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class TNTPrimedIterator18 implements TNTPrimedIterator {
|
||||
|
||||
private static final CraftWorld WORLD = (CraftWorld) Bukkit.getWorlds().get(0);
|
||||
|
||||
@Override
|
||||
public Stream<TNTPrimed> iterator() {
|
||||
return StreamSupport.stream(WORLD.getHandle().H().a().spliterator(), false)
|
||||
.filter(EntityTNTPrimed.class::isInstance)
|
||||
.map(entity -> (TNTPrimed) entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
62
BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java
Normale Datei
62
BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java
Normale Datei
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.shared;
|
||||
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.decoration.EntityArmorStand;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BaseArmorStand18 extends EntityArmorStand implements AbstractEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
|
||||
protected Vector position;
|
||||
|
||||
public BaseArmorStand18(World world, Vector position) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ());
|
||||
|
||||
this.position = position;
|
||||
e(true);
|
||||
S = -12000;
|
||||
}
|
||||
|
||||
public void sendEntity(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.c, 0, ZERO);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
public void sendEntityDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae());
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
||||
}
|
||||
}
|
68
BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java
Normale Datei
68
BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java
Normale Datei
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.shared;
|
||||
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BaseEntity18 extends EntityFallingBlock implements AbstractEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
|
||||
private final IBlockData iBlockData;
|
||||
protected Vector position;
|
||||
|
||||
public BaseEntity18(World world, Vector position, Material blockType) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState());
|
||||
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
|
||||
this.position = position;
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
public void sendEntity(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(iBlockData), ZERO);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
public void sendEntityDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae());
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
||||
}
|
||||
}
|
@ -21,7 +21,15 @@ package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.entities.DetonatorEntity18;
|
||||
import de.steamwar.bausystem.entities.SimulatorEntity18;
|
||||
import de.steamwar.bausystem.entities.TraceEntity18;
|
||||
import de.steamwar.bausystem.entities.WarpEntity18;
|
||||
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
|
||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
||||
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
|
||||
import net.minecraft.SystemUtils;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@ -31,16 +39,14 @@ import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.server.level.PlayerInteractManager;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -73,6 +79,37 @@ public class NMSWrapper18 implements NMSWrapper {
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(LongSupplier longSupplier) {
|
||||
SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong();
|
||||
}
|
||||
|
||||
private static final List<Packet<?>> packets = new ArrayList<>();
|
||||
private static final Vec3D noMotion = new Vec3D(0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void createTickCache(World world) {
|
||||
packets.clear();
|
||||
world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> {
|
||||
packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion));
|
||||
packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle()));
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
net.minecraft.world.entity.Entity serverEntity = ((CraftEntity) entity).getHandle();
|
||||
packets.add(new PacketPlayOutEntityMetadata(serverEntity.ae(), serverEntity.ai(), true));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTickPackets() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
for (Packet<?> p : packets) {
|
||||
TinyProtocol.instance.sendPacket(player, p);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final Reflection.FieldAccessor<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
||||
|
||||
@Override
|
||||
@ -130,6 +167,26 @@ public class NMSWrapper18 implements NMSWrapper {
|
||||
return invalid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractWarpEntity createWarp(World world, Vector position, String name) {
|
||||
return new WarpEntity18(world, position, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) {
|
||||
return new SimulatorEntity18(world, tntPosition, highlight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDetonatorEntity constructDetonator(World world, Vector position) {
|
||||
return new DetonatorEntity18(world, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) {
|
||||
return new TraceEntity18(world, tntPosition, tnt);
|
||||
}
|
||||
|
||||
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
||||
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.bausystem.utils.PlayerMovementWrapper;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
@ -38,20 +37,4 @@ public class PlayerMovementWrapper18 implements PlayerMovementWrapper {
|
||||
entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertToOut(Player player, Object object) {
|
||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||
Object packet = Reflection.newInstance(teleportPacket);
|
||||
teleportEntity.set(packet, player.getEntityId());
|
||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||
if (packetPlayInFlying.h) {
|
||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||
} else {
|
||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
33
BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java
Normale Datei
33
BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java
Normale Datei
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
|
||||
public class ProtocolWrapper18 implements ProtocolWrapper {
|
||||
|
||||
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent);
|
||||
@Override
|
||||
public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) {
|
||||
return playerInfoDataConstructor.invoke(profile, 0, mode, null);
|
||||
}
|
||||
}
|
@ -27,8 +27,8 @@ version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
@ -51,7 +51,6 @@ dependencies {
|
||||
implementation project(":BauSystem_Main")
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
|
||||
compileOnly 'io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT'
|
||||
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
|
||||
compileOnly 'com.mojang:datafixerupper:4.0.26'
|
||||
compileOnly 'io.netty:netty-all:4.1.68.Final'
|
||||
|
124
BauSystem_19/src/de/steamwar/bausystem/entities/DetonatorEntity19.java
Normale Datei
124
BauSystem_19/src/de/steamwar/bausystem/entities/DetonatorEntity19.java
Normale Datei
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class DetonatorEntity19 extends EntityFallingBlock implements AbstractDetonatorEntity {
|
||||
|
||||
private static final Field ao;
|
||||
|
||||
static {
|
||||
try {
|
||||
ao = EntityFallingBlock.class.getDeclaredField("ao");
|
||||
ao.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
private final Vector position;
|
||||
private int references = 0;
|
||||
private IBlockData iBlockData;
|
||||
|
||||
public DetonatorEntity19(World world, Vector position) {
|
||||
super(EntityTypes.E, ((CraftWorld) world).getHandle());
|
||||
try {
|
||||
ao.set(this, ((CraftBlockData) Material.RED_STAINED_GLASS.createBlockData()).getState());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.q = true;
|
||||
e(position.getX(), position.getY(), position.getZ());
|
||||
f(Vec3D.b);
|
||||
t = position.getX();
|
||||
u = position.getY();
|
||||
v = position.getZ();
|
||||
a(this.db());
|
||||
|
||||
this.iBlockData = ((CraftBlockData) Material.RED_STAINED_GLASS.createBlockData()).getState();
|
||||
this.position = position;
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ae();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (references++ > 0)
|
||||
return;
|
||||
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.E, Block.i(iBlockData), ZERO, 0.0);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true);
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && --references > 0)
|
||||
return false;
|
||||
|
||||
sendDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntity(Player player) {
|
||||
display(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntityDestroy(Player player) {
|
||||
hide(player, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
||||
import de.steamwar.bausystem.shared.BaseEntity19;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SimulatorEntity19 extends BaseEntity19 implements AbstractSimulatorEntity {
|
||||
|
||||
private boolean printed = false;
|
||||
|
||||
public SimulatorEntity19(World world, Vector position, boolean highlight) {
|
||||
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ae();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (printed) return;
|
||||
printed = true;
|
||||
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector position) {
|
||||
this.position = position;
|
||||
e(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!printed) return false;
|
||||
printed = false;
|
||||
|
||||
sendEntityDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
}
|
74
BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java
Normale Datei
74
BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java
Normale Datei
@ -0,0 +1,74 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
|
||||
import de.steamwar.bausystem.shared.BaseEntity19;
|
||||
import de.steamwar.bausystem.shared.ReferenceCounter;
|
||||
import net.minecraft.network.chat.IChatMutableComponent;
|
||||
import net.minecraft.network.chat.contents.LiteralContents;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TraceEntity19 extends BaseEntity19 implements AbstractTraceEntity {
|
||||
|
||||
private boolean exploded = false;
|
||||
private ReferenceCounter referenceCounter = new ReferenceCounter();
|
||||
|
||||
public TraceEntity19(World world, Vector position, boolean tnt) {
|
||||
super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS);
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player, boolean exploded, int ticks) {
|
||||
if (ticks != -1) {
|
||||
this.n(true);
|
||||
this.b(IChatMutableComponent.a(new LiteralContents(ticks + "")));
|
||||
}
|
||||
if (!this.exploded && exploded) {
|
||||
this.n(true);
|
||||
this.b(IChatMutableComponent.a(new LiteralContents("Bumm")));
|
||||
this.exploded = true;
|
||||
if (referenceCounter.increment() > 0) {
|
||||
sendEntityDestroy(player);
|
||||
}
|
||||
} else if (referenceCounter.increment() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && referenceCounter.decrement() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendEntityDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
}
|
81
BauSystem_19/src/de/steamwar/bausystem/entities/WarpEntity19.java
Normale Datei
81
BauSystem_19/src/de/steamwar/bausystem/entities/WarpEntity19.java
Normale Datei
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.entities;
|
||||
|
||||
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
|
||||
import de.steamwar.bausystem.shared.BaseArmorStand19;
|
||||
import net.minecraft.network.chat.IChatMutableComponent;
|
||||
import net.minecraft.network.chat.contents.LiteralContents;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class WarpEntity19 extends BaseArmorStand19 implements AbstractWarpEntity {
|
||||
|
||||
public WarpEntity19(World world, Vector position, String name) {
|
||||
super(world, position);
|
||||
this.j(true);
|
||||
this.a(true);
|
||||
setName(name);
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.n(true);
|
||||
this.b(IChatMutableComponent.a(new LiteralContents(name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player) {
|
||||
sendEntityDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMetaData(Player player) {
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Player player, Vector position) {
|
||||
setPosRaw(position.getX(), position.getY(), position.getZ(), false);
|
||||
PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this);
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityTeleport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getPosition() {
|
||||
return new Vector(df(), dh(), dj());
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FakeExplosion19 extends Explosion {
|
||||
|
||||
private List<FakeTNT19> fakeTNT19s;
|
||||
private boolean c;
|
||||
private Explosion.Effect d;
|
||||
private RandomSource e;
|
||||
private World f;
|
||||
private double g;
|
||||
private double h;
|
||||
private double i;
|
||||
@Nullable
|
||||
public Entity j;
|
||||
private float k;
|
||||
private DamageSource l;
|
||||
private ExplosionDamageCalculator m;
|
||||
private ObjectArrayList<BlockPosition> n;
|
||||
private Map<EntityHuman, Vec3D> o;
|
||||
public boolean wasCanceled;
|
||||
|
||||
public FakeExplosion19(List<FakeTNT19> fakeTNT19s, World world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) {
|
||||
super(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType);
|
||||
this.fakeTNT19s = fakeTNT19s;
|
||||
this.wasCanceled = false;
|
||||
this.e = RandomSource.a();
|
||||
this.n = new ObjectArrayList();
|
||||
this.o = Maps.newHashMap();
|
||||
this.f = world;
|
||||
this.j = entity;
|
||||
this.k = (float) Math.max((double) power, 0.0D);
|
||||
this.g = x;
|
||||
this.h = y;
|
||||
this.i = z;
|
||||
this.c = createFire;
|
||||
this.d = destructionType;
|
||||
this.l = damageSource == null ? DamageSource.a(this) : damageSource;
|
||||
this.m = new ExplosionDamageCalculator();
|
||||
|
||||
}
|
||||
|
||||
private float getBlockDensity(Vec3D vec3d, Entity entity) {
|
||||
return a(vec3d, entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void a() {
|
||||
if ((this.k) >= 0.1F) {
|
||||
this.f.a(this.j, GameEvent.w, new Vec3D(this.g, this.h, this.i));
|
||||
/*
|
||||
Set<BlockPosition> set = Sets.newHashSet();
|
||||
|
||||
int i;
|
||||
int j;
|
||||
for (int k = 0; k < 16; ++k) {
|
||||
for (i = 0; i < 16; ++i) {
|
||||
for (j = 0; j < 16; ++j) {
|
||||
if (k == 0 || k == 15 || i == 0 || i == 15 || j == 0 || j == 15) {
|
||||
double d0 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
|
||||
double d1 = (double) ((float) i / 15.0F * 2.0F - 1.0F);
|
||||
double d2 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
|
||||
double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
|
||||
d0 /= d3;
|
||||
d1 /= d3;
|
||||
d2 /= d3;
|
||||
float f = this.k * (0.7F + this.f.w.i() * 0.6F);
|
||||
double d4 = this.g;
|
||||
double d5 = this.h;
|
||||
double d6 = this.i;
|
||||
|
||||
for (float var21 = 0.3F; f > 0.0F; f -= 0.22500001F) {
|
||||
BlockPosition blockposition = new BlockPosition(d4, d5, d6);
|
||||
IBlockData iblockdata = this.f.a_(blockposition);
|
||||
Fluid fluid = iblockdata.p();
|
||||
if (!this.f.j(blockposition)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Optional<Float> optional = this.m.a(this, this.f, blockposition, iblockdata, fluid);
|
||||
if (optional.isPresent()) {
|
||||
f -= ((Float) optional.get() + 0.3F) * 0.3F;
|
||||
}
|
||||
|
||||
if (f > 0.0F && this.m.a(this, this.f, blockposition, iblockdata, f)) {
|
||||
set.add(blockposition);
|
||||
}
|
||||
|
||||
d4 += d0 * 0.30000001192092896D;
|
||||
d5 += d1 * 0.30000001192092896D;
|
||||
d6 += d2 * 0.30000001192092896D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.n.addAll(set);
|
||||
*/
|
||||
|
||||
float f2 = this.k * 2.0F;
|
||||
Vec3D vec3d = new Vec3D(this.g, this.h, this.i);
|
||||
for (int l1 = 0; l1 < fakeTNT19s.size(); ++l1) {
|
||||
Entity entity = (Entity) fakeTNT19s.get(l1);
|
||||
if (!entity.cF()) {
|
||||
double d7 = Math.sqrt(entity.e(vec3d)) / (double) f2;
|
||||
if (d7 <= 1.0D) {
|
||||
double d8 = entity.df() - this.g;
|
||||
double d9 = entity.dh() - this.h;
|
||||
double d10 = entity.dl() - this.i;
|
||||
double d11 = Math.sqrt(d8 * d8 + d9 * d9 + d10 * d10);
|
||||
if (d11 != 0.0D) {
|
||||
d8 /= d11;
|
||||
d9 /= d11;
|
||||
d10 /= d11;
|
||||
double d12 = (double) this.getBlockDensity(vec3d, entity);
|
||||
|
||||
double d13 = (1.0D - d7) * d12;
|
||||
entity.lastDamageCancelled = false;
|
||||
CraftEventFactory.entityDamage = null;
|
||||
entity.f(entity.dd().b(d8 * d13, d9 * d13, d10 * d13));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
257
BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeTNT19.java
Normale Datei
257
BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeTNT19.java
Normale Datei
@ -0,0 +1,257 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
import net.minecraft.network.syncher.DataWatcher;
|
||||
import net.minecraft.network.syncher.DataWatcherObject;
|
||||
import net.minecraft.network.syncher.DataWatcherRegistry;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.bukkit.entity.Explosive;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FakeTNT19 extends EntityTNTPrimed {
|
||||
private static final DataWatcherObject<Integer> b;
|
||||
private static final int c = 80;
|
||||
private List<FakeTNT19> fakeTNT19s;
|
||||
private List<FakeTNT19> spawnList = new ArrayList<>();
|
||||
private int count;
|
||||
@Nullable
|
||||
public EntityLiving d;
|
||||
public float yield;
|
||||
public boolean isIncendiary;
|
||||
|
||||
public FakeTNT19(List<FakeTNT19> fakeTNT19s, EntityTypes<? extends EntityTNTPrimed> type, World world) {
|
||||
super(type, world);
|
||||
this.fakeTNT19s = fakeTNT19s;
|
||||
this.yield = 4.0F;
|
||||
this.isIncendiary = false;
|
||||
super.q = true;
|
||||
}
|
||||
|
||||
public FakeTNT19(List<FakeTNT19> fakeTNT19s, World world, double x, double y, double z, int fuse, int count) {
|
||||
this(fakeTNT19s, EntityTypes.av, world);
|
||||
this.e(x, y, z);
|
||||
double d3 = world.w.j() * 6.2831854820251465D;
|
||||
this.n(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
|
||||
this.a(fuse);
|
||||
super.t = x;
|
||||
super.u = y;
|
||||
super.v = z;
|
||||
this.d = null;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
protected void a_() {
|
||||
super.Y.a(b, 80);
|
||||
}
|
||||
|
||||
protected MovementEmission aO() {
|
||||
return MovementEmission.a;
|
||||
}
|
||||
|
||||
public boolean bl() {
|
||||
return !this.dt();
|
||||
}
|
||||
|
||||
private Vec3D g(Vec3D vec3d) {
|
||||
AxisAlignedBB axisalignedbb = this.cz();
|
||||
List<VoxelShape> list = this.s.b(this, axisalignedbb.b(vec3d));
|
||||
Vec3D vec3d1 = vec3d.g() == 0.0 ? vec3d : a(this, vec3d, axisalignedbb, this.s, list);
|
||||
boolean flag = vec3d.c != vec3d1.c;
|
||||
boolean flag1 = vec3d.d != vec3d1.d;
|
||||
boolean flag2 = vec3d.e != vec3d1.e;
|
||||
boolean flag3 = this.y || flag1 && vec3d.d < 0.0;
|
||||
if (this.P > 0.0F && flag3 && (flag || flag2)) {
|
||||
Vec3D vec3d2 = a(this, new Vec3D(vec3d.c, (double)this.P, vec3d.e), axisalignedbb, this.s, list);
|
||||
Vec3D vec3d3 = a(this, new Vec3D(0.0, (double)this.P, 0.0), axisalignedbb.b(vec3d.c, 0.0, vec3d.e), this.s, list);
|
||||
if (vec3d3.d < (double)this.P) {
|
||||
Vec3D vec3d4 = a(this, new Vec3D(vec3d.c, 0.0, vec3d.e), axisalignedbb.c(vec3d3), this.s, list).e(vec3d3);
|
||||
if (vec3d4.i() > vec3d2.i()) {
|
||||
vec3d2 = vec3d4;
|
||||
}
|
||||
}
|
||||
|
||||
if (vec3d2.i() > vec3d1.i()) {
|
||||
return vec3d2.e(a(this, new Vec3D(0.0, -vec3d2.d + vec3d.d, 0.0), axisalignedbb.c(vec3d2), this.s, list));
|
||||
}
|
||||
}
|
||||
|
||||
return vec3d1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(EnumMoveType enummovetype, Vec3D vec3d) {
|
||||
if (this.E.g() > 1.0E-7) {
|
||||
vec3d = vec3d.h(this.E);
|
||||
this.E = Vec3D.b;
|
||||
this.f(Vec3D.b);
|
||||
}
|
||||
|
||||
Vec3D vec3d1 = this.g(vec3d);
|
||||
double d0 = vec3d1.g();
|
||||
if (d0 > 1.0E-7) {
|
||||
this.e(this.df() + vec3d1.c, this.dg() + vec3d1.d, this.dl() + vec3d1.e);
|
||||
}
|
||||
|
||||
boolean flag = !MathHelper.b(vec3d.c, vec3d1.c);
|
||||
boolean flag1 = !MathHelper.b(vec3d.e, vec3d1.e);
|
||||
this.z = flag || flag1;
|
||||
this.A = vec3d.d != vec3d1.d;
|
||||
this.B = this.A && vec3d.d < 0.0;
|
||||
if (this.z) {
|
||||
this.C = this.b(vec3d1);
|
||||
} else {
|
||||
this.C = false;
|
||||
}
|
||||
|
||||
this.y = this.A && vec3d.d < 0.0;
|
||||
BlockPosition blockposition = this.aA();
|
||||
IBlockData iblockdata = this.s.a_(blockposition);
|
||||
// this.a(vec3d1.d, this.y, iblockdata, blockposition);
|
||||
if (!this.dt()) {
|
||||
if (this.z) {
|
||||
Vec3D vec3d2 = this.dd();
|
||||
this.n(flag ? 0.0 : vec3d2.c, vec3d2.d, flag1 ? 0.0 : vec3d2.e);
|
||||
}
|
||||
|
||||
net.minecraft.world.level.block.Block block = iblockdata.b();
|
||||
if (vec3d.d != vec3d1.d) {
|
||||
block.a(this.s, this);
|
||||
}
|
||||
|
||||
if (this.y) {
|
||||
block.a(this.s, blockposition, iblockdata, this);
|
||||
}
|
||||
|
||||
this.ax();
|
||||
float f2 = this.aD();
|
||||
this.f(this.dd().d((double)f2, 1.0, (double)f2));
|
||||
}
|
||||
}
|
||||
|
||||
public void k(List<FakeTNT19> spawnList) {
|
||||
if (!this.aN()) {
|
||||
this.f(this.dd().b(0.0D, -0.04D, 0.0D));
|
||||
}
|
||||
|
||||
this.a(EnumMoveType.a, this.dd());
|
||||
this.f(this.dd().a(0.98D));
|
||||
if (super.y) {
|
||||
this.f(this.dd().d(0.7D, -0.5D, 0.7D));
|
||||
}
|
||||
|
||||
int i = this.i() - 1;
|
||||
this.a(i);
|
||||
if (i <= 0) {
|
||||
if (!super.s.y) {
|
||||
this.j1();
|
||||
}
|
||||
|
||||
this.ah();
|
||||
} else {
|
||||
this.aY();
|
||||
}
|
||||
|
||||
if (i == 1 && count > 1) {
|
||||
for (int c = 0; c < count - 1; c++) {
|
||||
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, this.s, this.df(), this.dh(), this.dl(), i, 1);
|
||||
fakeTNT19.y = this.y;
|
||||
fakeTNT19.f(new Vec3D(this.dd().c, this.dd().d, this.dd().e));
|
||||
spawnList.add(fakeTNT19);
|
||||
}
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void j1() {
|
||||
ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) this.getBukkitEntity());
|
||||
super.s.getCraftServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
this.a(this, this.df(), this.e(0.0625D), this.dl(), event.getRadius(), event.getFire(), Explosion.Effect.b);
|
||||
}
|
||||
}
|
||||
|
||||
public FakeExplosion19 a(@Nullable Entity entity, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) {
|
||||
return this.a(entity, (DamageSource) null, (ExplosionDamageCalculator) null, x, y, z, power, createFire, destructionType);
|
||||
}
|
||||
|
||||
public FakeExplosion19 a(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) {
|
||||
FakeExplosion19 explosion = new FakeExplosion19(fakeTNT19s, SimulatorPreview19.WORLD, entity, damageSource, behavior, x, y, z, power, createFire, destructionType);
|
||||
explosion.a();
|
||||
// explosion.a(true);
|
||||
return explosion;
|
||||
}
|
||||
|
||||
|
||||
protected void b(NBTTagCompound nbt) {
|
||||
nbt.a("Fuse", (short) this.i());
|
||||
}
|
||||
|
||||
protected void a(NBTTagCompound nbt) {
|
||||
this.a(nbt.g("Fuse"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityLiving h() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
protected float a(EntityPose pose, EntitySize dimensions) {
|
||||
return 0.15F;
|
||||
}
|
||||
|
||||
public void a(int fuse) {
|
||||
super.Y.b(b, fuse);
|
||||
}
|
||||
|
||||
public int i() {
|
||||
return (Integer) super.Y.a(b);
|
||||
}
|
||||
|
||||
public Packet<?> S() {
|
||||
return new PacketPlayOutSpawnEntity(this);
|
||||
}
|
||||
|
||||
public boolean cr() {
|
||||
return super.cr();
|
||||
}
|
||||
|
||||
static {
|
||||
b = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b);
|
||||
}
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import net.minecraft.world.level.World;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SimulatorPreview19 implements SimulatorPreview {
|
||||
|
||||
public static final World WORLD = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
||||
|
||||
@Override
|
||||
public Record simulate(TNTSimulator tntSimulator) {
|
||||
if (true) {
|
||||
return new Record(null);
|
||||
}
|
||||
|
||||
Map<Integer, Map<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> result = new HashMap<>();
|
||||
for (SimulatorElement element : tntSimulator.getTntElementList()) {
|
||||
element.locations(result);
|
||||
}
|
||||
|
||||
AtomicInteger maxTick = new AtomicInteger(0);
|
||||
Map<Integer, List<List<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> toSpawn = new HashMap<>();
|
||||
AtomicInteger tntCount = new AtomicInteger(0);
|
||||
result.forEach((integer, integerSetMap) -> {
|
||||
List<Pair<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> internal = new ArrayList<>();
|
||||
integerSetMap.forEach((integer1, pairs) -> {
|
||||
internal.add(new Pair<>(integer1, pairs));
|
||||
});
|
||||
internal.sort(Comparator.comparingInt(Pair::getKey));
|
||||
|
||||
toSpawn.put(integer, internal.stream().map(Pair::getValue).peek(pairs -> {
|
||||
tntCount.addAndGet(pairs.stream().mapToInt(Pair::getValue).sum());
|
||||
}).map(ArrayList::new).peek(Collections::shuffle).collect(Collectors.toList()));
|
||||
|
||||
if (maxTick.get() < integer) {
|
||||
maxTick.set(integer);
|
||||
}
|
||||
});
|
||||
if (tntCount.get() > 500) {
|
||||
return new Record(null);
|
||||
}
|
||||
|
||||
List<FakeTNT19> fakeTNT19s = new ArrayList<>();
|
||||
Record record = new Record(null);
|
||||
Map<FakeTNT19, Record.TNTRecord> tntRecords = new HashMap<>();
|
||||
|
||||
int maxTickToCalc = maxTick.get() + 160;
|
||||
for (int tick = 0; tick < maxTickToCalc; tick++) {
|
||||
List<List<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>> toSpawnInTick = toSpawn.get(tick);
|
||||
try {
|
||||
if (toSpawnInTick == null) continue;
|
||||
toSpawnInTick.forEach(pairs -> {
|
||||
AtomicBoolean hasSomeLeft = new AtomicBoolean(true);
|
||||
while(hasSomeLeft.get()) {
|
||||
hasSomeLeft.set(false);
|
||||
pairs.forEach(pair -> {
|
||||
SimulatorPreview.SimulatorPreviewTNTData previewTNTData = pair.getKey();
|
||||
if (!previewTNTData.isXVelocity() && !previewTNTData.isZVelocity()) {
|
||||
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), pair.getValue());
|
||||
TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity();
|
||||
if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
|
||||
if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
|
||||
if (!previewTNTData.isZVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
|
||||
fakeTNT19s.add(fakeTNT19);
|
||||
pair.setValue(0);
|
||||
} else if (pair.getValue() > 0) {
|
||||
hasSomeLeft.set(true);
|
||||
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), 1);
|
||||
TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity();
|
||||
if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
|
||||
if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
|
||||
if (!previewTNTData.isZVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
|
||||
fakeTNT19s.add(fakeTNT19);
|
||||
pair.setValue(pair.getValue() - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
calculateTick(fakeTNT19s, record, tntRecords);
|
||||
}
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
private void calculateTick(List<FakeTNT19> fakeTNT19s, Record record, Map<FakeTNT19, Record.TNTRecord> tntRecords) {
|
||||
int i = 0;
|
||||
while (i < fakeTNT19s.size()) {
|
||||
List<FakeTNT19> spawnList = new ArrayList<>();
|
||||
FakeTNT19 fakeTNT19 = fakeTNT19s.get(i);
|
||||
fakeTNT19.k(spawnList);
|
||||
TNTPrimed tntPrimed = ((TNTPrimed) (fakeTNT19.getBukkitEntity()));
|
||||
if (tntPrimed.getFuseTicks() <= 0) {
|
||||
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed);
|
||||
fakeTNT19s.remove(i);
|
||||
i--;
|
||||
} else {
|
||||
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed);
|
||||
}
|
||||
if (!spawnList.isEmpty()) {
|
||||
fakeTNT19s.addAll(i, spawnList);
|
||||
i += spawnList.size();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tracer.record;
|
||||
|
||||
import net.minecraft.world.entity.item.EntityTNTPrimed;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class TNTPrimedIterator19 implements TNTPrimedIterator {
|
||||
|
||||
private static final CraftWorld WORLD = (CraftWorld) Bukkit.getWorlds().get(0);
|
||||
|
||||
@Override
|
||||
public Stream<TNTPrimed> iterator() {
|
||||
return StreamSupport.stream(WORLD.getHandle().F().a().spliterator(), false)
|
||||
.filter(EntityTNTPrimed.class::isInstance)
|
||||
.map(entity -> (TNTPrimed) entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
62
BauSystem_19/src/de/steamwar/bausystem/shared/BaseArmorStand19.java
Normale Datei
62
BauSystem_19/src/de/steamwar/bausystem/shared/BaseArmorStand19.java
Normale Datei
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.shared;
|
||||
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.decoration.EntityArmorStand;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BaseArmorStand19 extends EntityArmorStand implements AbstractEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
|
||||
protected Vector position;
|
||||
|
||||
public BaseArmorStand19(World world, Vector position) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ());
|
||||
|
||||
this.position = position;
|
||||
e(true);
|
||||
S = -12000;
|
||||
}
|
||||
|
||||
public void sendEntity(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.d, 0, ZERO, 0.0);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
public void sendEntityDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae());
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
||||
}
|
||||
}
|
94
BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java
Normale Datei
94
BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java
Normale Datei
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.shared;
|
||||
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class BaseEntity19 extends EntityFallingBlock implements AbstractEntity {
|
||||
|
||||
private static final Field ao;
|
||||
|
||||
static {
|
||||
try {
|
||||
ao = EntityFallingBlock.class.getDeclaredField("ao");
|
||||
ao.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
|
||||
private final IBlockData iBlockData;
|
||||
protected Vector position;
|
||||
|
||||
public BaseEntity19(World world, Vector position, Material blockType) {
|
||||
super(EntityTypes.E, ((CraftWorld) world).getHandle());
|
||||
try {
|
||||
ao.set(this, ((CraftBlockData) blockType.createBlockData()).getState());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.q = true;
|
||||
e(position.getX(), position.getY(), position.getZ());
|
||||
f(Vec3D.b);
|
||||
t = position.getX();
|
||||
u = position.getY();
|
||||
v = position.getZ();
|
||||
a(this.db());
|
||||
|
||||
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
|
||||
this.position = position;
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
public void sendEntity(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.E, Block.i(iBlockData), ZERO, 0.0);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
public void sendEntityDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae());
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
||||
}
|
||||
}
|
@ -21,27 +21,32 @@ package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.entities.DetonatorEntity19;
|
||||
import de.steamwar.bausystem.entities.SimulatorEntity19;
|
||||
import de.steamwar.bausystem.entities.TraceEntity19;
|
||||
import de.steamwar.bausystem.entities.WarpEntity19;
|
||||
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
|
||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
||||
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
|
||||
import net.minecraft.SystemUtils;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.network.syncher.DataWatcher;
|
||||
import net.minecraft.server.level.PlayerInteractManager;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -55,6 +60,7 @@ public class NMSWrapper19 implements NMSWrapper {
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
playerGameMode.set(((CraftPlayer) player).getHandle().d, EnumGamemode.a(gameMode.getValue()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,6 +79,37 @@ public class NMSWrapper19 implements NMSWrapper {
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(LongSupplier longSupplier) {
|
||||
SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong();
|
||||
}
|
||||
|
||||
private static final List<Packet<?>> packets = new ArrayList<>();
|
||||
private static final Vec3D noMotion = new Vec3D(0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void createTickCache(World world) {
|
||||
packets.clear();
|
||||
world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> {
|
||||
packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion));
|
||||
packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle()));
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
net.minecraft.world.entity.Entity serverEntity = ((CraftEntity) entity).getHandle();
|
||||
packets.add(new PacketPlayOutEntityMetadata(serverEntity.ae(), serverEntity.ai(), true));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTickPackets() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
for (Packet<?> p : packets) {
|
||||
TinyProtocol.instance.sendPacket(player, p);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final Reflection.FieldAccessor<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
||||
|
||||
@Override
|
||||
@ -82,8 +119,8 @@ public class NMSWrapper19 implements NMSWrapper {
|
||||
|
||||
@Override
|
||||
public void setPlayerBuildAbilities(Player player) {
|
||||
((CraftPlayer) player).getHandle().fF().d = true;
|
||||
((CraftPlayer) player).getHandle().fF().e = true;
|
||||
((CraftPlayer) player).getHandle().fB().d = true;
|
||||
((CraftPlayer) player).getHandle().fB().e = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,6 +167,26 @@ public class NMSWrapper19 implements NMSWrapper {
|
||||
return invalid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractWarpEntity createWarp(World world, Vector position, String name) {
|
||||
return new WarpEntity19(world, position, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) {
|
||||
return new SimulatorEntity19(world, tntPosition, highlight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDetonatorEntity constructDetonator(World world, Vector position) {
|
||||
return new DetonatorEntity19(world, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) {
|
||||
return new TraceEntity19(world, tntPosition, tnt);
|
||||
}
|
||||
|
||||
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
||||
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
||||
|
@ -19,17 +19,12 @@
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.bausystem.utils.PlayerMovementWrapper;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerMovementWrapper19 implements PlayerMovementWrapper {
|
||||
|
||||
@Override
|
||||
@ -42,20 +37,4 @@ public class PlayerMovementWrapper19 implements PlayerMovementWrapper {
|
||||
entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertToOut(Player player, Object object) {
|
||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||
Object packet = Reflection.newInstance(teleportPacket);
|
||||
teleportEntity.set(packet, player.getEntityId());
|
||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||
if (packetPlayInFlying.h) {
|
||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||
} else {
|
||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
33
BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java
Normale Datei
33
BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java
Normale Datei
@ -0,0 +1,33 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
|
||||
public class ProtocolWrapper19 implements ProtocolWrapper {
|
||||
|
||||
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent, Reflection.getClass("net.minecraft.world.entity.player.ProfilePublicKey$a"));
|
||||
@Override
|
||||
public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) {
|
||||
return playerInfoDataConstructor.invoke(profile, 0, mode, null, null);
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.destroystokyo.paper.event.server.ServerTickEndEvent;
|
||||
import com.destroystokyo.paper.event.server.ServerTickStartEvent;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class TickListener19 implements TickListener, Listener {
|
||||
|
||||
private boolean tickStartRan = false;
|
||||
|
||||
public TickListener19() {
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerTickStart(ServerTickStartEvent event) {
|
||||
if (TPSFreezeUtils.isFrozen()) return;
|
||||
Bukkit.getPluginManager().callEvent(new TickStartEvent());
|
||||
tickStartRan = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerTickEnd(ServerTickEndEvent event) {
|
||||
if (!tickStartRan) return;
|
||||
Bukkit.getPluginManager().callEvent(new TickEndEvent());
|
||||
tickStartRan = false;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'base'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group 'steamwar'
|
||||
version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs = ['src/']
|
||||
}
|
||||
resources {
|
||||
srcDirs = ['src/']
|
||||
exclude '**/*.java', '**/*.kt'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
|
||||
implementation project(":BauSystem_Main")
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
|
||||
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
|
||||
compileOnly 'com.mojang:datafixerupper:4.0.26'
|
||||
compileOnly 'io.netty:netty-all:4.1.68.Final'
|
||||
compileOnly 'com.mojang:authlib:1.5.25'
|
||||
compileOnly 'com.mojang:brigadier:1.0.18'
|
||||
|
||||
compileOnly swdep('Spigot-1.20')
|
||||
compileOnly swdep('SpigotCore')
|
||||
}
|
@ -1,136 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutExplosion;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
|
||||
import net.minecraft.server.level.PlayerInteractManager;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NMSWrapper20 implements NMSWrapper {
|
||||
|
||||
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
playerGameMode.set(((CraftPlayer) player).getHandle().e, EnumGamemode.a(gameMode.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlotToItemStack(Player player, Object o) {
|
||||
PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o;
|
||||
int index = packetPlayInSetCreativeSlot.a();
|
||||
if (index >= 36 && index <= 44) {
|
||||
index -= 36;
|
||||
} else if (index > 44) {
|
||||
index -= 5;
|
||||
} else if (index <= 8) {
|
||||
index = index - 8 + 36;
|
||||
}
|
||||
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.c()));
|
||||
if (index < 9) player.getInventory().setHeldItemSlot(index);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
private static final Reflection.FieldAccessor<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
||||
|
||||
@Override
|
||||
public void setGameStateChangeReason(Object packet) {
|
||||
gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerBuildAbilities(Player player) {
|
||||
((CraftPlayer) player).getHandle().fO().d = true;
|
||||
((CraftPlayer) player).getHandle().fO().e = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material pathMaterial() {
|
||||
return Material.DIRT_PATH;
|
||||
}
|
||||
|
||||
private static final int threshold = 2048;
|
||||
|
||||
@Override
|
||||
public boolean checkItemStack(ItemStack item) {
|
||||
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tag = nmsItem.v();
|
||||
if (tag != null && tag.e("BlockEntityTag")) {
|
||||
NBTTagCompound blockTag = tag.p("BlockEntityTag");
|
||||
if (blockTag.e("Items")) {
|
||||
return drillDown(blockTag.c("Items", 10), 0, 0) > threshold;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private int drillDown(NBTTagList items, int layer, int start) {
|
||||
if (layer > 2) return start + threshold;
|
||||
int invalid = start;
|
||||
for (NBTBase nbtBase : items) {
|
||||
if (!(nbtBase instanceof NBTTagCompound))
|
||||
continue;
|
||||
NBTTagCompound slot = (NBTTagCompound) nbtBase;
|
||||
if (slot.e("tag")) {
|
||||
invalid += slot.f("Count");
|
||||
NBTTagCompound iTag = slot.p("tag");
|
||||
if (iTag.e("BlockEntityTag")) {
|
||||
NBTTagCompound blockTag = iTag.p("BlockEntityTag");
|
||||
if (blockTag.e("Items")) {
|
||||
invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalid > threshold)
|
||||
break;
|
||||
}
|
||||
return invalid;
|
||||
}
|
||||
|
||||
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
||||
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
||||
private final Reflection.FieldAccessor<Double> c = Reflection.getField(explosionPacket, double.class, 2);
|
||||
private final Reflection.FieldAccessor<Float> d = Reflection.getField(explosionPacket, float.class, 0);
|
||||
private final Reflection.FieldAccessor<List> e = Reflection.getField(explosionPacket, List.class, 0);
|
||||
|
||||
@Override
|
||||
public Object resetExplosionKnockback(Object packet) {
|
||||
PacketPlayOutExplosion packetPlayOutExplosion = (PacketPlayOutExplosion) packet;
|
||||
return new PacketPlayOutExplosion(a.get(packetPlayOutExplosion), b.get(packetPlayOutExplosion), c.get(packetPlayOutExplosion), d.get(packetPlayOutExplosion), e.get(packetPlayOutExplosion), null);
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class PlaceItemWrapper20 implements PlaceItemWrapper {
|
||||
|
||||
public PlaceItemWrapper20() {
|
||||
for (Material material : Material.values()) {
|
||||
if (!material.isBlock()) continue;
|
||||
if (material.isLegacy()) continue;
|
||||
BlockData blockData = material.createBlockData();
|
||||
Material placementMaterial = blockData.getPlacementMaterial();
|
||||
if (material == placementMaterial) continue;
|
||||
if (placementMaterial == Material.AIR) continue;
|
||||
if (placementMaterial.isItem() && !placementMaterial.isBlock()) {
|
||||
ITEM_MATERIAL_TO_BLOCK_MATERIAL.put(placementMaterial, material);
|
||||
}
|
||||
if (material.name().contains("WALL")) {
|
||||
BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL.put(placementMaterial, material);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,62 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerMovementWrapper20 implements PlayerMovementWrapper {
|
||||
|
||||
@Override
|
||||
public void setPosition(Player player, Object object) {
|
||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||
if (packetPlayInFlying.h) {
|
||||
entityPlayer.b(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, packetPlayInFlying.d, packetPlayInFlying.e);
|
||||
} else {
|
||||
entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertToOut(Player player, Object object) {
|
||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||
Object packet = Reflection.newInstance(teleportPacket);
|
||||
teleportEntity.set(packet, player.getEntityId());
|
||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||
if (packetPlayInFlying.h) {
|
||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||
} else {
|
||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
}
|
@ -27,8 +27,8 @@ version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* 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
|
||||
@ -25,16 +25,16 @@ import de.steamwar.linkage.plan.MethodBuilder;
|
||||
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
public class ScoreboardElement_GENERIC implements LinkageType {
|
||||
public class BlockAttribute_GENERIC implements LinkageType {
|
||||
|
||||
@Override
|
||||
public String method() {
|
||||
return "link";
|
||||
return "linkBlockAttributes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
|
||||
buildPlan.addImport("de.steamwar.bausystem.features.world.BauScoreboard");
|
||||
methodBuilder.addLine("BauScoreboard.addElement(" + s + ");");
|
||||
buildPlan.addImport("de.steamwar.bausystem.features.attributescopy.*");
|
||||
methodBuilder.addLine("AttributesCopyCommand.add(" + s + ");");
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.linkage.types;
|
||||
|
||||
import de.steamwar.linkage.LinkageType;
|
||||
import de.steamwar.linkage.plan.BuildPlan;
|
||||
import de.steamwar.linkage.plan.MethodBuilder;
|
||||
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
public class LuaLib_GENERIC implements LinkageType {
|
||||
|
||||
@Override
|
||||
public String method() {
|
||||
return "link";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
|
||||
buildPlan.addImport("de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin");
|
||||
methodBuilder.addLine("SteamWarLuaPlugin.add(" + s + ");");
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.linkage.types;
|
||||
|
||||
import de.steamwar.linkage.LinkageType;
|
||||
import de.steamwar.linkage.plan.BuildPlan;
|
||||
import de.steamwar.linkage.plan.MethodBuilder;
|
||||
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
public class Operator_GENERIC implements LinkageType {
|
||||
|
||||
@Override
|
||||
public String method() {
|
||||
return "linkScriptCommands";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
|
||||
buildPlan.addImport("de.steamwar.bausystem.features.script.expression.Expression");
|
||||
methodBuilder.addLine("Expression.registerOperator(" + s + ");");
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.linkage.types;
|
||||
|
||||
import de.steamwar.linkage.LinkageType;
|
||||
import de.steamwar.linkage.plan.BuildPlan;
|
||||
import de.steamwar.linkage.plan.MethodBuilder;
|
||||
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
public class SmartPlaceBehaviour_GENERIC implements LinkageType {
|
||||
|
||||
@Override
|
||||
public String method() {
|
||||
return "linkSmartPlace";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
|
||||
buildPlan.addImport("de.steamwar.bausystem.features.smartplace.SmartPlaceListener");
|
||||
methodBuilder.addLine("SmartPlaceListener.add(" + s + ");");
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.linkage.types;
|
||||
|
||||
import de.steamwar.linkage.LinkageType;
|
||||
import de.steamwar.linkage.plan.BuildPlan;
|
||||
import de.steamwar.linkage.plan.MethodBuilder;
|
||||
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
public class SpecialCommand_GENERIC implements LinkageType {
|
||||
|
||||
@Override
|
||||
public String method() {
|
||||
return "linkScriptCommands";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
|
||||
buildPlan.addImport("de.steamwar.bausystem.features.script.ScriptExecutor");
|
||||
methodBuilder.addLine("ScriptExecutor.SPECIAL_COMMANDS.add(" + s + ");");
|
||||
}
|
||||
}
|
@ -27,8 +27,8 @@ version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
@ -54,16 +54,14 @@ dependencies {
|
||||
implementation project(":BauSystem_Linkage")
|
||||
annotationProcessor project(":BauSystem_Linkage")
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
|
||||
compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
|
||||
compileOnly 'com.mojang:authlib:1.5.25'
|
||||
compileOnly 'io.netty:netty-all:4.1.68.Final'
|
||||
|
||||
compileOnly swdep('Spigot-1.20')
|
||||
compileOnly swdep('Spigot-1.19')
|
||||
// compileOnly swdep('WorldEdit-1.15')
|
||||
compileOnly swdep('SpigotCore')
|
||||
annotationProcessor swdep('SpigotCore')
|
||||
|
||||
compileOnly swdep('FastAsyncWorldEdit-1.18')
|
||||
compileOnly swdep('AxiomPaper')
|
||||
|
||||
implementation 'org.luaj:luaj-jse:3.0.1'
|
||||
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -21,44 +21,37 @@ package de.steamwar.bausystem;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
||||
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
||||
import de.steamwar.bausystem.region.loader.RegionLoader;
|
||||
import de.steamwar.bausystem.region.loader.Updater;
|
||||
import de.steamwar.bausystem.utils.TickListener;
|
||||
import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import de.steamwar.command.AbstractValidator;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
||||
import de.steamwar.message.Message;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BauSystem extends JavaPlugin implements Listener {
|
||||
|
||||
// This should be treated as final!
|
||||
public static Message MESSAGE;
|
||||
public static final boolean DEV_SERVER = !System.getProperty("user.home").endsWith("minecraft");
|
||||
|
||||
@Getter
|
||||
private static BauSystem instance;
|
||||
|
||||
private World world;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
world = Bukkit.getWorlds().get(0);
|
||||
|
||||
// LOGGER
|
||||
fixLogging();
|
||||
|
||||
@ -73,40 +66,30 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
} catch (SecurityException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
Bukkit.shutdown();
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
new Updater(PrototypeLoader.file, PrototypeLoader::load);
|
||||
new Updater(RegionLoader.file, RegionLoader::load);
|
||||
|
||||
SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD));
|
||||
SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD));
|
||||
SWCommandUtils.addValidator("supervisor", validator(Permission.SUPERVISOR));
|
||||
SWCommandUtils.addValidator("owner", validator(Permission.OWNER));
|
||||
|
||||
try {
|
||||
LinkageUtils.link();
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
Bukkit.shutdown();
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
TickListener.impl.init();
|
||||
}
|
||||
|
||||
private <T extends CommandSender> AbstractValidator<T, ?> validator(Permission permission) {
|
||||
return (commandSender, object, messageSender) -> {
|
||||
if (commandSender instanceof Player) {
|
||||
if (permission.hasPermission((Player) commandSender)) {
|
||||
return true;
|
||||
// This could disable any watchdog stuff. We need to investigate if this is a problem.
|
||||
/*
|
||||
Thread thread = new Thread(() -> {
|
||||
while (true) {
|
||||
WatchdogThread.tick();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
messageSender.send("NO_PERMISSION");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
});
|
||||
thread.setName("WatchdogThread ticker");
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -139,44 +122,18 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
}));
|
||||
}
|
||||
|
||||
public static BukkitTask runTaskLater(Plugin plugin, Runnable runnable, long delay) {
|
||||
return new BukkitRunnable() {
|
||||
private int counter = 1;
|
||||
private void createLink(String source, String destination) {
|
||||
try {
|
||||
Bukkit.getLogger().log(Level.INFO, "Executing: ln -s /home/minecraft/server/Bau15/{0} {1}", new String[]{source, destination});
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("ln", "-s", "/home/minecraft/server/Bau15/" + source, destination);
|
||||
processBuilder.directory(world.getWorldFolder());
|
||||
processBuilder.inheritIO();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (TPSFreezeUtils.isFrozen()) return;
|
||||
if (counter >= delay) {
|
||||
runnable.run();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 0, 1);
|
||||
}
|
||||
|
||||
public static BukkitTask runTaskTimer(Plugin plugin, Runnable runnable, long delay, long period) {
|
||||
return new BukkitRunnable() {
|
||||
private int counter = 1;
|
||||
private boolean first = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (TPSFreezeUtils.isFrozen()) return;
|
||||
if (counter >= (first ? delay : period)) {
|
||||
first = false;
|
||||
runnable.run();
|
||||
counter = 1;
|
||||
return;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 0, 1);
|
||||
}
|
||||
|
||||
public static void runTaskTimer(Plugin plugin, Consumer<BukkitTask> consumer, long delay, long period) {
|
||||
AtomicReference<BukkitTask> task = new AtomicReference<>();
|
||||
task.set(runTaskTimer(plugin, () -> consumer.accept(task.get()), delay, period));
|
||||
Process process = processBuilder.start();
|
||||
process.waitFor();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
@ -20,77 +20,72 @@
|
||||
package de.steamwar.bausystem;
|
||||
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.features.world.BauMemberUpdate;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.command.CommandMetaData;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum Permission {
|
||||
|
||||
OWNER(bauweltMember -> false),
|
||||
SUPERVISOR(bauweltMember -> {
|
||||
return bauweltMember.isSupervisor();
|
||||
}),
|
||||
BUILD(bauweltMember -> {
|
||||
if (isTempOnlySpectator(bauweltMember)) return false;
|
||||
return bauweltMember.isBuild() || SUPERVISOR.permissionPredicate.test(bauweltMember);
|
||||
}),
|
||||
/**
|
||||
* Only used for {@link BauMemberUpdate}
|
||||
*/
|
||||
REAL_SPECTATOR(bauweltMember -> {
|
||||
return !bauweltMember.isBuild() && !bauweltMember.isSupervisor();
|
||||
}),
|
||||
/**
|
||||
* Primarily used for {@link de.steamwar.bausystem.linkage.specific.GuiItem}
|
||||
*/
|
||||
MEMBER(bauweltMember -> {
|
||||
return true;
|
||||
});
|
||||
|
||||
private static final Set<Integer> TEMP_ONLY_SPECTATOR = new HashSet<>();
|
||||
|
||||
private static boolean isTempOnlySpectator(BauweltMember bauweltMember) {
|
||||
return TEMP_ONLY_SPECTATOR.contains(bauweltMember.getMemberID());
|
||||
}
|
||||
|
||||
public static boolean isTempOnlySpectator(Player player) {
|
||||
return TEMP_ONLY_SPECTATOR.contains(SteamwarUser.get(player.getUniqueId()).getId());
|
||||
}
|
||||
|
||||
public static void forceOnlySpectator(Player player) {
|
||||
TEMP_ONLY_SPECTATOR.add(SteamwarUser.get(player.getUniqueId()).getId());
|
||||
BauMemberUpdate.baumemberUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Only used by {@link BauMemberUpdate}
|
||||
*/
|
||||
public static void removeForceOnlySpectator(Player player) {
|
||||
TEMP_ONLY_SPECTATOR.remove(SteamwarUser.get(player.getUniqueId()).getId());
|
||||
}
|
||||
WORLD(BauweltMember::isWorld),
|
||||
WORLDEDIT(BauweltMember::isWorldEdit),
|
||||
MEMBER(bauweltMember -> true),
|
||||
OWNER(bauweltMember -> false);
|
||||
|
||||
private final Predicate<BauweltMember> permissionPredicate;
|
||||
|
||||
public boolean hasPermission(BauweltMember bauweltMember) {
|
||||
if (bauweltMember == null) return false;
|
||||
return permissionPredicate.test(bauweltMember);
|
||||
public boolean hasPermission(Player member) {
|
||||
if (member.getUniqueId().equals(BauServer.getInstance().getOwner())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player member) {
|
||||
if (SteamwarUser.get(member.getUniqueId()).getId() == BauServer.getInstance().getOwnerID()) {
|
||||
return this != REAL_SPECTATOR;
|
||||
BauweltMember bauMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId());
|
||||
if (bauMember == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return permissionPredicate.test(bauMember);
|
||||
}
|
||||
|
||||
public static boolean hasPermission(Player member, Permission permission) {
|
||||
return permission.hasPermission(member);
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
@CommandMetaData.Parameter({Player.class})
|
||||
@CommandMetaData.ImplicitValidator(handler = Perm.Handler.class, order = -10)
|
||||
public @interface Perm {
|
||||
Permission value();
|
||||
String message() default "";
|
||||
|
||||
class Handler implements TypeValidator<Player> {
|
||||
|
||||
private Permission permission;
|
||||
private String message;
|
||||
|
||||
public Handler(Perm perm) {
|
||||
this.permission = perm.value();
|
||||
this.message = perm.message();
|
||||
if (message != null && message.isEmpty()) message = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate(CommandSender commandSender, Player player, MessageSender messageSender) {
|
||||
if (message == null) {
|
||||
return permission.hasPermission(player);
|
||||
}
|
||||
return !messageSender.send(!permission.hasPermission((Player) commandSender), message);
|
||||
}
|
||||
}
|
||||
BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId());
|
||||
if (bauweltMember == null) return this == REAL_SPECTATOR;
|
||||
return permissionPredicate.test(bauweltMember);
|
||||
}
|
||||
}
|
@ -97,7 +97,7 @@ public class Config implements Listener {
|
||||
|
||||
public void saveAll() {
|
||||
playerConfigurations.forEach((uuid, yapionObject) -> {
|
||||
String string = yapionObject.toYAPION(new StringOutput()).getResult().replaceAll("\\+", "\\");
|
||||
String string = yapionObject.toYAPION(new StringOutput()).getResult();
|
||||
UserConfig.updatePlayerConfig(uuid, "bausystem", string);
|
||||
});
|
||||
playerConfigurations.clear();
|
||||
@ -112,7 +112,7 @@ public class Config implements Listener {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (playerConfigurations.containsKey(uuid)) {
|
||||
YAPIONObject yapionObject = playerConfigurations.get(uuid);
|
||||
String string = yapionObject.toYAPION(new StringOutput()).getResult().replaceAll("\\\\+", "\\\\");
|
||||
String string = yapionObject.toYAPION(new StringOutput()).getResult();
|
||||
UserConfig.updatePlayerConfig(uuid, "bausystem", string);
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
@MinVersion(18)
|
||||
public class AttributeRemoveCommand extends SWCommand {
|
||||
|
||||
public AttributeRemoveCommand() {
|
||||
@ -44,7 +45,7 @@ public class AttributeRemoveCommand extends SWCommand {
|
||||
|
||||
@Register({"all"})
|
||||
@Register({"*"})
|
||||
public void genericCommand(@Validator Player player) {
|
||||
public void genericCommand(Player player) {
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setLore(new ArrayList<>());
|
||||
@ -53,7 +54,7 @@ public class AttributeRemoveCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(description = "ATTRIBUTE_REMOVE_COMMAND_HELP")
|
||||
public void genericCommand(@Validator Player player, @Mapper("attribute") String attribute) {
|
||||
public void genericCommand(Player player, @Mapper("attribute") String attribute) {
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (itemMeta == null) {
|
||||
@ -73,7 +74,7 @@ public class AttributeRemoveCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.send("ATTRIBUTE_REMOVE_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
lore.removeIf(s -> s.startsWith("§8-§7 " + attribute + "§8:"));
|
||||
lore.removeIf(s -> s.equals("§8-§7 " + attribute));
|
||||
if (lore.size() == 1) {
|
||||
itemStack.setItemMeta(null);
|
||||
} else {
|
||||
@ -99,13 +100,13 @@ public class AttributeRemoveCommand extends SWCommand {
|
||||
return lore.stream()
|
||||
.skip(1)
|
||||
.map(s1 -> s1.substring(6))
|
||||
.map(s1 -> s1.substring(0, s1.indexOf("§8:")))
|
||||
.map(s1 -> s1.replace(' ', '_'))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||
return s;
|
||||
return s.replace('_', ' ');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,128 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@UtilityClass
|
||||
public class AttributeUtils {
|
||||
|
||||
private Map<Method, String> names = new HashMap<>();
|
||||
private Map<Class<?>, List<Method>> getters = new HashMap<>();
|
||||
private Map<Class<?>, Map<String, Method>> setters = new HashMap<>();
|
||||
|
||||
private void generate(BlockData blockData) {
|
||||
Class<? extends BlockData> clazz = blockData.getClass();
|
||||
if (getters.containsKey(clazz) && setters.containsKey(clazz)) return;
|
||||
|
||||
Map<String, List<Method>> methods = new HashMap<>();
|
||||
for (Method declaredMethod : clazz.getMethods()) {
|
||||
String s = declaredMethod.getName();
|
||||
if (s.startsWith("get") && declaredMethod.getParameterCount() == 0) {
|
||||
methods.computeIfAbsent(s.substring(3), aClass -> new ArrayList<>()).add(declaredMethod);
|
||||
} else if (s.startsWith("is") && declaredMethod.getParameterCount() == 0) {
|
||||
methods.computeIfAbsent(s.substring(2), aClass -> new ArrayList<>()).add(declaredMethod);
|
||||
} else if (s.startsWith("set") && declaredMethod.getParameterCount() == 1) {
|
||||
methods.computeIfAbsent(s.substring(3), aClass -> new ArrayList<>()).add(declaredMethod);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, List<Method>> entry : methods.entrySet()) {
|
||||
if (entry.getValue().size() != 2) continue;
|
||||
for (Method method : entry.getValue()) {
|
||||
names.put(method, entry.getKey());
|
||||
if (method.getName().startsWith("is") || method.getName().startsWith("get")) {
|
||||
getters.computeIfAbsent(clazz, aClass -> new ArrayList<>()).add(method);
|
||||
} else {
|
||||
setters.computeIfAbsent(clazz, aClass -> new HashMap<>()).put(entry.getKey(), method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void copy(BlockData blockData, List<String> attributes) {
|
||||
generate(blockData);
|
||||
|
||||
getters.getOrDefault(blockData.getClass(), new ArrayList<>()).forEach(method -> {
|
||||
try {
|
||||
Object invoke = method.invoke(blockData);
|
||||
if (invoke != null) {
|
||||
attributes.add("§8-§7 " + names.get(method) + "§8:§7 " + convert(invoke));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void paste(BlockData blockData, List<String> attributes) {
|
||||
generate(blockData);
|
||||
|
||||
for (String attribute : attributes) {
|
||||
String[] split = attribute.split("§8:§7 ");
|
||||
if (split.length != 2) continue;
|
||||
String name = split[0].substring(6);
|
||||
String value = split[1];
|
||||
Method method = setters.getOrDefault(blockData.getClass(), new HashMap<>()).get(name);
|
||||
if (method == null) continue;
|
||||
try {
|
||||
method.invoke(blockData, convert(value, method.getParameterTypes()[0]));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String convert(Object o) {
|
||||
if (o.getClass().isEnum()) {
|
||||
return ((Enum<?>) o).name();
|
||||
} else {
|
||||
return o.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private Object convert(String s, Class<?> type) {
|
||||
if (type.isEnum()) {
|
||||
return Enum.valueOf((Class<? extends Enum>) type, s);
|
||||
} else if (type == int.class || type == Integer.class) {
|
||||
return Integer.parseInt(s);
|
||||
} else if (type == double.class || type == Double.class) {
|
||||
return Double.parseDouble(s);
|
||||
} else if (type == float.class || type == Float.class) {
|
||||
return Float.parseFloat(s);
|
||||
} else if (type == long.class || type == Long.class) {
|
||||
return Long.parseLong(s);
|
||||
} else if (type == short.class || type == Short.class) {
|
||||
return Short.parseShort(s);
|
||||
} else if (type == byte.class || type == Byte.class) {
|
||||
return Byte.parseByte(s);
|
||||
} else if (type == boolean.class || type == Boolean.class) {
|
||||
return Boolean.parseBoolean(s);
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,8 +20,10 @@
|
||||
package de.steamwar.bausystem.features.attributescopy;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -34,29 +36,40 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Linked
|
||||
@MinVersion(18)
|
||||
public class AttributesCopyCommand extends SWCommand {
|
||||
|
||||
static List<BlockAttribute<?>> blockAttributeList = new ArrayList<>();
|
||||
|
||||
public static void add(BlockAttribute<?> blockAttribute) {
|
||||
blockAttributeList.add(blockAttribute);
|
||||
}
|
||||
|
||||
public AttributesCopyCommand() {
|
||||
super("copyattributes", "attributescopy", "ac");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(@Validator Player player) {
|
||||
public void genericCommand(Player player) {
|
||||
linkIfNeeded();
|
||||
|
||||
Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS);
|
||||
if (block == null) return;
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (!(block.getType().isItem() && block.getType() == mainHand.getType() || isSame(block, mainHand))) {
|
||||
if (!isSame(block, mainHand)) {
|
||||
BauSystem.MESSAGE.send("ATTRIBUTES_CANT_COPY", player);
|
||||
return;
|
||||
}
|
||||
|
||||
BlockData blockData = block.getBlockData();
|
||||
List<String> attributesToCopy = new ArrayList<>();
|
||||
if (block.getType() != mainHand.getType()) {
|
||||
attributesToCopy.add("§8-§7 Material§8:§7 " + block.getType().name());
|
||||
if (needsType(block)) {
|
||||
attributesToCopy.add("§8-§7 material " + block.getType().name().toLowerCase());
|
||||
}
|
||||
for (BlockAttribute blockAttribute : blockAttributeList) {
|
||||
if (blockAttribute.type().isInstance(blockData)) {
|
||||
blockAttribute.copy(attributesToCopy, blockData);
|
||||
}
|
||||
}
|
||||
AttributeUtils.copy(blockData, attributesToCopy);
|
||||
if (attributesToCopy.isEmpty()) {
|
||||
BauSystem.MESSAGE.send("ATTRIBUTES_NO_COPY", player);
|
||||
return;
|
||||
@ -70,7 +83,15 @@ public class AttributesCopyCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.send("ATTRIBUTES_COPIED", player);
|
||||
}
|
||||
|
||||
private static boolean isLinked = false;
|
||||
static void linkIfNeeded() {
|
||||
if (isLinked) return;
|
||||
LinkageUtils.linkBlockAttributes();
|
||||
isLinked = true;
|
||||
}
|
||||
|
||||
private boolean isSame(Block block, ItemStack itemStack) {
|
||||
if (block.getType() == itemStack.getType()) return true;
|
||||
if (itemStack.getType() == Material.REDSTONE && block.getType() == Material.REDSTONE_WIRE) return true;
|
||||
if (itemStack.getType() == Material.PLAYER_HEAD && block.getType() == Material.PLAYER_WALL_HEAD) return true;
|
||||
if (itemStack.getType() == Material.ZOMBIE_HEAD && block.getType() == Material.ZOMBIE_WALL_HEAD) return true;
|
||||
@ -81,8 +102,22 @@ public class AttributesCopyCommand extends SWCommand {
|
||||
if (itemStack.getType() == Material.TORCH && block.getType() == Material.WALL_TORCH) return true;
|
||||
if (itemStack.getType() == Material.SOUL_TORCH && block.getType() == Material.SOUL_WALL_TORCH) return true;
|
||||
if (itemStack.getType() == Material.REDSTONE_TORCH && block.getType() == Material.REDSTONE_WALL_TORCH) return true;
|
||||
if (itemStack.getType() == Material.WHEAT_SEEDS && block.getType() == Material.WHEAT) return true;
|
||||
if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean needsType(Block block) {
|
||||
if (block.getType().name().contains("WALL")) return true;
|
||||
if (block.getType() == Material.PLAYER_HEAD) return true;
|
||||
if (block.getType() == Material.ZOMBIE_HEAD) return true;
|
||||
if (block.getType() == Material.CREEPER_HEAD) return true;
|
||||
if (block.getType() == Material.DRAGON_HEAD) return true;
|
||||
if (block.getType() == Material.SKELETON_SKULL) return true;
|
||||
if (block.getType() == Material.WITHER_SKELETON_SKULL) return true;
|
||||
if (block.getType() == Material.TORCH) return true;
|
||||
if (block.getType() == Material.SOUL_TORCH) return true;
|
||||
if (block.getType() == Material.REDSTONE_TORCH) return true;
|
||||
if (block.getType().name().contains("_BANNER")) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@
|
||||
package de.steamwar.bausystem.features.attributescopy;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -33,15 +33,21 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.profile.PlayerProfile;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static de.steamwar.bausystem.features.attributescopy.AttributesCopyCommand.blockAttributeList;
|
||||
|
||||
@Linked
|
||||
@MinVersion(18)
|
||||
public class AttributesPlaceListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
AttributesCopyCommand.linkIfNeeded();
|
||||
ItemStack itemStack = event.getItemInHand();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (itemMeta == null) return;
|
||||
@ -59,12 +65,12 @@ public class AttributesPlaceListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
Material material = strings.stream()
|
||||
.filter(s -> s.startsWith("§8-§7 Material§8:§7 "))
|
||||
.map(s -> s.replace("§8-§7 Material§8:§7 ", ""))
|
||||
.filter(s -> s.startsWith("§8-§7 material "))
|
||||
.map(s -> s.replace("§8-§7 material ", ""))
|
||||
.map(String::toUpperCase)
|
||||
.map(s -> {
|
||||
try {
|
||||
return Material.valueOf(s);
|
||||
return Material.valueOf(s.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
@ -72,6 +78,7 @@ public class AttributesPlaceListener implements Listener {
|
||||
.findFirst()
|
||||
.orElse(type);
|
||||
event.getBlock().setType(material, false);
|
||||
Set<String> attributesToPaste = new HashSet<>(strings);
|
||||
Block block = event.getBlock();
|
||||
BlockData blockData = block.getBlockData();
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
@ -81,7 +88,11 @@ public class AttributesPlaceListener implements Listener {
|
||||
skull.update(true, false);
|
||||
}
|
||||
}, 1);
|
||||
AttributeUtils.paste(blockData, strings);
|
||||
for (BlockAttribute blockAttribute : blockAttributeList) {
|
||||
if (blockAttribute.type().isInstance(blockData)) {
|
||||
blockAttribute.paste(attributesToPaste, blockData);
|
||||
}
|
||||
}
|
||||
block.setBlockData(blockData, false);
|
||||
}, 1);
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface BlockAttribute<T extends BlockData> {
|
||||
Class<T> type();
|
||||
void copy(List<String> attributes, T blockData);
|
||||
void paste(Set<String> attributes, T blockData);
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class AgeableAttribute implements BlockAttribute<Ageable> {
|
||||
|
||||
private String attribute = "§8-§7 age ";
|
||||
|
||||
@Override
|
||||
public Class<Ageable> type() {
|
||||
return Ageable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Ageable blockData) {
|
||||
attributes.add(attribute + blockData.getAge());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Ageable blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setAge);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.AnaloguePowerable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class AnaloguePowerableAttribute implements BlockAttribute<AnaloguePowerable> {
|
||||
|
||||
private String attribute = "§8-§7 power ";
|
||||
|
||||
@Override
|
||||
public Class<AnaloguePowerable> type() {
|
||||
return AnaloguePowerable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, AnaloguePowerable blockData) {
|
||||
attributes.add(attribute + blockData.getPower());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, AnaloguePowerable blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setPower);
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* 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
|
||||
@ -17,31 +17,32 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.region;
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.block.data.Attachable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RegionScoreboardElement implements ScoreboardElement {
|
||||
public class AttachableAttribute implements BlockAttribute<Attachable> {
|
||||
|
||||
private String attribute = "§8-§7 attached";
|
||||
|
||||
@Override
|
||||
public ScoreboardGroup getGroup() {
|
||||
return ScoreboardGroup.HEADER;
|
||||
public Class<Attachable> type() {
|
||||
return Attachable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
return 1;
|
||||
public void copy(List<String> attributes, Attachable blockData) {
|
||||
if (blockData.isAttached()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (GlobalRegion.getInstance() == region) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName();
|
||||
public void paste(Set<String> attributes, Attachable blockData) {
|
||||
blockData.setAttached(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class BisectedAttribute implements BlockAttribute<Bisected> {
|
||||
|
||||
private String attribute = "§8-§7 half ";
|
||||
|
||||
@Override
|
||||
public Class<Bisected> type() {
|
||||
return Bisected.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Bisected blockData) {
|
||||
attributes.add(attribute + blockData.getHalf().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Bisected blockData) {
|
||||
for (Bisected.Half half : Bisected.Half.values()) {
|
||||
if (attributes.contains(attribute + half.name().toLowerCase())) {
|
||||
blockData.setHalf(half);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Directional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class DirectionalAttribute implements BlockAttribute<Directional> {
|
||||
|
||||
private String attribute = "§8-§7 facing ";
|
||||
|
||||
@Override
|
||||
public Class<Directional> type() {
|
||||
return Directional.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Directional blockData) {
|
||||
attributes.add(attribute + blockData.getFacing().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Directional blockData) {
|
||||
for (BlockFace blockFace : blockData.getFaces()) {
|
||||
if (attributes.contains(attribute + blockFace.name().toLowerCase())) {
|
||||
blockData.setFacing(blockFace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.FaceAttachable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class FaceAttachableAttribute implements BlockAttribute<FaceAttachable> {
|
||||
|
||||
private String attribute = "§8-§7 attached ";
|
||||
|
||||
@Override
|
||||
public Class<FaceAttachable> type() {
|
||||
return FaceAttachable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, FaceAttachable blockData) {
|
||||
attributes.add(attribute + blockData.getAttachedFace().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, FaceAttachable blockData) {
|
||||
for (FaceAttachable.AttachedFace attachedFace : FaceAttachable.AttachedFace.values()) {
|
||||
if (attributes.contains(attribute + attachedFace.name().toLowerCase())) {
|
||||
blockData.setAttachedFace(attachedFace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.block.data.Hangable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
@MinVersion(19)
|
||||
public class HangableAttribute implements BlockAttribute<Hangable> {
|
||||
|
||||
private String attribute = "§8-§7 hanging";
|
||||
|
||||
@Override
|
||||
public Class<Hangable> type() {
|
||||
return Hangable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Hangable blockData) {
|
||||
if (!blockData.isHanging()) return;
|
||||
attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Hangable blockData) {
|
||||
blockData.setHanging(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Levelled;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class LevelledAttribute implements BlockAttribute<Levelled> {
|
||||
|
||||
private String attribute = "§8-§7 level ";
|
||||
|
||||
@Override
|
||||
public Class<Levelled> type() {
|
||||
return Levelled.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Levelled blockData) {
|
||||
attributes.add(attribute + blockData.getLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Levelled blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setLevel);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Lightable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class LightableAttribute implements BlockAttribute<Lightable> {
|
||||
|
||||
private String attribute = "§8-§7 lit";
|
||||
|
||||
@Override
|
||||
public Class<Lightable> type() {
|
||||
return Lightable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Lightable blockData) {
|
||||
if (blockData.isLit()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Lightable blockData) {
|
||||
blockData.setLit(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class MultipleFacingAttribute implements BlockAttribute<MultipleFacing> {
|
||||
|
||||
private String attribute = "§8-§7 connected ";
|
||||
|
||||
@Override
|
||||
public Class<MultipleFacing> type() {
|
||||
return MultipleFacing.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, MultipleFacing blockData) {
|
||||
blockData.getFaces().forEach(blockFace -> {
|
||||
attributes.add(attribute + blockFace.name().toLowerCase());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, MultipleFacing blockData) {
|
||||
for (BlockFace blockFace : BlockFace.values()) {
|
||||
blockData.setFace(blockFace, attributes.contains(attribute + blockFace.name().toLowerCase()));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Openable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class OpenableAttribute implements BlockAttribute<Openable> {
|
||||
|
||||
private String attribute = "§8-§7 open";
|
||||
|
||||
@Override
|
||||
public Class<Openable> type() {
|
||||
return Openable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Openable blockData) {
|
||||
if (blockData.isOpen()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Openable blockData) {
|
||||
blockData.setOpen(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Axis;
|
||||
import org.bukkit.block.data.Orientable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class OrientableAttribute implements BlockAttribute<Orientable> {
|
||||
|
||||
private String attribute = "§8-§7 orientation ";
|
||||
|
||||
@Override
|
||||
public Class<Orientable> type() {
|
||||
return Orientable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Orientable blockData) {
|
||||
attributes.add(attribute + blockData.getAxis().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Orientable blockData) {
|
||||
for (Axis axis : Axis.values()) {
|
||||
if (attributes.contains(attribute + axis.name().toLowerCase())) {
|
||||
blockData.setAxis(axis);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Powerable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class PowerableAttribute implements BlockAttribute<Powerable> {
|
||||
|
||||
private String attribute = "§8-§7 powered";
|
||||
|
||||
@Override
|
||||
public Class<Powerable> type() {
|
||||
return Powerable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Powerable blockData) {
|
||||
if (blockData.isPowered()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Powerable blockData) {
|
||||
blockData.setPowered(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Rail;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RailAttribute implements BlockAttribute<Rail> {
|
||||
|
||||
private String attribute = "§8-§7 rail shape ";
|
||||
|
||||
@Override
|
||||
public Class<Rail> type() {
|
||||
return Rail.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Rail blockData) {
|
||||
attributes.add(attribute + blockData.getShape().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Rail blockData) {
|
||||
for (Rail.Shape shape : Rail.Shape.values()) {
|
||||
if (attributes.contains(attribute + shape)) {
|
||||
blockData.setShape(shape);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Rotatable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RotatableAttribute implements BlockAttribute<Rotatable> {
|
||||
|
||||
private String attribute = "§8-§7 rotation ";
|
||||
|
||||
@Override
|
||||
public Class<Rotatable> type() {
|
||||
return Rotatable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Rotatable blockData) {
|
||||
attributes.add(attribute + blockData.getRotation().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Rotatable blockData) {
|
||||
for (BlockFace face : BlockFace.values()) {
|
||||
if (attributes.contains(attribute + face.name())) {
|
||||
blockData.setRotation(face);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Snowable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class SnowableAttribute implements BlockAttribute<Snowable> {
|
||||
|
||||
private String attribute = "§8-§7 snowy";
|
||||
|
||||
@Override
|
||||
public Class<Snowable> type() {
|
||||
return Snowable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Snowable blockData) {
|
||||
if (blockData.isSnowy()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Snowable blockData) {
|
||||
blockData.setSnowy(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class WaterloggedAttribute implements BlockAttribute<Waterlogged> {
|
||||
|
||||
private String attribute = "§8-§7 waterlogged";
|
||||
|
||||
@Override
|
||||
public Class<Waterlogged> type() {
|
||||
return Waterlogged.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Waterlogged waterlogged) {
|
||||
if (!waterlogged.isWaterlogged()) return;
|
||||
attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Waterlogged waterlogged) {
|
||||
waterlogged.setWaterlogged(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Bamboo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class BambooAttribute implements BlockAttribute<Bamboo> {
|
||||
|
||||
private String attribute = "§8-§7 leaves ";
|
||||
|
||||
@Override
|
||||
public Class<Bamboo> type() {
|
||||
return Bamboo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Bamboo blockData) {
|
||||
attributes.add(attribute + blockData.getLeaves());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Bamboo blockData) {
|
||||
for (Bamboo.Leaves leaves : Bamboo.Leaves.values()) {
|
||||
if (attributes.contains(attribute + leaves)) {
|
||||
blockData.setLeaves(leaves);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Bell;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class BellAttribute implements BlockAttribute<Bell> {
|
||||
|
||||
private String attribute = "§8-§7 attachament ";
|
||||
|
||||
@Override
|
||||
public Class<Bell> type() {
|
||||
return Bell.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Bell blockData) {
|
||||
attributes.add(attribute + blockData.getAttachment());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Bell blockData) {
|
||||
for (Bell.Attachment attachment : Bell.Attachment.values()) {
|
||||
if (attributes.contains(attribute + attachment)) {
|
||||
blockData.setAttachment(attachment);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.block.data.type.BigDripleaf;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
@MinVersion(18)
|
||||
public class BigDripleafAttribute implements BlockAttribute<BigDripleaf> {
|
||||
|
||||
private String attribute = "§8-§7 tilt ";
|
||||
|
||||
@Override
|
||||
public Class<BigDripleaf> type() {
|
||||
return BigDripleaf.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, BigDripleaf blockData) {
|
||||
attributes.add(attribute + blockData.getTilt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, BigDripleaf blockData) {
|
||||
for (BigDripleaf.Tilt tilt : BigDripleaf.Tilt.values()) {
|
||||
if (attributes.contains(attribute + tilt)) {
|
||||
blockData.setTilt(tilt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Cake;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class CakeAttribute implements BlockAttribute<Cake> {
|
||||
|
||||
private String attribute = "§8-§7 bites ";
|
||||
|
||||
@Override
|
||||
public Class<Cake> type() {
|
||||
return Cake.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Cake blockData) {
|
||||
attributes.add(attribute + blockData.getBites());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Cake blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setBites);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Campfire;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class CampfireAttribute implements BlockAttribute<Campfire> {
|
||||
|
||||
private String attribute = "§8-§7 signal fire";
|
||||
|
||||
@Override
|
||||
public Class<Campfire> type() {
|
||||
return Campfire.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Campfire blockData) {
|
||||
if (blockData.isSignalFire()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Campfire blockData) {
|
||||
blockData.setSignalFire(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Candle;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class CandleAttribute implements BlockAttribute<Candle> {
|
||||
|
||||
private String attribute = "§8-§7 candles ";
|
||||
|
||||
@Override
|
||||
public Class<Candle> type() {
|
||||
return Candle.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Candle blockData) {
|
||||
if (blockData.getCandles() > 0) attributes.add(attribute + blockData.getCandles());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Candle blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setCandles);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.CaveVinesPlant;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class CaveVinesPlantAttribute implements BlockAttribute<CaveVinesPlant> {
|
||||
|
||||
private String attribute = "§8-§7 berries";
|
||||
|
||||
@Override
|
||||
public Class<CaveVinesPlant> type() {
|
||||
return CaveVinesPlant.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, CaveVinesPlant blockData) {
|
||||
if (blockData.isBerries()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, CaveVinesPlant blockData) {
|
||||
blockData.setBerries(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Comparator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class ComparatorAttribute implements BlockAttribute<Comparator> {
|
||||
|
||||
private String attribute = "§8-§7 mode ";
|
||||
|
||||
@Override
|
||||
public Class<Comparator> type() {
|
||||
return Comparator.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Comparator blockData) {
|
||||
attributes.add(attribute + blockData.getMode().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Comparator blockData) {
|
||||
for (Comparator.Mode mode : Comparator.Mode.values()) {
|
||||
if (attributes.contains(attribute + mode.name())) {
|
||||
blockData.setMode(mode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.DaylightDetector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class DaylightDetectorAttribute implements BlockAttribute<DaylightDetector> {
|
||||
|
||||
private String attribute = "§8-§7 inverted";
|
||||
|
||||
@Override
|
||||
public Class<DaylightDetector> type() {
|
||||
return DaylightDetector.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, DaylightDetector blockData) {
|
||||
if (blockData.isInverted()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, DaylightDetector blockData) {
|
||||
blockData.setInverted(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Door;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class DoorAttribute implements BlockAttribute<Door> {
|
||||
|
||||
private String attribute = "§8-§7 hinge ";
|
||||
|
||||
@Override
|
||||
public Class<Door> type() {
|
||||
return Door.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Door blockData) {
|
||||
attributes.add(attribute + blockData.getHinge().toString().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Door blockData) {
|
||||
for (Door.Hinge hinge : Door.Hinge.values()) {
|
||||
if (attributes.contains(attribute + hinge.toString().toLowerCase())) {
|
||||
blockData.setHinge(hinge);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.EndPortalFrame;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class EndPortalFrameAttribute implements BlockAttribute<EndPortalFrame> {
|
||||
|
||||
private String attribute = "§8-§7 eye";
|
||||
|
||||
@Override
|
||||
public Class<EndPortalFrame> type() {
|
||||
return EndPortalFrame.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, EndPortalFrame blockData) {
|
||||
if (blockData.hasEye()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, EndPortalFrame blockData) {
|
||||
blockData.setEye(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Farmland;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class FarmlandAttribute implements BlockAttribute<Farmland> {
|
||||
|
||||
private String attribute = "§8-§7 moisture ";
|
||||
|
||||
@Override
|
||||
public Class<Farmland> type() {
|
||||
return Farmland.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Farmland blockData) {
|
||||
attributes.add(attribute + blockData.getMoisture());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Farmland blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setMoisture);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Gate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class GateAttribute implements BlockAttribute<Gate> {
|
||||
|
||||
private String attribute = "§8-§7 inWall";
|
||||
|
||||
@Override
|
||||
public Class<Gate> type() {
|
||||
return Gate.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Gate blockData) {
|
||||
if (blockData.isInWall()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Gate blockData) {
|
||||
blockData.setInWall(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Hopper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class HopperAttribute implements BlockAttribute<Hopper> {
|
||||
|
||||
private String attribute = "§8-§7 enabled";
|
||||
|
||||
@Override
|
||||
public Class<Hopper> type() {
|
||||
return Hopper.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Hopper blockData) {
|
||||
if (blockData.isEnabled()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Hopper blockData) {
|
||||
blockData.setEnabled(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Jigsaw;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class JigsawAttribute implements BlockAttribute<Jigsaw> {
|
||||
|
||||
private String attribute = "§8-§7 orientation ";
|
||||
|
||||
@Override
|
||||
public Class<Jigsaw> type() {
|
||||
return Jigsaw.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Jigsaw blockData) {
|
||||
attributes.add(attribute + blockData.getOrientation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Jigsaw blockData) {
|
||||
for (Jigsaw.Orientation orientation : Jigsaw.Orientation.values()) {
|
||||
if (attributes.contains(attribute + orientation)) {
|
||||
blockData.setOrientation(orientation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Lantern;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class LanternAttribute implements BlockAttribute<Lantern> {
|
||||
|
||||
private String attribute = "§8-§7 lantern";
|
||||
|
||||
@Override
|
||||
public Class<Lantern> type() {
|
||||
return Lantern.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Lantern lantern) {
|
||||
if (!lantern.isHanging()) return;
|
||||
attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Lantern lantern) {
|
||||
lantern.setHanging(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Leaves;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class LeavesAttribute implements BlockAttribute<Leaves> {
|
||||
|
||||
private String attribute = "§8-§7 persistent";
|
||||
|
||||
@Override
|
||||
public Class<Leaves> type() {
|
||||
return Leaves.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Leaves blockData) {
|
||||
if (blockData.isPersistent()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Leaves blockData) {
|
||||
blockData.setPersistent(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.PointedDripstone;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class PointedDripstoneAttribute implements BlockAttribute<PointedDripstone> {
|
||||
|
||||
private String attribute1 = "§8-§7 vertialDirection ";
|
||||
private String attribute2 = "§8-§7 thickness ";
|
||||
|
||||
@Override
|
||||
public Class<PointedDripstone> type() {
|
||||
return PointedDripstone.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, PointedDripstone blockData) {
|
||||
attributes.add(attribute1 + " " + blockData.getVerticalDirection().name().toLowerCase());
|
||||
attributes.add(attribute2 + " " + blockData.getThickness().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, PointedDripstone blockData) {
|
||||
for (BlockFace blockFace : blockData.getVerticalDirections()) {
|
||||
if (attributes.contains(attribute1 + " " + blockFace.name().toLowerCase())) {
|
||||
blockData.setVerticalDirection(blockFace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (PointedDripstone.Thickness thickness : PointedDripstone.Thickness.values()) {
|
||||
if (attributes.contains(attribute2 + " " + thickness.name().toLowerCase())) {
|
||||
blockData.setThickness(thickness);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.RedstoneWire;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RedstoneWireAttribute implements BlockAttribute<RedstoneWire> {
|
||||
|
||||
private String attribute = "§8-§7 connection ";
|
||||
|
||||
@Override
|
||||
public Class<RedstoneWire> type() {
|
||||
return RedstoneWire.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, RedstoneWire blockData) {
|
||||
for (BlockFace blockFace : blockData.getAllowedFaces()) {
|
||||
attributes.add(attribute + blockFace.name().toLowerCase() + " " + blockData.getFace(blockFace).name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, RedstoneWire blockData) {
|
||||
for (BlockFace blockFace : blockData.getAllowedFaces()) {
|
||||
for (RedstoneWire.Connection connection : RedstoneWire.Connection.values()) {
|
||||
if (attributes.contains(attribute + blockFace.name().toLowerCase() + " " + connection.name().toLowerCase())) {
|
||||
blockData.setFace(blockFace, connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Repeater;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RepeaterAttribute implements BlockAttribute<Repeater> {
|
||||
|
||||
private String attribute1 = "§8-§7 delay ";
|
||||
private String attribute2 = "§8-§7 locked";
|
||||
|
||||
@Override
|
||||
public Class<Repeater> type() {
|
||||
return Repeater.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Repeater blockData) {
|
||||
attributes.add(attribute1 + blockData.getDelay());
|
||||
if (blockData.isLocked()) attributes.add(attribute2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Repeater blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute1))
|
||||
.map(s -> s.replace(attribute1, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setDelay);
|
||||
blockData.setLocked(attributes.contains(attribute2));
|
||||
}
|
||||
}
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
In neuem Issue referenzieren
Einen Benutzer sperren