Merge pull request 'Custom Testblock' (#69) from customTestblock into master
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
c3f344e9c2
@ -45,11 +45,5 @@
|
|||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>FAWE</artifactId>
|
|
||||||
<version>1.12</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -1,13 +1,19 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.boydti.fawe.object.schematic.Schematic;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -15,15 +21,23 @@ public class Region_12 {
|
|||||||
private Region_12(){}
|
private Region_12(){}
|
||||||
|
|
||||||
static void paste(File file, int x, int y, int z, boolean rotate){
|
static void paste(File file, int x, int y, int z, boolean rotate){
|
||||||
Schematic schem;
|
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||||
|
Clipboard clipboard;
|
||||||
try {
|
try {
|
||||||
schem = FaweAPI.load(file);
|
clipboard = Objects.requireNonNull(ClipboardFormat.findByFile(file)).getReader(new FileInputStream(file)).read(w.getWorldData());
|
||||||
}catch(IOException e){
|
} catch (NullPointerException | IOException e) {
|
||||||
throw new SecurityException("Bausystem schematic not found", e);
|
throw new SecurityException("Bausystem schematic not found", e);
|
||||||
}
|
}
|
||||||
Vector dimensions = Objects.requireNonNull(schem.getClipboard()).getDimensions();
|
|
||||||
|
paste(clipboard, x, y, z, rotate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
|
||||||
|
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||||
|
|
||||||
|
Vector dimensions = clipboard.getDimensions();
|
||||||
Vector v = new Vector(x, y, z);
|
Vector v = new Vector(x, y, z);
|
||||||
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
|
Vector offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||||
AffineTransform aT = new AffineTransform();
|
AffineTransform aT = new AffineTransform();
|
||||||
if(rotate){
|
if(rotate){
|
||||||
aT = aT.rotateY(180);
|
aT = aT.rotateY(180);
|
||||||
@ -31,6 +45,11 @@ public class Region_12 {
|
|||||||
}else{
|
}else{
|
||||||
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
||||||
}
|
}
|
||||||
schem.paste(new BukkitWorld(Bukkit.getWorlds().get(0)), v, false, true, aT).flushQueue();
|
|
||||||
|
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
||||||
|
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
|
||||||
|
ch.setTransform(aT);
|
||||||
|
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).build());
|
||||||
|
e.flushQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||||
@ -28,6 +34,36 @@ public class Region_15 {
|
|||||||
throw new SecurityException("Bausystem schematic not found", e);
|
throw new SecurityException("Bausystem schematic not found", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paste(clipboard, x, y, z, rotate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
|
||||||
|
BlockVector3 dimensions = clipboard.getDimensions();
|
||||||
|
BlockVector3 v = BlockVector3.at(x, y, z);
|
||||||
|
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||||
|
AffineTransform aT = new AffineTransform();
|
||||||
|
if(rotate){
|
||||||
|
aT = aT.rotateY(180);
|
||||||
|
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
|
||||||
|
}else{
|
||||||
|
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1);
|
||||||
|
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||||
|
ch.setTransform(aT);
|
||||||
|
Operations.completeBlindly(ch.createPaste(e).to(v).build());
|
||||||
|
e.flushSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void fastpaste(File file, int x, int y, int z, boolean rotate){
|
||||||
|
Clipboard clipboard;
|
||||||
|
try {
|
||||||
|
clipboard = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file)).read();
|
||||||
|
} catch (NullPointerException | IOException e) {
|
||||||
|
throw new SecurityException("Bausystem schematic not found", e);
|
||||||
|
}
|
||||||
|
|
||||||
BlockVector3 dimensions = clipboard.getDimensions();
|
BlockVector3 dimensions = clipboard.getDimensions();
|
||||||
BlockVector3 v = BlockVector3.at(x, y, z);
|
BlockVector3 v = BlockVector3.at(x, y, z);
|
||||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||||
|
@ -67,5 +67,11 @@
|
|||||||
<version>1.15</version>
|
<version>1.15</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>WorldEdit</artifactId>
|
||||||
|
<version>1.15</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -4,6 +4,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.world.ArenaSection;
|
import de.steamwar.bausystem.world.ArenaSection;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -28,7 +29,16 @@ public class CommandReset implements CommandExecutor {
|
|||||||
for(ArenaSection section : BauSystem.getSections()){
|
for(ArenaSection section : BauSystem.getSections()){
|
||||||
if(section.inRegion(player.getLocation())){
|
if(section.inRegion(player.getLocation())){
|
||||||
try {
|
try {
|
||||||
section.reset();
|
if(args.length > 0){
|
||||||
|
Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
|
||||||
|
if(schem == null){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
section.reset(schem);
|
||||||
|
}else{
|
||||||
|
section.fastreset();
|
||||||
|
}
|
||||||
player.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
player.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
||||||
|
@ -4,11 +4,15 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.world.ArenaSection;
|
import de.steamwar.bausystem.world.ArenaSection;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
import de.steamwar.sql.NoClipboardException;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CommandTestblock implements CommandExecutor {
|
public class CommandTestblock implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -24,7 +28,21 @@ public class CommandTestblock implements CommandExecutor {
|
|||||||
|
|
||||||
for(ArenaSection section : BauSystem.getSections()){
|
for(ArenaSection section : BauSystem.getSections()){
|
||||||
if(section.inRegion(player.getLocation())){
|
if(section.inRegion(player.getLocation())){
|
||||||
section.getTestblock().reset();
|
if(args.length > 0){
|
||||||
|
Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
|
||||||
|
if(schem == null){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
section.getTestblock().reset(schem);
|
||||||
|
} catch (IOException | NoClipboardException e) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Laden der Schematic");
|
||||||
|
throw new SecurityException("Failed to load Testblock Schematic", e);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
section.getTestblock().reset();
|
||||||
|
}
|
||||||
player.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
|
player.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.sql.NoClipboardException;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class Region {
|
public class Region {
|
||||||
final int sizeX;
|
final int sizeX;
|
||||||
@ -38,11 +42,20 @@ public class Region {
|
|||||||
return min <= l && l <= min + size;
|
return min <= l && l <= min + size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fastreset(){
|
||||||
|
File file = new File(BauSystem.SECTION_PATH + schematic);
|
||||||
|
fastpaste(file, minX + sizeX/2, minY, minZ + sizeZ/2, rotate);
|
||||||
|
}
|
||||||
|
|
||||||
public void reset(){
|
public void reset(){
|
||||||
File file = new File(BauSystem.SECTION_PATH + schematic);
|
File file = new File(BauSystem.SECTION_PATH + schematic);
|
||||||
paste(file, minX + sizeX/2, minY, minZ + sizeZ/2, rotate);
|
paste(file, minX + sizeX/2, minY, minZ + sizeZ/2, rotate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset(Schematic schem) throws IOException, NoClipboardException {
|
||||||
|
paste(schem.load(), minX + sizeX/2, minY, minZ + sizeZ/2, rotate);
|
||||||
|
}
|
||||||
|
|
||||||
static void paste(File file, int x, int y, int z, boolean rotate){
|
static void paste(File file, int x, int y, int z, boolean rotate){
|
||||||
switch(Core.getVersion()){
|
switch(Core.getVersion()){
|
||||||
case 15:
|
case 15:
|
||||||
@ -52,4 +65,24 @@ public class Region {
|
|||||||
Region_12.paste(file, x, y, z, rotate);
|
Region_12.paste(file, x, y, z, rotate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void fastpaste(File file, int x, int y, int z, boolean rotate){
|
||||||
|
switch(Core.getVersion()){
|
||||||
|
case 15:
|
||||||
|
Region_15.fastpaste(file, x, y, z, rotate);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Region_12.paste(file, x, y, z, rotate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
|
||||||
|
switch(Core.getVersion()){
|
||||||
|
case 15:
|
||||||
|
Region_15.paste(clipboard, x, y, z, rotate);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Region_12.paste(clipboard, x, y, z, rotate);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren