Skip to content

Commit

Permalink
fix recipe deprecation, update arrow positioning for newer spigots with
Browse files Browse the repository at this point in the history
the bug fixed.
  • Loading branch information
jrbudda committed Mar 20, 2018
1 parent 8821960 commit 4a9b9de
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Vivecraft-Spigot-Extensions
version: '1.12.X-r6'
version: '1.12.X-r7'
main: org.vivecraft.VSE
website: http://www.vivecraft.org/
author: jrbudda, jaron780
Expand Down
14 changes: 9 additions & 5 deletions src/org/vivecraft/VSE.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
Expand Down Expand Up @@ -44,6 +45,7 @@
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.mcstats.Metrics;
import org.spigotmc.SpigotConfig;
import org.vivecraft.command.ConstructTabCompleter;
Expand All @@ -64,21 +66,24 @@ public class VSE extends JavaPlugin implements Listener {
public static VSE me;

int task = 0;
private String readurl = "https://raw.githubusercontent.com/jrbudda/Vivecraft_Spigot_Extensions/1.12/version.txt";
private String readurl = "https://raw.githubusercontent.com/jrbudda/Vivecraft_Spigot_Extensions/master/version.txt";

public List<String> blocklist = new ArrayList<>();

@SuppressWarnings("deprecation")
@Override
public void onEnable() {
super.onEnable();

me = this;

ItemStack is = new ItemStack(Material.LEATHER_BOOTS);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName("Jump Boots");
meta.setUnbreakable(true);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
is.setItemMeta(meta);
ShapedRecipe recipe = new ShapedRecipe(is);
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, "jump_boots"),is);
recipe.shape("B", "S");
recipe.setIngredient('B', Material.LEATHER_BOOTS);
recipe.setIngredient('S', Material.SLIME_BLOCK);
Expand All @@ -90,7 +95,7 @@ public void onEnable() {
meta2.setUnbreakable(true);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
is2.setItemMeta(meta2);
ShapedRecipe recipe2 = new ShapedRecipe(is2);
ShapedRecipe recipe2 = new ShapedRecipe( new NamespacedKey(this, "climb_claws"), is2);
recipe2.shape("E E", "S S");
recipe2.setIngredient('E', Material.SPIDER_EYE);
recipe2.setIngredient('S', Material.SHEARS);
Expand Down Expand Up @@ -188,8 +193,7 @@ public void run() {
getLogger().severe("Vault not found, permissions groups will not be set");
vault = false;
}

getServer().getScheduler().scheduleAsyncDelayedTask(this, new Runnable() {
getServer().getScheduler().scheduleAsyncDelayedTask(this, new BukkitRunnable() {
@Override
public void run() {
startUpdateCheck();
Expand Down
2 changes: 2 additions & 0 deletions src/org/vivecraft/VivePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public float getDraw(){
return 0;
}

@SuppressWarnings("unused")
public Vec3D getHMDDir(){
try {
if(hmdData != null){
Expand Down Expand Up @@ -83,6 +84,7 @@ public Vec3D getHMDDir(){
return ((CraftPlayer)player).getHandle().f(1.0f);
}

@SuppressWarnings("unused")
public Vec3D getControllerDir(int controller){
byte[] data = controller0data;
if(controller == 1) data = controller1data;
Expand Down
41 changes: 17 additions & 24 deletions src/org/vivecraft/listeners/VivecraftCombatListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.vivecraft.VSE;
import org.vivecraft.VivePlayer;
Expand Down Expand Up @@ -53,30 +52,24 @@ public void onProjectileLaunch(ProjectileLaunchEvent event) {
proj.setVelocity(proj.getVelocity().multiply(vp.getDraw()));
}

vse.getServer().getScheduler().runTaskLater(vse, new Runnable() {
//The bug necessitating this to be delayed a tick has been fixed in Spigot 1.12.2, but leave here for compatibility.
@Override
public void run() {

int hand = arrow ? 1 : 0;

Vec3D aim = vp.getControllerDir(hand);

if(arrow){
aim = vp.getControllerDir(0);
if(!vp.isSeated() && vp.getDraw() !=0){ //standing
Vector m = (vp.getControllerPos(1).subtract(vp.getControllerPos(0))).toVector();
m = m.normalize();
aim = new Vec3D(m.getX(), m.getY(), m.getZ());
} else { //seated or roomscale off
hand = 0;
}
}

Location pos = vp.getControllerPos(hand);
proj.teleport(new Location(proj.getWorld(), pos.getX() + aim.x*0.6f, pos.getY()+aim.y*0.6f, pos.getZ()+aim.z*0.6f));
int hand = arrow ? 1 : 0;

Vec3D aim = vp.getControllerDir(hand);

if(arrow){
aim = vp.getControllerDir(0);
if(!vp.isSeated() && vp.getDraw() !=0){ //standing
Vector m = (vp.getControllerPos(1).subtract(vp.getControllerPos(0))).toVector();
m = m.normalize();
aim = new Vec3D(m.getX(), m.getY(), m.getZ());
} else { //seated or roomscale off
hand = 0;
}
}, 0);
}

Location pos = vp.getControllerPos(hand);
proj.teleport(new Location(proj.getWorld(), pos.getX() + aim.x*0.6f, pos.getY()+aim.y*0.6f, pos.getZ()+aim.z*0.6f));

}

@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
Expand Down
1 change: 0 additions & 1 deletion src/org/vivecraft/listeners/VivecraftItemListener.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.vivecraft.listeners;

import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down
3 changes: 2 additions & 1 deletion version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
1.12-r3: VSE has a newer version!
1.12.X-r4: VSE has a newer version!
1.12.X-r5: VSE has a newer version!
1.12.X-r6: VSE is up to date!
1.12.X-r6: VSE has a newer version!
1.12.X-r7: VSE is up to date!

0 comments on commit 4a9b9de

Please sign in to comment.