Skip to content

Commit

Permalink
Adds player targeting commands
Browse files Browse the repository at this point in the history
Adds player targeting summon commands, customizable summon messages, changes the shooting star summon to now appear directly above the player's head, and now adds the config by default upon installation
  • Loading branch information
IdreesInc committed Jul 24, 2020
1 parent 4e8e9c3 commit c9e9cbb
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 36 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Additionally, the worlds that shooting and falling stars can spawn in must meet
- Will not spawn in the nether or end

## Configuration
Installation is as simple as copying the newest build jar to your plugins folder. **A configuration file is not added by default**, but can be easily created by making a "Celeste" directory in your plugins folder and creating a "config.yml" within that directory. It is not necessary (nor recommended) to copy everything from the default config shown below, instead copy only the lines you wish to change.
Installation is as simple as copying the newest build jar to your plugins folder. A configuration file is created by default, but if the file was created previously it may not include default values that were added in later updates. These values can be added easily by just copying and pasting the particular lines from the defaults below.
### Defaults
``` yaml
# The average number of shooting stars to create per minute for each world
Expand All @@ -51,6 +51,10 @@ new-moon-meteor-shower: true
shooting-stars-per-minute-during-meteor-showers: 15
# The number of falling stars to create per minute during meteor showers
falling-stars-per-minute-during-meteor-showers: 0.3
# The message to send in response to summoning a shooting star
shooting-stars-summon-text: "Make a wish!"
# The message to send in response to summoning a falling star
falling-stars-summon-text: "Make a wish!"
```
### Falling Star Loot
Falling stars drop loot wherever they fall, and spark for 10 seconds (200 ticks) by default to show their location. The loot they drop is randomly selected from the loot table in the config, with each material being given a weight. For instance, in the default config, there is a 60% chance for a diamond, 20% of an emerald, and 20% chance of a fire_charge. Experience also drops from falling stars, 100 points (not levels) by default.
Expand All @@ -68,7 +72,7 @@ falling-stars-loot:
```

## Commands
**/shootingstar** summons a shooting star in the sky around the player, however because the area a shooting star can spawn is quite large, it is easy to miss just a single one. I am currently working on making it appear exactly above the player for easy testing
**/shootingstar [player]** summons a shooting star in the sky directly above the player. If no player is given, spawns one above the summoner.

**/fallingstar** summons a falling star at the exact location of the player
**/fallingstar [player]** summons a falling star directly above the player. If no player is given, spawns one above the summoner.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.idreesinc</groupId>
<artifactId>Celeste</artifactId>
<version>1.2</version>
<version>1.3</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/idreesinc/celeste/Celeste.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Celeste extends JavaPlugin {

@Override
public void onEnable() {
this.saveDefaultConfig();
Metrics metrics = new Metrics(this, 81862);

this.getCommand("shootingstar").setExecutor(new CommandShootingStar(this));
Expand Down Expand Up @@ -44,11 +45,10 @@ public void onEnable() {
stargazingTask.runTaskTimer(this, 0, 10);

new UpdateChecker(this, 81862).getVersion(version -> {
// System.out.println(version);
if (this.getDescription().getVersion().equalsIgnoreCase(version)) {
// this.getLogger().info("Celeste is up to date!");
this.getLogger().info("Celeste is up to date!");
} else {
this.getLogger().info("There is a new update available for Celeste!");
this.getLogger().info("There is an update available for Celeste (" + this.getDescription().getVersion() + " -> " + version + ")");
}
});
}
Expand Down
26 changes: 16 additions & 10 deletions src/main/java/com/idreesinc/celeste/CelestialSphere.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,31 @@
import java.util.Random;

public class CelestialSphere {

public static void createShootingStar(Player player) {
createShootingStar(player.getLocation());
createShootingStar(player, true);
}

public static void createShootingStar(Player player, boolean approximate) {
createShootingStar(player.getLocation(), approximate);
}

public static void createShootingStar(Location location) {
// double radius = 100 + new Random().nextDouble() * 30;
// Vector locationMod = new Vector(new Random().nextDouble() * 2 - 1, new Random().nextDouble(), new Random().nextDouble() * 2 - 1);
// locationMod.normalize();
// locationMod.multiply(radius);
// Location starLocation = new Location(location.getWorld(), locationMod.getX() + location.getX(), Math.min(256,
// Math.max(150, locationMod.getY() + location.getY() + 10)), locationMod.getZ() + location.getZ());
// Vector direction = new Vector(new Random().nextDouble() * 2 - 1, new Random().nextDouble() * -1 * Math.cos(locationMod.getY() / radius * (Math.PI / 2)), new Random().nextDouble() * 2 - 1);
// direction.normalize();
createShootingStar(location, true);
}

public static void createShootingStar(Location location, boolean approximate) {
Location starLocation;
double w = 100 * Math.sqrt(new Random().nextDouble());
double t = 2d * Math.PI * new Random().nextDouble();
double x = w * Math.cos(t);
double y = Math.max(new Random().nextDouble() * 50 + 100, location.getY() + 50);
double z = w * Math.sin(t);
Location starLocation = new Location(location.getWorld(), location.getX() + x, y, location.getZ() + z);
if (approximate) {
starLocation = new Location(location.getWorld(), location.getX() + x, y, location.getZ() + z);
} else {
starLocation = new Location(location.getWorld(), location.getX(), y, location.getZ());
}
Vector direction = new Vector(new Random().nextDouble() * 2 - 1, new Random().nextDouble() * -0.75d, new Random().nextDouble() * 2 - 1);
direction.normalize();
double speed = new Random().nextDouble() * 2 + 0.75;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.idreesinc.celeste.Celeste;
import com.idreesinc.celeste.CelestialSphere;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
Expand All @@ -16,13 +17,25 @@ public CommandFallingStar(Celeste celeste) {
}

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage("Make a wish!");
CelestialSphere.createFallingStar(celeste, player, false);
return true;
if (args.length > 0) {
if (Bukkit.getPlayer(args[0]) == null) {
sender.sendMessage("\u00a7cError: Player not found.");
return true;
}
CelestialSphere.createFallingStar(celeste, Bukkit.getPlayer(args[0]), false);
} else {
if (sender instanceof Player) {
Player player = (Player) sender;
CelestialSphere.createFallingStar(celeste, player, false);
} else {
return false;
}
}
return false;
String message = this.celeste.getConfig().getString("falling-stars-summon-text");
if (message != null) {
sender.sendMessage(message);
}
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.idreesinc.celeste.Celeste;
import com.idreesinc.celeste.CelestialSphere;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
Expand All @@ -16,13 +17,25 @@ public CommandShootingStar(Celeste celeste) {
}

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage("Make a wish!");
CelestialSphere.createShootingStar(player);
return true;
if (args.length > 0) {
if (Bukkit.getPlayer(args[0]) == null) {
sender.sendMessage("\u00a7cError: Player not found.");
return true;
}
CelestialSphere.createShootingStar(Bukkit.getPlayer(args[0]), false);
} else {
if (sender instanceof Player) {
Player player = (Player) sender;
CelestialSphere.createShootingStar(player, false);
} else {
return false;
}
}
return false;
String message = this.celeste.getConfig().getString("shooting-stars-summon-text");
if (message != null) {
sender.sendMessage(message);
}
return true;
}

}
4 changes: 3 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ falling-stars-loot:
fire_charge: 20
new-moon-meteor-shower: true
shooting-stars-per-minute-during-meteor-showers: 15
falling-stars-per-minute-during-meteor-showers: 0.3
falling-stars-per-minute-during-meteor-showers: 0.3
shooting-stars-summon-text: "Make a wish!"
falling-stars-summon-text: "Make a wish!"
12 changes: 6 additions & 6 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Celeste
version: 1.2
version: 1.3
api-version: 1.14
author: Idrees
main: com.idreesinc.celeste.Celeste

commands:
shootingstar:
description: Creates a shooting star near the player that summons it
usage: /<command>
description: Creates a shooting star near the player that summons it, or optionally near another player
usage: /<command> [player]
permission: celeste.shootingstar
fallingstar:
description: Creates a falling star near the player that summons it
usage: /<command>
permission: celeste.fallingstar
description: Creates a falling star near the player that summons it, or optionally near another player
usage: /<command> [player]
permission: celeste.fallingstar

0 comments on commit c9e9cbb

Please sign in to comment.