SteamWar/FightSystem
Archiviert
13
1

FAWE free 1.8, Kit fixes

Dieser Commit ist enthalten in:
Lixfel 2019-11-15 08:22:16 +01:00
Ursprung d1d0d4ee36
Commit 065dc58f98
10 geänderte Dateien mit 156 neuen und 65 gelöschten Zeilen

Datei anzeigen

@ -32,6 +32,12 @@
<artifactId>FightSystem_8</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>

Datei anzeigen

@ -1,16 +1,24 @@
package de.steamwar.fightsystem.fight;
import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.scoreboard.Team;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
import java.util.logging.Level;
public class FightTeam_12 {
private FightTeam_12(){}
@ -35,11 +43,43 @@ public class FightTeam_12 {
@SuppressWarnings("deprecation")
static void replaceTeamColor(EditSession e, DyeColor c, CuboidRegion region){
FightTeam_8.replaceTeamColor(e, c, region);
try {
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData()));
} catch (MaxChangedBlocksException ex) {
// ignore, will never occur
}
}
static EditSession pasteSchematic(File file, Vector paste, boolean rotate, boolean alignWater, int waterDepth){
com.boydti.fawe.object.schematic.Schematic schem;
try {
schem = FaweAPI.load(file);
if(schem.getClipboard() == null)
throw new IOException();
}catch(IOException e){
Bukkit.getLogger().log(Level.SEVERE, "Failed loading Schematic", e);
return null;
}
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = schem.getClipboard().getDimensions();
Vector v;
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
aT = aT.rotateY(180);
v = paste.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 = paste.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
if(alignWater){
Vector it = schem.getClipboard().getMinimumPoint();
int depth = 0;
while(!schem.getClipboard().getBlock(it).isAir()){
depth++;
it = it.setY(it.getY()+1);
}
v = v.add(0, waterDepth - depth, 0);
}
return schem.paste(w, v, false, true, aT);
}
}

Datei anzeigen

@ -6,8 +6,8 @@ import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
class TechHider_v12 {
private TechHider_v12(){}
class TechHider_12 {
private TechHider_12(){}
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535));

Datei anzeigen

@ -1,17 +1,29 @@
package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.schematic.SchematicFormat;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.World;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
import java.util.logging.Level;
class FightTeam_8 {
private FightTeam_8(){}
@ -49,4 +61,55 @@ class FightTeam_8 {
// ignore, will never occur
}
}
static EditSession pasteSchematic(File file, Vector paste, boolean rotate, boolean alignWater, int waterDepth, Plugin plugin){
CuboidClipboard clipboard;
try {
clipboard = SchematicFormat.getFormat(file).load(file);
}catch(IOException | DataException e){
Bukkit.getLogger().log(Level.SEVERE, "Failed loading Schematic", e);
return null;
}
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = clipboard.getSize();
Vector v;
Vector offset = new Vector(clipboard.getOffset());
if(rotate){
clipboard.rotate2D(180);
v = paste.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 = paste.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
if(alignWater){
Vector it = Vector.ZERO;
int depth = 0;
while(!clipboard.getBlock(it).isAir()){
depth++;
it = it.setY(it.getY()+1);
}
v = v.add(0, waterDepth - depth, 0);
}
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
FreezeWorld freezer = new FreezeWorld();
Bukkit.getPluginManager().registerEvents(freezer, plugin);
try {
clipboard.paste(e, v, false, true);
} catch (MaxChangedBlocksException ex) {
//ignore
}
e.flushQueue();
HandlerList.unregisterAll(freezer);
return e;
}
static class FreezeWorld implements Listener{
@EventHandler
public void onBlockPhysicsEvent(BlockPhysicsEvent e){
e.setCancelled(true);
}
}
}

Datei anzeigen

@ -6,8 +6,8 @@ import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
class TechHider_v8 {
private TechHider_v8(){}
class TechHider_8 {
private TechHider_8(){}
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), true, 65535));

Datei anzeigen

@ -1,12 +1,8 @@
package de.steamwar.fightsystem.fight;
import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.kit.KitManager;
@ -21,12 +17,10 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.scoreboard.Team;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
public class FightTeam {
@ -207,39 +201,14 @@ public class FightTeam {
private void pasteSchematic(){
File file = new File(Config.SchematicDirectory + SteamwarUser.get(schematic.getSchemOwner()).getUUID().toString(), schematic.getSchemName() + ".schematic");
com.boydti.fawe.object.schematic.Schematic schem;
try {
schem = FaweAPI.load(file);
if(schem.getClipboard() == null)
throw new IOException();
}catch(IOException e){
Bukkit.getLogger().log(Level.SEVERE, "Failed loading Schematic", e);
return;
EditSession e;
switch(Core.getVersion()){
case 8:
e = FightTeam_8.pasteSchematic(file, paste, rotate, Config.AlignWater, Config.WaterDepth, FightSystem.getPlugin());
break;
default:
e = FightTeam_12.pasteSchematic(file, paste, rotate, Config.AlignWater, Config.WaterDepth);
}
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = schem.getClipboard().getDimensions();
Vector v;
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
aT = aT.rotateY(180);
v = paste.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 = paste.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
if(Config.AlignWater){
Vector it = schem.getClipboard().getMinimumPoint();
int depth = 0;
while(!schem.getClipboard().getBlock(it).isAir()){
depth++;
it = it.setY(it.getY()+1);
}
v = v.add(0, Config.WaterDepth - depth, 0);
}
EditSession e = schem.paste(w, v, false, true, aT);
replaceTeamColor(e);
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
}

Datei anzeigen

@ -9,12 +9,14 @@ public class Kit {
private boolean leaderAllowed;
private boolean memberAllowed;
private ItemStack[] inventory;
private ItemStack[] armor;
Kit(String name, boolean leaderAllowed, boolean memberAllowed, ItemStack[] inventory) {
Kit(String name, boolean leaderAllowed, boolean memberAllowed, ItemStack[] inventory, ItemStack[] armor) {
this.name = name;
this.leaderAllowed = leaderAllowed;
this.memberAllowed = memberAllowed;
this.inventory = inventory;
this.armor = armor;
}
public String getName() {
@ -33,8 +35,14 @@ public class Kit {
return inventory;
}
ItemStack[] getArmor(){
return armor;
}
public void loadToPlayer(Player player) {
player.getInventory().setContents(inventory);
if(armor != null)
player.getInventory().setArmorContents(armor);
player.updateInventory();
}
}

Datei anzeigen

@ -24,7 +24,7 @@ public class KitManager {
private static final ArrayList<Kit> loadedKits = new ArrayList<>();
public static void saveInventory(String kitName, Player player){
loadedKits.add(new Kit(kitName, true, true, player.getInventory().getContents()));
loadedKits.add(new Kit(kitName, true, true, player.getInventory().getContents(), player.getInventory().getArmorContents()));
saveAllKits();
}
@ -33,10 +33,14 @@ public class KitManager {
if(kitData.contains(path)) {
List<ItemStack> items = (List<ItemStack>) kitData.getList(path + ".Items");
ItemStack[] armor = null;
if(kitData.isList(path + ".Armor"))
armor = kitData.getList(path + ".Armor").toArray(new ItemStack[1]);
boolean leaderAllowed = kitData.getBoolean(path + ".LeaderAllowed");
boolean memberAllowed = kitData.getBoolean(path + ".MemberAllowed");
return new Kit(name, leaderAllowed, memberAllowed, items.toArray(new ItemStack[1]));
return new Kit(name, leaderAllowed, memberAllowed, items.toArray(new ItemStack[1]), armor);
}
return null;
}
@ -61,6 +65,8 @@ public class KitManager {
for(Kit k : loadedKits){
String path = "Kits." + k.getName();
yamlConfiguration.set(path + ".Items", k.getInventory());
if(k.getArmor() != null)
yamlConfiguration.set(path + ".Armor", k.getArmor());
yamlConfiguration.set(path + ".LeaderAllowed", k.isLeaderAllowed());
yamlConfiguration.set(path + ".MemberAllowed", k.isMemberAllowed());
}

Datei anzeigen

@ -104,16 +104,21 @@ public class TechHider {
return;
running = true;
if(disabled() || Core.getVersion() != 12)
if(disabled())
return;
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), packetCache::clear, 1, 1);
switch(Core.getVersion()){
case 8:
break;
default:
chunkHider();
multiBlockHider();
blockHider();
blockActionHider();
}
}
private static boolean bypass(Player p, int chunkX, int chunkZ){
if(p == FightSystem.getEventLeiter())
@ -368,10 +373,10 @@ public class TechHider {
private static void reloadChunk(Player p, Pair<Integer, Integer> chunk){
switch(Core.getVersion()){
case 8:
TechHider_v8.reloadChunk(p, chunk);
TechHider_8.reloadChunk(p, chunk);
break;
default:
TechHider_v12.reloadChunk(p, chunk);
TechHider_12.reloadChunk(p, chunk);
}
}

Datei anzeigen

@ -54,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>ProtocolLib</artifactId>