SteamWar/BauSystem
Archiviert
13
0

Beginning with 1.14 support

Dieser Commit ist enthalten in:
Lixfel 2019-11-18 18:43:33 +01:00
Ursprung be7e5acec5
Commit a4d748b392
42 geänderte Dateien mit 695 neuen und 252 gelöschten Zeilen

49
BauSystem_12/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>steamwar</groupId>
<artifactId>BauSystem</artifactId>
<version>1.0</version>
</parent>
<artifactId>BauSystem_12</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>BauSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,11 @@
package de.steamwar.bausystem.commands;
import net.minecraft.server.v1_12_R1.MinecraftServer;
class CommandInfo_12 {
private CommandInfo_12(){}
static double[] getTps(){
return MinecraftServer.getServer().recentTps;
}
}

Datei anzeigen

@ -0,0 +1,72 @@
package de.steamwar.bausystem.world;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
class AutoLoader_12 {
private AutoLoader_12(){}
static boolean tntPlaceActionPerform(Location location){
Material m = location.getBlock().getType();
if(m != Material.AIR && m != Material.STATIONARY_WATER && m != Material.WATER)
return false;
location.getBlock().setType(Material.TNT);
return true;
}
@SuppressWarnings("deprecation")
static boolean setRedstone(Location location, boolean active){
Block block = location.getBlock();
Material material = block.getType();
if(material == Material.LEVER || material == Material.STONE_BUTTON || material == Material.WOOD_BUTTON){
if(active)
block.setData((byte)(block.getData() | 8));
else
block.setData((byte)(block.getData() & -9));
}else if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){
if(active)
block.setData((byte)1);
else
block.setData((byte)0);
}else{
return false;
}
block.getState().update(true);
return true;
}
@SuppressWarnings("deprecation")
static void onPlayerInteract(IAutoLoader loader, PlayerInteractEvent event){
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
Block block = event.getClickedBlock();
Material material = block.getType();
if(material == Material.LEVER){
if((block.getData() & 8) == 8) {
new IAutoLoader.RedstoneActivation(loader, block.getLocation(), loader.getLastActivation(), false);
loader.print("§eHebel zurückgesetzt", true);
}else{
new IAutoLoader.RedstoneActivation(loader, block.getLocation(), 1, true);
loader.print("§eHebel betätigt", true);
}
}else if(material == Material.STONE_BUTTON){
new IAutoLoader.TemporaryActivation(loader, block.getLocation(), 20);
loader.print("§eKnopf betätigt", true);
}else if(material == Material.WOOD_BUTTON){
new IAutoLoader.TemporaryActivation(loader, block.getLocation(), 30);
loader.print("§eKnopf betätigt", true);
}
}else if(event.getAction() == Action.PHYSICAL){
Block block = event.getClickedBlock();
Material material = block.getType();
if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){
new IAutoLoader.TemporaryActivation(loader, block.getLocation(), 20);
loader.print("§eDruckplatte betätigt", true);
}
}
}
}

Datei anzeigen

@ -0,0 +1,15 @@
package de.steamwar.bausystem.world;
import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform;
import org.bukkit.Bukkit;
public class Region_12 {
private Region_12(){}
static void paste(Schematic schem, Vector v, AffineTransform aT){
schem.paste(new BukkitWorld(Bukkit.getWorlds().get(0)), v, false, true, aT).flushQueue();
}
}

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -9,91 +8,65 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.material.Step;
import org.bukkit.scheduler.BukkitTask;
import java.util.*;
@SuppressWarnings("deprecation")
public class TNTTracer {
class TNTTracer_12 {
private TNTTracer_12(){}
private static final byte BRICK_STEP = new Step(Material.BRICK).getData();
private static final byte INVERTED_BRICK_STEP = (byte)(BRICK_STEP + 8);
private static final World world = Bukkit.getWorlds().get(0);
private static BukkitTask task;
private static final Set<Location> printedLocs = new HashSet<>();
private static final Map<TNTPrimed, LinkedList<Location>> locations = new HashMap<>();
private static World world;
static Status getStatus() {
return status;
}
private static Status status = Status.IDLE;
static void remove(TNTPrimed tnt){
static void remove(Map<TNTPrimed, LinkedList<Location>> locations, TNTPrimed tnt){
Material material = tnt.getLocation().getBlock().getType();
if(material == Material.WATER || material == Material.STATIONARY_WATER)
locations.remove(tnt);
}
public static void start(){
if(status == Status.RECORD)
return;
stop();
locations.clear();
world = Bukkit.getWorlds().get(0);
status = Status.RECORD;
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), TNTTracer::run, 1, 1);
}
public static int show(){
if(status == Status.SHOW)
return printedLocs.size();
stop();
status = Status.SHOW;
static int show(Map<TNTPrimed, LinkedList<Location>> locations, Set<Location> printedLocs){
for(LinkedList<Location> tntTrace : locations.values()){
if(tntTrace.size() == 1)
printLocation(tntTrace.getFirst());
printLocation(tntTrace.getFirst(), printedLocs);
else if(tntTrace.size() > 1)
interpolate(tntTrace);
interpolate(tntTrace, printedLocs);
}
locations.clear();
return printedLocs.size();
}
public static void stop(){
status = Status.IDLE;
if(task != null)
task.cancel();
static boolean airOrBrick(Block block){
Material material = block.getType();
if(material == Material.AIR || material == Material.BRICK)
return true;
if(material != Material.STEP)
return false;
for(Location l : printedLocs){
Block b = world.getBlockAt(l);
if(airOrBrick(b))
b.setType(Material.AIR);
}
printedLocs.clear();
byte data = block.getData();
return data == BRICK_STEP || data == INVERTED_BRICK_STEP;
}
private static void interpolate(LinkedList<Location> trace){
private static void interpolate(LinkedList<Location> trace, Set<Location> printedLocs){
ListIterator<Location> it = trace.listIterator();
Location previous = it.next();
printLocation(previous);
printLocation(previous, printedLocs);
while(it.hasNext()){
Location actual = it.next();
Set<Double> xSteps = getSteps(previous.getX(), actual.getX());
Set<Double> ySteps = getSteps(previous.getY(), actual.getY());
Set<Double> zSteps = getSteps(previous.getZ(), actual.getZ());
for(double y : ySteps)
printLocation(new Location(world, previous.getX(), y, previous.getZ()));
printLocation(new Location(world, previous.getX(), y, previous.getZ()), printedLocs);
for(double x : xSteps)
printLocation(new Location(world, x, actual.getY(), previous.getZ()));
printLocation(new Location(world, x, actual.getY(), previous.getZ()), printedLocs);
for(double z : zSteps)
printLocation(new Location(world, actual.getX(), actual.getY(), z));
printLocation(new Location(world, actual.getX(), actual.getY(), z), printedLocs);
previous = actual;
}
}
private static Set<Double> getSteps(double previous, double actual){
Set<Double> steps = new HashSet<>();
if(actual < previous){
@ -111,7 +84,7 @@ public class TNTTracer {
}
return steps;
}
private static void printLocation(Location l){
private static void printLocation(Location l, Set<Location> printedLocs){
Block block = l.getBlock();
double rx = l.getX() - Math.floor(l.getX());
double ry = l.getY() - Math.floor(l.getY());
@ -161,22 +134,23 @@ public class TNTTracer {
}
}
setBlock(block, main);
setBlock(block.getRelative(BlockFace.UP), upper);
setBlock(block, main, printedLocs);
setBlock(block.getRelative(BlockFace.UP), upper, printedLocs);
if(nearX != null){
setBlock(nearX, main);
setBlock(nearX.getRelative(BlockFace.UP), upper);
setBlock(nearX, main, printedLocs);
setBlock(nearX.getRelative(BlockFace.UP), upper, printedLocs);
}
if(nearZ != null){
setBlock(nearZ, main);
setBlock(nearZ.getRelative(BlockFace.UP), upper);
setBlock(nearZ, main, printedLocs);
setBlock(nearZ.getRelative(BlockFace.UP), upper, printedLocs);
}
if(nearCross != null){
setBlock(nearCross, main);
setBlock(nearCross.getRelative(BlockFace.UP), upper);
setBlock(nearCross, main, printedLocs);
setBlock(nearCross.getRelative(BlockFace.UP), upper, printedLocs);
}
}
private static void setBlock(Block block, BlockStatus status){
private static void setBlock(Block block, BlockStatus status, Set<Location> printedLocs){
if(status == BlockStatus.NONE)
return;
@ -199,28 +173,6 @@ public class TNTTracer {
}
}
}
private static boolean airOrBrick(Block block){
Material material = block.getType();
if(material == Material.AIR || material == Material.BRICK)
return true;
if(material != Material.STEP)
return false;
byte data = block.getData();
return data == BRICK_STEP || data == INVERTED_BRICK_STEP;
}
private static void run() {
for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
locations.computeIfAbsent(tnt, k -> new LinkedList<>()).add(tnt.getLocation());
}
}
enum Status{
RECORD,
SHOW,
IDLE
}
enum BlockStatus{
NONE(Material.AIR, 0),
@ -241,5 +193,4 @@ public class TNTTracer {
b.setTypeIdAndData(material.getId(), data, true);
}
}
}

48
BauSystem_14/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>steamwar</groupId>
<artifactId>BauSystem</artifactId>
<version>1.0</version>
</parent>
<artifactId>BauSystem_14</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>BauSystem_API</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.14</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,11 @@
package de.steamwar.bausystem.commands;
import net.minecraft.server.v1_14_R1.MinecraftServer;
public class CommandInfo_14 {
private CommandInfo_14(){}
static double[] getTps(){
return MinecraftServer.getServer().recentTps;
}
}

Datei anzeigen

@ -0,0 +1,27 @@
package de.steamwar.bausystem.world;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.event.player.PlayerInteractEvent;
class AutoLoader_14 {
private AutoLoader_14(){}
static boolean tntPlaceActionPerform(Location location){
Material m = location.getBlock().getType();
if(m != Material.AIR && m != Material.WATER)
return false;
location.getBlock().setType(Material.TNT);
return true;
}
static boolean setRedstone(Location location, boolean active){
return true;
}
@SuppressWarnings("deprecation")
static void onPlayerInteract(IAutoLoader loader, PlayerInteractEvent event){
loader.print("§cDer AutoLoader ist in der 1.14 noch nicht fertig implementiert", false);
}
}

Datei anzeigen

@ -0,0 +1,16 @@
package de.steamwar.bausystem.world;
import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import org.bukkit.Bukkit;
public class Region_14 {
private Region_14(){}
static void paste(Schematic schem, Vector v, AffineTransform aT){
schem.paste(new BukkitWorld(Bukkit.getWorlds().get(0)), BlockVector3.at(v.getX(), v.getY(), v.getZ()), false, true, aT).flushQueue();
}
}

Datei anzeigen

@ -0,0 +1,36 @@
package de.steamwar.bausystem.world;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.TNTPrimed;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
class TNTTracer_14 {
private TNTTracer_14(){}
static void remove(Map<TNTPrimed, LinkedList<Location>> locations, TNTPrimed tnt){
Material material = tnt.getLocation().getBlock().getType();
if(material == Material.WATER)
locations.remove(tnt);
}
static int show(Map<TNTPrimed, LinkedList<Location>> locations, Set<Location> printedLocs){
for(LinkedList<Location> tntTrace : locations.values()){
for(Location location : tntTrace){
if(location.getBlock().getType() == Material.AIR)
location.getBlock().setType(Material.RED_STAINED_GLASS);
}
}
locations.clear();
return printedLocs.size();
}
static boolean airOrBrick(Block block){
return block.getType() == Material.RED_STAINED_GLASS;
}
}

37
BauSystem_API/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>steamwar</groupId>
<artifactId>BauSystem</artifactId>
<version>1.0</version>
</parent>
<artifactId>BauSystem_API</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,94 @@
package de.steamwar.bausystem.world;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.LinkedList;
abstract class IAutoLoader {
abstract Player getPlayer();
abstract boolean setRedstone(Location location, boolean active);
abstract LinkedList<LoaderAction> getActions();
abstract void resetLastActivation();
abstract int getLastActivation();
void print(String message, boolean withSize){
if(withSize)
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + getActions().size()));
else
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}
abstract static class LoaderAction {
final Location location;
final IAutoLoader loader;
LoaderAction(IAutoLoader loader, Location location){
this.location = location;
this.loader = loader;
loader.getActions().add(this);
loader.resetLastActivation();
}
abstract boolean perform();
abstract int ticks();
}
static class RedstoneActivation extends LoaderAction{
final boolean active;
final int length;
RedstoneActivation(IAutoLoader loader, Location location, int ticks, boolean active){
super(loader, location);
this.length = ticks;
this.active = active;
}
@Override
public boolean perform() {
return loader.setRedstone(location, active);
}
@Override
int ticks() {
return length;
}
}
static class TemporaryActivation extends LoaderAction{
final int length;
int status;
TemporaryActivation(IAutoLoader loader, Location location, int ticks){
super(loader, location);
this.length = ticks;
status = 0;
}
@Override
public boolean perform() {
if(status == 0){
if(!loader.setRedstone(location, true))
return false;
}else if(status == length){
if(!loader.setRedstone(location, false))
return false;
status = 0;
return true;
}
status++;
return false;
}
@Override
int ticks() {
return 1;
}
}
}

79
BauSystem_Main/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>steamwar</groupId>
<artifactId>BauSystem</artifactId>
<version>1.0</version>
</parent>
<artifactId>BauSystem_Main</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>BauSystem_12</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>BauSystem_14</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>BauSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,9 +1,9 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.core.Core;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import net.minecraft.server.v1_12_R1.MinecraftServer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -31,8 +31,14 @@ public class CommandInfo implements CommandExecutor {
}
sender.sendMessage(membermessage.toString());
double[] tps = MinecraftServer.getServer().recentTps;
double[] tps;
switch(Core.getVersion()){
case 14:
tps = CommandInfo_14.getTps();
break;
default:
tps = CommandInfo_12.getTps();
}
StringBuilder tpsmessage = new StringBuilder().append(BauSystem.PREFIX).append("TPS:§e");
for(double t : tps){
tpsmessage.append(String.format(" %.1f", t));

Datei anzeigen

@ -1,7 +1,7 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Material;
import de.steamwar.inventory.SWItem;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -23,7 +23,7 @@ public class CommandSkull implements CommandExecutor {
return false;
}
ItemStack is = new ItemStack(Material.SKULL_ITEM, 1, (short)0, (byte)3);
ItemStack is = new ItemStack(SWItem.getMaterial("SKULL_ITEM"), 1, (short)0, (byte)3);
SkullMeta sm = (SkullMeta)is.getItemMeta();
sm.setOwner(args[0]);
sm.setDisplayName("§e" + args[0] + "§8s Kopf");

Datei anzeigen

@ -21,7 +21,7 @@ public class CommandSpeed implements CommandExecutor {
float speed;
try{
speed = Float.valueOf(args[0]);
speed = Float.parseFloat(args[0]);
}catch(NumberFormatException e){
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
return false;

Datei anzeigen

@ -3,11 +3,8 @@ package de.steamwar.bausystem.world;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.world.World;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
@ -54,7 +51,6 @@ public class ArenaSection extends Region {
e.printStackTrace();
return;
}
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = schem.getClipboard().getDimensions();
Vector v = new Vector(minX + sizeX/2, testblock.minY-1, minZ + sizeZ/2);
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
@ -65,6 +61,6 @@ public class ArenaSection extends Region {
}else{
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
schem.paste(w, v, false, true, aT).flushQueue();
Region.paste(schem, v, aT);
}
}

Datei anzeigen

@ -1,17 +1,14 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import de.steamwar.core.Core;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -22,7 +19,7 @@ import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map;
public class AutoLoader implements Listener {
public class AutoLoader extends IAutoLoader implements Listener {
private static final Map<Player, AutoLoader> players = new HashMap<>();
@ -132,42 +129,19 @@ public class AutoLoader implements Listener {
if(event.getBlock().getType() != Material.TNT)
return;
new TNTPlaceAction(event.getBlock().getLocation());
new TNTPlaceAction(this, event.getBlock().getLocation());
print("§eTNT platziert", true);
}
//BlockRedstoneEvent?
@EventHandler
@SuppressWarnings("deprecation")
public void onPlayerInteract(PlayerInteractEvent event){
if(!setup || !event.getPlayer().equals(player))
return;
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
Block block = event.getClickedBlock();
Material material = block.getType();
if(material == Material.LEVER){
if((block.getData() & 8) == 8) {
new RedstoneActivation(block.getLocation(), lastActivation, false);
print("§eHebel zurückgesetzt", true);
}else{
new RedstoneActivation(block.getLocation(), 1, true);
print("§eHebel betätigt", true);
}
}else if(material == Material.STONE_BUTTON){
new TemporaryActivation(block.getLocation(), 20);
print("§eKnopf betätigt", true);
}else if(material == Material.WOOD_BUTTON){
new TemporaryActivation(block.getLocation(), 30);
print("§eKnopf betätigt", true);
}
}else if(event.getAction() == Action.PHYSICAL){
Block block = event.getClickedBlock();
Material material = block.getType();
if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){
new TemporaryActivation(block.getLocation(), 20);
print("§eDruckplatte betätigt", true);
}
switch(Core.getVersion()){
default:
AutoLoader_12.onPlayerInteract(this, event);
}
}
@ -200,62 +174,46 @@ public class AutoLoader implements Listener {
}
}
private void print(String message, boolean withSize){
if(withSize)
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + actions.size()));
else
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
@Override
Player getPlayer() {
return player;
}
@SuppressWarnings("deprecation")
private boolean setRedstone(Location location, boolean active){
Block block = location.getBlock();
Material material = block.getType();
if(material == Material.LEVER || material == Material.STONE_BUTTON || material == Material.WOOD_BUTTON){
if(active)
block.setData((byte)(block.getData() | 8));
else
block.setData((byte)(block.getData() & -9));
}else if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){
if(active)
block.setData((byte)1);
else
block.setData((byte)0);
}else{
return false;
@Override
boolean setRedstone(Location location, boolean active){
switch(Core.getVersion()){
default:
return AutoLoader_12.setRedstone(location, active);
}
block.getState().update(true);
return true;
}
private abstract class LoaderAction {
final Location location;
LoaderAction(Location location){
this.location = location;
actions.add(this);
lastActivation = 0;
}
abstract boolean perform();
abstract int ticks();
@Override
LinkedList<LoaderAction> getActions() {
return actions;
}
private class TNTPlaceAction extends LoaderAction{
@Override
void resetLastActivation() {
lastActivation = 0;
}
TNTPlaceAction(Location location){
super(location);
@Override
int getLastActivation() {
return lastActivation;
}
class TNTPlaceAction extends IAutoLoader.LoaderAction {
TNTPlaceAction(IAutoLoader loader, Location location){
super(loader, location);
}
@Override
public boolean perform() {
Material m = location.getBlock().getType();
if(m != Material.AIR && m != Material.STATIONARY_WATER)
return false;
location.getBlock().setType(Material.TNT);
return true;
switch(Core.getVersion()){
default:
return AutoLoader_12.tntPlaceActionPerform(location);
}
}
@Override
@ -263,58 +221,4 @@ public class AutoLoader implements Listener {
return ticksBetweenBlocks;
}
}
private class RedstoneActivation extends LoaderAction{
final boolean active;
final int length;
RedstoneActivation(Location location, int ticks, boolean active){
super(location);
this.length = ticks;
this.active = active;
}
@Override
public boolean perform() {
return setRedstone(location, active);
}
@Override
int ticks() {
return length;
}
}
private class TemporaryActivation extends LoaderAction{
final int length;
int status;
TemporaryActivation(Location location, int ticks){
super(location);
this.length = ticks;
status = 0;
}
@Override
public boolean perform() {
if(status == 0){
if(!setRedstone(location, true))
return false;
}else if(status == length){
if(!setRedstone(location, false))
return false;
status = 0;
return true;
}
status++;
return false;
}
@Override
int ticks() {
return 1;
}
}
}

Datei anzeigen

@ -3,11 +3,9 @@ package de.steamwar.bausystem.world;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.world.World;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Bukkit;
import de.steamwar.core.Core;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
@ -54,7 +52,6 @@ public class Region {
e.printStackTrace();
return;
}
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = schem.getClipboard().getDimensions();
Vector v = new Vector(minX + sizeX/2, minY, minZ + sizeZ/2);
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
@ -65,6 +62,15 @@ public class Region {
}else{
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
schem.paste(w, v, false, true, aT).flushQueue();
paste(schem, v, aT);
}
static void paste(Schematic schem, Vector v, AffineTransform aT){
switch(Core.getVersion()){
case 14:
Region_14.paste(schem, v, aT);
default:
Region_12.paste(schem, v, aT);
}
}
}

Datei anzeigen

@ -61,6 +61,8 @@ public class RegionListener implements Listener {
public void onSignChange(SignChangeEvent event) {
for(int i = 0; i <= 3; ++i) {
String line = event.getLine(i);
if(line == null)
continue;
line = ChatColor.translateAlternateColorCodes('&', line);
event.setLine(i, line);
}

Datei anzeigen

@ -0,0 +1,96 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.core.Core;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.scheduler.BukkitTask;
import java.util.*;
public class TNTTracer {
private static BukkitTask task;
private static final Set<Location> printedLocs = new HashSet<>();
private static final Map<TNTPrimed, LinkedList<Location>> locations = new HashMap<>();
private static final World world = Bukkit.getWorlds().get(0);
static Status getStatus() {
return status;
}
private static Status status = Status.IDLE;
static void remove(TNTPrimed tnt){
switch (Core.getVersion()){
case 14:
TNTTracer_14.remove(locations, tnt);
break;
default:
TNTTracer_12.remove(locations, tnt);
}
}
public static void start(){
if(status == Status.RECORD)
return;
stop();
locations.clear();
status = Status.RECORD;
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), TNTTracer::run, 1, 1);
}
public static int show(){
if(status == Status.SHOW)
return printedLocs.size();
stop();
status = Status.SHOW;
switch (Core.getVersion()){
case 14:
return TNTTracer_14.show(locations, printedLocs);
default:
return TNTTracer_12.show(locations, printedLocs);
}
}
public static void stop(){
status = Status.IDLE;
if(task != null)
task.cancel();
for(Location l : printedLocs){
Block b = world.getBlockAt(l);
if(airOrBrick(b))
b.setType(Material.AIR);
}
printedLocs.clear();
}
private static boolean airOrBrick(Block block){
switch(Core.getVersion()){
case 14:
return TNTTracer_14.airOrBrick(block);
default:
return TNTTracer_12.airOrBrick(block);
}
}
private static void run() {
for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
locations.computeIfAbsent(tnt, k -> new LinkedList<>()).add(tnt.getLocation());
}
}
enum Status{
RECORD,
SHOW,
IDLE
}
}

37
pom.xml
Datei anzeigen

@ -4,9 +4,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.steamwar</groupId>
<groupId>steamwar</groupId>
<artifactId>BauSystem</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -14,26 +15,17 @@
<repositories>
<repository>
<id>maven</id>
<url>https://steamwar.de/maven/</url>
<id>steamwar</id>
<url>https://steamwar.de:81/maven/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>8</source>
<target>8</target>
@ -42,13 +34,14 @@
</plugins>
</build>
<modules>
<module>BauSystem_12</module>
<module>BauSystem_14</module>
<module>BauSystem_Main</module>
<module>BauSystem_API</module>
</modules>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SpigotCore</artifactId>
@ -61,12 +54,6 @@
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>F3NPerm</artifactId>