mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Remove FAWE-Piston
Disables a lot of previous functionality in FAWE until replacements can be made. This commit was untested and may cause major issues.
This commit is contained in:
@ -2,7 +2,6 @@ package com.boydti.fawe.bukkit.listener;
|
||||
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
||||
import com.boydti.fawe.command.CFICommands;
|
||||
import com.boydti.fawe.object.brush.BrushSettings;
|
||||
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
@ -57,31 +56,32 @@ public class BukkitImageListener implements Listener {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerInteractEntity(AsyncPlayerChatEvent event) {
|
||||
Set<Player> recipients = event.getRecipients();
|
||||
Iterator<Player> iter = recipients.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Player player = iter.next();
|
||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
if (player.equals(event.getPlayer()) || !bukkitPlayer.hasMeta() || settings == null || !settings.hasGenerator()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = player.getName().toLowerCase();
|
||||
if (!event.getMessage().toLowerCase().contains(name)) {
|
||||
ArrayDeque<String> buffered = bukkitPlayer.getMeta("CFIBufferedMessages");
|
||||
if (buffered == null) {
|
||||
bukkitPlayer.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<>());
|
||||
}
|
||||
String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(),
|
||||
event.getMessage());
|
||||
buffered.add(full);
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO Fix along with CFI code 2020-02-04
|
||||
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
// public void onPlayerInteractEntity(AsyncPlayerChatEvent event) {
|
||||
// Set<Player> recipients = event.getRecipients();
|
||||
// Iterator<Player> iter = recipients.iterator();
|
||||
// while (iter.hasNext()) {
|
||||
// Player player = iter.next();
|
||||
// BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
// if (player.equals(event.getPlayer()) || !bukkitPlayer.hasMeta() || settings == null || !settings.hasGenerator()) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// String name = player.getName().toLowerCase();
|
||||
// if (!event.getMessage().toLowerCase().contains(name)) {
|
||||
// ArrayDeque<String> buffered = bukkitPlayer.getMeta("CFIBufferedMessages");
|
||||
// if (buffered == null) {
|
||||
// bukkitPlayer.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<>());
|
||||
// }
|
||||
// String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(),
|
||||
// event.getMessage());
|
||||
// buffered.add(full);
|
||||
// iter.remove();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
||||
@ -184,126 +184,127 @@ public class BukkitImageListener implements Listener {
|
||||
}
|
||||
|
||||
private void handleInteract(Event event, Player player, Entity entity, boolean primary) {
|
||||
if (!(entity instanceof ItemFrame)) {
|
||||
return;
|
||||
}
|
||||
ItemFrame itemFrame = (ItemFrame) entity;
|
||||
|
||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator();
|
||||
BukkitImageViewer viewer = get(generator);
|
||||
if (viewer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemFrame.getRotation() != Rotation.NONE) {
|
||||
itemFrame.setRotation(Rotation.NONE);
|
||||
}
|
||||
|
||||
LocalSession session = bukkitPlayer.getSession();
|
||||
BrushTool tool;
|
||||
try {
|
||||
tool = session.getBrushTool(bukkitPlayer, false);
|
||||
} catch (InvalidToolBindException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemFrame[][] frames = viewer.getItemFrames();
|
||||
if (frames == null || tool == null) {
|
||||
viewer.selectFrame(itemFrame);
|
||||
player.updateInventory();
|
||||
TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
||||
return;
|
||||
}
|
||||
|
||||
BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
|
||||
Brush brush = context.getBrush();
|
||||
if (brush == null) {
|
||||
return;
|
||||
}
|
||||
tool.setContext(context);
|
||||
|
||||
if (event instanceof Cancellable) {
|
||||
((Cancellable) event).setCancelled(true);
|
||||
}
|
||||
|
||||
Location target = itemFrame.getLocation();
|
||||
Location source = player.getLocation();
|
||||
|
||||
double yawRad = Math.toRadians(source.getYaw() + 90d);
|
||||
double pitchRad = Math.toRadians(-source.getPitch());
|
||||
|
||||
double a = Math.cos(pitchRad);
|
||||
double xRat = Math.cos(yawRad) * a;
|
||||
double zRat = Math.sin(yawRad) * a;
|
||||
|
||||
BlockFace facing = itemFrame.getFacing();
|
||||
double thickness = 1 / 32D + 1 / 128D;
|
||||
double modX = facing.getModX();
|
||||
double modZ = facing.getModZ();
|
||||
double dx = source.getX() - target.getX() - modX * thickness;
|
||||
double dy = source.getY() + player.getEyeHeight() - target.getY();
|
||||
double dz = source.getZ() - target.getZ() - modZ * thickness;
|
||||
|
||||
double offset;
|
||||
double localX;
|
||||
if (modX != 0) {
|
||||
offset = dx / xRat;
|
||||
localX = (-modX) * (dz - offset * zRat);
|
||||
} else {
|
||||
offset = dz / zRat;
|
||||
localX = (modZ) * (dx - offset * xRat);
|
||||
}
|
||||
double localY = dy - offset * Math.sin(pitchRad);
|
||||
int localPixelX = (int) ((localX + 0.5) * 128);
|
||||
int localPixelY = (int) ((localY + 0.5) * 128);
|
||||
|
||||
UUID uuid = itemFrame.getUniqueId();
|
||||
for (int blockX = 0; blockX < frames.length; blockX++) {
|
||||
for (int blockY = 0; blockY < frames[0].length; blockY++) {
|
||||
if (uuid.equals(frames[blockX][blockY].getUniqueId())) {
|
||||
int pixelX = localPixelX + blockX * 128;
|
||||
int pixelY = (128 * frames[0].length) - (localPixelY + blockY * 128 + 1);
|
||||
|
||||
int width = generator.getWidth();
|
||||
int length = generator.getLength();
|
||||
int worldX = (int) (pixelX * width / (frames.length * 128d));
|
||||
int worldZ = (int) (pixelY * length / (frames[0].length * 128d));
|
||||
|
||||
if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) {
|
||||
return;
|
||||
}
|
||||
|
||||
bukkitPlayer.runAction(() -> {
|
||||
BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
||||
viewer.refresh();
|
||||
int topY = generator
|
||||
.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255,
|
||||
0, 255);
|
||||
wPos = wPos.withY(topY);
|
||||
|
||||
EditSession es = new EditSessionBuilder(bukkitPlayer.getWorld()).player(bukkitPlayer)
|
||||
.combineStages(false).autoQueue(false).blockBag(null).limitUnlimited()
|
||||
.build();
|
||||
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||
Extent extent = last.get();
|
||||
if (extent instanceof IQueueExtent) {
|
||||
last = last.previous();
|
||||
}
|
||||
last.setNext(generator);
|
||||
try {
|
||||
brush.build(es, wPos, context.getMaterial(), context.getSize());
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
es.flushQueue();
|
||||
viewer.view(generator);
|
||||
}, true, true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//todo fix with cfi code 2020-02-04
|
||||
// if (!(entity instanceof ItemFrame)) {
|
||||
// return;
|
||||
// }
|
||||
// ItemFrame itemFrame = (ItemFrame) entity;
|
||||
//
|
||||
// BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
// HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator();
|
||||
// BukkitImageViewer viewer = get(generator);
|
||||
// if (viewer == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (itemFrame.getRotation() != Rotation.NONE) {
|
||||
// itemFrame.setRotation(Rotation.NONE);
|
||||
// }
|
||||
//
|
||||
// LocalSession session = bukkitPlayer.getSession();
|
||||
// BrushTool tool;
|
||||
// try {
|
||||
// tool = session.getBrushTool(bukkitPlayer, false);
|
||||
// } catch (InvalidToolBindException e) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ItemFrame[][] frames = viewer.getItemFrames();
|
||||
// if (frames == null || tool == null) {
|
||||
// viewer.selectFrame(itemFrame);
|
||||
// player.updateInventory();
|
||||
// TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
|
||||
// Brush brush = context.getBrush();
|
||||
// if (brush == null) {
|
||||
// return;
|
||||
// }
|
||||
// tool.setContext(context);
|
||||
//
|
||||
// if (event instanceof Cancellable) {
|
||||
// ((Cancellable) event).setCancelled(true);
|
||||
// }
|
||||
//
|
||||
// Location target = itemFrame.getLocation();
|
||||
// Location source = player.getLocation();
|
||||
//
|
||||
// double yawRad = Math.toRadians(source.getYaw() + 90d);
|
||||
// double pitchRad = Math.toRadians(-source.getPitch());
|
||||
//
|
||||
// double a = Math.cos(pitchRad);
|
||||
// double xRat = Math.cos(yawRad) * a;
|
||||
// double zRat = Math.sin(yawRad) * a;
|
||||
//
|
||||
// BlockFace facing = itemFrame.getFacing();
|
||||
// double thickness = 1 / 32D + 1 / 128D;
|
||||
// double modX = facing.getModX();
|
||||
// double modZ = facing.getModZ();
|
||||
// double dx = source.getX() - target.getX() - modX * thickness;
|
||||
// double dy = source.getY() + player.getEyeHeight() - target.getY();
|
||||
// double dz = source.getZ() - target.getZ() - modZ * thickness;
|
||||
//
|
||||
// double offset;
|
||||
// double localX;
|
||||
// if (modX != 0) {
|
||||
// offset = dx / xRat;
|
||||
// localX = (-modX) * (dz - offset * zRat);
|
||||
// } else {
|
||||
// offset = dz / zRat;
|
||||
// localX = (modZ) * (dx - offset * xRat);
|
||||
// }
|
||||
// double localY = dy - offset * Math.sin(pitchRad);
|
||||
// int localPixelX = (int) ((localX + 0.5) * 128);
|
||||
// int localPixelY = (int) ((localY + 0.5) * 128);
|
||||
//
|
||||
// UUID uuid = itemFrame.getUniqueId();
|
||||
// for (int blockX = 0; blockX < frames.length; blockX++) {
|
||||
// for (int blockY = 0; blockY < frames[0].length; blockY++) {
|
||||
// if (uuid.equals(frames[blockX][blockY].getUniqueId())) {
|
||||
// int pixelX = localPixelX + blockX * 128;
|
||||
// int pixelY = (128 * frames[0].length) - (localPixelY + blockY * 128 + 1);
|
||||
//
|
||||
// int width = generator.getWidth();
|
||||
// int length = generator.getLength();
|
||||
// int worldX = (int) (pixelX * width / (frames.length * 128d));
|
||||
// int worldZ = (int) (pixelY * length / (frames[0].length * 128d));
|
||||
//
|
||||
// if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// bukkitPlayer.runAction(() -> {
|
||||
// BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
||||
// viewer.refresh();
|
||||
// int topY = generator
|
||||
// .getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255,
|
||||
// 0, 255);
|
||||
// wPos = wPos.withY(topY);
|
||||
//
|
||||
// EditSession es = new EditSessionBuilder(bukkitPlayer.getWorld()).player(bukkitPlayer)
|
||||
// .combineStages(false).autoQueue(false).blockBag(null).limitUnlimited()
|
||||
// .build();
|
||||
// ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||
// Extent extent = last.get();
|
||||
// if (extent instanceof IQueueExtent) {
|
||||
// last = last.previous();
|
||||
// }
|
||||
// last.setNext(generator);
|
||||
// try {
|
||||
// brush.build(es, wPos, context.getMaterial(), context.getSize());
|
||||
// } catch (WorldEditException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// es.flushQueue();
|
||||
// viewer.view(generator);
|
||||
// }, true, true);
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe.bukkit.listener;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.command.CFICommands;
|
||||
import com.boydti.fawe.object.RunnableVal3;
|
||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
@ -262,10 +261,10 @@ public class CFIPacketListener implements Listener {
|
||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
VirtualWorld vw = bukkitPlayer.getSession().getVirtualWorld();
|
||||
if (vw != null) return vw;
|
||||
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) {
|
||||
return settings.getGenerator();
|
||||
}
|
||||
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
// if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) {
|
||||
// return settings.getGenerator();
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user