-
Notifications
You must be signed in to change notification settings - Fork 1
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 #7 from PixelOutlaw/develop
Ability System Release
- Loading branch information
Showing
150 changed files
with
4,518 additions
and
1,534 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
Large diffs are not rendered by default.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
src/main/java/land/face/strife/commands/AgilityCommand.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,61 @@ | ||
/** | ||
* The MIT License Copyright (c) 2015 Teal Cube Games | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
* associated documentation files (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, | ||
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or | ||
* substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT | ||
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
package land.face.strife.commands; | ||
|
||
import static com.tealcube.minecraft.bukkit.facecore.utilities.MessageUtils.sendMessage; | ||
|
||
import land.face.strife.StrifePlugin; | ||
import org.bukkit.entity.Player; | ||
import se.ranzdo.bukkit.methodcommand.Arg; | ||
import se.ranzdo.bukkit.methodcommand.Command; | ||
|
||
public class AgilityCommand { | ||
|
||
private final StrifePlugin plugin; | ||
|
||
public AgilityCommand(StrifePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Command(identifier = "agility create", permissions = "strife.command.agility") | ||
public void creationCommand(Player sender, @Arg(name = "name") String name, | ||
@Arg(name = "difficulty") double difficulty, @Arg(name = "xp") double xp) { | ||
|
||
boolean success = plugin.getAgilityManager() | ||
.createAgilityContainer(name, sender.getLocation(), (float) difficulty, (float) xp); | ||
|
||
if (success) { | ||
sendMessage(sender, "&eMAde it"); | ||
} else { | ||
sendMessage(sender, "&efailed"); | ||
} | ||
} | ||
|
||
@Command(identifier = "agility add", permissions = "strife.command.agility") | ||
public void addCommand(Player sender, @Arg(name = "name") String name) { | ||
|
||
boolean success = plugin.getAgilityManager().addAgilityLocation(name, sender.getLocation()); | ||
|
||
if (success) { | ||
sendMessage(sender, "&eMAde it"); | ||
} else { | ||
sendMessage(sender, "&efailed"); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* The MIT License Copyright (c) 2015 Teal Cube Games | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
* associated documentation files (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, | ||
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or | ||
* substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT | ||
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
package land.face.strife.commands; | ||
|
||
import static com.tealcube.minecraft.bukkit.facecore.utilities.MessageUtils.sendMessage; | ||
|
||
import java.util.ArrayList; | ||
import land.face.strife.StrifePlugin; | ||
import land.face.strife.data.champion.Champion; | ||
import land.face.strife.stats.AbilitySlot; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import se.ranzdo.bukkit.methodcommand.Arg; | ||
import se.ranzdo.bukkit.methodcommand.Command; | ||
|
||
public class StyleCommand { | ||
|
||
private final StrifePlugin plugin; | ||
|
||
public StyleCommand(StrifePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Command(identifier = "strife style add", permissions = "strife.command.ability-style", onlyPlayers = true) | ||
public void addStyleCommand(CommandSender sender, @Arg(name = "slot") String slot, | ||
@Arg(name = "text") String text) { | ||
AbilitySlot abilitySlot; | ||
try { | ||
abilitySlot = AbilitySlot.valueOf(slot); | ||
} catch (Exception e) { | ||
sendMessage(sender, "&cValid slots are: SLOT_A, SLOT_B, SLOT_C"); | ||
return; | ||
} | ||
if (abilitySlot != AbilitySlot.SLOT_A && abilitySlot != AbilitySlot.SLOT_B | ||
&& abilitySlot != AbilitySlot.SLOT_C) { | ||
sendMessage(sender, "&cValid slots are: SLOT_A, SLOT_B, SLOT_C"); | ||
return; | ||
} | ||
Champion champion = plugin.getChampionManager().getChampion((Player) sender); | ||
champion.getSaveData().getCastMessages().computeIfAbsent(abilitySlot, k -> new ArrayList<>()); | ||
champion.getSaveData().getCastMessages().get(abilitySlot).add(text); | ||
} | ||
|
||
@Command(identifier = "strife style clear", permissions = "strife.command.ability-style", onlyPlayers = true) | ||
public void clearStyleCommand(CommandSender sender, @Arg(name = "slot") String slot) { | ||
AbilitySlot abilitySlot; | ||
try { | ||
abilitySlot = AbilitySlot.valueOf(slot); | ||
} catch (Exception e) { | ||
sendMessage(sender, "&cValid slots are: SLOT_A, SLOT_B, SLOT_C"); | ||
return; | ||
} | ||
if (abilitySlot != AbilitySlot.SLOT_A && abilitySlot != AbilitySlot.SLOT_B | ||
&& abilitySlot != AbilitySlot.SLOT_C) { | ||
sendMessage(sender, "&cValid slots are: SLOT_A, SLOT_B, SLOT_C"); | ||
return; | ||
} | ||
Champion champion = plugin.getChampionManager().getChampion((Player) sender); | ||
champion.getSaveData().getCastMessages().computeIfAbsent(abilitySlot, k -> new ArrayList<>()); | ||
champion.getSaveData().getCastMessages().get(abilitySlot).clear(); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
src/main/java/land/face/strife/data/AgilityLocationContainer.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,96 @@ | ||
package land.face.strife.data; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.Particle; | ||
import org.bukkit.Sound; | ||
import org.bukkit.entity.Player; | ||
|
||
public class AgilityLocationContainer { | ||
|
||
private Map<UUID, Integer> progress = new HashMap<>(); | ||
|
||
private String name; | ||
private float exp; | ||
private float difficulty; | ||
private List<Location> locations = new ArrayList<>(); | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public float getExp() { | ||
return exp; | ||
} | ||
|
||
public void setExp(float exp) { | ||
this.exp = exp; | ||
} | ||
|
||
public float getDifficulty() { | ||
return difficulty; | ||
} | ||
|
||
public void setDifficulty(float difficulty) { | ||
this.difficulty = difficulty; | ||
} | ||
|
||
public List<Location> getLocations() { | ||
return locations; | ||
} | ||
|
||
public Map<UUID, Integer> getProgress() { | ||
return progress; | ||
} | ||
|
||
public static void checkStart(AgilityLocationContainer cont, Player player, Location loc) { | ||
if (!cont.getProgress().containsKey(player.getUniqueId())) { | ||
if (loc.distanceSquared(cont.getLocations().get(0)) < 2) { | ||
cont.getProgress().put(player.getUniqueId(), 0); | ||
if (cont.getLocations().get(1) != null) { | ||
player.spawnParticle(Particle.FIREWORKS_SPARK, cont.getLocations().get(1), 10, 0.5, 0.5, | ||
0.5, 0); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static boolean setProgress(AgilityLocationContainer cont, Player player, Location loc) { | ||
if (!cont.getProgress().containsKey(player.getUniqueId())) { | ||
return false; | ||
} | ||
if (cont.getLocations().size() == 1) { | ||
Bukkit.getLogger().warning("Agility set " + cont.getName() + "has only 1 location"); | ||
return false; | ||
} | ||
int progress = cont.getProgress().get(player.getUniqueId()); | ||
if (loc.distanceSquared(cont.getLocations().get(progress + 1)) < 2) { | ||
if (progress + 2 == cont.getLocations().size()) { | ||
cont.getProgress().remove(player.getUniqueId()); | ||
player.playSound(loc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); | ||
return true; | ||
} else { | ||
cont.getProgress().put(player.getUniqueId(), progress + 1); | ||
player.playSound(loc, Sound.ENTITY_CHICKEN_EGG, 1, 2); | ||
player.spawnParticle(Particle.FIREWORKS_SPARK, | ||
cont.getLocations().get(progress + 2), 10, 0.5, 0.5, 0.5, 0); | ||
return false; | ||
} | ||
} | ||
if (loc.distanceSquared(cont.getLocations().get(progress)) < 2) { | ||
return false; | ||
} | ||
cont.getProgress().remove(player.getUniqueId()); | ||
player.playSound(loc, Sound.BLOCK_NOTE_BLOCK_BASS, 1, 0.7f); | ||
return false; | ||
} | ||
} |
Oops, something went wrong.