use of org.bukkit.craftbukkit.v.entity.CraftPlayer in project Arclight by IzzelAliz.
the class LivingEntityMixin method arclight$setScaled.
@Inject(method = "setHealth", cancellable = true, at = @At("HEAD"))
public void arclight$setScaled(float health, CallbackInfo ci) {
if (this instanceof ServerPlayerEntityBridge) {
CraftPlayer player = ((ServerPlayerEntityBridge) this).bridge$getBukkitEntity();
player.setRealHealth(MathHelper.clamp(health, 0.0F, player.getMaxHealth()));
player.updateScaledHealth(false);
ci.cancel();
}
}
use of org.bukkit.craftbukkit.v.entity.CraftPlayer in project Arclight by IzzelAliz.
the class SaveHandlerMixin method arclight$lastSeenTime.
@Inject(method = "readPlayerData", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;contains(Ljava/lang/String;I)Z"))
public void arclight$lastSeenTime(PlayerEntity player, CallbackInfoReturnable<CompoundNBT> cir) {
if (player instanceof ServerPlayerEntity) {
CraftPlayer craftPlayer = ((ServerPlayerEntityBridge) player).bridge$getBukkitEntity();
// Only update first played if it is older than the one we have
long modified = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat").lastModified();
if (modified < craftPlayer.getFirstPlayed()) {
craftPlayer.setFirstPlayed(modified);
}
}
}
use of org.bukkit.craftbukkit.v.entity.CraftPlayer in project Arclight by IzzelAliz.
the class ServerPlayNetHandlerMixin method handleSlashCommand.
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
private void handleSlashCommand(String s) {
if (SpigotConfig.logCommands) {
LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s);
}
CraftPlayer player = this.getPlayer();
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet(this.minecraftServer));
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
try {
minecraftServer.getCommandManager().handleCommand(((CraftPlayer) event.getPlayer()).getHandle().getCommandSource(), event.getMessage());
} catch (CommandException ex) {
player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
java.util.logging.Logger.getLogger(ServerPlayNetHandler.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of org.bukkit.craftbukkit.v.entity.CraftPlayer in project Arclight by IzzelAliz.
the class EndGatewayTileEntityMixin method arclight$portal.
// @formatter:on
@Inject(method = "teleportEntity", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;teleportKeepLoaded(DDD)V"))
public void arclight$portal(Entity entityIn, CallbackInfo ci) {
if (entityIn instanceof ServerPlayerEntity) {
CraftPlayer player = ((ServerPlayerEntityBridge) entityIn).bridge$getBukkitEntity();
Location location = new Location(((WorldBridge) world).bridge$getWorld(), pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D);
location.setPitch(player.getLocation().getPitch());
location.setYaw(player.getLocation().getYaw());
PlayerTeleportEvent event = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.END_GATEWAY);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
ci.cancel();
return;
}
((ServerPlayNetHandlerBridge) (((ServerPlayerEntity) entityIn)).connection).bridge$teleport(event.getTo());
// CraftBukkit - call at end of method
this.isCoolingDown();
ci.cancel();
}
}
use of org.bukkit.craftbukkit.v.entity.CraftPlayer in project Arclight by IzzelAliz.
the class EntityTeleportEventDispatcher method onTeleport.
@SubscribeEvent(receiveCanceled = true)
public void onTeleport(EnderTeleportEvent event) {
if (!(event.getEntity() instanceof EndermanEntity)) {
if (event.getEntity() instanceof ServerPlayerEntity) {
CraftPlayer player = ((ServerPlayerEntityBridge) event.getEntity()).bridge$getBukkitEntity();
PlayerTeleportEvent bukkitEvent = new PlayerTeleportEvent(player, player.getLocation(), new Location(player.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()), PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(bukkitEvent);
event.setCanceled(bukkitEvent.isCancelled());
event.setTargetX(bukkitEvent.getTo().getX());
event.setTargetY(bukkitEvent.getTo().getY());
event.setTargetZ(bukkitEvent.getTo().getZ());
} else {
CraftEntity entity = ((EntityBridge) event.getEntity()).bridge$getBukkitEntity();
EntityTeleportEvent bukkitEvent = new EntityTeleportEvent(entity, entity.getLocation(), new Location(entity.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()));
Bukkit.getPluginManager().callEvent(bukkitEvent);
event.setCanceled(bukkitEvent.isCancelled());
event.setTargetX(bukkitEvent.getTo().getX());
event.setTargetY(bukkitEvent.getTo().getY());
event.setTargetZ(bukkitEvent.getTo().getZ());
}
}
}
Aggregations