Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of NMS and CB classes. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.5.2-R0.1-SNAPSHOT</version>
<version>1.6.2-R0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.5.2-R0.1-SNAPSHOT</version>
<version>1.6.2-R0.2-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
35 changes: 6 additions & 29 deletions src/main/java/com/thevoxelbox/VoxelPlus/PlusDrunk.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
package com.thevoxelbox.VoxelPlus;

import net.minecraft.server.v1_5_R3.Packet41MobEffect;
import net.minecraft.server.v1_5_R3.Packet42RemoveMobEffect;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;

/**
*
* @author alex
*/
public class PlusDrunk implements Runnable {

private Player drunkplayer;
private final Player drunkplayer;
private int drunkduration;
private Packet41MobEffect drunkpacket;
private Packet42RemoveMobEffect removepacket;
//private Packet41MobEffect drunkpacket;
//private Packet42RemoveMobEffect removepacket;
private int taskid;
private boolean drunkloggedout = false;
private boolean drunkmessages = true;

public PlusDrunk(Player user, int dur, byte effect, byte amplifier, boolean messages) {
public PlusDrunk(Player user, int dur, PotionEffect effect, boolean messages) {
drunkplayer = user;
drunkduration = dur;
drunkmessages = messages;
Expand All @@ -35,20 +31,7 @@ public PlusDrunk(Player user, int dur, byte effect, byte amplifier, boolean mess
drunkplayer.sendMessage(ChatColor.GOLD + "The VoxeLager goes down smooth and easy.");
}
}
drunkpacket = new Packet41MobEffect();
drunkpacket.a = drunkplayer.getEntityId();
drunkpacket.b = effect;
drunkpacket.c = amplifier;
drunkpacket.d = 300;

if (effect == 1 || effect == 3) {
removepacket = new Packet42RemoveMobEffect();
removepacket.a = drunkplayer.getEntityId();
removepacket.b = effect;

}

drunkplayer.playEffect(drunkplayer.getLocation(), Effect.POTION_BREAK, 0);
drunkplayer.addPotionEffect(effect);

}

Expand All @@ -70,18 +53,12 @@ public void run() {
} else if (drunkduration >= 1000 && drunkduration <= 1100 && drunkmessages) {
drunkplayer.sendMessage(ChatColor.GOLD + "You feel tipsy. Whee!");
}

drunkpacket.a = drunkplayer.getEntityId();
drunkduration -= 200;
((CraftPlayer) drunkplayer).getHandle().playerConnection.sendPacket(drunkpacket);
if (drunkduration <= 0) {
if (drunkmessages) {
drunkplayer.sendMessage(ChatColor.GOLD + "You feel your buzz start to fade.");
}
Bukkit.getScheduler().cancelTask(taskid);
if (drunkpacket.b == 3 || drunkpacket.b == 1) {
((CraftPlayer) drunkplayer).getHandle().playerConnection.sendPacket(removepacket);
}
}
} else {
drunkloggedout = true;
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/thevoxelbox/VoxelPlus/PlusListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

/**
*
Expand All @@ -30,7 +32,7 @@ public void vplusRightClick(PlayerInteractEvent beerconsume) {
int amount = beerconsume.getPlayer().getItemInHand().getAmount();
ItemStack emptyBottles = new ItemStack(281, amount);
beerconsume.getPlayer().setItemInHand(emptyBottles);
PlusDrunk drunktank = new PlusDrunk(beerconsume.getPlayer(), (amount * 100) + 400, (byte) 9, (byte) 0, true);
PlusDrunk drunktank = new PlusDrunk(beerconsume.getPlayer(), (amount * 100) + 400 , new PotionEffect(PotionEffectType.CONFUSION, (amount * 100) + 400, 0) , true);
drunktank.settaskid(Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, drunktank, 5, 200));
}
// right click with book to gain levels
Expand All @@ -41,10 +43,10 @@ public void vplusRightClick(PlayerInteractEvent beerconsume) {
// (commented out until I can crack checking item data values.
if (beerconsume.hasItem() && beerconsume.getItem().getTypeId() == 351 && beerconsume.getItem().getDurability() == 3) {
beerconsume.setCancelled(true);
int amount = beerconsume.getPlayer().getItemInHand().getAmount();
PlusDrunk drunktank = new PlusDrunk(beerconsume.getPlayer(), 600, (byte) 1, (byte) 3, true);
//int amount = beerconsume.getPlayer().getItemInHand().getAmount();
PlusDrunk drunktank = new PlusDrunk(beerconsume.getPlayer(), 600, new PotionEffect(PotionEffectType.CONFUSION, 600, 0), true);
// faster digging
PlusDrunk drunktank2 = new PlusDrunk(beerconsume.getPlayer(), 600, (byte) 3, (byte) 3, false);
PlusDrunk drunktank2 = new PlusDrunk(beerconsume.getPlayer(), 600, new PotionEffect(PotionEffectType.CONFUSION, 600, 0), false);
drunktank.settaskid(Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, drunktank, 5, 200));
drunktank2.settaskid(Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, drunktank2, 5, 200));
}
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/com/thevoxelbox/VoxelPlus/VoxelPlusCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

/**
*
Expand Down Expand Up @@ -39,15 +41,10 @@ public void onEnable() {
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
String commandName = command.getName().toLowerCase();
if (commandName.equals("plusnine") && sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage("plusnine's first plugin works! ...kinda.");
return true;
}
// get drunk command (self) by plusnine
if (commandName.equals("getmedrunk") && sender instanceof Player) {
Player drunkplayer = (Player) sender;
PlusDrunk drunktank = new PlusDrunk(drunkplayer, 600, (byte) 9, (byte) 0, true);
PlusDrunk drunktank = new PlusDrunk(drunkplayer, 600, new PotionEffect(PotionEffectType.CONFUSION, 600, 0), true);
drunktank.settaskid(Bukkit.getScheduler().scheduleSyncRepeatingTask(this, drunktank, 5, 200));
return true;
}
Expand All @@ -58,7 +55,7 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa
Player player = (Player) sender;
for (Player p : player.getServer().getOnlinePlayers()) {
if (p.getName().equals(args[0].toString())) {
PlusDrunk drunktank = new PlusDrunk(p, 600, (byte) 9, (byte) 0, true);
PlusDrunk drunktank = new PlusDrunk(p, 600, new PotionEffect(PotionEffectType.CONFUSION, 600, 0), true);
drunktank.settaskid(Bukkit.getScheduler().scheduleSyncRepeatingTask(this, drunktank, 5, 200));
player.sendMessage(ChatColor.GOLD + p.getName() + " sure did enjoy their VoxelLager");
return true;
Expand All @@ -75,7 +72,7 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa
if (sender instanceof Player) {
Player player = (Player) sender;
if (args.length >= 2) {
player.sendMessage("Too many arguements!");
player.sendMessage("Too many arguments!");
} else {
int vhelmid = Integer.parseInt(args[0]);
ItemStack vhelmstack = new ItemStack(vhelmid);
Expand Down Expand Up @@ -125,9 +122,9 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa
if (Integer.parseInt(args[0]) <= 15 && Integer.parseInt(args[0]) >= 0) {
Player drunkplayer = (Player) sender;
// faster movement
PlusDrunk drunktank = new PlusDrunk(drunkplayer, 600, (byte) 1, (byte) Integer.parseInt(args[0]), true);
PlusDrunk drunktank = new PlusDrunk(drunkplayer, 600, new PotionEffect(PotionEffectType.SPEED, 600, (byte) Integer.parseInt(args[0])), false);
// faster digging
PlusDrunk drunktank2 = new PlusDrunk(drunkplayer, 600, (byte) 3, (byte) Integer.parseInt(args[0]), false);
PlusDrunk drunktank2 = new PlusDrunk(drunkplayer, 600, new PotionEffect(PotionEffectType.FAST_DIGGING, 600, (byte) Integer.parseInt(args[0])), false);
drunktank.settaskid(Bukkit.getScheduler().scheduleSyncRepeatingTask(this, drunktank, 5, 200));
drunktank2.settaskid(Bukkit.getScheduler().scheduleSyncRepeatingTask(this, drunktank2, 5, 200));
return true;
Expand Down
9 changes: 3 additions & 6 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ author: plusnine et al.
description: >
Libations, potent potables and fine smokeables!
commands:
plusnine:
description: Prints out a test command.
usage: |
/<command>
Example: /<command> - hope for the best.
getmedrunk:
description: Gives you a sweet buzz!
usage: |
/<command>
Example: /<command> - gets ya buzzed with the power of VoxelLager.
getotherdrunk:
permission: voxelplus.drunk.other
description: Gives your 'friend' a sweet buzz!
usage: |
/<command>
Expand All @@ -25,13 +21,14 @@ commands:
description: Gives you a quick pick-me-up that you need sometimes!
usage: |
/<command>
Example: /<command> <coffee strength> - Coffeeeeeee. Strength is 0-15 (I think try 5 to start)
Example: /<command> <coffee strength> - Coffieeeeeee. Strength is 0-15 (I think try 5 to start)
vhelm:
description: Places block on head!
usage: |
/<command>
Example: /<command> <itemID> - Block helmets! ItemId is any block ID.
vsit:
permission: voxelplus.vsit
description: Makes you or another player sit
usage: |
/<command>
Expand Down