Skip to content

Commit efd094c

Browse files
author
BuildTools
committed
fixed shift crafting, and added a tp sfx
1 parent cb3b180 commit efd094c

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group = 'ep1n'
7-
version = '1.0'
7+
version = '1.1'
88

99
repositories {
1010
mavenCentral()

src/main/java/ep1n/endRelay/EventManager.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.bukkit.event.inventory.CraftItemEvent;
2626
import org.bukkit.event.inventory.PrepareItemCraftEvent;
2727
import org.bukkit.event.player.PlayerInteractEvent;
28+
import org.bukkit.event.player.PlayerTeleportEvent;
2829
import org.bukkit.inventory.ItemFlag;
2930
import org.bukkit.inventory.ItemStack;
3031
import org.bukkit.inventory.meta.BlockDataMeta;
@@ -94,12 +95,12 @@ public void playerInteractRelayEvent (PlayerInteractEvent ev) {
9495
Location loq = baseLoq.clone();
9596
if (ev.getPlayer().getWorld().getKey().equals(loq.getWorld().getKey()) && ev.getPlayer().getWorld().getKey().asString().equalsIgnoreCase("minecraft:the_end")) {
9697
if (loq.getBlock().getType().equals(Material.LODESTONE)) {
97-
ev.getPlayer().teleport(loq.add(.5, 1, .5).setDirection(ev.getPlayer().getLocation().getDirection()));
98+
ev.getPlayer().teleport(loq.add(.5, 1, .5).setDirection(ev.getPlayer().getLocation().getDirection()), PlayerTeleportEvent.TeleportCause.PLUGIN);
9899
ev.getClickedBlock().setType(Material.DEAD_HORN_CORAL_BLOCK);
99100
ev.setUseItemInHand(Event.Result.ALLOW);
100101
ev.getClickedBlock().getWorld().playSound(ev.getClickedBlock().getLocation(), Sound.BLOCK_RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, 1F, 1F);
101102
BukkitTask tpTask = new TpSfxTask(ev.getPlayer()).runTaskLater(EndRelay.instance, 1);
102-
Bukkit.getLogger().info(ev.getPlayer().getName() + " just teleported, if there's some kind of \"moved too quickly\" error.");
103+
Bukkit.getLogger().warning("vvvvvvv " + ev.getPlayer().getName() + " just teleported, ignore the potential \"moved too quickly\" error below.");
103104
} else {
104105
//no lodestone
105106
ev.getClickedBlock().setType(Material.DEAD_HORN_CORAL_BLOCK);
@@ -153,6 +154,16 @@ public void onCraftAnchor(CraftItemEvent ev) {
153154
if (!compass.getWorld().equals(ev.getView().getPlayer().getWorld())) ev.getView().getPlayer().getLocation().createExplosion(7F);
154155
ItemStack item = new ItemStack(EndRelay.instance.endAnchor.getType());
155156
ItemMeta meta = item.getItemMeta();
157+
if (ev.isShiftClick()) {
158+
int count = 64;
159+
for(ItemStack it : ev.getInventory().getMatrix()) {
160+
if (it.getAmount() < count) count = it.getAmount();
161+
}
162+
item.setAmount(count);
163+
for(ItemStack ite : ev.getInventory().getMatrix()) {
164+
ite.setAmount(ite.getAmount() - count);
165+
}
166+
}
156167
meta.customName(Component.text("End Relay").style(Style.style(TextDecoration.ITALIC)));
157168
item.setItemMeta(meta);
158169
item.setData(DataComponentTypes.LODESTONE_TRACKER, LodestoneTracker.lodestoneTracker(compass, true));

src/main/java/ep1n/endRelay/TpSfxTask.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package ep1n.endRelay;
22

3+
import org.bukkit.Bukkit;
34
import org.bukkit.Sound;
45
import org.bukkit.SoundCategory;
56
import org.bukkit.entity.Player;
@@ -16,5 +17,6 @@ public TpSfxTask(Player p) {
1617
@Override
1718
public void run() {
1819
p.playSound(p, Sound.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1F, 1F);
20+
Bukkit.getLogger().warning("^^^^^^^ " + p.getName() + " just teleported, ignore the potential \"moved too quickly\" error above.");
1921
}
2022
}

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: EndRelay
2-
version: '1.0'
2+
version: '1.1'
33
main: ep1n.endRelay.EndRelay
44
api-version: '1.21'
55
authors: [ Ep1n ]

0 commit comments

Comments
 (0)