Initializing repository

main
Shinare 2 years ago
parent 0c76d99215
commit 36e6047546

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zivilon</groupId>
<artifactId>Abilities</artifactId>
<version>1.1</version>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.flinbein</groupId>
<artifactId>PowerNBT</artifactId>
<version>0.8.9.2</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,35 @@
package com.zivilon.abilities;
import com.zivilon.abilities.command.surge_command;
import com.zivilon.abilities.command.ArrowSwarmCommand;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
public class Abilities extends JavaPlugin {
private static Abilities plugin;
PluginDescriptionFile pdfFile; // plugin.yml
public void onDisable() {
plugin = getPlugin(Abilities.class);
this.pdfFile = getDescription();
}
public static Abilities getPlugin() { // getter for the static plugin instance
return plugin;
}
public PluginDescriptionFile getPdfFile() {
return pdfFile;
}
public void onEnable() {
PluginManager pm = getServer().getPluginManager();
this.pdfFile = getDescription();
this.getCommand("surge").setExecutor(new surge_command());
this.getCommand("arrowswarm").setExecutor(new ArrowSwarmCommand());
this.getLogger()
.info(this.pdfFile.getName() + " - Version " + this.pdfFile.getVersion() + " - has been enabled!");
}
}

@ -0,0 +1,45 @@
package com.zivilon.abilities.command;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class ArrowSwarmCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command can only be run by a player.");
return true;
}
Player player = (Player) sender;
String perms = "abilities.arrowswarm";
if (!player.hasPermission(perms)) {
player.sendMessage("You do not have permission to use this command");
return true;
}
Location playerLocation = player.getLocation();
Vector direction = playerLocation.getDirection().normalize();
for (int i = 0; i < 5; i++) {
Arrow arrow = player.getWorld().spawnArrow(
playerLocation.add(direction.multiply(2)),
direction,
1.0f, // Projectile speed
1.0f); // Spread
arrow.setShooter(player);
}
return true;
}
}

@ -0,0 +1,58 @@
package com.zivilon.abilities.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.Location;
import org.bukkit.util.Vector;
public class surge_command implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
Player player = (Player) sender;
String perms = "abilities.surge";
if (!sender.hasPermission(perms)) {
player.sendMessage("You do not have permission to use this command");
return true;
}
if (sender instanceof ConsoleCommandSender) {
sender.sendMessage(" > " + "You cannot run this command from the console!");
return true;
}
Location pos = player.getPlayer().getLocation();
Float yaw = pos.getYaw();
if (yaw < 0) {
yaw += 360;
}
Float pitch = pos.getPitch();
Float pitch_multi = 0.0f;
Float x_multi = 0.0f;
Float z_multi = 0.0f;
// The math from here on could have been compressed a lot but I found it easier to understand when done step by step
if (pitch >= 0.0) {
pitch_multi = 1.0f;
} else {
pitch_multi = 1.0f+(Math.abs(pitch)/90*2.5f);
}
if (yaw > 180 && yaw < 360) { //Mids 90 and 270
x_multi = (-180.0f+yaw); //Returns value 0-180
x_multi = 1-(Math.abs((90.0f-x_multi)/90)); //Returns negative value 0-1, higher is closer to 90
} else if (yaw > 0 && yaw < 180) {
x_multi = -1+(Math.abs((90.0f-yaw)/90)); //Returns positive value 0.1, higher is closer to 90
}
if (yaw > 90 && yaw < 270) { //Mids 0 and 180
z_multi = (-90.0f+yaw); //Returns value 0-180
z_multi = -1+(Math.abs(90.0f-z_multi)/90); //Returns negative value 0-1, higher is closer to 90
} else if (yaw < 90) {
z_multi = 1-yaw/90; //Returns positive value 0.1, higher is closer to 90
} else if (yaw > 270) {
z_multi = 1-Math.abs(yaw-360)/90; //Returns positive value 0.1, higher is closer to 90
}
player.setVelocity(new Vector((3*x_multi/pitch_multi), (0.25f*pitch_multi), (3*z_multi/pitch_multi)));
return false;
}
}

@ -0,0 +1,9 @@
main: com.zivilon.abilities.Abilities
name: Abilities
author: Shinare
version: 1.0
commands:
surge:
description: Throws the player forward
arrowswarm:
description: Shoots arrows
Loading…
Cancel
Save