mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-12 10:24:07 +01:00
potion effects and banners
This commit is contained in:
parent
7afe2c0799
commit
a2ddd702cb
@ -72,6 +72,9 @@ public class EntityWrapper {
|
||||
entity.setCustomName(this.lived.name);
|
||||
entity.setCustomNameVisible(this.lived.visible);
|
||||
}
|
||||
if (this.lived.potions != null && this.lived.potions.size() > 0) {
|
||||
entity.addPotionEffects(this.lived.potions);
|
||||
}
|
||||
entity.setRemainingAir(this.lived.air);
|
||||
entity.setRemoveWhenFarAway(this.lived.persistent);
|
||||
|
||||
@ -98,6 +101,7 @@ public class EntityWrapper {
|
||||
|
||||
public void storeLiving(final LivingEntity lived) {
|
||||
this.lived = new LivingEntityStats();
|
||||
this.lived.potions = lived.getActivePotionEffects();
|
||||
this.lived.loot = lived.getCanPickupItems();
|
||||
this.lived.name = lived.getCustomName();
|
||||
this.lived.visible = lived.isCustomNameVisible();
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.intellectualcrafters.plot.object.entity;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
public class LivingEntityStats {
|
||||
|
||||
@ -22,5 +25,6 @@ public class LivingEntityStats {
|
||||
public ItemStack boots;
|
||||
public ItemStack leggings;
|
||||
public ItemStack chestplate;
|
||||
public Collection<PotionEffect> potions;
|
||||
|
||||
}
|
||||
|
@ -8,11 +8,13 @@ import java.util.HashSet;
|
||||
import org.apache.commons.lang.mutable.MutableInt;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Beacon;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -29,6 +31,8 @@ import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.block.NoteBlock;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -117,6 +121,8 @@ public class ChunkManager {
|
||||
private static HashMap<BlockLoc, String> cmdData;
|
||||
private static HashMap<BlockLoc, String[]> signContents;
|
||||
private static HashMap<BlockLoc, Note> noteBlockContents;
|
||||
private static HashMap<BlockLoc, ArrayList<Byte[]>> bannerColors;
|
||||
private static HashMap<BlockLoc, Byte> bannerBase;
|
||||
|
||||
private static HashSet<EntityWrapper> entities;
|
||||
|
||||
@ -234,6 +240,8 @@ public class ChunkManager {
|
||||
noteBlockContents = new HashMap<>();
|
||||
signContents = new HashMap<>();
|
||||
cmdData = new HashMap<>();
|
||||
bannerBase= new HashMap<>();
|
||||
bannerColors = new HashMap<>();
|
||||
|
||||
entities = new HashSet<>();
|
||||
}
|
||||
@ -425,6 +433,22 @@ public class ChunkManager {
|
||||
}
|
||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate furnace: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); }
|
||||
}
|
||||
|
||||
for (BlockLoc loc: bannerBase.keySet()) {
|
||||
Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset);
|
||||
BlockState state = block.getState();
|
||||
if (state instanceof Banner) {
|
||||
Banner banner = (Banner) state;
|
||||
byte base = bannerBase.get(loc);
|
||||
ArrayList<Byte[]> colors = bannerColors.get(loc);
|
||||
banner.setBaseColor(DyeColor.values()[base]);
|
||||
for (Byte[] color : colors) {
|
||||
banner.addPattern(new Pattern(DyeColor.getByDyeData(color[1]), PatternType.values()[color[0]]));
|
||||
}
|
||||
state.update(true);
|
||||
}
|
||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate banner: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); }
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveBlock(World world, int maxY, int x, int z) {
|
||||
@ -537,6 +561,19 @@ public class ChunkManager {
|
||||
short rot = (short) getOrdinal(BlockFace.values(), skull.getRotation());
|
||||
skullData.put(bl, new Object[] {o, rot, skulltype});
|
||||
break;
|
||||
case 176:
|
||||
case 177:
|
||||
bl = new BlockLoc(x, y, z);
|
||||
Banner banner = (Banner) block.getState();
|
||||
byte base = getOrdinal(DyeColor.values(), banner.getBaseColor());
|
||||
ArrayList<Byte[]> types = new ArrayList<>();
|
||||
|
||||
for (Pattern pattern : banner.getPatterns()) {
|
||||
types.add(new Byte[] {getOrdinal(PatternType.values(), pattern.getPattern()), pattern.getColor().getDyeData() });
|
||||
}
|
||||
bannerBase.put(bl, base);
|
||||
bannerColors.put(bl, types);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user