Compare commits
No commits in common. 'master' and 'testdev' have entirely different histories.
@ -1,2 +1 @@ |
||||
.* |
||||
/bin |
||||
/bin/ |
||||
|
Binary file not shown.
@ -1,163 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Sound; |
||||
import org.bukkit.configuration.file.FileConfiguration; |
||||
import org.bukkit.configuration.file.YamlConfiguration; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.inventory.ItemStack; |
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; |
||||
|
||||
public class ChallengeReward { |
||||
public static boolean hasRewards(Player p) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
return pd.rewards.length()>0; |
||||
} |
||||
|
||||
public static void rewardAwards(Player p) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
GlobalLoot gl = GlobalLoot.spawnGlobalLoot(p.getLocation(), ChatColor.GREEN+"Daily Challenge Loot"); |
||||
String[] awards = pd.rewards.split(","); |
||||
for (String s : awards) { |
||||
int rank = Integer.parseInt(s); |
||||
if (pd.isFirstReward) { |
||||
gl.addNewDropInventory(p.getUniqueId(), getAward(rank)); |
||||
pd.isFirstReward=false; |
||||
} |
||||
gl.addNewDropInventory(p.getUniqueId(), getAward(rank)); |
||||
} |
||||
pd.rewards=""; |
||||
SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.2f); |
||||
} |
||||
|
||||
public static void provideAwards() { |
||||
provideAwards(TwosideKeeper.dpschallenge_records); |
||||
provideHOFAwards(TwosideKeeper.dpschallenge_recordsHOF); |
||||
provideAwards(TwosideKeeper.tankchallenge_records); |
||||
provideHOFAwards(TwosideKeeper.tankchallenge_recordsHOF); |
||||
provideAwards(TwosideKeeper.parkourchallenge_records); |
||||
provideHOFAwards(TwosideKeeper.parkourchallenge_recordsHOF); |
||||
} |
||||
|
||||
private static void provideAwards(RecordKeeping r) { |
||||
for (int i=0;i<r.recordlist.size();i++) { |
||||
Record rec = r.recordlist.get(i); |
||||
int rank = i+1; |
||||
Player p = Bukkit.getPlayer(rec.getName()); |
||||
if (p!=null && p.isOnline()) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
if (hasRewards(p)) { |
||||
pd.rewards+=","+rank; |
||||
} else { |
||||
pd.rewards=Integer.toString(rank); |
||||
} |
||||
} else { |
||||
File config; |
||||
config = new File(TwosideKeeper.filesave,"users/"+Bukkit.getOfflinePlayer(rec.getName()).getUniqueId()+".data"); |
||||
FileConfiguration workable = YamlConfiguration.loadConfiguration(config); |
||||
|
||||
if (!config.exists()) { |
||||
//Something bad happened if we got here.
|
||||
TwosideKeeper.log("[WARNING] Could not find the correct player data file for "+p+" to get money data from.",1); |
||||
} else { |
||||
|
||||
String rewards = workable.getString("rewards"); |
||||
if (rewards.length()>0) { |
||||
rewards+=","+rank; |
||||
} else { |
||||
rewards=Integer.toString(rank); |
||||
} |
||||
|
||||
workable.set("rewards", rewards); |
||||
|
||||
try { |
||||
workable.save(config); |
||||
} catch (IOException e) { |
||||
TwosideKeeper.log("[WARNING] Could not find the correct player data file for "+p+" to get money data from.",1); |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void provideHOFAwards(RecordKeeping r) { |
||||
if (r.recordlist.size()>0) { |
||||
Record rec = r.recordlist.get(0); |
||||
Player p = Bukkit.getPlayer(rec.getName()); |
||||
if (p!=null && p.isOnline()) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
if (hasRewards(p)) { |
||||
pd.rewards+=","+438190894; |
||||
} else { |
||||
pd.rewards=Integer.toString(438190894); |
||||
} |
||||
} else { |
||||
File config; |
||||
config = new File(TwosideKeeper.filesave,"users/"+Bukkit.getOfflinePlayer(rec.getName()).getUniqueId()+".data"); |
||||
FileConfiguration workable = YamlConfiguration.loadConfiguration(config); |
||||
|
||||
if (!config.exists()) { |
||||
//Something bad happened if we got here.
|
||||
TwosideKeeper.log("[WARNING] Could not find the correct player data file for "+p+" to get money data from.",1); |
||||
} else { |
||||
|
||||
String rewards = workable.getString("rewards"); |
||||
if (rewards.length()>0) { |
||||
rewards+=","+438190894; |
||||
} else { |
||||
rewards=Integer.toString(438190894); |
||||
} |
||||
|
||||
workable.set("rewards", rewards); |
||||
|
||||
try { |
||||
workable.save(config); |
||||
} catch (IOException e) { |
||||
TwosideKeeper.log("[WARNING] Could not find the correct player data file for "+p+" to get money data from.",1); |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static ItemStack[] getAward(int rank) { |
||||
switch (rank) { |
||||
case 1:{ |
||||
return new ItemStack[]{ |
||||
Artifact.createArtifactItem(ArtifactItem.MYSTERIOUS_ESSENCE,2), |
||||
Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE,2), |
||||
Artifact.createArtifactItem(ArtifactItem.ARTIFACT_CORE,1), |
||||
}; |
||||
} |
||||
case 2:{ |
||||
return new ItemStack[]{ |
||||
Artifact.createArtifactItem(ArtifactItem.MYSTERIOUS_ESSENCE,1), |
||||
Artifact.createArtifactItem(ArtifactItem.ARTIFACT_ESSENCE,1), |
||||
}; |
||||
} |
||||
case 3:{ |
||||
return new ItemStack[]{ |
||||
Artifact.createArtifactItem(ArtifactItem.MYSTERIOUS_ESSENCE,1), |
||||
}; |
||||
} |
||||
case 438190894:{ |
||||
return new ItemStack[]{ |
||||
Artifact.createArtifactItem(ArtifactItem.MYSTERIOUS_ESSENCE,2), |
||||
}; |
||||
} |
||||
default:{ |
||||
return new ItemStack[]{ |
||||
Artifact.createArtifactItem(ArtifactItem.MYSTERIOUS_ESSENCE), |
||||
}; |
||||
} |
||||
} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,34 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Events; |
||||
|
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.event.Event; |
||||
import org.bukkit.event.HandlerList; |
||||
|
||||
public class EntityChannelCastEvent extends Event{ |
||||
private LivingEntity l; |
||||
private String abilityName; |
||||
private static final HandlerList handlers = new HandlerList(); |
||||
|
||||
public EntityChannelCastEvent(LivingEntity l, String abilityName) { |
||||
this.l=l; |
||||
this.abilityName=abilityName; |
||||
} |
||||
|
||||
public LivingEntity getLivingEntity() { |
||||
return l; |
||||
} |
||||
|
||||
public String getAbilityName() { |
||||
return abilityName; |
||||
} |
||||
|
||||
@Override |
||||
public HandlerList getHandlers() { |
||||
return handlers; |
||||
} |
||||
|
||||
public static HandlerList getHandlerList() { |
||||
return handlers; |
||||
} |
||||
|
||||
} |
@ -1,61 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Generators; |
||||
|
||||
import java.util.Random; |
||||
|
||||
import org.bukkit.Material; |
||||
import org.bukkit.World; |
||||
import org.bukkit.generator.ChunkGenerator; |
||||
|
||||
public class DPSRoom extends Room{ |
||||
|
||||
public DPSRoom(int width,int length) { |
||||
super(width,length); |
||||
} |
||||
|
||||
@Override |
||||
public byte[] generate(World world, Random rand, int chunkx, int chunkz) { |
||||
byte[] result = new byte[65536]; |
||||
if (chunkx<ROOM_WIDTH/16 && |
||||
chunkz<ROOM_LENGTH/16 && |
||||
chunkx>=0 && |
||||
chunkz>=0) { |
||||
for(int x=0; x<16; x++){ |
||||
for(int z=0; z<16; z++) { |
||||
result[xyzToByte(x,0,z)] = (byte) Material.BEDROCK.getId(); |
||||
//result[xyzToByte(x,255,z)] = (byte) Material.BARRIER.getId();
|
||||
} |
||||
} |
||||
GenerateOuterWalls(chunkx, chunkz, result); |
||||
} |
||||
/*for(int x=0; x<16; x++){ |
||||
for(int z=0; z<16; z++) { |
||||
result[xyzToByte(x,0,z)] = (byte) Material.BEDROCK.getId(); |
||||
result[xyzToByte(x,255,z)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
}*/ |
||||
return result; |
||||
} |
||||
|
||||
protected void GenerateOuterWalls(int chunkx, int chunkz, byte[] result) { |
||||
int wallslotx = Math.floorMod(chunkx,ROOM_WIDTH/16); |
||||
int wallslotz = Math.floorMod(chunkz,ROOM_LENGTH/16); |
||||
for (int y=1;y<20;y++) { |
||||
for(int x=0; x<16; x++){ |
||||
for (int z=0;z<16;z++) { |
||||
if (wallslotx==0) { |
||||
result[xyzToByte(0,y,z)] = (byte) Material.BEDROCK.getId(); |
||||
} else |
||||
if (wallslotx==(ROOM_WIDTH/16)-1){ |
||||
result[xyzToByte(15,y,z)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
if (wallslotz==0) { |
||||
result[xyzToByte(x,y,0)] = (byte) Material.BEDROCK.getId(); |
||||
} else |
||||
if (wallslotz==(ROOM_LENGTH/16)-1){ |
||||
result[xyzToByte(x,y,15)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,61 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Generators; |
||||
|
||||
import java.util.Random; |
||||
|
||||
import org.bukkit.Material; |
||||
import org.bukkit.World; |
||||
import org.bukkit.generator.ChunkGenerator; |
||||
|
||||
public class ParkourRoom extends Room{ |
||||
|
||||
public ParkourRoom(int width,int length) { |
||||
super(width,length); |
||||
} |
||||
|
||||
@Override |
||||
public byte[] generate(World world, Random rand, int chunkx, int chunkz) { |
||||
byte[] result = new byte[65536]; |
||||
if (chunkx<ROOM_WIDTH/16 && |
||||
chunkz<ROOM_LENGTH/16 && |
||||
chunkx>=0 && |
||||
chunkz>=0) { |
||||
for(int x=0; x<16; x++){ |
||||
for(int z=0; z<16; z++) { |
||||
result[xyzToByte(x,0,z)] = (byte) Material.BEDROCK.getId(); |
||||
//result[xyzToByte(x,255,z)] = (byte) Material.BARRIER.getId();
|
||||
} |
||||
} |
||||
GenerateOuterWalls(chunkx, chunkz, result); |
||||
} |
||||
/*for(int x=0; x<16; x++){ |
||||
for(int z=0; z<16; z++) { |
||||
result[xyzToByte(x,0,z)] = (byte) Material.BEDROCK.getId(); |
||||
result[xyzToByte(x,255,z)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
}*/ |
||||
return result; |
||||
} |
||||
|
||||
protected void GenerateOuterWalls(int chunkx, int chunkz, byte[] result) { |
||||
int wallslotx = Math.floorMod(chunkx,ROOM_WIDTH/16); |
||||
int wallslotz = Math.floorMod(chunkz,ROOM_LENGTH/16); |
||||
for (int y=1;y<80;y++) { |
||||
for(int x=0; x<16; x++){ |
||||
for (int z=0;z<16;z++) { |
||||
if (wallslotx==0) { |
||||
result[xyzToByte(0,y,z)] = (byte) Material.BEDROCK.getId(); |
||||
} else |
||||
if (wallslotx==(ROOM_WIDTH/16)-1){ |
||||
result[xyzToByte(15,y,z)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
if (wallslotz==0) { |
||||
result[xyzToByte(x,y,0)] = (byte) Material.BEDROCK.getId(); |
||||
} else |
||||
if (wallslotz==(ROOM_LENGTH/16)-1){ |
||||
result[xyzToByte(x,y,15)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,83 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Generators; |
||||
|
||||
import java.util.Random; |
||||
|
||||
import org.bukkit.Material; |
||||
import org.bukkit.World; |
||||
import org.bukkit.generator.ChunkGenerator; |
||||
|
||||
public class Room extends ChunkGenerator{ |
||||
int ROOM_WIDTH = 32; |
||||
int ROOM_LENGTH = 32; |
||||
|
||||
public Room() { |
||||
|
||||
} |
||||
|
||||
public Room(int width, int length) { |
||||
ROOM_WIDTH=width; |
||||
ROOM_LENGTH=length; |
||||
} |
||||
|
||||
@Override |
||||
public boolean canSpawn(World world, int x, int z) { |
||||
return true; |
||||
} |
||||
public int xyzToByte(int x, int y, int z) { |
||||
return (x * 16 + z) * 256 + y; |
||||
} |
||||
|
||||
@Override |
||||
public byte[] generate(World world, Random rand, int chunkx, int chunkz) { |
||||
byte[] result = new byte[65536]; |
||||
if (chunkx<ROOM_WIDTH/16 && |
||||
chunkz<ROOM_LENGTH/16 && |
||||
chunkx>=0 && |
||||
chunkz>=0) { |
||||
for(int x=0; x<16; x++){ |
||||
for(int z=0; z<16; z++) { |
||||
result[xyzToByte(x,0,z)] = (byte) Material.BEDROCK.getId(); |
||||
result[xyzToByte(x,255,z)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
} |
||||
GenerateOuterWalls(chunkx, chunkz, result); |
||||
} |
||||
/*for(int x=0; x<16; x++){ |
||||
for(int z=0; z<16; z++) { |
||||
result[xyzToByte(x,0,z)] = (byte) Material.BEDROCK.getId(); |
||||
result[xyzToByte(x,255,z)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
}*/ |
||||
return result; |
||||
} |
||||
|
||||
protected void GenerateOuterWalls(int chunkx, int chunkz, byte[] result) { |
||||
int wallslotx = Math.floorMod(chunkx,ROOM_WIDTH/16); |
||||
int wallslotz = Math.floorMod(chunkz,ROOM_LENGTH/16); |
||||
for (int y=1;y<255;y++) { |
||||
for(int x=0; x<16; x++){ |
||||
for (int z=0;z<16;z++) { |
||||
if (wallslotx==0) { |
||||
result[xyzToByte(0,y,z)] = (byte) Material.BEDROCK.getId(); |
||||
} else |
||||
if (wallslotx==(ROOM_WIDTH/16)-1){ |
||||
result[xyzToByte(15,y,z)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
if (wallslotz==0) { |
||||
result[xyzToByte(x,y,0)] = (byte) Material.BEDROCK.getId(); |
||||
} else |
||||
if (wallslotz==(ROOM_LENGTH/16)-1){ |
||||
result[xyzToByte(x,y,15)] = (byte) Material.BEDROCK.getId(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public int getRoomWidth() { |
||||
return ROOM_WIDTH; |
||||
} |
||||
public int getRoomLength() { |
||||
return ROOM_LENGTH; |
||||
} |
||||
} |
@ -1,132 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.UUID; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Chunk; |
||||
import org.bukkit.Location; |
||||
import org.bukkit.Material; |
||||
import org.bukkit.entity.Item; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.event.inventory.InventoryCloseEvent; |
||||
import org.bukkit.event.inventory.InventoryType; |
||||
import org.bukkit.inventory.Inventory; |
||||
import org.bukkit.inventory.ItemStack; |
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent; |
||||
import net.md_5.bungee.api.chat.TextComponent; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.TextUtils; |
||||
|
||||
public class GlobalLoot { |
||||
Item item; |
||||
public static List<Chunk> chunks = new ArrayList<Chunk>(); |
||||
Chunk c; |
||||
String lootname; |
||||
UUID item_uuid; |
||||
HashMap<UUID,Inventory> drop_inventories = new HashMap<UUID,Inventory>(); |
||||
HashMap<UUID,Long> last_opened_loot = new HashMap<UUID,Long>(); |
||||
|
||||
GlobalLoot(Location spawnLoc, String lootName) { |
||||
Chunk c = spawnLoc.getChunk(); |
||||
if (!chunks.contains(c)) { |
||||
chunks.add(c); |
||||
c.load(); |
||||
} |
||||
TwosideKeeper.temporary_chunks.add(c); |
||||
item = (Item)spawnLoc.getWorld().dropItemNaturally(spawnLoc, new ItemStack(Material.CHEST)); |
||||
//item = GenericFunctions.dropItem(new ItemStack(Material.CHEST), spawnLoc);
|
||||
item_uuid = item.getUniqueId(); |
||||
item.setCustomName(TextUtils.RandomColor()+ChatColor.stripColor(lootName)); |
||||
item.setCustomNameVisible(true); |
||||
item.setPickupDelay(Integer.MAX_VALUE); |
||||
item.setInvulnerable(true); |
||||
this.lootname = lootName; |
||||
TwosideKeeper.temporary_chunks.remove(c); |
||||
} |
||||
|
||||
public void runInventoryCloseEvent(InventoryCloseEvent ev) { |
||||
Player p = (Player)ev.getPlayer(); |
||||
if (drop_inventories.containsKey(p.getUniqueId()) && |
||||
ev.getInventory().getTitle()!=null && |
||||
ev.getInventory().getTitle().equalsIgnoreCase(lootname)) { |
||||
last_opened_loot.put(p.getUniqueId(), TwosideKeeper.getServerTickTime()); |
||||
} |
||||
} |
||||
|
||||
public boolean runTick() { |
||||
if ((item!=null && item.isValid())) { |
||||
List<Player> players = GenericFunctions.getNearbyPlayers(item.getLocation(), 1.5); |
||||
for (Player p : players) { |
||||
if (p.getOpenInventory().getType()==InventoryType.CRAFTING && |
||||
drop_inventories.containsKey(p.getUniqueId())) { |
||||
if ((!last_opened_loot.containsKey(p.getUniqueId()) || |
||||
last_opened_loot.get(p.getUniqueId())+100<=TwosideKeeper.getServerTickTime()) && |
||||
!InventoryUtils.hasEmptyInventory(drop_inventories.get(p.getUniqueId()))) { |
||||
last_opened_loot.put(p.getUniqueId(), TwosideKeeper.getServerTickTime()); |
||||
//Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"tellraw @a [\"\",{\"text\":\"<"+p.getName()+"> \"},{\"text\":\""+ChatColor.GREEN+"A "+item.getCustomName()+" is nearby! "+ChatColor.BOLD+"[\"},{\"text\":\"[Click Here]"+ChatColor.RESET+ChatColor.GREEN+"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\""+GenericFunctions.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand())+""+WorldShop.GetItemInfo(ev.getPlayer().getEquipment().getItemInMainHand()).replace("\"", "\\\"")+"\"}},{\"text\":\""+ev.getMessage().substring(pos)+"\"}]");
|
||||
TextComponent tc = new TextComponent(ChatColor.GREEN+"A "+item.getCustomName()+ChatColor.RESET+ChatColor.GREEN+" is nearby! "); |
||||
TextComponent tc2 = new TextComponent(ChatColor.YELLOW+""+ChatColor.BOLD+"[Click here]"); |
||||
tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/dailyloot "+item.getUniqueId())); |
||||
tc.addExtra(tc2); |
||||
tc2 = new TextComponent(ChatColor.RESET+""+ChatColor.GREEN+" to open its contents."); |
||||
tc.addExtra(tc2); |
||||
p.spigot().sendMessage(tc); |
||||
//p.openInventory(drop_inventories.get(p.getUniqueId()));
|
||||
} |
||||
}/* else { |
||||
if (!drop_inventories.containsKey(p.getUniqueId())) { |
||||
TwosideKeeper.log("WARNING! Could not find UUID "+p.getUniqueId()+". UUID List: "+TextUtils.outputHashmap(drop_inventories), 1); |
||||
} |
||||
}*/ |
||||
} |
||||
return true; |
||||
} else { |
||||
chunks.remove(c); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public Item getItem() { |
||||
return item; |
||||
} |
||||
|
||||
public UUID getItemUniqueID() { |
||||
return item_uuid; |
||||
} |
||||
|
||||
public void addNewDropInventory(UUID id, ItemStack...lootitems) { |
||||
if (drop_inventories.containsKey(id)) { |
||||
Inventory inv = drop_inventories.get(id); |
||||
inv.addItem(lootitems); |
||||
} else { |
||||
Inventory newinv = Bukkit.createInventory(null, ((((lootitems.length-1)/9)+1)*9),this.lootname); |
||||
newinv.addItem(lootitems); |
||||
drop_inventories.put(id, newinv); |
||||
} |
||||
} |
||||
|
||||
public void openDropInventory(Player p) { |
||||
if (drop_inventories.containsKey(p.getUniqueId()) && |
||||
!InventoryUtils.hasEmptyInventory(drop_inventories.get(p.getUniqueId()))) { |
||||
p.openInventory(drop_inventories.get(p.getUniqueId())); |
||||
} else { |
||||
TwosideKeeper.log("WARNING! Drop Inventory for Player with UUID <"+p.getUniqueId()+"> does not have an associated inventory with Global Loot <"+item.getUniqueId()+">. THIS SHOULD NOT BE HAPPENING!!", 1); |
||||
p.sendMessage(ChatColor.RED+"Something terrible has happened! "+ChatColor.RESET+"Please let the server administrator know about this."); |
||||
} |
||||
} |
||||
|
||||
public static GlobalLoot spawnGlobalLoot(Location loc, String lootName) { |
||||
GlobalLoot loot = new GlobalLoot(loc,lootName); |
||||
TwosideKeeper.globalloot.put(loot.getItem().getUniqueId(), loot); |
||||
return loot; |
||||
} |
||||
} |
@ -1,176 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import java.text.DecimalFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Player; |
||||
|
||||
import sig.plugin.TwosideKeeper.PlayerStructure; |
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.DebugUtils; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.PlayerUtils; |
||||
|
||||
public class AdvancedTitle { |
||||
TitlePart large_lefttitle = new TitlePart("",0); |
||||
TitlePart large_centertitle = new TitlePart("",0); |
||||
TitlePart large_righttitle = new TitlePart("",0); |
||||
TitlePart small_centertitle = new TitlePart("",0); |
||||
Player p; |
||||
|
||||
public AdvancedTitle(Player p) { |
||||
this.p=p; |
||||
} |
||||
|
||||
public void modifyLargeLeftTitle(String title, int duration) { |
||||
large_lefttitle.setTitle(title); |
||||
large_lefttitle.setDuration(duration); |
||||
update(); |
||||
} |
||||
public void modifyLargeCenterTitle(String title, int duration) { |
||||
large_centertitle.setTitle(title); |
||||
large_centertitle.setDuration(duration); |
||||
update(); |
||||
} |
||||
public void modifyLargeRightTitle(String title, int duration) { |
||||
large_righttitle.setTitle(title); |
||||
large_righttitle.setDuration(duration); |
||||
update(); |
||||
} |
||||
public void modifySmallCenterTitle(String title, int duration) { |
||||
small_centertitle.setTitle(title); |
||||
small_centertitle.setDuration(duration); |
||||
update(); |
||||
} |
||||
|
||||
public void checkExpiredTitles() { |
||||
boolean refreshnames=false; |
||||
if (large_lefttitle.isExpired()) { |
||||
large_lefttitle.clear(); |
||||
refreshnames=true; |
||||
} |
||||
if (large_centertitle.isExpired()) { |
||||
large_centertitle.clear(); |
||||
refreshnames=true; |
||||
} |
||||
if (large_righttitle.isExpired()) { |
||||
large_righttitle.clear(); |
||||
refreshnames=true; |
||||
} |
||||
if (small_centertitle.isExpired()) { |
||||
small_centertitle.clear(); |
||||
refreshnames=true; |
||||
} |
||||
if (refreshnames) { |
||||
update(); |
||||
} |
||||
} |
||||
|
||||
public void update() { |
||||
p.sendTitle(combineLargeTitles(), combineSmallTitles()); |
||||
} |
||||
|
||||
private String combineSmallTitles() { |
||||
StringBuilder sb = new StringBuilder(small_centertitle.getTitle()); |
||||
return sb.toString(); |
||||
} |
||||
|
||||
private String combineLargeTitles() { |
||||
StringBuilder sb = new StringBuilder(large_lefttitle.getTitle()); |
||||
sb.append(ChatColor.RESET); |
||||
if (large_lefttitle.getTitle().length()>0 || |
||||
large_righttitle.getTitle().length()>0) { |
||||
if (large_centertitle.getTitle().length()==0) { |
||||
sb.append(" "); |
||||
} else { |
||||
sb.append(" "); |
||||
sb.append(large_centertitle.getTitle()); |
||||
sb.append(ChatColor.RESET); |
||||
sb.append(" "); |
||||
} |
||||
} else { |
||||
sb.append(large_centertitle.getTitle()); |
||||
sb.append(ChatColor.RESET); |
||||
} |
||||
sb.append(large_righttitle.getTitle()); |
||||
return sb.toString(); |
||||
} |
||||
|
||||
public void updateCombatBar(Player p, LivingEntity target) { |
||||
updateSideTitleStats(p); |
||||
TwosideKeeper.updateHealthbarDisplay(p, target); |
||||
update(); |
||||
} |
||||
|
||||
public void updateCombatBar(Player p, LivingEntity target, double damage, int flags) { |
||||
updateSideTitleStats(p); |
||||
TwosideKeeper.updateHealthbarDisplay(p, target, damage, flags); |
||||
update(); |
||||
} |
||||
|
||||
public void updateSideTitleStats(Player p) { |
||||
//DebugUtils.showStackTrace();
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
if (PlayerMode.getPlayerMode(p)==PlayerMode.BARBARIAN) { |
||||
modifyLargeLeftTitle(ChatColor.DARK_AQUA+"☤"+Integer.toString((int)pd.weaponcharges),100); |
||||
modifyLargeRightTitle(ChatColor.DARK_PURPLE+Integer.toString((int)pd.damagepool)+"♥",100); |
||||
} |
||||
if (PlayerMode.getPlayerMode(p)==PlayerMode.DEFENDER) { |
||||
if (ItemSet.hasFullSet(p, ItemSet.SONGSTEEL)) { |
||||
modifyLargeLeftTitle(ChatColor.YELLOW+Integer.toString((int)pd.vendetta_amt),100); |
||||
} |
||||
//modifyLargeRightTitle(ChatColor.GOLD+Integer.toString((int)pd.thorns_amt),100);
|
||||
modifyLargeRightTitle(ChatColor.DARK_AQUA+Integer.toString(pd.blockStacks)+"☉",100); |
||||
} |
||||
} |
||||
|
||||
public String[] getTitles() { |
||||
return new String[]{large_lefttitle.getTitle(),large_centertitle.getTitle(),large_righttitle.getTitle()}; |
||||
} |
||||
} |
||||
|
||||
class TitlePart { |
||||
String title; |
||||
long expiretime; |
||||
boolean hasExpired=false; |
||||
|
||||
TitlePart(String title, int duration) { |
||||
this.title=title; |
||||
this.expiretime=TwosideKeeper.getServerTickTime()+duration; |
||||
} |
||||
|
||||
public void clear() { |
||||
title=""; |
||||
hasExpired=true; |
||||
} |
||||
|
||||
void setTitle(String title) { |
||||
this.title=title; |
||||
} |
||||
|
||||
void setDuration(int duration) { |
||||
this.expiretime=TwosideKeeper.getServerTickTime()+duration; |
||||
hasExpired=false; |
||||
} |
||||
|
||||
boolean alreadyExpired() { |
||||
return hasExpired; |
||||
} |
||||
|
||||
boolean isExpired() { |
||||
return !hasExpired && expiretime<=TwosideKeeper.getServerTickTime(); |
||||
} |
||||
|
||||
String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
long getExpirationTime() { |
||||
return expiretime; |
||||
} |
||||
} |
@ -1,31 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import java.io.File; |
||||
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
|
||||
public enum Book { |
||||
BEGINNERSGUIDE("NewPlayerGuide.txt"), |
||||
COMMANDGUIDE("CommandGuide.txt"), |
||||
STRIKERGUIDE("StrikerGuide.txt"), |
||||
DEFENDERGUIDE("DefenderGuide.txt"), |
||||
RANGERGUIDE("RangerGuide.txt"), |
||||
SLAYERGUIDE("SlayerGuide.txt"), |
||||
BARBARIANGUIDE("BarbarianGuide.txt"), |
||||
SUMMONERGUIDE("SummonerGuide.txt"), |
||||
ADVENTURERGUIDE("AdventurerGuide.txt"); |
||||
|
||||
String fileLoc; |
||||
|
||||
Book(String loc) { |
||||
this.fileLoc=loc; |
||||
} |
||||
|
||||
public File getBookFile() { |
||||
return new File(TwosideKeeper.plugin.getDataFolder()+"/books/"+this.fileLoc); |
||||
} |
||||
|
||||
public String getBookFilepath() { |
||||
return TwosideKeeper.plugin.getDataFolder()+"/books/"+this.fileLoc; |
||||
} |
||||
} |
@ -1,81 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Color; |
||||
|
||||
import sig.plugin.TwosideKeeper.Buff; |
||||
|
||||
public enum BuffTemplate { |
||||
POISON("Poison","Poison",Color.YELLOW,ChatColor.YELLOW+"☣",false), |
||||
SHRAPNEL("SHRAPNEL","Shrapnel",Color.RED,ChatColor.RED+"❂",false), |
||||
WINDCHARGES("WINDCHARGE","Wind",Color.GRAY,"๑",true), |
||||
BLEEDING("BLEEDING","Bleed",Color.MAROON,ChatColor.DARK_RED+"☠",false), |
||||
REGENERATION("REGENERATION","Regeneration",Color.GREEN,ChatColor.GREEN+""+ChatColor.BOLD+"✙",true), |
||||
INFECTION("INFECTION","Infection",Color.GRAY,ChatColor.GRAY+"❧",false), |
||||
CRIPPLE("CRIPPLE","Cripple",Color.WHITE,ChatColor.WHITE+"☹",false), |
||||
DARKSUBMISSION("DARKSUBMISSION",ChatColor.GRAY+"Dark Submission"+ChatColor.RESET,Color.BLACK,ChatColor.BLACK+""+ChatColor.MAGIC+"☁"+ChatColor.RESET,false), |
||||
CONFUSION("CONFUSION","Confusion",Color.PURPLE,ChatColor.DARK_PURPLE+"๑"+ChatColor.RESET,false), |
||||
|
||||
UNDYINGRAGE_COOLDOWN("COOLDOWN_UNDYING_RAGE","Undying Rage Cooldown",null,ChatColor.WHITE+"",true,true), |
||||
UNSTOPPABLETEAM_COOLDOWN("Unstoppable Team Unavailable","Unstoppable Team Unavailable",null,ChatColor.WHITE+"",true,true), |
||||
; |
||||
|
||||
String keyName; |
||||
String displayName; |
||||
Color col; |
||||
String icon; |
||||
boolean isGoodBuff; |
||||
boolean permanentBuff; |
||||
boolean displayTimer; |
||||
|
||||
public String getKeyName() { |
||||
return keyName; |
||||
} |
||||
public String getDisplayName() { |
||||
return displayName; |
||||
} |
||||
public Color getParticleColor() { |
||||
return col; |
||||
} |
||||
public String getIcon() { |
||||
return icon; |
||||
} |
||||
public boolean isGoodBuff() { |
||||
return isGoodBuff; |
||||
} |
||||
public boolean isPermanentBuff() { |
||||
return permanentBuff; |
||||
} |
||||
public boolean isDisplayTimer() { |
||||
return displayTimer; |
||||
} |
||||
|
||||
BuffTemplate(String keyName, String displayName, Color particleColor, String icon, boolean isGoodBuff) { |
||||
this.keyName=keyName; |
||||
this.displayName=displayName; |
||||
this.col=particleColor; |
||||
this.icon=icon; |
||||
this.isGoodBuff=isGoodBuff; |
||||
this.permanentBuff=false; |
||||
this.displayTimer=false; |
||||
} |
||||
BuffTemplate(String keyName, String displayName, Color particleColor, String icon, boolean isGoodBuff, boolean isPermanentBuff) { |
||||
this.keyName=keyName; |
||||
this.displayName=displayName; |
||||
this.col=particleColor; |
||||
this.icon=icon; |
||||
this.isGoodBuff=isGoodBuff; |
||||
this.permanentBuff=isPermanentBuff; |
||||
this.displayTimer=false; |
||||
} |
||||
BuffTemplate(String keyName, String displayName, Color particleColor, String icon, boolean isGoodBuff, boolean isPermanentBuff, boolean displayTimer) { |
||||
this.keyName=keyName; |
||||
this.displayName=displayName; |
||||
this.col=particleColor; |
||||
this.icon=icon; |
||||
this.isGoodBuff=isGoodBuff; |
||||
this.permanentBuff=isPermanentBuff; |
||||
this.displayTimer=displayTimer; |
||||
} |
||||
//new Buff("Poison",20*20,Integer.parseInt(args[1]),Color.YELLOW,ChatColor.YELLOW+"☣",false)
|
||||
} |
@ -1,28 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import org.bukkit.Material; |
||||
import org.bukkit.entity.Player; |
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.CastBarItem; |
||||
|
||||
public class CastBar { |
||||
List<CastBarItem> castbaritems = new ArrayList<CastBarItem>(); |
||||
|
||||
public CastBar(CastBarItem...items) { |
||||
castbaritems = Arrays.asList(items); |
||||
while (castbaritems.size()<9) { |
||||
castbaritems.add(new CastBarItem(Material.AIR)); |
||||
} |
||||
} |
||||
|
||||
public void run(Player p) { |
||||
aPlugin.API.setSlot(p, 9); |
||||
for (int i=0;i<9;i++) { |
||||
aPlugin.API.setItem(p, p.getOpenInventory(), i, castbaritems.get(i).getItemStack()); |
||||
} |
||||
} |
||||
} |
@ -1,166 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.boss.BarColor; |
||||
import org.bukkit.boss.BarFlag; |
||||
import org.bukkit.boss.BarStyle; |
||||
import org.bukkit.boss.BossBar; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Player; |
||||
|
||||
import sig.plugin.TwosideKeeper.LivingEntityStructure; |
||||
import sig.plugin.TwosideKeeper.PlayerStructure; |
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.Events.EntityChannelCastEvent; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; |
||||
|
||||
public class Channel { |
||||
LivingEntity l; |
||||
String channelName; |
||||
int duration; |
||||
long channelStartTime; |
||||
BossBar channelBar; |
||||
boolean cancelled=false; |
||||
|
||||
public Channel(LivingEntity l, String spellName, int tickDuration) { |
||||
this.l=l; |
||||
this.channelName=spellName; |
||||
this.duration=tickDuration; |
||||
this.channelStartTime=TwosideKeeper.getServerTickTime(); |
||||
if (l instanceof Player) { |
||||
Player p = (Player)l; |
||||
channelBar = l.getServer().createBossBar(ChatColor.YELLOW+channelName, BarColor.YELLOW, BarStyle.SOLID, BarFlag.CREATE_FOG); |
||||
channelBar.addPlayer(p); |
||||
UpdateBossBar(); |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
pd.currentChannel=this; |
||||
} else { |
||||
UpdateMobChannelingBar(l); |
||||
l.setCustomNameVisible(true); |
||||
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); |
||||
les.currentChannel=this; |
||||
} |
||||
GenericFunctions.addSuppressionTime(l, duration+5); |
||||
AddToStructure(); |
||||
} |
||||
|
||||
public static Channel createNewChannel(LivingEntity l, String spellName, int channelDuration){ |
||||
return new Channel(l,spellName,channelDuration); |
||||
} |
||||
|
||||
public static boolean isChanneling(LivingEntity l) { |
||||
if (l instanceof Player) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); |
||||
return pd.currentChannel!=null; |
||||
} else { |
||||
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); |
||||
return les.currentChannel!=null; |
||||
} |
||||
} |
||||
|
||||
public static void stopChanneling(LivingEntity l) { |
||||
if (isChanneling(l)) { |
||||
Channel c = getCurrentChannel(l); |
||||
c.setCancelled(true); |
||||
} |
||||
} |
||||
|
||||
public static Channel getCurrentChannel(LivingEntity l) { |
||||
if (isChanneling(l)) { |
||||
if (l instanceof Player) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); |
||||
return pd.currentChannel; |
||||
} else { |
||||
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); |
||||
return les.currentChannel; |
||||
} |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
private void AddToStructure() { |
||||
TwosideKeeper.channels.add(this); |
||||
} |
||||
|
||||
private void UpdateMobChannelingBar(LivingEntity l) { |
||||
LivingEntityStructure.setChannelingBar(l, getMobChannelingBar()); |
||||
} |
||||
|
||||
private void UpdateBossBar() { |
||||
long tickTimeChanneled = TwosideKeeper.getServerTickTime()-channelStartTime; |
||||
double ratio = (double)tickTimeChanneled/duration; |
||||
channelBar.setProgress(ratio); |
||||
} |
||||
|
||||
private String getMobChannelingBar() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(ChatColor.YELLOW); |
||||
sb.append(channelName); |
||||
sb.append("["); |
||||
long tickTimeChanneled = TwosideKeeper.getServerTickTime()-channelStartTime; |
||||
double ratio = (double)tickTimeChanneled/duration; |
||||
int bars = (int)(ratio*10); |
||||
for (int i=0;i<bars;i++) { |
||||
sb.append("█"); |
||||
} |
||||
for (int i=0;i<10-bars;i++) { |
||||
sb.append("-"); |
||||
} |
||||
sb.append("]"); |
||||
sb.append(ChatColor.RESET); |
||||
return sb.toString(); |
||||
} |
||||
|
||||
public void setCancelled(boolean isCancelled) { |
||||
cancelled=isCancelled; |
||||
LivingEntityStructure.setChannelingBar(l, ""); |
||||
if (channelBar!=null) { |
||||
channelBar.removeAll(); |
||||
} |
||||
} |
||||
|
||||
public String getSpellName() { |
||||
return channelName; |
||||
} |
||||
|
||||
public LivingEntity getLivingEntity() { |
||||
return l; |
||||
} |
||||
|
||||
public boolean runTick() { |
||||
if (l==null || !l.isValid() || cancelled) { |
||||
return false; |
||||
} |
||||
if (channelStartTime+duration<TwosideKeeper.getServerTickTime()) { |
||||
if (channelBar!=null) { |
||||
channelBar.removeAll(); |
||||
} else { |
||||
LivingEntityStructure.setChannelingBar(l, ""); |
||||
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); |
||||
if (les.suffix_bar.length()==0 && les.prefix.length()>0) { |
||||
l.setCustomNameVisible(false); |
||||
} |
||||
} |
||||
if (l instanceof Player) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); |
||||
pd.currentChannel=null; |
||||
} else { |
||||
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); |
||||
les.currentChannel=null; |
||||
} |
||||
EntityChannelCastEvent ev = new EntityChannelCastEvent(l,channelName); |
||||
Bukkit.getPluginManager().callEvent(ev); |
||||
return false; |
||||
} else { |
||||
if (channelBar!=null) { |
||||
UpdateBossBar(); |
||||
} else { |
||||
UpdateMobChannelingBar(l); |
||||
LivingEntityStructure.UpdateMobName(l); |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Location; |
||||
import org.bukkit.entity.AreaEffectCloud; |
||||
import org.bukkit.entity.EnderSignal; |
||||
import org.bukkit.entity.EntityType; |
||||
import org.bukkit.entity.FallingBlock; |
||||
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.EntityUtils; |
||||
|
||||
public class CloudRunnableRemoveLabel implements Runnable{ |
||||
AreaEffectCloud aec; |
||||
Location loc; |
||||
String str; |
||||
double spd; |
||||
int duration; |
||||
|
||||
public CloudRunnableRemoveLabel(Location loc,String str,double spd,int duration) { |
||||
this.loc=loc; |
||||
this.str=str; |
||||
this.spd=spd; |
||||
this.duration=duration; |
||||
} |
||||
|
||||
@Override |
||||
public void run() { |
||||
aec = EntityUtils.CreateOverlayText(loc, str); |
||||
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, new CloudRunnable(aec,spd,duration), 1); |
||||
} |
||||
|
||||
} |
@ -1,207 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Common; |
||||
|
||||
import org.bukkit.Material; |
||||
import org.bukkit.inventory.ItemStack; |
||||
import org.bukkit.util.EulerAngle; |
||||
import org.bukkit.util.Vector; |
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.MathUtils; |
||||
|
||||
public class ArmorStandProperties { |
||||
final public static ArmorStandProperties SCEPTERBASE = new ArmorStandProperties(); |
||||
final public static ArmorStandProperties SCEPTERTOP = new ArmorStandProperties(); |
||||
|
||||
boolean arms = false; |
||||
boolean baseplate = false; |
||||
EulerAngle bodyPose = EulerAngle.ZERO; |
||||
ItemStack boots = new ItemStack(Material.AIR); |
||||
ItemStack chestplate = new ItemStack(Material.AIR); |
||||
EulerAngle headPose = EulerAngle.ZERO; |
||||
ItemStack helmet = new ItemStack(Material.AIR); |
||||
ItemStack hand = new ItemStack(Material.AIR); |
||||
EulerAngle leftArmPose = EulerAngle.ZERO; |
||||
EulerAngle leftLegPose = EulerAngle.ZERO; |
||||
ItemStack leggings = new ItemStack(Material.AIR); |
||||
boolean marker = false; |
||||
EulerAngle rightArmPose = EulerAngle.ZERO; |
||||
EulerAngle rightLegPose = EulerAngle.ZERO; |
||||
|
||||
boolean small = false; |
||||
boolean visible=true; |
||||
boolean customNameVisible=false; |
||||
String customName=""; |
||||
Vector offset = new Vector(); |
||||
|
||||
public ArmorStandProperties() { |
||||
|
||||
} |
||||
|
||||
public boolean isArms() { |
||||
return arms; |
||||
} |
||||
|
||||
public void setArms(boolean arms) { |
||||
this.arms = arms; |
||||
} |
||||
|
||||
public boolean isBaseplate() { |
||||
return baseplate; |
||||
} |
||||
|
||||
public void setBaseplate(boolean baseplate) { |
||||
this.baseplate = baseplate; |
||||
} |
||||
|
||||
public EulerAngle getBodyPose() { |
||||
return bodyPose; |
||||
} |
||||
|
||||
public void setBodyPose(EulerAngle bodyPose) { |
||||
this.bodyPose = bodyPose; |
||||
} |
||||
|
||||
public ItemStack getBoots() { |
||||
return boots; |
||||
} |
||||
|
||||
public void setBoots(ItemStack boots) { |
||||
this.boots = boots; |
||||
} |
||||
|
||||
public ItemStack getChestplate() { |
||||
return chestplate; |
||||
} |
||||
|
||||
public void setChestplate(ItemStack chestplate) { |
||||
this.chestplate = chestplate; |
||||
} |
||||
|
||||
public EulerAngle getHeadPose() { |
||||
return headPose; |
||||
} |
||||
|
||||
public void setHeadPose(EulerAngle headPose) { |
||||
this.headPose = headPose; |
||||
} |
||||
|
||||
public ItemStack getHelmet() { |
||||
return helmet; |
||||
} |
||||
|
||||
public void setHelmet(ItemStack helmet) { |
||||
this.helmet = helmet; |
||||
} |
||||
|
||||
public ItemStack getHand() { |
||||
return hand; |
||||
} |
||||
|
||||
public void setHand(ItemStack hand) { |
||||
this.hand = hand; |
||||
} |
||||
|
||||
public EulerAngle getLeftArmPose() { |
||||
return leftArmPose; |
||||
} |
||||
|
||||
public void setLeftArmPose(EulerAngle leftArmPose) { |
||||
this.leftArmPose = leftArmPose; |
||||
} |
||||
|
||||
public EulerAngle getLeftLegPose() { |
||||
return leftLegPose; |
||||
} |
||||
|
||||
public void setLeftLegPose(EulerAngle leftLegPose) { |
||||
this.leftLegPose = leftLegPose; |
||||
} |
||||
|
||||
public ItemStack getLeggings() { |
||||
return leggings; |
||||
} |
||||
|
||||
public void setLeggings(ItemStack leggings) { |
||||
this.leggings = leggings; |
||||
} |
||||
|
||||
public boolean isMarker() { |
||||
return marker; |
||||
} |
||||
|
||||
public void setMarker(boolean marker) { |
||||
this.marker = marker; |
||||
} |
||||
|
||||
public EulerAngle getRightArmPose() { |
||||
return rightArmPose; |
||||
} |
||||
|
||||
public void setRightArmPose(EulerAngle rightArmPose) { |
||||
this.rightArmPose = rightArmPose; |
||||
} |
||||
|
||||
public boolean isSmall() { |
||||
return small; |
||||
} |
||||
|
||||
public void setSmall(boolean small) { |
||||
this.small = small; |
||||
} |
||||
|
||||
public boolean isVisible() { |
||||
return visible; |
||||
} |
||||
|
||||
public void setVisible(boolean visible) { |
||||
this.visible = visible; |
||||
} |
||||
|
||||
public boolean isCustomNameVisible() { |
||||
return customNameVisible; |
||||
} |
||||
|
||||
public void setCustomNameVisible(boolean customNameVisible) { |
||||
this.customNameVisible = customNameVisible; |
||||
} |
||||
|
||||
public String getCustomName() { |
||||
return customName; |
||||
} |
||||
|
||||
public void setCustomName(String customName) { |
||||
this.customName = customName; |
||||
} |
||||
public EulerAngle getRightLegPose() { |
||||
return rightLegPose; |
||||
} |
||||
|
||||
public void setRightLegPose(EulerAngle rightLegPose) { |
||||
this.rightLegPose = rightLegPose; |
||||
} |
||||
|
||||
public Vector getOffset() { |
||||
return offset; |
||||
} |
||||
|
||||
public void setOffset(Vector offset) { |
||||
this.offset = offset; |
||||
} |
||||
|
||||
public static void defineAllModels() { |
||||
SetupScepterBase(); |
||||
SetupScepterTop(); |
||||
} |
||||
|
||||
private static void SetupScepterTop() { |
||||
SCEPTERTOP.rightArmPose = MathUtils.getEulerAngleDegrees(-90, 0, 0); |
||||
SCEPTERTOP.hand = new ItemStack(Material.DOUBLE_PLANT); |
||||
SCEPTERTOP.offset = new Vector(-0.7,0,0.1); |
||||
} |
||||
|
||||
private static void SetupScepterBase() { |
||||
SCEPTERBASE.rightArmPose = MathUtils.getEulerAngleDegrees(-90, 90, 0); |
||||
SCEPTERBASE.small = true; |
||||
SCEPTERBASE.hand = new ItemStack(Material.BONE); |
||||
} |
||||
} |
||||
|
@ -1,34 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Common; |
||||
|
||||
import org.bukkit.Material; |
||||
import org.bukkit.inventory.ItemStack; |
||||
import org.bukkit.material.MaterialData; |
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; |
||||
|
||||
public class CastBarItem { |
||||
ItemStack item; |
||||
|
||||
public CastBarItem(Material mat) { |
||||
this(mat,(short)0,1,null); |
||||
} |
||||
|
||||
public CastBarItem(Material mat, short data, String displayName) { |
||||
this(mat,data,1,displayName); |
||||
} |
||||
|
||||
public CastBarItem(Material mat, short data, int amt, String displayName) { |
||||
item = new ItemStack(mat,amt,data); |
||||
if (displayName!=null) { |
||||
ItemUtils.setDisplayName(item, displayName); |
||||
} |
||||
} |
||||
|
||||
public CastBarItem(MaterialData matdata, String displayName) { |
||||
item = new ItemStack(matdata.getItemType(),1,matdata.getData()); |
||||
} |
||||
|
||||
public ItemStack getItemStack() { |
||||
return item; |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,20 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Common; |
||||
|
||||
|
||||
|
||||
public class PVPValue { |
||||
int points; //Number of points in this value.
|
||||
double baseval; //The base value of this ability.
|
||||
|
||||
public PVPValue(int points, double baseval) { |
||||
this.points=points; |
||||
this.baseval=baseval; |
||||
} |
||||
|
||||
public int getPointValue() { |
||||
return points; |
||||
} |
||||
public double getBaseValue() { |
||||
return baseval; |
||||
} |
||||
} |
@ -1,55 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import org.bukkit.Location; |
||||
import org.bukkit.entity.ArmorStand; |
||||
import org.bukkit.entity.EntityType; |
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.ArmorStandProperties; |
||||
|
||||
public class CustomModel { |
||||
List<ArmorStandProperties> modelParts = new ArrayList<ArmorStandProperties>(); |
||||
List<ArmorStand> stands = new ArrayList<ArmorStand>(); |
||||
|
||||
public CustomModel(Location loc, ArmorStandProperties...modelParts) { |
||||
for (ArmorStandProperties asp : modelParts) { |
||||
this.modelParts.add(asp); |
||||
this.stands.add(setupArmorStand(loc, asp)); |
||||
} |
||||
} |
||||
|
||||
private ArmorStand setupArmorStand(Location loc, ArmorStandProperties asp) { |
||||
ArmorStand stand = (ArmorStand)loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND); |
||||
stand.setArms(asp.isArms()); |
||||
stand.setBasePlate(asp.isBaseplate()); |
||||
stand.setBodyPose(asp.getBodyPose()); |
||||
stand.setBoots(asp.getBoots()); |
||||
stand.setChestplate(asp.getChestplate()); |
||||
stand.setHeadPose(asp.getHeadPose()); |
||||
stand.setHelmet(asp.getHelmet()); |
||||
stand.setItemInHand(asp.getHand()); |
||||
stand.setLeftArmPose(asp.getLeftArmPose()); |
||||
stand.setLeftLegPose(asp.getLeftLegPose()); |
||||
stand.setLeggings(asp.getLeggings()); |
||||
stand.setMarker(asp.isMarker()); |
||||
stand.setRightArmPose(asp.getRightArmPose()); |
||||
stand.setRightLegPose(asp.getRightLegPose()); |
||||
stand.setSmall(asp.isSmall()); |
||||
stand.setVisible(asp.isVisible()); |
||||
stand.setCustomNameVisible(asp.isCustomNameVisible()); |
||||
stand.setCustomName(asp.getCustomName()); |
||||
stand.teleport(loc.add(asp.getOffset())); |
||||
return stand; |
||||
} |
||||
|
||||
public void displayModel(Location loc) { |
||||
for (int i=0;i<stands.size();i++) { |
||||
if (stands.get(i)!=null && stands.get(i).isValid()) { |
||||
stands.get(i).teleport(loc.add(modelParts.get(i).getOffset())); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,65 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Effects; |
||||
|
||||
import org.bukkit.Effect; |
||||
import org.bukkit.Location; |
||||
import org.bukkit.Particle; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Player; |
||||
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes.ColoredParticle; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes.MixedDamage; |
||||
|
||||
public class DarkSlash extends WindSlash{ |
||||
|
||||
final static int EFFECT_DENSITY = 10; |
||||
final static Particle EFFECT_PARTICLE = Particle.ENCHANTMENT_TABLE; |
||||
final static float SPEED_MULT = 2.5f; |
||||
|
||||
public DarkSlash(Location loc, LivingEntity l, MixedDamage dmg, int tick_duration) { |
||||
super(loc, l, dmg, tick_duration); |
||||
} |
||||
|
||||
public boolean runTick() { |
||||
if (!moveWindSlash()) { |
||||
return false; |
||||
} |
||||
createParticles(); |
||||
damageNearbyTargets(); |
||||
if (TwosideKeeper.getServerTickTime()>death_time) { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
protected void createParticles() { |
||||
//loc.getWorld().spawnParticle(Particle.END_ROD, loc.clone().add(0,-SLASH_SIZE/2,0), 4);
|
||||
for (int i=0;i<EFFECT_DENSITY;i++) { |
||||
Location randloc = loc.clone(); |
||||
loc.getWorld().spawnParticle(EFFECT_PARTICLE, randloc.add(randloc.getDirection().setY(randloc.getDirection().getY()*2).multiply(Math.random())).clone().add(0,-SLASH_SIZE/2,0), 1); |
||||
} |
||||
//loc.getWorld().playEffect(loc.clone().add(0,-SLASH_SIZE/2,0), Effect.DRAGON_BREATH, 4);
|
||||
//loc.getWorld().playEffect(loc.clone().add(0,-SLASH_SIZE/2,0), Effect.COLOURED_DUST, 20);
|
||||
|
||||
Location baseloc = loc.clone(); |
||||
|
||||
final int density=100; |
||||
final int height=30; |
||||
|
||||
for (int j=0;j<density;j++) { |
||||
for (int i=0;i<height;i++) { |
||||
ColoredParticle.RED_DUST.send(baseloc.clone().add(0,-SLASH_SIZE/2,0).add(0,(2d/height)*i,0) |
||||
, 20, 0, 0, 255); |
||||
} |
||||
baseloc.add(baseloc.getDirection().multiply(SPEED_MULT/density)); |
||||
} |
||||
} |
||||
|
||||
private void damageNearbyTargets() { |
||||
//GenericFunctions.DealDamageToNearbyMobs(loc, dmg, SLASH_SIZE, false, 0, sourcep, sourcep.getEquipment().getItemInMainHand(), false, "Dark Slash");
|
||||
GenericFunctions.DealDamageToNearbyPlayers(loc, dmg.getDmgComponent(), SLASH_SIZE, false, true, 0, l, "Dark Slash", false, false); |
||||
if (dmg.getTruePctDmgComponent()>0) {GenericFunctions.DealDamageToNearbyPlayers(loc, dmg.getTruePctDmgComponent(), SLASH_SIZE, false, true, 0, l, "Dark Slash", false, true);} |
||||
if (dmg.getTrueDmgComponent()>0) {GenericFunctions.DealDamageToNearbyPlayers(loc, dmg.getTrueDmgComponent(), SLASH_SIZE, false, true, 0, l, "Dark Slash", true, false);} |
||||
} |
||||
} |
@ -1,35 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Effects; |
||||
|
||||
import org.bukkit.Color; |
||||
import org.bukkit.Location; |
||||
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes.ColoredParticle; |
||||
|
||||
public class EffectPool { |
||||
double radius = 1; |
||||
Color col = null; |
||||
Location loc = null; |
||||
long expireTime=0; |
||||
final int PARTICLE_DENSITY = 5; |
||||
public EffectPool(Location loc, double radius, int duration, Color col) { |
||||
this.loc=loc.clone(); |
||||
this.radius=radius; |
||||
this.col=col; |
||||
this.expireTime=TwosideKeeper.getServerTickTime()+duration; |
||||
TwosideKeeper.effectpools.add(this); |
||||
} |
||||
|
||||
public boolean runTick() { |
||||
int density = (int)Math.pow(PARTICLE_DENSITY, radius); |
||||
for (int i=0;i<density;i++) { |
||||
Location particleloc = loc.clone().add( |
||||
(Math.random()*(radius+1))-radius, |
||||
0.66, |
||||
(Math.random()*(radius+1))-radius |
||||
); |
||||
ColoredParticle.RED_DUST.send(particleloc, 50, col.getRed(), col.getGreen(), col.getBlue()); |
||||
} |
||||
return !(expireTime<=TwosideKeeper.getServerTickTime()); |
||||
} |
||||
} |
@ -1,67 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Effects; |
||||
|
||||
import org.bukkit.Location; |
||||
import org.bukkit.Particle; |
||||
import org.bukkit.util.Vector; |
||||
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes.ParticleEffect; |
||||
|
||||
public class HighlightCircle { |
||||
final Particle PARTICLE = Particle.BLOCK_DUST; |
||||
final int PARTICLE_DENSITY = 16; |
||||
final int ANGLE_OFFSET = 10; |
||||
Location center = null; |
||||
double r = 0; |
||||
double h = 0; |
||||
long expireTime = 0; |
||||
|
||||
/** |
||||
* Creates a cylinder zone that will be outline by particles. |
||||
* @param l The centered location of the zone. |
||||
* @param radius The radius of the zone. |
||||
* @param height The height of the zone. |
||||
* @param duration The amount of time in ticks the zone will exist. |
||||
*/ |
||||
public HighlightCircle(Location l, double radius, double height, int duration) { |
||||
this.center=l.clone(); |
||||
this.r=radius; |
||||
this.h=height; |
||||
this.expireTime=TwosideKeeper.getServerTickTime()+duration; |
||||
TwosideKeeper.circles.add(this); |
||||
} |
||||
|
||||
public Location getCenter() { |
||||
return center; |
||||
} |
||||
|
||||
public double getRadius() { |
||||
return r; |
||||
} |
||||
|
||||
public double getHeight() { |
||||
return h; |
||||
} |
||||
|
||||
public boolean hasExpired() { |
||||
return expireTime<TwosideKeeper.getServerTickTime(); |
||||
} |
||||
|
||||
public boolean runTick() { |
||||
for (int j=0;j<h;j++) { |
||||
for (int i=0;i<PARTICLE_DENSITY;i++) { |
||||
double angle = ((1d/PARTICLE_DENSITY)*360d)*i+(ANGLE_OFFSET*j); |
||||
double xamt = Math.sin(Math.toRadians(angle))*r; |
||||
double zamt = Math.cos(Math.toRadians(angle))*r; |
||||
Location particleloc = center.clone().add(new Location(center.getWorld(), |
||||
xamt, |
||||
j, |
||||
zamt) |
||||
); |
||||
//TwosideKeeper.log("Location: "+particleloc, 0);
|
||||
ParticleEffect.CRIT.display(new Vector(0,0,0), 0f, particleloc, 50); |
||||
} |
||||
} |
||||
return !hasExpired(); |
||||
} |
||||
} |
@ -1,141 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Effects; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Color; |
||||
import org.bukkit.Location; |
||||
import org.bukkit.Particle; |
||||
import org.bukkit.entity.Entity; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Player; |
||||
|
||||
import sig.plugin.TwosideKeeper.Buff; |
||||
import sig.plugin.TwosideKeeper.CustomDamage; |
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
|
||||
public class TemporaryBlockNode { |
||||
Location l; |
||||
double range; |
||||
int duration; |
||||
String specialKey; |
||||
Particle effect; |
||||
int particleDensity; //Number of particles per second.
|
||||
long lastAppliedEffect=TwosideKeeper.getServerTickTime(); |
||||
|
||||
public TemporaryBlockNode(Location l, double range, int duration, String key) { |
||||
this.l=l; |
||||
this.range=range; |
||||
this.specialKey=key; |
||||
this.duration=duration; |
||||
this.effect=null; |
||||
this.particleDensity=0; |
||||
TwosideKeeper.blocknodes.add(this); |
||||
} |
||||
|
||||
public TemporaryBlockNode(Location l, double range, int duration, String key, Particle effect, int density) { |
||||
this.l=l; |
||||
this.range=range; |
||||
this.specialKey=key; |
||||
this.duration=duration; |
||||
this.effect=effect; |
||||
this.particleDensity=density; |
||||
TwosideKeeper.blocknodes.add(this); |
||||
} |
||||
|
||||
public boolean runTick() { |
||||
playParticleEffects(); |
||||
affectEntitiesBasedOnKey(); |
||||
duration-=5; |
||||
if (duration<0) { |
||||
return false; |
||||
} else { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
private void affectEntitiesBasedOnKey() { |
||||
switch (specialKey) { |
||||
case "TESTNODE":{ |
||||
for (Entity e : getNonPlayersOnNode()) { |
||||
if (e instanceof LivingEntity) { |
||||
CustomDamage.ApplyDamage(1, null, (LivingEntity)e, null, "Test Damage"); |
||||
} |
||||
} |
||||
}break; |
||||
case "FIREPOOL":{ |
||||
if (lastAppliedEffect+20<TwosideKeeper.getServerTickTime()) { |
||||
lastAppliedEffect = TwosideKeeper.getServerTickTime(); |
||||
for (Entity e : getNonPlayersOnNode()) { |
||||
if (e instanceof LivingEntity) { |
||||
Buff.addBuff((LivingEntity)e, "BURN", new Buff("Burn",100,1,Color.ORANGE,ChatColor.GOLD+"❂",false),true); |
||||
} |
||||
} |
||||
} |
||||
}break; |
||||
} |
||||
} |
||||
|
||||
private void playParticleEffects() { |
||||
if (effect!=null) { |
||||
for (int i=0;i<particleDensity/4;i++) { |
||||
SpawnParticleInRandomLocation(); |
||||
} |
||||
if (Math.random()<=(particleDensity%20)*0.05) { |
||||
SpawnParticleInRandomLocation(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void SpawnParticleInRandomLocation() { |
||||
l.getWorld().spawnParticle(effect, new Location(l.getWorld(),l.getX()+Math.random()*range-(Math.random()*(range*2)) |
||||
,l.getY()+Math.random()*range-(Math.random()*(range*2)) |
||||
,l.getZ()+Math.random()*range-(Math.random()*(range*2))), 2); |
||||
} |
||||
|
||||
public Entity[] getEntitiesOnNode() { |
||||
Collection<Entity> ents = l.getWorld().getNearbyEntities(l, range, range, range); |
||||
return ents.toArray(new Entity[ents.size()]); |
||||
} |
||||
|
||||
public List<Entity> getPlayersOnNode() { |
||||
long time = System.nanoTime(); |
||||
Collection<Entity> ents = l.getWorld().getNearbyEntities(l, range, range, range); |
||||
List<Entity> list = new ArrayList<Entity>(); |
||||
for (Entity e : ents) { |
||||
if (e instanceof Player) { |
||||
list.add(e); |
||||
} |
||||
} |
||||
TwosideKeeper.log("Calculation time via nearby entities: "+(System.nanoTime()-time), TwosideKeeper.TIMINGS_DEBUG); |
||||
return list; |
||||
} |
||||
|
||||
public List<Entity> getNonPlayersOnNode() { |
||||
long time = System.nanoTime(); |
||||
Collection<Entity> ents = l.getWorld().getNearbyEntities(l, range, range, range); |
||||
List<Entity> list = new ArrayList<Entity>(); |
||||
for (Entity e : ents) { |
||||
if (!(e instanceof Player)) { |
||||
list.add(e); |
||||
} |
||||
} |
||||
TwosideKeeper.log("Calculation time via nearby entities: "+(System.nanoTime()-time), TwosideKeeper.TIMINGS_DEBUG); |
||||
return list; |
||||
} |
||||
@Deprecated |
||||
public List<Entity> getPlayersOnNodeViaDistanceSearch() { |
||||
long time = System.nanoTime(); |
||||
List<Entity> list = new ArrayList<Entity>(); |
||||
for (Player p : Bukkit.getOnlinePlayers()) { |
||||
if (p.getLocation().distance(l)<=range) { |
||||
list.add(p); |
||||
} |
||||
} |
||||
TwosideKeeper.log("Calculation time via distance search: "+(System.nanoTime()-time), TwosideKeeper.TIMINGS_DEBUG); |
||||
return list; |
||||
} |
||||
} |
@ -1,170 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.Material; |
||||
import org.bukkit.Sound; |
||||
import org.bukkit.entity.Item; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.event.player.PlayerPickupItemEvent; |
||||
import org.bukkit.inventory.ItemStack; |
||||
|
||||
import sig.plugin.TwosideKeeper.PVP; |
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.Events.InventoryUpdateEvent; |
||||
import sig.plugin.TwosideKeeper.Events.InventoryUpdateEvent.UpdateReason; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.ArrowQuiver; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; |
||||
|
||||
public class ItemPickupStructure { |
||||
PlayerPickupItemEvent ev; |
||||
|
||||
public ItemPickupStructure(PlayerPickupItemEvent itemEvent) { |
||||
this.ev=itemEvent; |
||||
} |
||||
|
||||
public void run() { |
||||
//Arrow quiver code goes here.
|
||||
//TwosideKeeper.log("["+TwosideKeeper.getServerTickTime()+"] PlayerPickupItemEvent fired w/ "+ev.getItem().getItemStack(), 1);
|
||||
if (ev.isCancelled()) { |
||||
return; |
||||
} |
||||
Player p = ev.getPlayer(); |
||||
if (PVP.isPvPing(p)) { |
||||
ev.setCancelled(true); |
||||
return; |
||||
} |
||||
//log("Item Right now: "+ev.getItem().getItemStack(),0);
|
||||
long time = System.nanoTime(); |
||||
long totaltime = System.nanoTime(); |
||||
|
||||
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, ()->{ |
||||
InventoryUpdateEvent.TriggerUpdateInventoryEvent(p,ev.getItem().getItemStack(),UpdateReason.PICKEDUPITEM); |
||||
}, 1); |
||||
ItemStack newstack = InventoryUtils.AttemptToFillPartialSlotsFirst(p,ev.getItem().getItemStack()); |
||||
TwosideKeeper.PickupLogger.AddEntry("Fill Partial Slots First", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
//TwosideKeeper.log(" New Stack is: "+newstack,0);
|
||||
if (newstack==null || newstack.getType()==Material.AIR) { |
||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(ev.getItem().getItemStack())); |
||||
TwosideKeeper.PlayPickupParticle(ev.getPlayer(),ev.getItem()); |
||||
if (ev.getRemaining()>0) { |
||||
Item it = ev.getItem(); |
||||
it.getItemStack().setAmount(ev.getRemaining()); |
||||
//GenericFunctions.giveItem(p, it.getItemStack());
|
||||
GenericFunctions.dropItem(it.getItemStack(), p.getLocation()); |
||||
} |
||||
ev.getItem().remove();ev.setCancelled(true);return;} |
||||
TwosideKeeper.PickupLogger.AddEntry("Pickup Item when it's null", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
ev.getItem().setItemStack(newstack); |
||||
//log("Pickup Metadata: "+ev.getItem().getItemStack().getItemMeta().toString(),0);
|
||||
//GenericFunctions.updateSetItems(p.getInventory());
|
||||
GenericFunctions.UpdateItemLore(ev.getItem().getItemStack()); |
||||
TwosideKeeper.PickupLogger.AddEntry("Update Item Lore", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
/*//LEGACY CODE
|
||||
if (!ev.isCancelled()) { |
||||
if (ev.getItem().getItemStack().getType()==Material.ARROW && |
||||
playerHasArrowQuiver(p)) { |
||||
int arrowquiver_slot = playerGetArrowQuiver(p); |
||||
playerInsertArrowQuiver(p, arrowquiver_slot, ev.getItem().getItemStack().getAmount()); |
||||
log("Added "+ev.getItem().getItemStack().getAmount()+" arrow"+((ev.getItem().getItemStack().getAmount()==1)?"":"s")+" to quiver in slot "+arrowquiver_slot+". New amount: "+playerGetArrowQuiverAmt(p,arrowquiver_slot),4); |
||||
//If we added it here, we destroy the item stack.
|
||||
p.sendMessage(ChatColor.DARK_GRAY+""+ev.getItem().getItemStack().getAmount()+" arrow"+((ev.getItem().getItemStack().getAmount()==1)?"":"s")+" "+((ev.getItem().getItemStack().getAmount()==1)?"was":"were")+" added to your arrow quiver. Arrow Count: "+ChatColor.GRAY+playerGetArrowQuiverAmt(p,arrowquiver_slot)); |
||||
ev.getPlayer().playSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, 1.0f); |
||||
ev.getItem().remove(); |
||||
ev.setCancelled(true); |
||||
} |
||||
}*/ |
||||
|
||||
TwosideKeeper.HandlePickupAchievements(ev.getPlayer(), ev.getItem().getItemStack()); |
||||
TwosideKeeper.PickupLogger.AddEntry("Pickup Achievements", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
|
||||
boolean handled = TwosideKeeper.AutoEquipItem(ev.getItem().getItemStack(), p); |
||||
TwosideKeeper.PickupLogger.AddEntry("Auto Equip Item Check", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
if (handled) { |
||||
TwosideKeeper.PlayPickupParticle(ev.getPlayer(),ev.getItem()); |
||||
ev.getItem().remove(); |
||||
ev.setCancelled(handled); |
||||
return; |
||||
} |
||||
|
||||
/*if (AutoConsumeItem(p,ev.getItem().getItemStack())) { |
||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f); |
||||
PlayPickupParticle(ev.getPlayer(),ev.getItem()); |
||||
ev.getItem().remove(); |
||||
ev.setCancelled(true); |
||||
return; |
||||
}*/ |
||||
TwosideKeeper.PickupLogger.AddEntry("Auto Consume Item Check", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
|
||||
if (ev.getItem().hasMetadata("INFINITEARROW")) { //Not allowed to be picked up, this was an infinite arrow.
|
||||
TwosideKeeper.log("INFINITE PICKUP", 5); |
||||
ev.setCancelled(true); |
||||
return; |
||||
} |
||||
TwosideKeeper.PickupLogger.AddEntry("Infinite Arrow Check", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
|
||||
if (GenericFunctions.isValidArrow(ev.getItem().getItemStack()) && ArrowQuiver.getArrowQuiverInPlayerInventory(p)!=null) { |
||||
ev.setCancelled(true); |
||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(ev.getItem().getItemStack())); |
||||
TwosideKeeper.PlayPickupParticle(ev.getPlayer(),ev.getItem()); |
||||
ev.getItem().remove(); |
||||
TwosideKeeper.AddToPlayerInventory(ev.getItem().getItemStack(), p); |
||||
return; |
||||
} |
||||
TwosideKeeper.PickupLogger.AddEntry("Valid Arrow check", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
|
||||
/** |
||||
* MUST BE HANDLED AFTER EVERYTHING ELSE. |
||||
*/ |
||||
|
||||
//TwosideKeeper.log("(1)Item is "+ev.getItem().getItemStack(), 0);
|
||||
if (InventoryUtils.isCarryingFilterCube(p)) { |
||||
//Try to insert it into the Filter cube.
|
||||
//TwosideKeeper.log("(2)Item is "+ev.getItem().getItemStack(), 0);
|
||||
ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, ev.getItem().getItemStack()); |
||||
//TwosideKeeper.log("(3)Item is "+ev.getItem().getItemStack(), 0);
|
||||
if (remaining.length==0) { |
||||
ev.setCancelled(true); |
||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(ev.getItem().getItemStack())); |
||||
TwosideKeeper.PlayPickupParticle(ev.getPlayer(),ev.getItem()); |
||||
ev.getItem().remove(); |
||||
return; |
||||
} else { |
||||
ev.getItem().setItemStack(remaining[0]); |
||||
} |
||||
} |
||||
TwosideKeeper.PickupLogger.AddEntry("Filter Cube Check", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
|
||||
//TwosideKeeper.log("(1)Item is "+ev.getItem().getItemStack(), 0);
|
||||
if (ev.getItem().getItemStack().getType().isBlock() && InventoryUtils.isCarryingVacuumCube(p)) { |
||||
//Try to insert it into the Vacuum cube.
|
||||
ItemStack[] remaining = InventoryUtils.insertItemsInVacuumCube(p, ev.getItem().getItemStack()); |
||||
if (remaining.length==0) { |
||||
ev.setCancelled(true); |
||||
SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.6f, SoundUtils.DetermineItemPitch(ev.getItem().getItemStack())); |
||||
TwosideKeeper.PlayPickupParticle(ev.getPlayer(),ev.getItem()); |
||||
ev.getItem().remove(); |
||||
return; |
||||
} else { |
||||
ev.getItem().setItemStack(remaining[0]); |
||||
} |
||||
} |
||||
TwosideKeeper.PickupLogger.AddEntry("Vacuum Cube Check", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
|
||||
//ItemCubeUtils.pickupAndAddItemCubeToGraph(ev.getItem().getItemStack(), p);
|
||||
|
||||
ev.setCancelled(true); |
||||
ItemStack givenitem = ev.getItem().getItemStack().clone(); |
||||
GenericFunctions.giveItem(p, givenitem); |
||||
if (ev.getRemaining()>0) { |
||||
givenitem.setAmount(ev.getRemaining()); |
||||
GenericFunctions.giveItem(p, givenitem); |
||||
} |
||||
TwosideKeeper.PlayPickupParticle(ev.getPlayer(),ev.getItem()); |
||||
ev.getItem().remove(); |
||||
ItemSet.updateItemSets(ev.getPlayer()); |
||||
TwosideKeeper.PickupLogger.AddEntry("Update Item Sets", (int)(System.nanoTime()-time));time=System.nanoTime(); |
||||
return; |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,37 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.inventory.ItemStack; |
||||
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
|
||||
public enum ItemSlot { |
||||
MAINHAND, |
||||
OFFHAND; |
||||
|
||||
public ItemStack getItem(Player p) { |
||||
switch (this) { |
||||
case MAINHAND: |
||||
return p.getEquipment().getItemInMainHand(); |
||||
case OFFHAND: |
||||
return p.getEquipment().getItemInOffHand(); |
||||
default: |
||||
TwosideKeeper.log("WARNING! Could not find proper enum for this item slot! Slot: "+this, 0); |
||||
return p.getEquipment().getItemInMainHand(); |
||||
} |
||||
} |
||||
|
||||
public void setItem(Player p, ItemStack item) { |
||||
switch (this) { |
||||
case MAINHAND: |
||||
p.getEquipment().setItemInMainHand(item); |
||||
break; |
||||
case OFFHAND: |
||||
p.getEquipment().setItemInOffHand(item); |
||||
break; |
||||
default: |
||||
TwosideKeeper.log("WARNING! Could not find proper enum for this item slot! Slot: "+this, 0); |
||||
p.getEquipment().setItemInMainHand(item); |
||||
} |
||||
} |
||||
} |
@ -1,19 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Items; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Material; |
||||
import org.bukkit.inventory.ItemStack; |
||||
|
||||
public class Scepter { |
||||
ItemStack item; |
||||
|
||||
public Scepter(ItemStack item) { |
||||
|
||||
} |
||||
|
||||
public static boolean isScepter(ItemStack item) { |
||||
return item.getType()==Material.BONE && (item.hasItemMeta() && |
||||
item.getItemMeta().hasLore() && |
||||
item.getItemMeta().getLore().contains(ChatColor.LIGHT_PURPLE+"Summoner Gear")); |
||||
} |
||||
} |
@ -1,232 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Material; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.event.inventory.InventoryClickEvent; |
||||
import org.bukkit.inventory.Inventory; |
||||
import org.bukkit.inventory.InventoryHolder; |
||||
import org.bukkit.inventory.ItemFlag; |
||||
import org.bukkit.inventory.ItemStack; |
||||
import org.bukkit.material.MaterialData; |
||||
|
||||
import sig.plugin.TwosideKeeper.PlayerStructure; |
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; |
||||
|
||||
public class OptionsMenu { |
||||
Player p; |
||||
Inventory inv; |
||||
List<Option> options; |
||||
|
||||
final int NUMBER_OF_ROWS = (OptionName.values().length/3)+(((OptionName.values().length%3)!=0)?1:0); |
||||
|
||||
public OptionsMenu(Player p) { |
||||
this.p=p; |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
pd.optionsmenu=this; |
||||
inv = Bukkit.createInventory(p, NUMBER_OF_ROWS*9, ChatColor.BLUE+"Options Menu"); |
||||
this.options = new ArrayList<Option>(); |
||||
|
||||
PopulateInterface(p); |
||||
|
||||
//inv.setItem(arg0, arg1);
|
||||
|
||||
p.openInventory(inv); |
||||
} |
||||
|
||||
private void PopulateInterface(Player p) { |
||||
for (int i=0;i<OptionName.values().length;i++) { |
||||
Option o = new Option(OptionName.values()[i],i*3,(i*3)+1); |
||||
ItemStack it = o.getOption().getMaterialData().toItemStack(); |
||||
SetupDescriptions(o, it); |
||||
ItemStack it2 = new ItemStack(o.getTorchIcon(p)); |
||||
it2.setAmount(0); |
||||
SetupDescriptions(o, it2); |
||||
//TwosideKeeper.log(o+";;"+it+";;"+it2, 0);
|
||||
|
||||
inv.setItem(o.getPositions()[0], it); |
||||
inv.setItem(o.getPositions()[1], it2); |
||||
options.add(o); |
||||
} |
||||
} |
||||
|
||||
private void SetupDescriptions(Option o, ItemStack it) { |
||||
ItemUtils.setDisplayName(it, o.getOption().getTitle()); |
||||
ItemUtils.addLore(it, o.getOption().getDescription()); |
||||
ItemUtils.addFlag(it, ItemFlag.values()); |
||||
} |
||||
|
||||
public static boolean runOptionsMenuClick(InventoryClickEvent ev) { |
||||
InventoryHolder holder = ev.getInventory().getHolder(); |
||||
if (holder!=null && holder instanceof Player) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)holder); |
||||
if (pd.optionsmenu!=null) { |
||||
if (ev.getClickedInventory().equals(pd.optionsmenu.getInventory())) { |
||||
pd.optionsmenu.checkForClick(ev.getSlot()); |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
private void checkForClick(int slot) { |
||||
for (Option o : options) { |
||||
for (Integer i : o.getPositions()) { |
||||
if (i==slot) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
if (o.getOption().getTitle().equalsIgnoreCase("DPS Tracking") && pd.dpstrackinglocked) { |
||||
return; |
||||
} |
||||
boolean val = o.getOption().isOptionEnabled(p, true); |
||||
doExtraThings(o.getOption()); |
||||
p.sendMessage(o.getOption().getTitle()+" is now turned "+(val?ChatColor.GREEN+"ON":ChatColor.RED+"OFF")+ChatColor.RESET+"."); |
||||
PopulateInterface(p); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void doExtraThings(OptionName o) { |
||||
if (o==OptionName.DPS && !o.isOptionEnabled(p, false)) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
p.sendMessage(pd.damagedata.OutputResults()); |
||||
} |
||||
} |
||||
|
||||
private Inventory getInventory() { |
||||
return inv; |
||||
} |
||||
} |
||||
class Option{ |
||||
int iconpos; |
||||
int torchpos; |
||||
OptionName option; |
||||
|
||||
Option(OptionName option, int iconslot, int torchslot) { |
||||
this.option=option; |
||||
this.iconpos=iconslot; |
||||
this.torchpos=torchslot; |
||||
} |
||||
|
||||
OptionName getOption() { |
||||
return option; |
||||
} |
||||
int[] getPositions() { |
||||
return new int[]{iconpos,torchpos}; |
||||
} |
||||
Material getTorchIcon(Player p) { |
||||
return (getOption().isOptionEnabled(p,false)?Material.SLIME_BALL:Material.FIREBALL); |
||||
} |
||||
public String toString() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append("Option(option="); |
||||
sb.append(option); |
||||
sb.append(",iconpos="); |
||||
sb.append(iconpos); |
||||
sb.append(",torchpos="); |
||||
sb.append(torchpos); |
||||
sb.append(")"); |
||||
return sb.toString(); |
||||
} |
||||
} |
||||
|
||||
enum OptionName{ |
||||
DPSDISPLAY("Damage Number Display",ChatColor.GRAY+"Toggles the display of Damage Numbers on/off.",Material.SKULL_ITEM,(byte)0), |
||||
DPS("DPS Tracking",ChatColor.GRAY+"Toggles the tracking of damage stats on/off.\nTurning it off reports the last damage session breakdown.",Material.WRITTEN_BOOK,(byte)0), |
||||
HEALTHBARDISPLAY("Healthbar Display",ChatColor.GRAY+"Toggles the healthbar near the player's cursor\nwhen attacking or getting hit by mobs.",Material.BED,(byte)0), |
||||
AUTOEQUIPARMOR("Auto-Equip Armor",ChatColor.GRAY+"Toggles automatically equipping appropriate armor.",Material.LEATHER_CHESTPLATE,(byte)0), |
||||
AUTOEQUIPWEAPON("Auto-Equip Weapon",ChatColor.GRAY+"Toggles automatically equipping appropriate weapons.",Material.IRON_SWORD,(byte)0), |
||||
SOUNDS("Login/Logout Sounds",ChatColor.GRAY+"Toggles the playing of login/logout sound\nnotifications as well as message sound notifications.",Material.RECORD_7,(byte)0), |
||||
MOUSEOVERHEALTHBAR("Mouseover Healthbar",ChatColor.GRAY+"Toggles the display of a mob's healthbar without having to attack it.",Material.WATCH,(byte)0); |
||||
|
||||
String title; |
||||
String description; |
||||
MaterialData data; |
||||
|
||||
OptionName(String title, String desc, Material icon, byte data) { |
||||
this.data = new MaterialData(icon,data); |
||||
this.title=title; |
||||
this.description=desc; |
||||
} |
||||
|
||||
MaterialData getMaterialData() { |
||||
return data; |
||||
} |
||||
|
||||
boolean isOptionEnabled(Player p, boolean toggle) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
switch (this) { |
||||
case DPSDISPLAY:{ |
||||
if (toggle) { |
||||
pd.damagenumbers=!pd.damagenumbers; |
||||
} |
||||
return pd.damagenumbers; |
||||
} |
||||
case DPS:{ |
||||
if (toggle) { |
||||
pd.damagelogging=!pd.damagelogging; |
||||
} |
||||
return pd.damagelogging; |
||||
} |
||||
case AUTOEQUIPARMOR:{ |
||||
if (toggle) { |
||||
pd.equiparmor=!pd.equiparmor; |
||||
} |
||||
return pd.equiparmor; |
||||
} |
||||
case AUTOEQUIPWEAPON:{ |
||||
if (toggle) { |
||||
pd.equipweapons=!pd.equipweapons; |
||||
} |
||||
return pd.equipweapons; |
||||
} |
||||
case SOUNDS:{ |
||||
if (toggle) { |
||||
pd.sounds_enabled=!pd.sounds_enabled; |
||||
} |
||||
return pd.sounds_enabled; |
||||
} |
||||
case HEALTHBARDISPLAY:{ |
||||
if (toggle) { |
||||
pd.healthbardisplay=!pd.healthbardisplay; |
||||
} |
||||
return pd.healthbardisplay; |
||||
} |
||||
case MOUSEOVERHEALTHBAR:{ |
||||
if (toggle) { |
||||
pd.mouseoverhealthbar=!pd.mouseoverhealthbar; |
||||
} |
||||
return pd.mouseoverhealthbar; |
||||
} |
||||
} |
||||
TwosideKeeper.log("WARNING! Value for Option "+title+" does not exist!", 1); |
||||
return false; |
||||
} |
||||
|
||||
String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public String toString() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append("OptionName(title="); |
||||
sb.append(title); |
||||
sb.append(",description="); |
||||
sb.append(description); |
||||
sb.append(",data="); |
||||
sb.append(data); |
||||
sb.append(")"); |
||||
return sb.toString(); |
||||
} |
||||
} |
@ -1,246 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.bukkit.Location; |
||||
import org.bukkit.entity.EntityType; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.util.Vector; |
||||
|
||||
import sig.plugin.TwosideKeeper.CustomDamage; |
||||
import sig.plugin.TwosideKeeper.LivingEntityStructure; |
||||
import sig.plugin.TwosideKeeper.PlayerStructure; |
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.MovementUtils; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.PlayerUtils; |
||||
|
||||
public class Pet { |
||||
final static public int LEASHRANGE = 16; |
||||
final static public int LEASHRANGE_SQUARED = LEASHRANGE*LEASHRANGE; |
||||
Player owner; |
||||
Location targetLoc; |
||||
Location lastPos; |
||||
double moveSpd = 1; |
||||
double jumpHeight = 3.0; |
||||
int attackRate = 10; |
||||
long lastAttacked = 0; |
||||
LivingEntity ent; |
||||
String name=""; |
||||
int stuckTimer=0; |
||||
LivingEntity myTarget=null; |
||||
|
||||
PetState myState = PetState.PASSIVE; |
||||
double myDamage = 5; |
||||
|
||||
public Pet(Player owner, EntityType ent, String nickname) { |
||||
try { |
||||
this.ent = (LivingEntity)owner.getLocation().getWorld().spawnEntity(owner.getLocation(), ent); |
||||
this.owner = owner; |
||||
this.name = nickname; |
||||
this.setNickname(nickname); |
||||
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(this.ent); |
||||
les.isPet=true; |
||||
les.petOwner=owner; |
||||
} catch (ClassCastException e) { |
||||
TwosideKeeper.log("ERROR! Specified invalid Entity Type when creating Pet!", 0); |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
public void run() { |
||||
if (owner==null || !owner.isValid() || ent==null || !ent.isValid()) { |
||||
cleanup(); |
||||
return; |
||||
} |
||||
|
||||
grabEnemyTarget(); |
||||
|
||||
switch (myState) { |
||||
case PASSIVE:{ |
||||
if (myTarget!=null && !myTarget.isValid()) { |
||||
myTarget=null; |
||||
//TwosideKeeper.log("My Target is now "+GenericFunctions.GetEntityDisplayName(myTarget), 1);
|
||||
} else |
||||
if (myTarget!=null) { //This is a valid target. If we are too far away, move towards it. Perform an attack when close enough if possible.
|
||||
if (ent.getLocation().distanceSquared(myTarget.getLocation())>4) { |
||||
setTargetLocation(myTarget.getLocation()); |
||||
setState(PetState.MOVING); |
||||
} else { |
||||
//We are in attack range. Prepare an attack.
|
||||
if (lastAttacked+attackRate<=TwosideKeeper.getServerTickTime()) { |
||||
myState=PetState.ATTACKING; |
||||
lastAttacked=TwosideKeeper.getServerTickTime(); |
||||
} |
||||
} |
||||
} |
||||
if (owner.getLocation().distanceSquared(ent.getLocation())>LEASHRANGE_SQUARED) { |
||||
ent.teleport(owner.getLocation()); |
||||
} |
||||
}break; |
||||
case MOVING:{ |
||||
if (targetLoc!=null && ent.getLocation().distanceSquared(targetLoc)>2) { |
||||
Location loc = MoveTowardsPoint(targetLoc); |
||||
if (lastPos!=null) { |
||||
if (lastPos.distanceSquared(ent.getLocation())<4) { |
||||
stuckTimer++; |
||||
//TwosideKeeper.log("Stuck Timer: "+stuckTimer, 1);
|
||||
} else { |
||||
stuckTimer=0; |
||||
lastPos=null; |
||||
//setState(PetState.PASSIVE);
|
||||
} |
||||
} else { |
||||
lastPos = loc.clone(); |
||||
} |
||||
} |
||||
if (stuckTimer==20) { |
||||
//Try jumping.
|
||||
ent.setVelocity(new Vector(0,jumpHeight,0)); |
||||
stuckTimer++; |
||||
} else |
||||
if (stuckTimer==50) { |
||||
ent.teleport(owner); |
||||
stuckTimer=0; |
||||
lastPos=null; |
||||
targetLoc=null; |
||||
setState(PetState.PASSIVE); |
||||
} |
||||
if (targetLoc!=null && ent.getLocation().distanceSquared(targetLoc)<=2) { |
||||
targetLoc=null; |
||||
stuckTimer=0; |
||||
setState(PetState.PASSIVE); |
||||
} |
||||
if (targetLoc==null) { |
||||
stuckTimer=0; |
||||
setState(PetState.PASSIVE); |
||||
} |
||||
}break; |
||||
case ATTACKING:{ |
||||
if (myTarget!=null) { |
||||
MoveTowardsPoint(myTarget.getLocation(),0.4); |
||||
//Deal damage.
|
||||
CustomDamage.ApplyDamage(myDamage, ent, myTarget, null, "Pet Attack"); |
||||
} |
||||
setState(PetState.PASSIVE); |
||||
}break; |
||||
} |
||||
//TwosideKeeper.log("Pet State: "+myState, 1);
|
||||
} |
||||
|
||||
private Location MoveTowardsPoint(Location targetLoc) { |
||||
return MoveTowardsPoint(targetLoc,1); |
||||
} |
||||
|
||||
private Location MoveTowardsPoint(Location targetLoc, double mult) { |
||||
Vector dirToMove = MovementUtils.getVelocityTowardsLocation(ent.getLocation(), targetLoc, moveSpd*mult); |
||||
Location loc = ent.getLocation(); |
||||
loc.setDirection(dirToMove); |
||||
ent.setVelocity(dirToMove); |
||||
ent.teleport(loc); |
||||
return loc; |
||||
} |
||||
|
||||
public void setTarget(LivingEntity target) { |
||||
setTarget(target,false); |
||||
} |
||||
|
||||
public void setTarget(LivingEntity target, boolean force) { |
||||
if (myTarget==null || myTarget.getLocation().distanceSquared(ent.getLocation())>64 || force) { |
||||
myTarget = target; |
||||
} |
||||
} |
||||
|
||||
private void grabEnemyTarget() { |
||||
if (myTarget!=null){ |
||||
if (myTarget.isValid()) { |
||||
if (!myTarget.getWorld().equals(ent.getWorld())) { |
||||
myTarget=null; |
||||
return; |
||||
} |
||||
if (myTarget.getLocation().distanceSquared(ent.getLocation())>64) { |
||||
myTarget=null; |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
if (ent.hasAI() && isFighting()) { |
||||
ent.setAI(false); |
||||
if (myTarget==null || !myTarget.isValid()) { |
||||
//Attempt to find a target. Try the owner's target first.
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(owner); |
||||
myTarget = pd.target; |
||||
if (myTarget==null || !myTarget.isValid()) { |
||||
//Try to find a nearby target.
|
||||
List<LivingEntity> ents = GenericFunctions.getNearbyMonsters(ent.getLocation(), 4); |
||||
double closestrange = Integer.MAX_VALUE; |
||||
LivingEntity selectedent = null; |
||||
for (int i=0;i<ents.size();i++) { |
||||
LivingEntity ent = ents.get(i); |
||||
if (ent==this.ent || LivingEntityStructure.isFriendly(owner, ent)) { |
||||
ents.remove(i--); |
||||
} else { |
||||
double dist = ent.getLocation().distanceSquared(this.ent.getLocation()); |
||||
if (closestrange>dist) { |
||||
closestrange = dist; |
||||
selectedent = ent; |
||||
} |
||||
} |
||||
} |
||||
if (selectedent!=null) { |
||||
myTarget=selectedent; |
||||
} |
||||
} |
||||
} |
||||
} else |
||||
if (!ent.hasAI() && !isFighting()) { |
||||
ent.setAI(true); |
||||
} |
||||
} |
||||
|
||||
public PetState getState() { |
||||
return myState; |
||||
} |
||||
|
||||
public void setTargetLocation(Location loc) { |
||||
this.targetLoc=loc; |
||||
} |
||||
|
||||
public void setMoveSpeed(double spd) { |
||||
this.moveSpd = spd; |
||||
} |
||||
|
||||
public void setNickname(String nickname) { |
||||
this.name=nickname; |
||||
this.ent.setCustomName(nickname); |
||||
} |
||||
|
||||
public String getNickname() { |
||||
return name; |
||||
} |
||||
|
||||
public Location getTargetLocation() { |
||||
return targetLoc; |
||||
} |
||||
|
||||
public LivingEntity getEntity() { |
||||
return ent; |
||||
} |
||||
|
||||
public void cleanup() { |
||||
ent.remove(); |
||||
} |
||||
|
||||
public boolean isFighting() { |
||||
if (owner!=null && PlayerUtils.PlayerIsInCombat(owner)) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public void setState(PetState state) { |
||||
myState = state; |
||||
} |
||||
} |
@ -1,7 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
public enum PetState { |
||||
PASSIVE, |
||||
MOVING, |
||||
ATTACKING; |
||||
} |
@ -1,52 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes.MixedDamage; |
||||
|
||||
public class Spell { |
||||
String name; |
||||
int[] cast_time; |
||||
int[] cooldown_time; |
||||
MixedDamage[] damage; |
||||
long last_casted_spell; |
||||
|
||||
public Spell(String name, int[] cast_time, int[] cooldowns) { |
||||
this.name=name; |
||||
this.cast_time=cast_time; |
||||
this.cooldown_time=cooldowns; |
||||
this.damage=null; |
||||
this.last_casted_spell=TwosideKeeper.getServerTickTime(); |
||||
} |
||||
|
||||
public Spell(String name, int[] cast_time, int[] cooldowns, MixedDamage[] damage) { |
||||
this.name=name; |
||||
this.cast_time=cast_time; |
||||
this.cooldown_time=cooldowns; |
||||
this.damage=damage; |
||||
this.last_casted_spell=TwosideKeeper.getServerTickTime(); |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public int[] getCastTimes() { |
||||
return cast_time; |
||||
} |
||||
|
||||
public int[] getCooldowns() { |
||||
return cooldown_time; |
||||
} |
||||
|
||||
public MixedDamage[] getDamageValues() { |
||||
return damage; |
||||
} |
||||
|
||||
public long getLastCastedTime() { |
||||
return last_casted_spell; |
||||
} |
||||
|
||||
public void setLastCastedTime(long time) { |
||||
last_casted_spell = time; |
||||
} |
||||
} |
@ -1,43 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Utils; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Material; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.inventory.ItemStack; |
||||
import org.bukkit.inventory.meta.BookMeta; |
||||
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Book; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; |
||||
|
||||
public class BookUtils { |
||||
public static void GiveBookToPlayer(Player p,Book book) { |
||||
File file = book.getBookFile(); |
||||
if (file.exists()) { |
||||
ItemStack bookItem = new ItemStack(Material.WRITTEN_BOOK); |
||||
BookMeta meta = (BookMeta)bookItem.getItemMeta(); |
||||
String[] contents = FileUtils.readFromFile(book.getBookFilepath()); |
||||
List<String> bookContents = new ArrayList<String>(); |
||||
for (int i=0;i<contents.length;i++) { |
||||
bookContents.add(ChatColor.translateAlternateColorCodes('&', contents[i]).replace("\\n", "\n")); |
||||
} |
||||
//meta.setTitle(bookContents.remove(0));
|
||||
meta.setDisplayName(bookContents.remove(0)); |
||||
meta.setAuthor(bookContents.remove(0)); |
||||
meta.setPages(bookContents); |
||||
bookItem.setItemMeta(meta); |
||||
GenericFunctions.giveItem(p, bookItem); |
||||
} else { |
||||
try { |
||||
TwosideKeeper.log("WARNING! Book "+book.name()+" does not exist! Create a file in "+file.getCanonicalPath(), 1); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,23 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.bukkit.Location; |
||||
import org.bukkit.entity.Player; |
||||
|
||||
public enum ColoredParticle { |
||||
|
||||
MOB_SPELL("SPELL_MOB"), MOB_SPELL_AMBIENT("SPELL_MOB_AMBIENT"), RED_DUST("REDSTONE"); |
||||
|
||||
private ColoredParticle(String name) { |
||||
this.name = name; |
||||
} |
||||
String name; |
||||
public void send(Location location, List<Player> players, int r, int g, int b) { |
||||
ParticleEffect.valueOf(name).display(r/255f, g / 255f, b / 255f, 1, 0, location, players); |
||||
} |
||||
public void send(Location location, int Distance, int r, int g, int b) { |
||||
ParticleEffect.valueOf(name).display(r/255f, g / 255f, b / 255f, 1, 0, location, Distance); |
||||
} |
||||
|
||||
} |
@ -1,17 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileFilter; |
||||
|
||||
public class InstanceFilter implements FileFilter{ |
||||
|
||||
@Override |
||||
public boolean accept(File arg0) { |
||||
if (arg0.getName().contains("Instance")) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,48 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes; |
||||
|
||||
public class MixedDamage { |
||||
double dmgcomponent; |
||||
double truepctdmgcomponent; |
||||
double truedmgcomponent; |
||||
|
||||
public MixedDamage(double dmg) { |
||||
this.dmgcomponent=dmg; |
||||
this.truepctdmgcomponent=0; |
||||
this.truedmgcomponent=0; |
||||
} |
||||
public MixedDamage(double dmg,double truepctdmg) { |
||||
this.dmgcomponent=dmg; |
||||
this.truepctdmgcomponent=truepctdmg; |
||||
this.truedmgcomponent=0; |
||||
} |
||||
public MixedDamage(double dmg,double truepctdmg,double truedmg) { |
||||
this.dmgcomponent=dmg; |
||||
this.truepctdmgcomponent=truepctdmg; |
||||
this.truedmgcomponent=truedmg; |
||||
} |
||||
public static MixedDamage v(double dmg) { |
||||
return new MixedDamage(dmg); |
||||
} |
||||
public static MixedDamage v(double dmg,double truepctdmg) { |
||||
return new MixedDamage(dmg,truepctdmg); |
||||
} |
||||
public static MixedDamage v(double dmg,double truepctdmg,double truedmg) { |
||||
return new MixedDamage(dmg,truepctdmg,truedmg); |
||||
} |
||||
public double getDmgComponent() { |
||||
return dmgcomponent; |
||||
} |
||||
public double getTruePctDmgComponent() { |
||||
return truepctdmgcomponent; |
||||
} |
||||
public double getTrueDmgComponent() { |
||||
return truedmgcomponent; |
||||
} |
||||
|
||||
public boolean hasTruePctDmgComponent() { |
||||
return truepctdmgcomponent>0; |
||||
} |
||||
public boolean hasTrueDmgComponent() { |
||||
return truedmgcomponent>0; |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,605 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes; |
||||
import java.lang.reflect.Constructor; |
||||
import java.lang.reflect.Field; |
||||
import java.lang.reflect.InvocationTargetException; |
||||
import java.lang.reflect.Method; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
|
||||
/** |
||||
* <b>ReflectionUtils</b> |
||||
* <p> |
||||
* This class provides useful methods which makes dealing with reflection much easier, especially when working with Bukkit |
||||
* <p> |
||||
* You are welcome to use it, modify it and redistribute it under the following conditions: |
||||
* <ul> |
||||
* <li>Don't claim this class as your own |
||||
* <li>Don't remove this disclaimer |
||||
* </ul> |
||||
* <p> |
||||
* <i>It would be nice if you provide credit to me if you use this class in a published project</i> |
||||
* |
||||
* @author DarkBlade12 |
||||
* @version 1.1 |
||||
*/ |
||||
public final class ReflectionUtils { |
||||
// Prevent accidental construction
|
||||
private ReflectionUtils() {} |
||||
|
||||
/** |
||||
* Returns the constructor of a given class with the given parameter types |
||||
* |
||||
* @param clazz Target class
|
||||
* @param parameterTypes Parameter types of the desired constructor |
||||
* @return The constructor of the target class with the specified parameter types |
||||
* @throws NoSuchMethodException If the desired constructor with the specified parameter types cannot be found |
||||
* @see DataType |
||||
* @see DataType#getPrimitive(Class[]) |
||||
* @see DataType#compare(Class[], Class[]) |
||||
*/ |
||||
public static Constructor<?> getConstructor(Class<?> clazz, Class<?>... parameterTypes) throws NoSuchMethodException { |
||||
Class<?>[] primitiveTypes = DataType.getPrimitive(parameterTypes); |
||||
for (Constructor<?> constructor : clazz.getConstructors()) { |
||||
if (!DataType.compare(DataType.getPrimitive(constructor.getParameterTypes()), primitiveTypes)) { |
||||
continue; |
||||
} |
||||
return constructor; |
||||
} |
||||
throw new NoSuchMethodException("There is no such constructor in this class with the specified parameter types"); |
||||
} |
||||
|
||||
/** |
||||
* Returns the constructor of a desired class with the given parameter types |
||||
* |
||||
* @param className Name of the desired target class
|
||||
* @param packageType Package where the desired target class is located |
||||
* @param parameterTypes Parameter types of the desired constructor |
||||
* @return The constructor of the desired target class with the specified parameter types |
||||
* @throws NoSuchMethodException If the desired constructor with the specified parameter types cannot be found |
||||
* @throws ClassNotFoundException ClassNotFoundException If the desired target class with the specified name and package cannot be found |
||||
* @see #getClass(String, PackageType) |
||||
* @see #getConstructor(Class, Class...) |
||||
*/ |
||||
public static Constructor<?> getConstructor(String className, PackageType packageType, Class<?>... parameterTypes) throws NoSuchMethodException, ClassNotFoundException { |
||||
return getConstructor(packageType.getClass(className), parameterTypes); |
||||
} |
||||
|
||||
/** |
||||
* Returns an instance of a class with the given arguments |
||||
* |
||||
* @param clazz Target class
|
||||
* @param arguments Arguments which are used to construct an object of the target class
|
||||
* @return The instance of the target class with the specified arguments |
||||
* @throws InstantiationException If you cannot create an instance of the target class due to certain circumstances |
||||
* @throws IllegalAccessException If the desired constructor cannot be accessed due to certain circumstances |
||||
* @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the constructor (this should not occur since it searches for a constructor with the types of the arguments) |
||||
* @throws InvocationTargetException If the desired constructor cannot be invoked |
||||
* @throws NoSuchMethodException If the desired constructor with the specified arguments cannot be found |
||||
*/ |
||||
public static Object instantiateObject(Class<?> clazz, Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { |
||||
return getConstructor(clazz, DataType.getPrimitive(arguments)).newInstance(arguments); |
||||
} |
||||
|
||||
/** |
||||
* Returns an instance of a desired class with the given arguments |
||||
* |
||||
* @param className Name of the desired target class
|
||||
* @param packageType Package where the desired target class is located |
||||
* @param arguments Arguments which are used to construct an object of the desired target class
|
||||
* @return The instance of the desired target class with the specified arguments |
||||
* @throws InstantiationException If you cannot create an instance of the desired target class due to certain circumstances |
||||
* @throws IllegalAccessException If the desired constructor cannot be accessed due to certain circumstances |
||||
* @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the constructor (this should not occur since it searches for a constructor with the types of the arguments) |
||||
* @throws InvocationTargetException If the desired constructor cannot be invoked |
||||
* @throws NoSuchMethodException If the desired constructor with the specified arguments cannot be found |
||||
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found |
||||
* @see #getClass(String, PackageType) |
||||
* @see #instantiateObject(Class, Object...) |
||||
*/ |
||||
public static Object instantiateObject(String className, PackageType packageType, Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { |
||||
return instantiateObject(packageType.getClass(className), arguments); |
||||
} |
||||
|
||||
/** |
||||
* Returns a method of a class with the given parameter types |
||||
* |
||||
* @param clazz Target class
|
||||
* @param methodName Name of the desired method |
||||
* @param parameterTypes Parameter types of the desired method |
||||
* @return The method of the target class with the specified name and parameter types |
||||
* @throws NoSuchMethodException If the desired method of the target class with the specified name and parameter types cannot be found |
||||
* @see DataType#getPrimitive(Class[]) |
||||
* @see DataType#compare(Class[], Class[]) |
||||
*/ |
||||
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException { |
||||
Class<?>[] primitiveTypes = DataType.getPrimitive(parameterTypes); |
||||
for (Method method : clazz.getMethods()) { |
||||
if (!method.getName().equals(methodName) || !DataType.compare(DataType.getPrimitive(method.getParameterTypes()), primitiveTypes)) { |
||||
continue; |
||||
} |
||||
return method; |
||||
} |
||||
throw new NoSuchMethodException("There is no such method in this class with the specified name and parameter types"); |
||||
} |
||||
|
||||
/** |
||||
* Returns a method of a desired class with the given parameter types |
||||
* |
||||
* @param className Name of the desired target class
|
||||
* @param packageType Package where the desired target class is located |
||||
* @param methodName Name of the desired method |
||||
* @param parameterTypes Parameter types of the desired method |
||||
* @return The method of the desired target class with the specified name and parameter types |
||||
* @throws NoSuchMethodException If the desired method of the desired target class with the specified name and parameter types cannot be found |
||||
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found |
||||
* @see #getClass(String, PackageType) |
||||
* @see #getMethod(Class, String, Class...) |
||||
*/ |
||||
public static Method getMethod(String className, PackageType packageType, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException, ClassNotFoundException { |
||||
return getMethod(packageType.getClass(className), methodName, parameterTypes); |
||||
} |
||||
|
||||
/** |
||||
* Invokes a method on an object with the given arguments |
||||
* |
||||
* @param instance Target object |
||||
* @param methodName Name of the desired method |
||||
* @param arguments Arguments which are used to invoke the desired method |
||||
* @return The result of invoking the desired method on the target object |
||||
* @throws IllegalAccessException If the desired method cannot be accessed due to certain circumstances |
||||
* @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the method (this should not occur since it searches for a method with the types of the arguments) |
||||
* @throws InvocationTargetException If the desired method cannot be invoked on the target object |
||||
* @throws NoSuchMethodException If the desired method of the class of the target object with the specified name and arguments cannot be found |
||||
* @see #getMethod(Class, String, Class...) |
||||
* @see DataType#getPrimitive(Object[]) |
||||
*/ |
||||
public static Object invokeMethod(Object instance, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { |
||||
return getMethod(instance.getClass(), methodName, DataType.getPrimitive(arguments)).invoke(instance, arguments); |
||||
} |
||||
|
||||
/** |
||||
* Invokes a method of the target class on an object with the given arguments |
||||
* |
||||
* @param instance Target object |
||||
* @param clazz Target class
|
||||
* @param methodName Name of the desired method |
||||
* @param arguments Arguments which are used to invoke the desired method |
||||
* @return The result of invoking the desired method on the target object |
||||
* @throws IllegalAccessException If the desired method cannot be accessed due to certain circumstances |
||||
* @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the method (this should not occur since it searches for a method with the types of the arguments) |
||||
* @throws InvocationTargetException If the desired method cannot be invoked on the target object |
||||
* @throws NoSuchMethodException If the desired method of the target class with the specified name and arguments cannot be found |
||||
* @see #getMethod(Class, String, Class...) |
||||
* @see DataType#getPrimitive(Object[]) |
||||
*/ |
||||
public static Object invokeMethod(Object instance, Class<?> clazz, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { |
||||
return getMethod(clazz, methodName, DataType.getPrimitive(arguments)).invoke(instance, arguments); |
||||
} |
||||
|
||||
/** |
||||
* Invokes a method of a desired class on an object with the given arguments |
||||
* |
||||
* @param instance Target object |
||||
* @param className Name of the desired target class
|
||||
* @param packageType Package where the desired target class is located |
||||
* @param methodName Name of the desired method |
||||
* @param arguments Arguments which are used to invoke the desired method |
||||
* @return The result of invoking the desired method on the target object |
||||
* @throws IllegalAccessException If the desired method cannot be accessed due to certain circumstances |
||||
* @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the method (this should not occur since it searches for a method with the types of the arguments) |
||||
* @throws InvocationTargetException If the desired method cannot be invoked on the target object |
||||
* @throws NoSuchMethodException If the desired method of the desired target class with the specified name and arguments cannot be found |
||||
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found |
||||
* @see #getClass(String, PackageType) |
||||
* @see #invokeMethod(Object, Class, String, Object...) |
||||
*/ |
||||
public static Object invokeMethod(Object instance, String className, PackageType packageType, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { |
||||
return invokeMethod(instance, packageType.getClass(className), methodName, arguments); |
||||
} |
||||
|
||||
/** |
||||
* Returns a field of the target class with the given name |
||||
* |
||||
* @param clazz Target class
|
||||
* @param declared Whether the desired field is declared or not |
||||
* @param fieldName Name of the desired field |
||||
* @return The field of the target class with the specified name |
||||
* @throws NoSuchFieldException If the desired field of the given class cannot be found |
||||
* @throws SecurityException If the desired field cannot be made accessible |
||||
*/ |
||||
public static Field getField(Class<?> clazz, boolean declared, String fieldName) throws NoSuchFieldException, SecurityException { |
||||
Field field = declared ? clazz.getDeclaredField(fieldName) : clazz.getField(fieldName); |
||||
field.setAccessible(true); |
||||
return field; |
||||
} |
||||
|
||||
/** |
||||
* Returns a field of a desired class with the given name |
||||
* |
||||
* @param className Name of the desired target class
|
||||
* @param packageType Package where the desired target class is located |
||||
* @param declared Whether the desired field is declared or not |
||||
* @param fieldName Name of the desired field |
||||
* @return The field of the desired target class with the specified name |
||||
* @throws NoSuchFieldException If the desired field of the desired class cannot be found |
||||
* @throws SecurityException If the desired field cannot be made accessible |
||||
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found |
||||
* @see #getField(Class, boolean, String) |
||||
*/ |
||||
public static Field getField(String className, PackageType packageType, boolean declared, String fieldName) throws NoSuchFieldException, SecurityException, ClassNotFoundException { |
||||
return getField(packageType.getClass(className), declared, fieldName); |
||||
} |
||||
|
||||
/** |
||||
* Returns the value of a field of the given class of an object |
||||
* |
||||
* @param instance Target object |
||||
* @param clazz Target class
|
||||
* @param declared Whether the desired field is declared or not |
||||
* @param fieldName Name of the desired field |
||||
* @return The value of field of the target object |
||||
* @throws IllegalArgumentException If the target object does not feature the desired field |
||||
* @throws IllegalAccessException If the desired field cannot be accessed |
||||
* @throws NoSuchFieldException If the desired field of the target class cannot be found |
||||
* @throws SecurityException If the desired field cannot be made accessible |
||||
* @see #getField(Class, boolean, String) |
||||
*/ |
||||
public static Object getValue(Object instance, Class<?> clazz, boolean declared, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { |
||||
return getField(clazz, declared, fieldName).get(instance); |
||||
} |
||||
|
||||
/** |
||||
* Returns the value of a field of a desired class of an object |
||||
* |
||||
* @param instance Target object |
||||
* @param className Name of the desired target class
|
||||
* @param packageType Package where the desired target class is located |
||||
* @param declared Whether the desired field is declared or not |
||||
* @param fieldName Name of the desired field |
||||
* @return The value of field of the target object |
||||
* @throws IllegalArgumentException If the target object does not feature the desired field |
||||
* @throws IllegalAccessException If the desired field cannot be accessed |
||||
* @throws NoSuchFieldException If the desired field of the desired class cannot be found |
||||
* @throws SecurityException If the desired field cannot be made accessible |
||||
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found |
||||
* @see #getValue(Object, Class, boolean, String) |
||||
*/ |
||||
public static Object getValue(Object instance, String className, PackageType packageType, boolean declared, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, ClassNotFoundException { |
||||
return getValue(instance, packageType.getClass(className), declared, fieldName); |
||||
} |
||||
|
||||
/** |
||||
* Returns the value of a field with the given name of an object |
||||
* |
||||
* @param instance Target object |
||||
* @param declared Whether the desired field is declared or not |
||||
* @param fieldName Name of the desired field |
||||
* @return The value of field of the target object |
||||
* @throws IllegalArgumentException If the target object does not feature the desired field (should not occur since it searches for a field with the given name in the class of the object) |
||||
* @throws IllegalAccessException If the desired field cannot be accessed |
||||
* @throws NoSuchFieldException If the desired field of the target object cannot be found |
||||
* @throws SecurityException If the desired field cannot be made accessible |
||||
* @see #getValue(Object, Class, boolean, String) |
||||
*/ |
||||
public static Object getValue(Object instance, boolean declared, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { |
||||
return getValue(instance, instance.getClass(), declared, fieldName); |
||||
} |
||||
|
||||
/** |
||||
* Sets the value of a field of the given class of an object |
||||
* |
||||
* @param instance Target object |
||||
* @param clazz Target class
|
||||
* @param declared Whether the desired field is declared or not |
||||
* @param fieldName Name of the desired field |
||||
* @param value New value |
||||
* @throws IllegalArgumentException If the type of the value does not match the type of the desired field |
||||
* @throws IllegalAccessException If the desired field cannot be accessed |
||||
* @throws NoSuchFieldException If the desired field of the target class cannot be found |
||||
* @throws SecurityException If the desired field cannot be made accessible |
||||
* @see #getField(Class, boolean, String) |
||||
*/ |
||||
public static void setValue(Object instance, Class<?> clazz, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { |
||||
getField(clazz, declared, fieldName).set(instance, value); |
||||
} |
||||
|
||||
/** |
||||
* Sets the value of a field of a desired class of an object |
||||
* |
||||
* @param instance Target object |
||||
* @param className Name of the desired target class
|
||||
* @param packageType Package where the desired target class is located |
||||
* @param declared Whether the desired field is declared or not |
||||
* @param fieldName Name of the desired field |
||||
* @param value New value |
||||
* @throws IllegalArgumentException If the type of the value does not match the type of the desired field |
||||
* @throws IllegalAccessException If the desired field cannot be accessed |
||||
* @throws NoSuchFieldException If the desired field of the desired class cannot be found |
||||
* @throws SecurityException If the desired field cannot be made accessible |
||||
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found |
||||
* @see #setValue(Object, Class, boolean, String, Object) |
||||
*/ |
||||
public static void setValue(Object instance, String className, PackageType packageType, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, ClassNotFoundException { |
||||
setValue(instance, packageType.getClass(className), declared, fieldName, value); |
||||
} |
||||
|
||||
/** |
||||
* Sets the value of a field with the given name of an object |
||||
* |
||||
* @param instance Target object |
||||
* @param declared Whether the desired field is declared or not |
||||
* @param fieldName Name of the desired field |
||||
* @param value New value |
||||
* @throws IllegalArgumentException If the type of the value does not match the type of the desired field |
||||
* @throws IllegalAccessException If the desired field cannot be accessed |
||||
* @throws NoSuchFieldException If the desired field of the target object cannot be found |
||||
* @throws SecurityException If the desired field cannot be made accessible |
||||
* @see #setValue(Object, Class, boolean, String, Object) |
||||
*/ |
||||
public static void setValue(Object instance, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { |
||||
setValue(instance, instance.getClass(), declared, fieldName, value); |
||||
} |
||||
|
||||
/** |
||||
* Represents an enumeration of dynamic packages of NMS and CraftBukkit |
||||
* <p> |
||||
* This class is part of the <b>ReflectionUtils</b> and follows the same usage conditions |
||||
* |
||||
* @author DarkBlade12 |
||||
* @since 1.0 |
||||
*/ |
||||
public enum PackageType { |
||||
MINECRAFT_SERVER("net.minecraft.server." + getServerVersion()), |
||||
CRAFTBUKKIT("org.bukkit.craftbukkit." + getServerVersion()), |
||||
CRAFTBUKKIT_BLOCK(CRAFTBUKKIT, "block"), |
||||
CRAFTBUKKIT_CHUNKIO(CRAFTBUKKIT, "chunkio"), |
||||
CRAFTBUKKIT_COMMAND(CRAFTBUKKIT, "command"), |
||||
CRAFTBUKKIT_CONVERSATIONS(CRAFTBUKKIT, "conversations"), |
||||
CRAFTBUKKIT_ENCHANTMENS(CRAFTBUKKIT, "enchantments"), |
||||
CRAFTBUKKIT_ENTITY(CRAFTBUKKIT, "entity"), |
||||
CRAFTBUKKIT_EVENT(CRAFTBUKKIT, "event"), |
||||
CRAFTBUKKIT_GENERATOR(CRAFTBUKKIT, "generator"), |
||||
CRAFTBUKKIT_HELP(CRAFTBUKKIT, "help"), |
||||
CRAFTBUKKIT_INVENTORY(CRAFTBUKKIT, "inventory"), |
||||
CRAFTBUKKIT_MAP(CRAFTBUKKIT, "map"), |
||||
CRAFTBUKKIT_METADATA(CRAFTBUKKIT, "metadata"), |
||||
CRAFTBUKKIT_POTION(CRAFTBUKKIT, "potion"), |
||||
CRAFTBUKKIT_PROJECTILES(CRAFTBUKKIT, "projectiles"), |
||||
CRAFTBUKKIT_SCHEDULER(CRAFTBUKKIT, "scheduler"), |
||||
CRAFTBUKKIT_SCOREBOARD(CRAFTBUKKIT, "scoreboard"), |
||||
CRAFTBUKKIT_UPDATER(CRAFTBUKKIT, "updater"), |
||||
CRAFTBUKKIT_UTIL(CRAFTBUKKIT, "util"); |
||||
|
||||
private final String path; |
||||
|
||||
/** |
||||
* Construct a new package type |
||||
* |
||||
* @param path Path of the package
|
||||
*/ |
||||
private PackageType(String path) { |
||||
this.path = path; |
||||
} |
||||
|
||||
/** |
||||
* Construct a new package type |
||||
* |
||||
* @param parent Parent package of the package
|
||||
* @param path Path of the package
|
||||
*/ |
||||
private PackageType(PackageType parent, String path) { |
||||
this(parent + "." + path); |
||||
} |
||||
|
||||
/** |
||||
* Returns the path of this package type |
||||
* |
||||
* @return The path |
||||
*/ |
||||
public String getPath() { |
||||
return path; |
||||
} |
||||
|
||||
/** |
||||
* Returns the class with the given name |
||||
* |
||||
* @param className Name of the desired class
|
||||
* @return The class with the specified name |
||||
* @throws ClassNotFoundException If the desired class with the specified name and package cannot be found |
||||
*/ |
||||
public Class<?> getClass(String className) throws ClassNotFoundException { |
||||
return Class.forName(this + "." + className); |
||||
} |
||||
|
||||
// Override for convenience
|
||||
@Override |
||||
public String toString() { |
||||
return path; |
||||
} |
||||
|
||||
/** |
||||
* Returns the version of your server |
||||
* |
||||
* @return The server version |
||||
*/ |
||||
public static String getServerVersion() { |
||||
return Bukkit.getServer().getClass().getPackage().getName().substring(23); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Represents an enumeration of Java data types with corresponding classes |
||||
* <p> |
||||
* This class is part of the <b>ReflectionUtils</b> and follows the same usage conditions |
||||
* |
||||
* @author DarkBlade12 |
||||
* @since 1.0 |
||||
*/ |
||||
public enum DataType { |
||||
BYTE(byte.class, Byte.class), |
||||
SHORT(short.class, Short.class), |
||||
INTEGER(int.class, Integer.class), |
||||
LONG(long.class, Long.class), |
||||
CHARACTER(char.class, Character.class), |
||||
FLOAT(float.class, Float.class), |
||||
DOUBLE(double.class, Double.class), |
||||
BOOLEAN(boolean.class, Boolean.class); |
||||
|
||||
private static final Map<Class<?>, DataType> CLASS_MAP = new HashMap<Class<?>, DataType>(); |
||||
private final Class<?> primitive; |
||||
private final Class<?> reference; |
||||
|
||||
// Initialize map for quick class lookup
|
||||
static { |
||||
for (DataType type : values()) { |
||||
CLASS_MAP.put(type.primitive, type); |
||||
CLASS_MAP.put(type.reference, type); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Construct a new data type |
||||
* |
||||
* @param primitive Primitive class of this data type |
||||
* @param reference Reference class of this data type |
||||
*/ |
||||
private DataType(Class<?> primitive, Class<?> reference) { |
||||
this.primitive = primitive; |
||||
this.reference = reference; |
||||
} |
||||
|
||||
/** |
||||
* Returns the primitive class of this data type |
||||
* |
||||
* @return The primitive class
|
||||
*/ |
||||
public Class<?> getPrimitive() { |
||||
return primitive; |
||||
} |
||||
|
||||
/** |
||||
* Returns the reference class of this data type |
||||
* |
||||
* @return The reference class
|
||||
*/ |
||||
public Class<?> getReference() { |
||||
return reference; |
||||
} |
||||
|
||||
/** |
||||
* Returns the data type with the given primitive/reference class
|
||||
* |
||||
* @param clazz Primitive/Reference class of the data type |
||||
* @return The data type |
||||
*/ |
||||
public static DataType fromClass(Class<?> clazz) { |
||||
return CLASS_MAP.get(clazz); |
||||
} |
||||
|
||||
/** |
||||
* Returns the primitive class of the data type with the given reference class
|
||||
* |
||||
* @param clazz Reference class of the data type |
||||
* @return The primitive class
|
||||
*/ |
||||
public static Class<?> getPrimitive(Class<?> clazz) { |
||||
DataType type = fromClass(clazz); |
||||
return type == null ? clazz : type.getPrimitive(); |
||||
} |
||||
|
||||
/** |
||||
* Returns the reference class of the data type with the given primitive class
|
||||
* |
||||
* @param clazz Primitive class of the data type |
||||
* @return The reference class
|
||||
*/ |
||||
public static Class<?> getReference(Class<?> clazz) { |
||||
DataType type = fromClass(clazz); |
||||
return type == null ? clazz : type.getReference(); |
||||
} |
||||
|
||||
/** |
||||
* Returns the primitive class array of the given class array |
||||
* |
||||
* @param classes Given class array |
||||
* @return The primitive class array |
||||
*/ |
||||
public static Class<?>[] getPrimitive(Class<?>[] classes) { |
||||
int length = classes == null ? 0 : classes.length; |
||||
Class<?>[] types = new Class<?>[length]; |
||||
for (int index = 0; index < length; index++) { |
||||
types[index] = getPrimitive(classes[index]); |
||||
} |
||||
return types; |
||||
} |
||||
|
||||
/** |
||||
* Returns the reference class array of the given class array |
||||
* |
||||
* @param classes Given class array |
||||
* @return The reference class array |
||||
*/ |
||||
public static Class<?>[] getReference(Class<?>[] classes) { |
||||
int length = classes == null ? 0 : classes.length; |
||||
Class<?>[] types = new Class<?>[length]; |
||||
for (int index = 0; index < length; index++) { |
||||
types[index] = getReference(classes[index]); |
||||
} |
||||
return types; |
||||
} |
||||
|
||||
/** |
||||
* Returns the primitive class array of the given object array |
||||
* |
||||
* @param object Given object array |
||||
* @return The primitive class array |
||||
*/ |
||||
public static Class<?>[] getPrimitive(Object[] objects) { |
||||
int length = objects == null ? 0 : objects.length; |
||||
Class<?>[] types = new Class<?>[length]; |
||||
for (int index = 0; index < length; index++) { |
||||
types[index] = getPrimitive(objects[index].getClass()); |
||||
} |
||||
return types; |
||||
} |
||||
|
||||
/** |
||||
* Returns the reference class array of the given object array |
||||
* |
||||
* @param object Given object array |
||||
* @return The reference class array |
||||
*/ |
||||
public static Class<?>[] getReference(Object[] objects) { |
||||
int length = objects == null ? 0 : objects.length; |
||||
Class<?>[] types = new Class<?>[length]; |
||||
for (int index = 0; index < length; index++) { |
||||
types[index] = getReference(objects[index].getClass()); |
||||
} |
||||
return types; |
||||
} |
||||
|
||||
/** |
||||
* Compares two class arrays on equivalence |
||||
* |
||||
* @param primary Primary class array |
||||
* @param secondary Class array which is compared to the primary array |
||||
* @return Whether these arrays are equal or not |
||||
*/ |
||||
public static boolean compare(Class<?>[] primary, Class<?>[] secondary) { |
||||
if (primary == null || secondary == null || primary.length != secondary.length) { |
||||
return false; |
||||
} |
||||
for (int index = 0; index < primary.length; index++) { |
||||
Class<?> primaryClass = primary[index]; |
||||
Class<?> secondaryClass = secondary[index]; |
||||
if (primaryClass.equals(secondaryClass) || primaryClass.isAssignableFrom(secondaryClass)) { |
||||
continue; |
||||
} |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
} |
@ -1,9 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Utils; |
||||
|
||||
import org.bukkit.util.EulerAngle; |
||||
|
||||
public class MathUtils { |
||||
public static EulerAngle getEulerAngleDegrees(double degX,double degY,double degZ) { |
||||
return new EulerAngle(Math.toRadians(degX),Math.toRadians(degY),Math.toRadians(degZ)); |
||||
} |
||||
} |
@ -1,31 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.inventory.EquipmentSlot; |
||||
import org.bukkit.inventory.ItemStack; |
||||
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
|
||||
public class VerifyItemWasMovedTask implements Runnable{ |
||||
ItemStack checkitem; |
||||
ItemSlot slot; |
||||
Player p; |
||||
|
||||
public VerifyItemWasMovedTask(ItemStack checkitem, Player p, ItemSlot slot) { |
||||
this.checkitem=checkitem.clone(); |
||||
this.p=p; |
||||
this.slot=slot; |
||||
} |
||||
|
||||
@Override |
||||
public void run() { |
||||
if (!slot.getItem(p).isSimilar(checkitem)) { |
||||
TwosideKeeper.log("WARNING! Item "+checkitem+" was not inserted in slot "+slot.name()+" properly! Item in slot atm: "+slot.getItem(p)+". Trying again in 1 tick!", 1); |
||||
//This is bad. Try again on the next tick. Set the item.
|
||||
slot.setItem(p, checkitem); |
||||
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, this, 1); |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,39 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Modes; |
||||
|
||||
import org.bukkit.Location; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.event.Event; |
||||
import org.bukkit.event.block.Action; |
||||
import org.bukkit.event.player.PlayerInteractEntityEvent; |
||||
import org.bukkit.event.player.PlayerInteractEvent; |
||||
|
||||
import sig.plugin.TwosideKeeper.PlayerStructure; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.PetState; |
||||
|
||||
public class Summoner { |
||||
/** |
||||
* |
||||
* @return False means stop the action from passing onto other sections of code. |
||||
*/ |
||||
public static boolean HandleSummonerInteraction(Event e) { |
||||
if (e instanceof PlayerInteractEvent) { |
||||
PlayerInteractEvent ev = (PlayerInteractEvent)e; |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(ev.getPlayer()); |
||||
if (ev.getAction()==Action.RIGHT_CLICK_BLOCK && pd.myPet!=null && pd.myPet.getState()==PetState.PASSIVE) { |
||||
PetMoveCommand(ev.getClickedBlock().getLocation(),ev.getPlayer()); |
||||
} |
||||
} else |
||||
if (e instanceof PlayerInteractEntityEvent) { |
||||
PlayerInteractEntityEvent ev = (PlayerInteractEntityEvent)e; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
private static void PetMoveCommand(Location targetLoc, Player p) { |
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); |
||||
if (pd.myPet!=null) { |
||||
pd.myPet.setTargetLocation(targetLoc); |
||||
pd.myPet.setState(PetState.MOVING); |
||||
} |
||||
} |
||||
} |
@ -1,49 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Monster; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Color; |
||||
import org.bukkit.Material; |
||||
import org.bukkit.attribute.Attribute; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.inventivetalent.glow.GlowAPI; |
||||
|
||||
import sig.plugin.TwosideKeeper.CustomMonster; |
||||
import sig.plugin.TwosideKeeper.LivingEntityStructure; |
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Effects.EffectPool; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Effects.TemporaryBlock; |
||||
|
||||
public class Bloodmite extends CustomMonster{ |
||||
|
||||
long lastBloodPool=TwosideKeeper.getServerTickTime(); |
||||
SniperSkeleton main; |
||||
|
||||
public Bloodmite(LivingEntity m) { |
||||
super(m); |
||||
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(m); |
||||
les.setCustomLivingEntityName(m, ChatColor.RED+"Bloodmite"); |
||||
m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.12f); |
||||
} |
||||
|
||||
public void setMainEntity(SniperSkeleton ss) { |
||||
main = ss; |
||||
} |
||||
|
||||
public GlowAPI.Color getGlowColor() { |
||||
return GlowAPI.Color.WHITE; |
||||
} |
||||
|
||||
public void runTick() { |
||||
if (lastBloodPool+90<=TwosideKeeper.getServerTickTime()) { |
||||
TemporaryBlock.createTemporaryBlockCircle(m.getLocation(), 1, Material.WOOL, (byte)14, 20*30, "BLOODPOOL"); |
||||
new EffectPool(m.getLocation(),1,20*30,Color.fromRGB(255, 0, 0)); |
||||
lastBloodPool=TwosideKeeper.getServerTickTime(); |
||||
} |
||||
} |
||||
|
||||
public void cleanup() { |
||||
if (main!=null) { |
||||
main.bloodmites.remove(m); |
||||
} |
||||
} |
||||
} |
@ -1,28 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Monster; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Zombie; |
||||
|
||||
import sig.plugin.TwosideKeeper.CustomMonster; |
||||
import sig.plugin.TwosideKeeper.LivingEntityStructure; |
||||
import sig.plugin.TwosideKeeper.MonsterController; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty; |
||||
|
||||
public class ChallengeBlaze extends Blaze{ |
||||
|
||||
public ChallengeBlaze(LivingEntity m) { |
||||
super(m); |
||||
} |
||||
|
||||
|
||||
public static boolean isChallengeBlaze(LivingEntity m) { |
||||
if (m instanceof org.bukkit.entity.Blaze && |
||||
LivingEntityStructure.getCustomLivingEntityName(m).equalsIgnoreCase(ChatColor.RED+"Challenge Blaze") && |
||||
m.getMaxHealth()==25000000 && |
||||
MonsterController.getLivingEntityDifficulty(m)==LivingEntityDifficulty.NORMAL) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -1,27 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Monster; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.entity.Ghast; |
||||
import org.bukkit.entity.LivingEntity; |
||||
|
||||
import sig.plugin.TwosideKeeper.CustomMonster; |
||||
import sig.plugin.TwosideKeeper.LivingEntityStructure; |
||||
import sig.plugin.TwosideKeeper.MonsterController; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty; |
||||
|
||||
public class ChallengeGhast extends HellfireGhast{ |
||||
|
||||
public ChallengeGhast(LivingEntity m) { |
||||
super(m); |
||||
} |
||||
|
||||
public static boolean isChallengeGhast(LivingEntity m) { |
||||
if (m instanceof org.bukkit.entity.Ghast && |
||||
LivingEntityStructure.getCustomLivingEntityName(m).equalsIgnoreCase(ChatColor.RED+"Challenge Ghast") && |
||||
m.getMaxHealth()==25000000 && |
||||
MonsterController.getLivingEntityDifficulty(m)==LivingEntityDifficulty.NORMAL) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -1,27 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Monster; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.entity.LivingEntity; |
||||
|
||||
import sig.plugin.TwosideKeeper.CustomMonster; |
||||
import sig.plugin.TwosideKeeper.LivingEntityStructure; |
||||
import sig.plugin.TwosideKeeper.MonsterController; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty; |
||||
|
||||
public class ChallengeSpider extends HellfireSpider{ |
||||
|
||||
public ChallengeSpider(LivingEntity m) { |
||||
super(m); |
||||
} |
||||
|
||||
public static boolean isChallengeSpider(LivingEntity m) { |
||||
if (m instanceof org.bukkit.entity.Spider && |
||||
LivingEntityStructure.getCustomLivingEntityName(m).equalsIgnoreCase(ChatColor.RED+"Challenge Spider") && |
||||
m.getMaxHealth()==25000000 && |
||||
MonsterController.getLivingEntityDifficulty(m)==LivingEntityDifficulty.NORMAL) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -1,32 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Monster; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Zombie; |
||||
|
||||
import sig.plugin.TwosideKeeper.CustomMonster; |
||||
import sig.plugin.TwosideKeeper.LivingEntityStructure; |
||||
import sig.plugin.TwosideKeeper.MonsterController; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes.MixedDamage; |
||||
|
||||
public class ChallengeZombie extends CustomMonster{ |
||||
|
||||
public ChallengeZombie(LivingEntity m) { |
||||
super(m); |
||||
} |
||||
|
||||
public MixedDamage getBasicAttackDamage() { |
||||
return MixedDamage.v(50,0.01,1); |
||||
} |
||||
|
||||
public static boolean isChallengeZombie(LivingEntity m) { |
||||
if (m instanceof Zombie && |
||||
LivingEntityStructure.getCustomLivingEntityName(m).equalsIgnoreCase(ChatColor.RED+"Challenge Zombie") && |
||||
m.getMaxHealth()==25000000 && |
||||
MonsterController.getLivingEntityDifficulty(m)==LivingEntityDifficulty.NORMAL) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -1,232 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Monster; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Color; |
||||
import org.bukkit.Particle; |
||||
import org.bukkit.Sound; |
||||
import org.bukkit.entity.CaveSpider; |
||||
import org.bukkit.entity.EntityType; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.entity.Spider; |
||||
import org.bukkit.potion.PotionEffectType; |
||||
import org.inventivetalent.glow.GlowAPI; |
||||
|
||||
import sig.plugin.TwosideKeeper.Buff; |
||||
import sig.plugin.TwosideKeeper.CustomDamage; |
||||
import sig.plugin.TwosideKeeper.CustomMonster; |
||||
import sig.plugin.TwosideKeeper.LivingEntityStructure; |
||||
import sig.plugin.TwosideKeeper.MonsterController; |
||||
import sig.plugin.TwosideKeeper.TwosideKeeper; |
||||
import sig.plugin.TwosideKeeper.Events.EntityChannelCastEvent; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Channel; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Spell; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes.MixedDamage; |
||||
|
||||
public class DarkSpider extends CustomMonster{ |
||||
|
||||
Knight linked_knight; |
||||
|
||||
final static int[] SILENCE_DURATIONS = new int[]{200,100,60}; |
||||
final static int[] MINION_HEALTH = new int[]{900,3000,18000}; |
||||
List<LivingEntity> temp_spiders = new ArrayList<LivingEntity>(); |
||||
final Spell SPIDERSUMMON = new Spell("Summon Spider",new int[]{100,60,40},new int[]{600,500,400}); |
||||
final Spell ULTRABURST = new Spell("UltraBurst",new int[]{80,80,80},new int[]{1200,900,800}, new MixedDamage[]{MixedDamage.v(200),MixedDamage.v(1000),MixedDamage.v(50,0.95)}); |
||||
MixedDamage[] BASIC_ATTACK_DAMAGE = new MixedDamage[]{MixedDamage.v(20),MixedDamage.v(40),MixedDamage.v(40, 0.01)}; |
||||
|
||||
int randomness = 16; |
||||
|
||||
public DarkSpider(LivingEntity m) { |
||||
super(m); |
||||
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(m); |
||||
MonsterController.convertLivingEntity(m, LivingEntityDifficulty.NORMAL); |
||||
les.setCustomLivingEntityName(m, ChatColor.DARK_RED+"Dark Spider"); |
||||
m.setMaxHealth(100000); |
||||
m.setHealth(m.getMaxHealth()); |
||||
m.setAI(true); |
||||
} |
||||
|
||||
public void runTick() { |
||||
if (canCastSpells()) { //SPELL CASTS HERE.
|
||||
castSpiderSummon(); |
||||
} |
||||
removeIfCannotFindMaster(); |
||||
} |
||||
|
||||
private void removeIfCannotFindMaster() { |
||||
if (linked_knight==null) { |
||||
for (LivingEntity l : temp_spiders) { |
||||
l.remove(); |
||||
} |
||||
m.remove(); |
||||
} |
||||
} |
||||
|
||||
private void castSpiderSummon() { |
||||
CastSpell(SPIDERSUMMON); |
||||
} |
||||
|
||||
public void runChannelCastEvent(EntityChannelCastEvent ev) { |
||||
switch (ev.getAbilityName()) { |
||||
case "Summon Spider":{ |
||||
//Create another Spider.
|
||||
DarkSpiderMinion dsm = InitializeDarkSpiderMinion(linked_knight); |
||||
dsm.linked_knight = linked_knight; |
||||
SPIDERSUMMON.setLastCastedTime(TwosideKeeper.getServerTickTime()); |
||||
}break; |
||||
case "UltraBurst":{ |
||||
playUltraBurst(); |
||||
ULTRABURST.setLastCastedTime(TwosideKeeper.getServerTickTime()); |
||||
}break; |
||||
} |
||||
} |
||||
|
||||
private void playUltraBurst() { |
||||
SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_TNT_PRIMED, 1.0f, 1.0f); |
||||
for (int i=0;i<3;i++) { |
||||
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, ()->{ |
||||
SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_TNT_PRIMED, 1.0f, 1.2f);}, (i+1)*10); |
||||
} |
||||
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, ()->{ |
||||
aPlugin.API.sendSoundlessExplosion(m.getLocation(), 6); |
||||
m.getWorld().spawnParticle(Particle.LAVA, m.getLocation(), 30); |
||||
m.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, m.getLocation(), 2); |
||||
SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 0.7f); |
||||
|
||||
DealSpellDamageToNearbyPlayers(ULTRABURST,50,true,false,3); |
||||
m.remove(); |
||||
}, 40); |
||||
} |
||||
|
||||
private void DealSpellDamageToNearbyPlayers(Spell spell, int range, boolean knockup, boolean dodgeable, double knockupamt) { |
||||
List<Player> players = GenericFunctions.DealDamageToNearbyPlayers(m.getLocation(), spell.getDamageValues()[getDifficultySlot()].getDmgComponent(), range, knockup, dodgeable, knockupamt, m, spell.getName(), false); |
||||
if (spell.getDamageValues()[getDifficultySlot()].hasTruePctDmgComponent()) {GenericFunctions.DealDamageToNearbyPlayers(m.getLocation(), spell.getDamageValues()[getDifficultySlot()].getTruePctDmgComponent(), range, knockup, dodgeable, knockupamt, m, spell.getName(), false,true);} |
||||
if (spell.getDamageValues()[getDifficultySlot()].hasTrueDmgComponent()) {GenericFunctions.DealDamageToNearbyPlayers(m.getLocation(), spell.getDamageValues()[getDifficultySlot()].getTrueDmgComponent(), range, knockup, dodgeable, knockupamt, m, spell.getName(), true);} |
||||
for (Player p : players) { |
||||
GenericFunctions.addStackingPotionEffect(p, PotionEffectType.CONFUSION, 20*6, 1); |
||||
} |
||||
} |
||||
|
||||
private DarkSpiderMinion InitializeDarkSpiderMinion(Knight knight) { |
||||
LivingEntity knight_ent = knight.GetMonster(); |
||||
CaveSpider s = (CaveSpider)knight_ent.getWorld().spawnEntity(m.getLocation(), EntityType.CAVE_SPIDER); |
||||
DarkSpiderMinion dsm = new DarkSpiderMinion(s); |
||||
TwosideKeeper.custommonsters.put(s.getUniqueId(), dsm); |
||||
s.setMaxHealth(MINION_HEALTH[getDifficultySlot()]); |
||||
s.setHealth(s.getMaxHealth()); |
||||
temp_spiders.add(s); |
||||
return dsm; |
||||
} |
||||
|
||||
public MixedDamage getBasicAttackDamage() { |
||||
return BASIC_ATTACK_DAMAGE[getDifficultySlot()]; |
||||
} |
||||
|
||||
protected void CastSpell(Spell spell) { |
||||
if (hasValidKnight() && |
||||
cooldownIsAvailable(spell.getLastCastedTime(),spell)) { |
||||
Channel.createNewChannel(m, spell.getName(), spell.getCastTimes()[getDifficultySlot()]); |
||||
} |
||||
} |
||||
|
||||
private boolean cooldownIsAvailable(long spell_timer, Spell spell) { |
||||
return spell_timer+spell.getCooldowns()[getDifficultySlot()]<=TwosideKeeper.getServerTickTime(); |
||||
} |
||||
|
||||
public static double getDamageReduction() { |
||||
return 1.0; |
||||
} |
||||
|
||||
public static Spider InitializeDarkSpider(LivingEntity sourceKnight) { |
||||
Spider s = (Spider)sourceKnight.getWorld().spawnEntity(sourceKnight.getLocation(), EntityType.SPIDER); |
||||
DarkSpider ds = new DarkSpider(s); |
||||
TwosideKeeper.custommonsters.put(s.getUniqueId(), ds); |
||||
return s; |
||||
} |
||||
|
||||
public static boolean isDarkSpider(LivingEntity m) { |
||||
return (m instanceof Spider && !(m instanceof CaveSpider)) && |
||||
m.getMaxHealth()==100000 && |
||||
MonsterController.getLivingEntityDifficulty(m)==LivingEntityDifficulty.NORMAL; |
||||
} |
||||
|
||||
public LivingEntityDifficulty getDifficulty() { |
||||
if (hasValidKnight()) { |
||||
return MonsterController.getLivingEntityDifficulty(linked_knight.GetMonster()); |
||||
} else { |
||||
return LivingEntityDifficulty.T1_MINIBOSS; |
||||
} |
||||
} |
||||
|
||||
private boolean hasValidKnight() { |
||||
return linked_knight!=null && linked_knight.GetMonster()!=null && linked_knight.GetMonster().isValid(); |
||||
} |
||||
|
||||
public int getDifficultySlot() { |
||||
switch (getDifficulty()) { |
||||
case T1_MINIBOSS:{ |
||||
return 0; |
||||
} |
||||
case T2_MINIBOSS:{ |
||||
return 1; |
||||
} |
||||
case T3_MINIBOSS:{ |
||||
return 2; |
||||
} |
||||
default:{ |
||||
TwosideKeeper.log("WARNING! Could not get proper difficulty slot for Difficulty "+getDifficulty()+". Defaulting to slot 0.", 1); |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public boolean canCastSpells() { |
||||
return Math.random()<=1/16d && !Buff.hasBuff(m, "SILENCE") && hasValidKnight() && linked_knight.startedfight && !Channel.isChanneling(m); |
||||
} |
||||
|
||||
public void onHitEvent(LivingEntity damager, double damage) { |
||||
Buff.addBuff( |
||||
m, "SILENCE", new Buff( |
||||
"Silence",SILENCE_DURATIONS[getDifficultySlot()], |
||||
0,Color.BLUE,ChatColor.WHITE+"…",false)); |
||||
if (Channel.isChanneling(m)) { |
||||
Channel.stopChanneling(m); |
||||
} |
||||
if (hasValidKnight() && |
||||
(damager instanceof Player)) { |
||||
linked_knight.addParticipant((Player)damager); |
||||
} |
||||
} |
||||
|
||||
public void cleanup() { |
||||
for (LivingEntity l : temp_spiders) { |
||||
if (l!=null && l.isValid()) { |
||||
if (TwosideKeeper.custommonsters.containsKey(l.getUniqueId())) { |
||||
CustomMonster cm = TwosideKeeper.custommonsters.get(l.getUniqueId()); |
||||
cm.cleanup(); |
||||
} |
||||
l.remove(); |
||||
} |
||||
} |
||||
m.remove(); |
||||
} |
||||
|
||||
public GlowAPI.Color getGlowColor() { |
||||
if (Channel.isChanneling(m)) { |
||||
return GlowAPI.Color.YELLOW; |
||||
} else { |
||||
if (GenericFunctions.isSuppressed(m)) { |
||||
return GlowAPI.Color.BLACK; |
||||
} else { |
||||
return GlowAPI.Color.NONE; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,44 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Monster; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.attribute.Attribute; |
||||
import org.bukkit.entity.CaveSpider; |
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.bukkit.entity.Spider; |
||||
|
||||
import sig.plugin.TwosideKeeper.CustomMonster; |
||||
import sig.plugin.TwosideKeeper.LivingEntityStructure; |
||||
import sig.plugin.TwosideKeeper.MonsterController; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Spell; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes.MixedDamage; |
||||
|
||||
public class DarkSpiderMinion extends DarkSpider{ |
||||
MixedDamage[] BASIC_ATTACK_DAMAGE = new MixedDamage[]{MixedDamage.v(40),MixedDamage.v(80),MixedDamage.v(80, 0.02)}; |
||||
|
||||
public DarkSpiderMinion(LivingEntity m) { |
||||
super(m); |
||||
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(m); |
||||
les.setCustomLivingEntityName(m, ChatColor.DARK_PURPLE+"Dark Spider Minion"); |
||||
m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.5f); |
||||
} |
||||
|
||||
public void runTick() { |
||||
super.runTick(); |
||||
if (canCastSpells()) { |
||||
CastSpell(ULTRABURST); |
||||
} |
||||
} |
||||
|
||||
public MixedDamage getBasicAttackDamage() { |
||||
return BASIC_ATTACK_DAMAGE[getDifficultySlot()]; |
||||
} |
||||
|
||||
public static boolean isDarkSpiderMinion(LivingEntity m) { |
||||
return (m instanceof CaveSpider) && |
||||
(m.getMaxHealth()==MINION_HEALTH[0] || |
||||
m.getMaxHealth()==MINION_HEALTH[1] || |
||||
m.getMaxHealth()==MINION_HEALTH[2]) && |
||||
MonsterController.getLivingEntityDifficulty(m)==LivingEntityDifficulty.NORMAL; |
||||
} |
||||
} |
@ -1,17 +0,0 @@ |
||||
package sig.plugin.TwosideKeeper.Monster; |
||||
|
||||
import org.bukkit.entity.LivingEntity; |
||||
import org.inventivetalent.glow.GlowAPI; |
||||
|
||||
import sig.plugin.TwosideKeeper.CustomMonster; |
||||
|
||||
public class ExplosiveMite extends CustomMonster{ |
||||
|
||||
public ExplosiveMite(LivingEntity m) { |
||||
super(m); |
||||
} |
||||
|
||||
public GlowAPI.Color getGlowColor() { |
||||
return GlowAPI.Color.RED; |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue