-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* custom effects authored-by: goosius1 <=>
- Loading branch information
Showing
12 changed files
with
441 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/com/gmail/goosius/siegewar/events/ArtefactConsumeItemEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.gmail.goosius.siegewar.events; | ||
|
||
import com.gmail.goosius.siegewar.utils.SiegeWarDominationAwardsUtil; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class ArtefactConsumeItemEvent extends Event { | ||
|
||
private static final HandlerList handlers = new HandlerList(); | ||
private final Player consumer; | ||
private final ItemStack artefact; | ||
private final List<String> customEffects; | ||
|
||
public ArtefactConsumeItemEvent(Player consumer, ItemStack artefact) { | ||
super(!Bukkit.getServer().isPrimaryThread()); | ||
this.consumer = consumer; | ||
this.artefact = artefact; | ||
this.customEffects = SiegeWarDominationAwardsUtil.getCustomEffects(artefact); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public Player getConsumer() { | ||
return consumer; | ||
} | ||
|
||
public ItemStack getArtefact() { | ||
return artefact; | ||
} | ||
|
||
public List<String> getCustomEffects() { | ||
return customEffects; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/com/gmail/goosius/siegewar/events/ArtefactDamageEntityEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.gmail.goosius.siegewar.events; | ||
|
||
import com.gmail.goosius.siegewar.utils.SiegeWarDominationAwardsUtil; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class ArtefactDamageEntityEvent extends Event { | ||
|
||
private static final HandlerList handlers = new HandlerList(); | ||
private final Entity attacker; | ||
private final Entity victim; | ||
private final Object artefact; //Will either be Projectile or ItemStack | ||
private final List<String> customEffects; | ||
|
||
public ArtefactDamageEntityEvent(Entity attacker, Entity victim, Object artefact) { | ||
super(!Bukkit.getServer().isPrimaryThread()); | ||
this.attacker = attacker; | ||
this.victim = victim; | ||
this.artefact = artefact; | ||
this.customEffects = SiegeWarDominationAwardsUtil.getCustomEffects(artefact); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public Entity getAttacker() { | ||
return attacker; | ||
} | ||
|
||
public Entity getVictim() { | ||
return victim; | ||
} | ||
|
||
public Object getArtefact() { | ||
return artefact; | ||
} | ||
|
||
public List<String> getCustomEffects() { | ||
return customEffects; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/com/gmail/goosius/siegewar/events/ArtefactThrownPotionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.gmail.goosius.siegewar.events; | ||
|
||
import com.gmail.goosius.siegewar.utils.SiegeWarDominationAwardsUtil; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.entity.ThrownPotion; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
public class ArtefactThrownPotionEvent extends Event { | ||
|
||
private static final HandlerList handlers = new HandlerList(); | ||
private final ThrownPotion artefact; | ||
private final Collection<LivingEntity> affectedEntities; | ||
private final List<String> customEffects; | ||
|
||
public ArtefactThrownPotionEvent(ThrownPotion artefact, Collection<LivingEntity> affectedEntities) { | ||
super(!Bukkit.getServer().isPrimaryThread()); | ||
this.artefact = artefact; | ||
this.affectedEntities = affectedEntities; | ||
this.customEffects = SiegeWarDominationAwardsUtil.getCustomEffects(artefact.getItem()); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public ThrownPotion getArtefact() { | ||
return artefact; | ||
} | ||
|
||
public List<String> getCustomEffects() { | ||
return customEffects; | ||
} | ||
|
||
public Collection<LivingEntity> getAffectedEntities() { | ||
return affectedEntities; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/gmail/goosius/siegewar/listeners/SiegeWarArtefactListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.gmail.goosius.siegewar.listeners; | ||
|
||
import com.gmail.goosius.siegewar.SiegeWar; | ||
import com.gmail.goosius.siegewar.events.ArtefactDamageEntityEvent; | ||
import com.gmail.goosius.siegewar.settings.SiegeWarSettings; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
/** | ||
* | ||
* @author Goosius | ||
* | ||
*/ | ||
public class SiegeWarArtefactListener implements Listener { | ||
|
||
@SuppressWarnings("unused") | ||
private final SiegeWar plugin; | ||
|
||
public SiegeWarArtefactListener(SiegeWar siegeWar) { | ||
plugin = siegeWar; | ||
} | ||
|
||
@EventHandler (ignoreCancelled = true) | ||
public void on(ArtefactDamageEntityEvent event) { | ||
if (SiegeWarSettings.getWarSiegeEnabled()) { | ||
for(String customEffect: event.getCustomEffects()) { | ||
switch (customEffect) { | ||
case "lightning_strike_on_hit": | ||
event.getAttacker().getWorld().strikeLightning(event.getVictim().getLocation()); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.