-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Format, fixes and organisation * Chaos and Break hardness + perms * PhantomsFlight, Hearthstone, Tracer, Compass * Gravity
- Loading branch information
Showing
60 changed files
with
2,022 additions
and
375 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/bin/ | ||
/lib/ | ||
/.settings/ | ||
/target/ | ||
/.idea/ | ||
|
74 changes: 0 additions & 74 deletions
74
src/main/java/io/github/sefiraat/crystamaehistoria/ActiveStorage.java
This file was deleted.
Oops, something went wrong.
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
122 changes: 122 additions & 0 deletions
122
src/main/java/io/github/sefiraat/crystamaehistoria/SpellMemory.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,122 @@ | ||
package io.github.sefiraat.crystamaehistoria; | ||
|
||
import io.github.sefiraat.crystamaehistoria.magic.CastInformation; | ||
import io.github.sefiraat.crystamaehistoria.magic.spells.core.MagicProjectile; | ||
import io.github.sefiraat.crystamaehistoria.magic.spells.core.MagicSummon; | ||
import io.github.sefiraat.crystamaehistoria.runnables.spells.SpellTickRunnable; | ||
import io.github.thebusybiscuit.slimefun4.libraries.dough.blocks.BlockPosition; | ||
import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; | ||
import lombok.Getter; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
public class SpellMemory { | ||
|
||
@Getter | ||
private final Map<MagicProjectile, Pair<CastInformation, Long>> projectileMap = new HashMap<>(); | ||
@Getter | ||
private final Map<UUID, Pair<CastInformation, Long>> strikeMap = new HashMap<>(); | ||
@Getter | ||
private final Map<SpellTickRunnable, Integer> tickingCastables = new HashMap<>(); | ||
@Getter | ||
private final Map<BlockPosition, Long> blocksToRemove = new HashMap<>(); | ||
@Getter | ||
private final Map<MagicSummon, Long> summonedEntities = new HashMap<>(); | ||
@Getter | ||
private final Map<UUID, Long> playersWithFlight = new HashMap<>(); | ||
|
||
public void clearAll() { | ||
// Cancels all outstanding spells being cast | ||
for (SpellTickRunnable spellTickRunnable : tickingCastables.keySet()) { | ||
spellTickRunnable.cancel(); | ||
} | ||
tickingCastables.clear(); | ||
|
||
// Clear all projectiles created from spells | ||
removeProjectiles(true); | ||
projectileMap.clear(); | ||
|
||
// Clear all spawned entities created from spells | ||
removeEntities(true); | ||
summonedEntities.clear(); | ||
|
||
// Remove all temporary blocks | ||
removeBlocks(true); | ||
blocksToRemove.clear(); | ||
|
||
// Remove all temporary blocks | ||
removeFlight(true); | ||
playersWithFlight.clear(); | ||
} | ||
|
||
public void removeProjectiles(boolean forceRemoveAll) { | ||
Set<MagicProjectile> set = new HashSet<>(CrystamaeHistoria.getProjectileMap().keySet()); | ||
for (MagicProjectile magicProjectile : set) { | ||
long expiry = projectileMap.get(magicProjectile).getSecondValue(); | ||
if (System.currentTimeMillis() > expiry || forceRemoveAll) { | ||
magicProjectile.kill(); | ||
} else { | ||
magicProjectile.run(); | ||
} | ||
} | ||
} | ||
|
||
public void removeEntities(boolean forceRemoveAll) { | ||
Set<MagicSummon> set = new HashSet<>(CrystamaeHistoria.getSummonedEntityMap().keySet()); | ||
for (MagicSummon magicSummon : set) { | ||
long expiry = summonedEntities.get(magicSummon); | ||
if (System.currentTimeMillis() > expiry || magicSummon.getMob() == null || forceRemoveAll) { | ||
magicSummon.kill(); | ||
} else { | ||
magicSummon.run(); | ||
} | ||
} | ||
} | ||
|
||
public void removeBlocks(boolean forceRemoveAll) { | ||
long time = System.currentTimeMillis(); | ||
final Set<Map.Entry<BlockPosition, Long>> set = new HashSet<>(blocksToRemove.entrySet()); | ||
for (Map.Entry<BlockPosition, Long> entry : set) { | ||
if (forceRemoveAll || entry.getValue() < time) { | ||
entry.getKey().getBlock().setType(Material.AIR); | ||
blocksToRemove.remove(entry.getKey()); | ||
} | ||
} | ||
} | ||
|
||
public void removeFlight(boolean forceRemoveAll) { | ||
long time = System.currentTimeMillis(); | ||
final Set<Map.Entry<UUID, Long>> set = new HashSet<>(playersWithFlight.entrySet()); | ||
for (Map.Entry<UUID, Long> entry : set) { | ||
if (forceRemoveAll || entry.getValue() < time) { | ||
Player player = Bukkit.getPlayer(entry.getKey()); | ||
if (player != null) { | ||
player.setAllowFlight(false); | ||
player.setFlying(false); | ||
playersWithFlight.remove(entry.getKey()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void removeFlight(Player player) { | ||
if (playersWithFlight.containsKey(player.getUniqueId())) { | ||
player.setAllowFlight(false); | ||
player.setFlying(false); | ||
playersWithFlight.remove(player.getUniqueId()); | ||
} | ||
} | ||
|
||
public void stopBlockRemoval(Block block) { | ||
BlockPosition blockPosition = new BlockPosition(block); | ||
blocksToRemove.remove(blockPosition); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/io/github/sefiraat/crystamaehistoria/commands/GetBlockColors.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,59 @@ | ||
//package io.github.sefiraat.crystamaehistoria.commands; | ||
// | ||
//import io.github.mooy1.infinitylib.commands.SubCommand; | ||
//import org.bukkit.Color; | ||
//import org.bukkit.Material; | ||
//import org.bukkit.block.Block; | ||
//import org.bukkit.command.CommandSender; | ||
// import org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock; | ||
//import org.bukkit.entity.Player; | ||
// | ||
//import javax.annotation.ParametersAreNonnullByDefault; | ||
//import java.io.BufferedWriter; | ||
//import java.io.File; | ||
//import java.io.FileWriter; | ||
//import java.io.IOException; | ||
//import java.util.List; | ||
// | ||
//public class GetBlockColors extends SubCommand { | ||
// | ||
// public GetBlockColors() { | ||
// super("block_color", "Generates block colors", true); | ||
// } | ||
// | ||
// @Override | ||
// @ParametersAreNonnullByDefault | ||
// protected void execute(CommandSender sender, String[] args) { | ||
// if (sender instanceof Player) { | ||
// Player player = (Player) sender; | ||
// Block block = player.getLocation().getBlock(); | ||
// try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File("block_colors.yml")))) { | ||
// for (Material material : Material.values()) { | ||
// if (material.isBlock()) { | ||
// block.setType(material); | ||
// Color color = Color.fromRGB(((CraftBlock) block).getNMS().getBlock().s().al); | ||
// writeLine(writer, | ||
// material.name() + ": [" + | ||
// + color.getRed() + ", " | ||
// + color.getGreen() + ", " | ||
// + color.getBlue() + "]" | ||
// ); | ||
// } | ||
// } | ||
// } catch (IOException exception) { | ||
// exception.printStackTrace(); | ||
// } | ||
// } | ||
// } | ||
// | ||
// private static void writeLine(BufferedWriter writer, String line) throws IOException { | ||
// writer.write(line); | ||
// writer.newLine(); | ||
// } | ||
// | ||
// @Override | ||
// protected void complete(CommandSender commandSender, String[] strings, List<String> list) { | ||
// | ||
// } | ||
// | ||
//} |
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.