mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-08-16 16:37:07 +00:00
Merge remote-tracking branch 'refs/remotes/ProjectKorra/master'
This commit is contained in:
commit
3a544c6537
Binary file not shown.
|
@ -86,7 +86,7 @@ public class BendingPlayer {
|
|||
}
|
||||
|
||||
PLAYERS.put(uuid, this);
|
||||
PKListener.login(this);
|
||||
GeneralMethods.loadBendingPlayer(this);
|
||||
}
|
||||
|
||||
public void addCooldown(Ability ability, long cooldown) {
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.projectkorra.projectkorra.airbending.AirSwipe;
|
|||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthPassive;
|
||||
import com.projectkorra.projectkorra.event.BendingPlayerCreationEvent;
|
||||
import com.projectkorra.projectkorra.event.BendingReloadEvent;
|
||||
import com.projectkorra.projectkorra.event.BindChangeEvent;
|
||||
import com.projectkorra.projectkorra.firebending.Combustion;
|
||||
|
@ -1245,7 +1246,7 @@ public class GeneralMethods {
|
|||
|
||||
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(loc, true, null);
|
||||
|
||||
if (reason != null && claim.siegeData != null) {
|
||||
if (reason != null && claim != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1274,6 +1275,58 @@ public class GeneralMethods {
|
|||
public static boolean isWeapon(Material mat) {
|
||||
return mat != null && (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE || mat == Material.WOOD_SPADE || mat == Material.WOOD_SWORD || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE || mat == Material.STONE_SPADE || mat == Material.STONE_SWORD || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE || mat == Material.IRON_SWORD || mat == Material.IRON_SPADE || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SPADE);
|
||||
}
|
||||
|
||||
public static void loadBendingPlayer(BendingPlayer pl) {
|
||||
Player player = Bukkit.getPlayer(pl.getUUID());
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
|
||||
if (bPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PKListener.getToggledOut().contains(player.getUniqueId())) {
|
||||
bPlayer.toggleBending();
|
||||
player.sendMessage(ChatColor.YELLOW + "Reminder, you toggled your bending before signing off. Enable it again with /bending toggle.");
|
||||
}
|
||||
|
||||
Preset.loadPresets(player);
|
||||
Element element = null;
|
||||
String prefix = "";
|
||||
|
||||
boolean chatEnabled = ConfigManager.languageConfig.get().getBoolean("Chat.Enable");
|
||||
if (bPlayer.getElements().size() > 1) {
|
||||
prefix = Element.AVATAR.getPrefix();
|
||||
} else if (bPlayer.getElements().size() == 1){
|
||||
element = bPlayer.getElements().get(0);
|
||||
prefix = element.getPrefix();
|
||||
} else {
|
||||
prefix = ChatColor.WHITE + "[Nonbender] ";
|
||||
}
|
||||
|
||||
if (chatEnabled) {
|
||||
player.setDisplayName(player.getName());
|
||||
player.setDisplayName(prefix + ChatColor.RESET + player.getDisplayName());
|
||||
}
|
||||
|
||||
// Handle the AirSpout/WaterSpout login glitches
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
HashMap<Integer, String> bound = bPlayer.getAbilities();
|
||||
for (String str : bound.values()) {
|
||||
if (str.equalsIgnoreCase("AirSpout") || str.equalsIgnoreCase("WaterSpout") || str.equalsIgnoreCase("SandSpout")) {
|
||||
final Player fplayer = player;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fplayer.setFlying(false);
|
||||
fplayer.setAllowFlight(false);
|
||||
}
|
||||
}.runTaskLater(ProjectKorra.plugin, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Bukkit.getServer().getPluginManager().callEvent(new BendingPlayerCreationEvent(bPlayer));
|
||||
}
|
||||
|
||||
public static void reloadPlugin(CommandSender sender) {
|
||||
ProjectKorra.log.info("Reloading ProjectKorra and configuration");
|
||||
|
|
|
@ -97,7 +97,6 @@ import com.projectkorra.projectkorra.waterbending.WaterPassive;
|
|||
import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterSpoutWave;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
|
@ -172,73 +171,6 @@ public class PKListener implements Listener {
|
|||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static void login(BendingPlayer pl) {
|
||||
ProjectKorra plugin = ProjectKorra.plugin;
|
||||
Player player = Bukkit.getPlayer(pl.getUUID());
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
|
||||
if (bPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (TOGGLED_OUT.contains(player.getUniqueId())) {
|
||||
bPlayer.toggleBending();
|
||||
player.sendMessage(ChatColor.YELLOW + "Reminder, you toggled your bending before signing off. Enable it again with /bending toggle.");
|
||||
}
|
||||
|
||||
Preset.loadPresets(player);
|
||||
String append = "";
|
||||
ChatColor color = null;
|
||||
boolean chatEnabled = ProjectKorra.plugin.getConfig().getBoolean("Properties.Chat.Enable");
|
||||
if (bPlayer.getElements().size() > 1 && chatEnabled) {
|
||||
append = plugin.getConfig().getString("Properties.Chat.Prefixes.Avatar");
|
||||
color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Avatar"));
|
||||
} else if (bPlayer.hasElement(Element.AIR) && chatEnabled) {
|
||||
append = plugin.getConfig().getString("Properties.Chat.Prefixes.Air");
|
||||
color = Element.AIR.getColor();
|
||||
} else if (bPlayer.hasElement(Element.WATER) && chatEnabled) {
|
||||
append = plugin.getConfig().getString("Properties.Chat.Prefixes.Water");
|
||||
color = Element.WATER.getColor();
|
||||
} else if (bPlayer.hasElement(Element.EARTH) && chatEnabled) {
|
||||
append = plugin.getConfig().getString("Properties.Chat.Prefixes.Earth");
|
||||
color = Element.EARTH.getColor();
|
||||
} else if (bPlayer.hasElement(Element.FIRE) && chatEnabled) {
|
||||
append = plugin.getConfig().getString("Properties.Chat.Prefixes.Fire");
|
||||
color = Element.FIRE.getColor();
|
||||
} else if (bPlayer.hasElement(Element.CHI) && chatEnabled) {
|
||||
append = plugin.getConfig().getString("Properties.Chat.Prefixes.Chi");
|
||||
color = Element.CHI.getColor();
|
||||
} else {
|
||||
append = "[Nonbender]";
|
||||
color = ChatColor.WHITE;
|
||||
}
|
||||
|
||||
if (chatEnabled) {
|
||||
player.setDisplayName(player.getName());
|
||||
if(color != null) {
|
||||
player.setDisplayName(color + append + ChatColor.RESET + player.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the AirSpout/WaterSpout login glitches
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
HashMap<Integer, String> bound = bPlayer.getAbilities();
|
||||
for (String str : bound.values()) {
|
||||
if (str.equalsIgnoreCase("AirSpout") || str.equalsIgnoreCase("WaterSpout") || str.equalsIgnoreCase("SandSpout")) {
|
||||
final Player fplayer = player;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fplayer.setFlying(false);
|
||||
fplayer.setAllowFlight(false);
|
||||
}
|
||||
}.runTaskLater(ProjectKorra.plugin, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
|
|
|
@ -202,12 +202,13 @@ public abstract class WaterAbility extends ElementalAbility {
|
|||
continue;
|
||||
} else if (isWaterbendable(player, null, block) && (!isPlant(block) || plantbending)) {
|
||||
if (TempBlock.isTempBlock(block)) {
|
||||
TempBlock tb = TempBlock.get(block);
|
||||
continue;
|
||||
/*TempBlock tb = TempBlock.get(block);
|
||||
byte full = 0x0;
|
||||
if (tb.getState().getRawData() != full
|
||||
&& (tb.getState().getType() != Material.WATER || tb.getState().getType() != Material.STATIONARY_WATER)) {
|
||||
continue;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
@ -228,11 +229,7 @@ public abstract class WaterAbility extends ElementalAbility {
|
|||
|
||||
public static boolean isIcebendable(Player player, Material material, boolean onlyIce) {
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
if(onlyIce) {
|
||||
return bPlayer == null ? null : isIce(material) && bPlayer.canIcebend() && isIce(material);
|
||||
} else {
|
||||
return bPlayer == null ? null : isIce(material) && bPlayer.canIcebend();
|
||||
}
|
||||
return bPlayer == null ? null : isIce(material) && bPlayer.canIcebend() && (!onlyIce || material == Material.ICE);
|
||||
}
|
||||
|
||||
public static boolean isPlantbendable(Player player, Material material, boolean onlyLeaves) {
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.projectkorra.projectkorra.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
/**
|
||||
* Called when a new BendingPlayer is created
|
||||
*/
|
||||
|
||||
public class BendingPlayerCreationEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private BendingPlayer bPlayer;
|
||||
|
||||
public BendingPlayerCreationEvent(BendingPlayer bPlayer) {
|
||||
this.bPlayer = bPlayer;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BendingPlayer created
|
||||
*/
|
||||
public BendingPlayer getBendingPlayer() {
|
||||
return bPlayer;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ import org.bukkit.block.Block;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class HeatControlExtinguish extends FireAbility {
|
||||
|
||||
|
@ -20,6 +21,7 @@ public class HeatControlExtinguish extends FireAbility {
|
|||
private long cooldown;
|
||||
private Location location;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public HeatControlExtinguish(Player player) {
|
||||
super(player);
|
||||
|
||||
|
@ -33,7 +35,11 @@ public class HeatControlExtinguish extends FireAbility {
|
|||
|
||||
this.range = getDayFactor(this.range);
|
||||
this.radius = getDayFactor(this.radius);
|
||||
if (isMeltable(player.getTargetBlock((HashSet<Material>) null, (int) range))) {
|
||||
Set<Material> blocks = new HashSet<Material>();
|
||||
for (Integer mat : GeneralMethods.NON_OPAQUE) {
|
||||
blocks.add(Material.getMaterial(mat));
|
||||
}
|
||||
if (isMeltable(player.getTargetBlock(blocks, (int) range))) {
|
||||
new HeatControlMelt(player);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.bukkit.block.Block;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
@ -41,7 +42,6 @@ public class IceSpikeBlast extends IceAbility {
|
|||
private Location firstDestination;
|
||||
private Location destination;
|
||||
private TempBlock source;
|
||||
private TempBlock originalSource;
|
||||
|
||||
public IceSpikeBlast(Player player) {
|
||||
super(player);
|
||||
|
@ -203,7 +203,8 @@ public class IceSpikeBlast extends IceAbility {
|
|||
sourceBlock = block;
|
||||
source = new TempBlock(sourceBlock, Material.ICE, data);
|
||||
} else if (prepared) {
|
||||
playFocusWaterEffect(sourceBlock);
|
||||
if (sourceBlock != null)
|
||||
playFocusWaterEffect(sourceBlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,11 +222,10 @@ public class IceSpikeBlast extends IceAbility {
|
|||
}
|
||||
progressing = false;
|
||||
}
|
||||
originalSource.revertBlock();
|
||||
}
|
||||
|
||||
private void returnWater() {
|
||||
new WaterReturn(player, sourceBlock);
|
||||
new WaterReturn(player, location.getBlock());
|
||||
}
|
||||
|
||||
private void throwIce() {
|
||||
|
@ -257,12 +257,12 @@ public class IceSpikeBlast extends IceAbility {
|
|||
settingUp = true;
|
||||
prepared = false;
|
||||
|
||||
if (isPlant(sourceBlock)) {
|
||||
/*if (isPlant(sourceBlock)) {
|
||||
new PlantRegrowth(player, sourceBlock);
|
||||
sourceBlock.setType(Material.AIR);
|
||||
}
|
||||
|
||||
originalSource = new TempBlock(sourceBlock, Material.AIR, data);
|
||||
originalSource = new TempBlock(sourceBlock, Material.AIR, data);*/
|
||||
}
|
||||
|
||||
public static void activate(Player player) {
|
||||
|
@ -382,16 +382,19 @@ public class IceSpikeBlast extends IceAbility {
|
|||
return;
|
||||
}
|
||||
|
||||
MaterialData data = block.getState().getData();
|
||||
block.setType(Material.WATER);
|
||||
block.setData((byte) 0x0);
|
||||
block.setData((byte)0);
|
||||
IceSpikeBlast iceSpike = new IceSpikeBlast(player);
|
||||
iceSpike.throwIce();
|
||||
iceSpike.sourceBlock = null;
|
||||
|
||||
if (iceSpike.progressing) {
|
||||
WaterReturn.emptyWaterBottle(player);
|
||||
} else {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
block.setType(data.getItemType());
|
||||
block.setData(data.getData());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.bukkit.util.Vector;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class IceSpikePillar extends IceAbility {
|
||||
|
@ -46,6 +47,7 @@ public class IceSpikePillar extends IceAbility {
|
|||
private Vector direction;
|
||||
private ConcurrentHashMap<Block, Block> affectedBlocks;
|
||||
private ArrayList<LivingEntity> damaged;
|
||||
protected boolean inField = false;
|
||||
|
||||
public IceSpikePillar(Player player) {
|
||||
super(player);
|
||||
|
@ -107,7 +109,7 @@ public class IceSpikePillar extends IceAbility {
|
|||
|
||||
loadAffectedBlocks();
|
||||
|
||||
if (block.getType() == Material.ICE) {
|
||||
if (isIcebendable(block)) {
|
||||
if (canInstantiate()) {
|
||||
start();
|
||||
time = System.currentTimeMillis() - interval;
|
||||
|
@ -161,7 +163,7 @@ public class IceSpikePillar extends IceAbility {
|
|||
}
|
||||
|
||||
private boolean canInstantiate() {
|
||||
if (block.getType() != Material.ICE) {
|
||||
if (!isIcebendable(block.getType())) {
|
||||
return false;
|
||||
}
|
||||
for (Block block : affectedBlocks.keySet()) {
|
||||
|
@ -179,7 +181,7 @@ public class IceSpikePillar extends IceAbility {
|
|||
if (System.currentTimeMillis() - time >= interval) {
|
||||
time = System.currentTimeMillis();
|
||||
if (progress < height) {
|
||||
moveEarth();
|
||||
risePillar();
|
||||
removeTimestamp = System.currentTimeMillis();
|
||||
} else {
|
||||
if (removeTimestamp != 0 && removeTimestamp + removeTimer <= System.currentTimeMillis()) {
|
||||
|
@ -193,7 +195,7 @@ public class IceSpikePillar extends IceAbility {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean moveEarth() {
|
||||
private boolean risePillar() {
|
||||
progress++;
|
||||
Block affectedBlock = location.clone().add(direction).getBlock();
|
||||
location = location.add(direction);
|
||||
|
@ -210,7 +212,9 @@ public class IceSpikePillar extends IceAbility {
|
|||
}
|
||||
|
||||
affectedBlock.setType(Material.ICE);
|
||||
playIcebendingSound(block.getLocation());
|
||||
if (!inField || new Random().nextInt((int) ((height + 1) * 1.5)) == 0) {
|
||||
playIcebendingSound(block.getLocation());
|
||||
}
|
||||
loadAffectedBlocks();
|
||||
|
||||
if (location.distanceSquared(origin) >= height * height) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.waterbending;
|
|||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.IceAbility;
|
||||
import com.projectkorra.projectkorra.ability.WaterAbility;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -46,15 +47,15 @@ public class IceSpikePillarField extends IceAbility {
|
|||
for (int x = (int) -(radius - 1); x <= (radius - 1); x++) {
|
||||
for (int z = (int) -(radius - 1); z <= (radius - 1); z++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
Block testBlock = player.getWorld().getBlockAt(locX + x, locY + y, locZ + z);
|
||||
Block testBlock = player.getWorld().getBlockAt(locX + x, locY + y, locZ + z);
|
||||
|
||||
if (testBlock.getType() == Material.ICE
|
||||
if (WaterAbility.isIcebendable(player, testBlock.getType(), false)
|
||||
&& testBlock.getRelative(BlockFace.UP).getType() == Material.AIR
|
||||
&& !(testBlock.getX() == player.getEyeLocation().getBlock().getX()
|
||||
&& testBlock.getZ() == player.getEyeLocation().getBlock().getZ())) {
|
||||
iceBlocks.add(testBlock);
|
||||
for(Block iceBlockForSound : iceBlocks) {
|
||||
playIcebendingSound(iceBlockForSound.getLocation());
|
||||
for (int i = 0; i < iceBlocks.size() / 2 + 1; i++) {
|
||||
playIcebendingSound(iceBlocks.get(i).getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +91,8 @@ public class IceSpikePillarField extends IceAbility {
|
|||
}
|
||||
|
||||
if (targetBlock.getRelative(BlockFace.UP).getType() != Material.ICE) {
|
||||
new IceSpikePillar(player, targetBlock.getLocation(), (int) damage, thrownForce, cooldown);
|
||||
IceSpikePillar pillar = new IceSpikePillar(player, targetBlock.getLocation(), (int) damage, thrownForce, cooldown);
|
||||
pillar.inField = true;
|
||||
bPlayer.addCooldown("IceSpikePillarField", cooldown);
|
||||
iceBlocks.remove(targetBlock);
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ public class OctopusForm extends WaterAbility {
|
|||
if (oldOctopus.formed) {
|
||||
oldOctopus.attack();
|
||||
return;
|
||||
} else if (!oldOctopus.sourceSelected) {
|
||||
return;
|
||||
} else if (oldOctopus.sourceSelected) {
|
||||
oldOctopus.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,6 @@ public class OctopusForm extends WaterAbility {
|
|||
sourceLocation = sourceBlock.getLocation();
|
||||
sourceSelected = true;
|
||||
start();
|
||||
bPlayer.addCooldown(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,6 +99,7 @@ public class OctopusForm extends WaterAbility {
|
|||
if (sourceSelected) {
|
||||
sourceSelected = false;
|
||||
settingUp = true;
|
||||
bPlayer.addCooldown(this);
|
||||
} else if (settingUp) {
|
||||
settingUp = false;
|
||||
forming = true;
|
||||
|
|
Loading…
Reference in a new issue