clean up enchantments
This commit is contained in:
parent
89e5775632
commit
38d29ba9c8
32 changed files with 708 additions and 961 deletions
|
@ -188,6 +188,10 @@ public abstract class Command implements Executable {
|
|||
return this.addParameter(new PlayerParser(name, defaulted, policy));
|
||||
}
|
||||
|
||||
protected Command addPlayerList(String name, boolean defaulted, UserPolicy policy) {
|
||||
return this.addParameter(new PlayerListParser(name, defaulted, policy));
|
||||
}
|
||||
|
||||
protected Command addPlayerEntity(String name, boolean defaulted, UserPolicy policy) {
|
||||
return this.addParameter(new PlayerEntityParser(name, defaulted, policy));
|
||||
}
|
||||
|
|
|
@ -268,5 +268,7 @@ public class CommandEnvironment {
|
|||
this.registerExecutable(new CommandRename());
|
||||
this.registerExecutable(new CommandRepair());
|
||||
this.registerExecutable(new CommandMore());
|
||||
this.registerExecutable(new CommandReturn());
|
||||
this.registerExecutable(new CommandDeathspot());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.util.Position;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.RunException;
|
||||
import server.command.UserPolicy;
|
||||
import server.network.Player;
|
||||
|
||||
public class CommandDeathspot extends Command {
|
||||
public CommandDeathspot() {
|
||||
super("deathspot");
|
||||
|
||||
this.addPlayerEntity("player", true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
|
||||
this.addEntityList("entities", 'e', true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, EntityNPC player, List<Entity> entities) {
|
||||
Position pos = ((Player)player.connection).getLastDeath();
|
||||
if(pos == null)
|
||||
throw new RunException("%s hat keinen letzten Todespunkt", player.getCommandName());
|
||||
for(Entity entity : entities) {
|
||||
entity.teleport(pos);
|
||||
exec.log("%s zum Todespunkt von %s (%d, %d, %d in %s) teleportiert", entity.getCommandName(), player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false));
|
||||
}
|
||||
return entities.size();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
|
@ -10,13 +12,15 @@ public class CommandKick extends Command {
|
|||
public CommandKick() {
|
||||
super("kick");
|
||||
|
||||
this.addPlayer("player", false, UserPolicy.NON_ADMINS_NOT_SELF);
|
||||
this.addPlayerList("player", false, UserPolicy.NON_ADMINS_NOT_SELF);
|
||||
this.setParamsOptional();
|
||||
this.addString("message", "Du wurdest vom Server geworfen", false);
|
||||
}
|
||||
|
||||
public void exec(CommandEnvironment env, Executor exec, Player player, String message) {
|
||||
player.disconnect(message);
|
||||
exec.log("%s wurde vom Server geworfen", player.getUser());
|
||||
public void exec(CommandEnvironment env, Executor exec, List<Player> players, String message) {
|
||||
for(Player player : players) {
|
||||
player.disconnect(message);
|
||||
exec.log("%s wurde vom Server geworfen", player.getUser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class CommandMagic extends Command {
|
|||
|
||||
public void exec(CommandEnvironment env, Executor exec, Enchantment ench, Integer level, boolean remove, boolean force, ItemStack stack) {
|
||||
if(remove) {
|
||||
int current = EnchantmentHelper.getEnchantmentLevel(ench.effectId, stack);
|
||||
int current = EnchantmentHelper.getEnchantmentLevel(ench.id, stack);
|
||||
if(current == 0)
|
||||
throw new RunException("%s hat die Verzauberung %s nicht", stack.getDisplayName(), ench.getDisplay());
|
||||
stack.removeEnchantment(ench);
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.util.Position;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.UserPolicy;
|
||||
import server.network.Player;
|
||||
|
||||
public class CommandReturn extends Command {
|
||||
public CommandReturn() {
|
||||
super("return");
|
||||
|
||||
this.addPlayerEntityList("players", 'p', true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, List<EntityNPC> players) {
|
||||
int done = 0;
|
||||
for(EntityNPC player : players) {
|
||||
Position pos = ((Player)player.connection).getLastTeleport();
|
||||
if(pos != null) {
|
||||
player.teleport(pos);
|
||||
exec.log("%s zum letzten Punkt (%d, %d, %d in %s) teleportiert", player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false));
|
||||
done++;
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
}
|
|
@ -207,6 +207,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
|
||||
private Position forcedPos;
|
||||
private Executor forcedExec;
|
||||
private Position deathPos;
|
||||
private Position teleportPos;
|
||||
|
||||
public Player(Server server, NetConnection connection, String user)
|
||||
{
|
||||
|
@ -274,6 +276,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
}
|
||||
|
||||
public void onEntityDeath() {
|
||||
this.deathPos = this.entity.getPos();
|
||||
this.entity.sendDeathMessage();
|
||||
|
||||
if (!SVars.keepInventory && SVars.playerDrop)
|
||||
|
@ -635,6 +638,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
}
|
||||
|
||||
public void teleport(double x, double y, double z, float yaw, float pitch, int dimension) {
|
||||
this.teleportPos = this.entity.getPos();
|
||||
x = ExtMath.clampd(x, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
|
||||
z = ExtMath.clampd(z, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
|
||||
// this.setLastTeleport(this.getLocation());
|
||||
|
@ -2454,6 +2458,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.characters.set(this.selected, tag);
|
||||
int last = this.selected;
|
||||
this.selected = -1;
|
||||
this.teleportPos = this.deathPos = null;
|
||||
this.sendPacket(!this.characters.isEmpty() && last >= 0 ? new SPacketCharacterList(this.selected, last, this.getCharacterInfo(tag)) : new SPacketCharacterList(this.selected));
|
||||
break;
|
||||
}
|
||||
|
@ -2469,6 +2474,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.entity.setOrigin(origin);
|
||||
Position pos = this.server.getRandomSpawnPosition(origin);
|
||||
this.entity.teleport(pos);
|
||||
this.teleportPos = this.deathPos = null;
|
||||
this.sendPacket(new SPacketCharacterList(this.selected, this.selected, new PlayerCharacter(this.entity.getCustomNameTag(), this.entity.getDescription(), this.entity.getAlignment(), this.entity.worldObj.dimension.getFormattedName(false), this.entity.getPosition(), EntityRegistry.getEntityName(EntityRegistry.getEntityString(this.entity)), this.entity.experienceLevel)));
|
||||
// if(this.local)
|
||||
// this.server.setDone();
|
||||
|
@ -2482,6 +2488,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.charEditor = false;
|
||||
this.server.swapPlayer(this, this.characters.get(index), null);
|
||||
this.selected = index;
|
||||
this.teleportPos = this.deathPos = null;
|
||||
this.sendPacket(new SPacketCharacterList(this.selected));
|
||||
break;
|
||||
}
|
||||
|
@ -2495,6 +2502,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.characters.set(this.selected, etag);
|
||||
int last = this.selected;
|
||||
this.selected = index;
|
||||
this.teleportPos = this.deathPos = null;
|
||||
this.sendPacket(!this.characters.isEmpty() && last >= 0 ? new SPacketCharacterList(this.selected, last, this.getCharacterInfo(etag)) : new SPacketCharacterList(this.selected));
|
||||
break;
|
||||
}
|
||||
|
@ -3070,6 +3078,18 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.managedPosX = x;
|
||||
this.managedPosZ = z;
|
||||
}
|
||||
|
||||
public Position getLastTeleport() {
|
||||
return this.teleportPos;
|
||||
}
|
||||
|
||||
public Position getLastDeath() {
|
||||
return this.deathPos;
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return this.getPresentEntity() == null ? this.getUser() : this.getPresentEntity().getCommandName();
|
||||
}
|
||||
|
||||
// public void processCmdBlock(CPacketCmdBlock packetIn) {
|
||||
// NetHandler.checkThread(packetIn, this, this.serverController);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue