Fixing path typo
Dieser Commit ist enthalten in:
Ursprung
8f15d62c2b
Commit
96d51b3c0e
@ -75,6 +75,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
getCommand("testblock").setExecutor(new CommandTestblock());
|
getCommand("testblock").setExecutor(new CommandTestblock());
|
||||||
getCommand("bau").setExecutor(new CommandBau());
|
getCommand("bau").setExecutor(new CommandBau());
|
||||||
getCommand("bauinfo").setExecutor(new CommandInfo());
|
getCommand("bauinfo").setExecutor(new CommandInfo());
|
||||||
|
getCommand("protect").setExecutor(new CommandProtect());
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
||||||
|
36
src/de/steamwar/bausystem/commands/CommandProtect.java
Normale Datei
36
src/de/steamwar/bausystem/commands/CommandProtect.java
Normale Datei
@ -0,0 +1,36 @@
|
|||||||
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.world.ArenaSection;
|
||||||
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandProtect implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player))
|
||||||
|
return false;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if(!Welt.hasPermission(player, Permission.worldedit)){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Boden schützen");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ArenaSection section : BauSystem.getSections()){
|
||||||
|
if(section.inRegion(player.getLocation()) && section.hasProtection()){
|
||||||
|
section.protect();
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,13 @@
|
|||||||
package de.steamwar.bausystem.world;
|
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.ConfigurationSection;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -12,10 +20,12 @@ import java.util.List;
|
|||||||
public class ArenaSection extends Region {
|
public class ArenaSection extends Region {
|
||||||
|
|
||||||
private final Region testblock;
|
private final Region testblock;
|
||||||
|
private final String protectSchematic;
|
||||||
|
|
||||||
private ArenaSection(ConfigurationSection config) {
|
private ArenaSection(ConfigurationSection config) {
|
||||||
super(config);
|
super(config);
|
||||||
testblock = new Region(config.getConfigurationSection("testblock"));
|
testblock = new Region(config.getConfigurationSection("testblock"));
|
||||||
|
protectSchematic = config.getString("protection");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Region getTestblock(){
|
public Region getTestblock(){
|
||||||
@ -30,4 +40,31 @@ public class ArenaSection extends Region {
|
|||||||
list.add(new ArenaSection(config.getConfigurationSection(section)));
|
list.add(new ArenaSection(config.getConfigurationSection(section)));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasProtection(){
|
||||||
|
return !protectSchematic.equals("");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void protect(){
|
||||||
|
File file = new File(BauSystem.SECTION_PATH + protectSchematic);
|
||||||
|
Schematic schem;
|
||||||
|
try {
|
||||||
|
schem = FaweAPI.load(file);
|
||||||
|
}catch(IOException e){
|
||||||
|
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());
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
schem.paste(w, v, false, true, aT).flushQueue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,16 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class Region {
|
public class Region {
|
||||||
private final int sizeX;
|
final int sizeX;
|
||||||
private final int sizeY;
|
private final int sizeY;
|
||||||
private final int sizeZ;
|
final int sizeZ;
|
||||||
|
|
||||||
private final int minX;
|
final int minX;
|
||||||
private final int minY;
|
final int minY;
|
||||||
private final int minZ;
|
final int minZ;
|
||||||
|
|
||||||
private final String schematic;
|
private final String schematic;
|
||||||
private final boolean rotate;
|
final boolean rotate;
|
||||||
|
|
||||||
Region(ConfigurationSection config){
|
Region(ConfigurationSection config){
|
||||||
sizeX = config.getInt("sizeX");
|
sizeX = config.getInt("sizeX");
|
||||||
|
@ -11,6 +11,7 @@ commands:
|
|||||||
testblock:
|
testblock:
|
||||||
reset:
|
reset:
|
||||||
bau:
|
bau:
|
||||||
|
protect:
|
||||||
bauinfo:
|
bauinfo:
|
||||||
speed:
|
speed:
|
||||||
nightvision:
|
nightvision:
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren