fly command allowing anyone to fly might not work not sure
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.legacyminecraft.poseidon.commands;
|
||||
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FlyCommand extends Command {
|
||||
|
||||
public FlyCommand(String name) {
|
||||
super(name);
|
||||
this.description = "Toggles flight for yourself";
|
||||
this.usageMessage = "/fly";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("You can only use this command as a player.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length != 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /fly");
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityPlayer player = ((CraftPlayer) sender).getHandle();
|
||||
player.flightAllowed = !player.flightAllowed;
|
||||
|
||||
if (player.flightAllowed) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Flight enabled.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Flight disabled.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
private ItemStack[] bN = new ItemStack[]{null, null, null, null, null};
|
||||
private int bO = 0;
|
||||
public boolean h;
|
||||
public boolean flightAllowed;
|
||||
|
||||
public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
|
||||
super(world);
|
||||
@@ -65,6 +66,18 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
public org.bukkit.Location compassTarget;
|
||||
// CraftBukkit end
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
super.a(nbttagcompound);
|
||||
this.flightAllowed = nbttagcompound.m("FlightAllowed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
super.b(nbttagcompound);
|
||||
nbttagcompound.a("FlightAllowed", this.flightAllowed);
|
||||
}
|
||||
|
||||
public void spawnIn(World world) {
|
||||
super.spawnIn(world);
|
||||
// CraftBukkit - world fallback code, either respawn location or global spawn
|
||||
|
||||
@@ -425,7 +425,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
|
||||
AxisAlignedBB axisalignedbb = this.player.boundingBox.clone().b((double) f4, (double) f4, (double) f4).a(0.0D, -0.55D, 0.0D);
|
||||
|
||||
if (!this.minecraftServer.allowFlight && !worldserver.b(axisalignedbb)) {
|
||||
if (!this.minecraftServer.allowFlight && !this.player.flightAllowed && !worldserver.b(axisalignedbb)) {
|
||||
if (d6 >= -0.03125D) {
|
||||
++this.h;
|
||||
if (this.h > 80) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.command;
|
||||
|
||||
//Poseidon start
|
||||
import com.legacyminecraft.poseidon.PoseidonConfig;
|
||||
import com.legacyminecraft.poseidon.commands.FlyCommand;
|
||||
import com.legacyminecraft.poseidon.commands.PoseidonCommand;
|
||||
import com.legacyminecraft.poseidon.commands.ResolveCommand;
|
||||
import com.legacyminecraft.poseidon.commands.TPSCommand;
|
||||
@@ -55,6 +56,7 @@ public class SimpleCommandMap implements CommandMap {
|
||||
|
||||
//Poseidon Command Start
|
||||
register("poseidon", new PoseidonCommand("poseidon"));
|
||||
register("poseidon", new FlyCommand("fly"));
|
||||
if (PoseidonConfig.getInstance().getConfigBoolean("command.tps.enabled"))
|
||||
register("poseidon", new TPSCommand("tps"));
|
||||
//Poseidon Command End
|
||||
|
||||
Reference in New Issue
Block a user