-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Sefiraat/dev
Dev
- Loading branch information
Showing
19 changed files
with
2,890 additions
and
1,893 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
76 changes: 76 additions & 0 deletions
76
src/main/java/io/github/sefiraat/crystamaehistoria/SupportedPluginManager.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,76 @@ | ||
package io.github.sefiraat.crystamaehistoria; | ||
|
||
import com.gmail.nossr50.util.skills.CombatUtils; | ||
import io.github.thebusybiscuit.exoticgarden.items.BonemealableItem; | ||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; | ||
import lombok.Getter; | ||
import me.mrCookieSlime.Slimefun.api.BlockStorage; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.entity.Player; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
@Getter | ||
public class SupportedPluginManager { | ||
|
||
private final boolean mcMMO; | ||
private final boolean exoticGarden; | ||
private final boolean slimeTinker; | ||
|
||
public SupportedPluginManager() { | ||
mcMMO = Bukkit.getPluginManager().isPluginEnabled("mcMMO"); | ||
exoticGarden = Bukkit.getPluginManager().isPluginEnabled("ExoticGarden"); | ||
slimeTinker = Bukkit.getPluginManager().isPluginEnabled("SlimeTinker"); | ||
} | ||
|
||
/** | ||
* Damaging an entity and attributing to a player will make mcMMO give exp based | ||
* on the held item. If mcMMO is installed, we need to flag the entity to be ignored | ||
* briefly. | ||
* | ||
* @param livingEntity The {@link LivingEntity} to be damaged | ||
* @param player The {@link Player} to attribute the damage/drops to | ||
* @param damage The damage to apply | ||
*/ | ||
public void playerDamageWithoutMcMMO(LivingEntity livingEntity, Player player, double damage) { | ||
markEntityMcMMOIgnoreDamage(livingEntity); | ||
livingEntity.damage(damage, player); | ||
clearEntityMcMMOIgnoreDamage(livingEntity); | ||
} | ||
|
||
public void markEntityMcMMOIgnoreDamage(LivingEntity livingEntity) { | ||
if (mcMMO) CombatUtils.applyIgnoreDamageMetadata(livingEntity); | ||
} | ||
|
||
public void clearEntityMcMMOIgnoreDamage(LivingEntity livingEntity) { | ||
if (mcMMO) CombatUtils.removeIgnoreDamageMetadata(livingEntity); | ||
} | ||
|
||
public boolean isExoticGardenPlant(Block block) { | ||
return exoticGarden | ||
&& BlockStorage.hasBlockInfo(block) | ||
&& BlockStorage.check(block) instanceof BonemealableItem; | ||
} | ||
|
||
/** | ||
* Gets the SlimefunItem for the ExoticPlant if it exists | ||
* | ||
* @param block The {@link Block} to check | ||
* @return Returns null if there is not a plant (or Exotic is not installed) or the | ||
* the SlimefunItem if applicable. | ||
*/ | ||
@Nullable | ||
public SlimefunItem getExoticGardenPlant(Block block) { | ||
if (exoticGarden && BlockStorage.hasBlockInfo(block)) { | ||
SlimefunItem slimefunItem = BlockStorage.check(block); | ||
if (slimefunItem instanceof BonemealableItem) { | ||
return slimefunItem; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
|
||
} |
74 changes: 74 additions & 0 deletions
74
src/main/java/io/github/sefiraat/crystamaehistoria/commands/TestWand.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,74 @@ | ||
package io.github.sefiraat.crystamaehistoria.commands; | ||
|
||
import io.github.mooy1.infinitylib.commands.SubCommand; | ||
import io.github.sefiraat.crystamaehistoria.magic.SpellType; | ||
import io.github.sefiraat.crystamaehistoria.magic.spells.core.InstancePlate; | ||
import io.github.sefiraat.crystamaehistoria.magic.spells.core.InstanceStave; | ||
import io.github.sefiraat.crystamaehistoria.slimefun.Tools; | ||
import io.github.sefiraat.crystamaehistoria.slimefun.tools.stave.SpellSlot; | ||
import io.github.sefiraat.crystamaehistoria.utils.Keys; | ||
import io.github.sefiraat.crystamaehistoria.utils.datatypes.DataTypeMethods; | ||
import io.github.sefiraat.crystamaehistoria.utils.datatypes.PersistentStaveDataType; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class TestWand extends SubCommand { | ||
|
||
public TestWand() { | ||
super("test-wand", "gives a wand with the selected spell", true); | ||
} | ||
|
||
@Override | ||
@ParametersAreNonnullByDefault | ||
protected void execute(CommandSender sender, String[] args) { | ||
if (sender instanceof Player) { | ||
Player player = (Player) sender; | ||
if (args.length != 2) { | ||
return; | ||
} | ||
int power = Integer.parseInt(args[1]); | ||
if (power <= 2) { | ||
ItemStack stave; | ||
if (power == 1) { | ||
stave = Tools.getStaveBasic().getItem().clone(); | ||
} else if (power == 2) { | ||
stave = Tools.getStaveAdvanced().getItem().clone(); | ||
} else { | ||
return; | ||
} | ||
|
||
final InstanceStave staveInstance = new InstanceStave(stave); | ||
final Map<SpellSlot, InstancePlate> map = staveInstance.getSpellInstanceMap(); | ||
final InstancePlate plateInstance = new InstancePlate(1, SpellType.valueOf(args[0]), 9999); | ||
map.put(SpellSlot.LEFT_CLICK, plateInstance); | ||
ItemMeta itemMeta = stave.getItemMeta(); | ||
DataTypeMethods.setCustom( | ||
itemMeta, | ||
Keys.PDC_STAVE_STORAGE, | ||
PersistentStaveDataType.TYPE, | ||
staveInstance.getSpellInstanceMap() | ||
); | ||
stave.setItemMeta(itemMeta); | ||
staveInstance.buildLore(); | ||
player.getInventory().addItem(stave); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
@ParametersAreNonnullByDefault | ||
protected void complete(CommandSender commandSender, String[] strings, List<String> list) { | ||
if (strings.length == 1) { | ||
for (SpellType spell : SpellType.getEnabledSpells()) { | ||
list.add(spell.name()); | ||
} | ||
} | ||
} | ||
|
||
} |
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
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
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.