Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
dfaa04d0c4
@ -24,6 +24,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.Openable;
|
||||||
import org.bukkit.block.data.Powerable;
|
import org.bukkit.block.data.Powerable;
|
||||||
import org.bukkit.block.data.type.Switch;
|
import org.bukkit.block.data.type.Switch;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@ -48,11 +49,18 @@ class AutoLoader_15 {
|
|||||||
if (!(data instanceof Powerable))
|
if (!(data instanceof Powerable))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
Powerable powerable = (Powerable) data;
|
Powerable powerable = (Powerable) data;
|
||||||
powerable.setPowered(active);
|
powerable.setPowered(active);
|
||||||
block.setBlockData(powerable);
|
block.setBlockData(powerable);
|
||||||
|
|
||||||
if (data instanceof Switch){
|
if(data instanceof Openable) {
|
||||||
|
Openable openable = (Openable) data;
|
||||||
|
openable.setOpen(active);
|
||||||
|
block.setBlockData(openable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data instanceof Switch) {
|
||||||
Switch swtch = (Switch) data;
|
Switch swtch = (Switch) data;
|
||||||
Block relative;
|
Block relative;
|
||||||
switch(swtch.getFace()){
|
switch(swtch.getFace()){
|
||||||
@ -67,7 +75,7 @@ class AutoLoader_15 {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
updateBlock(relative);
|
updateBlock(relative);
|
||||||
}else if(block.getType() == Material.TRIPWIRE) {
|
} else if(block.getType() == Material.TRIPWIRE) {
|
||||||
updateBlock(block);
|
updateBlock(block);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -90,11 +98,7 @@ class AutoLoader_15 {
|
|||||||
Material material = block.getType();
|
Material material = block.getType();
|
||||||
|
|
||||||
if (material == Material.LEVER) {
|
if (material == Material.LEVER) {
|
||||||
if (powerable.isPowered()) {
|
return new Detoloader("Hebel", 0).setActive(!powerable.isPowered());
|
||||||
return new Detoloader("Hebel", 0).setActive(false);
|
|
||||||
} else {
|
|
||||||
return new Detoloader("Hebel", 0).setActive(true);
|
|
||||||
}
|
|
||||||
} else if (material == Material.STONE_BUTTON) {
|
} else if (material == Material.STONE_BUTTON) {
|
||||||
return new Detoloader("Knopf", Detoloader.STONE_BUTTON);
|
return new Detoloader("Knopf", Detoloader.STONE_BUTTON);
|
||||||
} else if (material.name().contains("PRESSURE_PLATE")){
|
} else if (material.name().contains("PRESSURE_PLATE")){
|
||||||
@ -111,6 +115,8 @@ class AutoLoader_15 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean getLever(Block block) {
|
static boolean getLever(Block block) {
|
||||||
return ((Powerable)block.getBlockData()).isPowered();
|
if(!(block.getBlockData() instanceof Powerable))
|
||||||
|
return false;
|
||||||
|
return ((Powerable) block.getBlockData()).isPowered();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,5 +83,5 @@ public class Detoloader {
|
|||||||
public static final int WOODEN_BUTTON = 30;
|
public static final int WOODEN_BUTTON = 30;
|
||||||
public static final int PRESSURE_PLATE = 20;
|
public static final int PRESSURE_PLATE = 20;
|
||||||
public static final int NOTE_BLOCK = 1;
|
public static final int NOTE_BLOCK = 1;
|
||||||
public static final int TRIPWIRE = 10;
|
public static final int TRIPWIRE = 20;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ public class CommandDetonator implements CommandExecutor {
|
|||||||
player.sendMessage("§8/§edetonator wand §8- §7Legt den Fernzünder ins Inventar");
|
player.sendMessage("§8/§edetonator wand §8- §7Legt den Fernzünder ins Inventar");
|
||||||
player.sendMessage("§8/§edetonator detonate §8- §7Benutzt den Fernzünder");
|
player.sendMessage("§8/§edetonator detonate §8- §7Benutzt den Fernzünder");
|
||||||
player.sendMessage("§8/§edetonator reset §8- §7Löscht alle markierten Positionen");
|
player.sendMessage("§8/§edetonator reset §8- §7Löscht alle markierten Positionen");
|
||||||
|
player.sendMessage("§8/§edetonator remove §8- §7Entfernt den Fernzünder");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean permissionCheck(Player player) {
|
private boolean permissionCheck(Player player) {
|
||||||
@ -65,16 +66,20 @@ public class CommandDetonator implements CommandExecutor {
|
|||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
Detonator.getDetonator(player);
|
Detonator.getDetonator(player);
|
||||||
break;
|
break;
|
||||||
case "delete":
|
|
||||||
case "reset":
|
|
||||||
case "remove":
|
case "remove":
|
||||||
Detonator.deleteDetonator(player);
|
Detonator.deleteDetonator(player);
|
||||||
|
player.getInventory().removeItem(Detonator.WAND);
|
||||||
break;
|
break;
|
||||||
case "detonate":
|
case "detonate":
|
||||||
case "click":
|
case "click":
|
||||||
case "use":
|
case "use":
|
||||||
Detonator.getDetonator(player).execute();
|
Detonator.getDetonator(player).execute();
|
||||||
break;
|
break;
|
||||||
|
case "clear":
|
||||||
|
case "delete":
|
||||||
|
case "reset":
|
||||||
|
Detonator.getDetonator(player).clearLocs();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
help(player);
|
help(player);
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public class CommandDetonatorTabCompleter implements TabCompleter {
|
|||||||
tabComplete.add("wand");
|
tabComplete.add("wand");
|
||||||
tabComplete.add("reset");
|
tabComplete.add("reset");
|
||||||
tabComplete.add("detonate");
|
tabComplete.add("detonate");
|
||||||
|
tabComplete.add("remove");
|
||||||
|
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
@ -21,6 +21,7 @@ package de.steamwar.bausystem.world;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.core.VersionedCallable;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -64,6 +65,7 @@ public class AutoLoader extends IAutoLoader implements Listener {
|
|||||||
private int waitTicks;
|
private int waitTicks;
|
||||||
private ListIterator<LoaderAction> lastAction;
|
private ListIterator<LoaderAction> lastAction;
|
||||||
private boolean setup;
|
private boolean setup;
|
||||||
|
private Location lastLocation;
|
||||||
|
|
||||||
private AutoLoader(Player player){
|
private AutoLoader(Player player){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@ -163,28 +165,28 @@ public class AutoLoader extends IAutoLoader implements Listener {
|
|||||||
if (event.getPlayer().isSneaking())
|
if (event.getPlayer().isSneaking())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!setup || !event.getPlayer().equals(player))
|
if (!setup || !event.getPlayer().equals(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Detoloader detoloader = null;
|
Detoloader detoloader = VersionedCallable.call(
|
||||||
switch(Core.getVersion()){
|
new VersionedCallable<>(() -> AutoLoader_12.onPlayerInteractLoader(event), 12),
|
||||||
case 15:
|
new VersionedCallable<>(() -> AutoLoader_15.onPlayerInteractLoader(event), 15));
|
||||||
detoloader = AutoLoader_15.onPlayerInteractLoader(event);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
detoloader = AutoLoader_12.onPlayerInteractLoader(event);
|
|
||||||
|
|
||||||
}
|
if (detoloader == null || detoloader.getActivation() < 0) return;
|
||||||
if(detoloader == null || detoloader.getActivation() < 0) return;
|
|
||||||
if(detoloader.useActive)
|
if (lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) return;
|
||||||
|
|
||||||
|
if (detoloader.useActive) {
|
||||||
new IAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation()
|
new IAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation()
|
||||||
, detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation()
|
, detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation()
|
||||||
, detoloader.isActive());
|
, detoloader.isActive());
|
||||||
else
|
} else {
|
||||||
new IAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation()
|
new IAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation()
|
||||||
, detoloader.getActivation());
|
, detoloader.getActivation());
|
||||||
|
}
|
||||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " betätigt" :
|
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " betätigt" :
|
||||||
detoloader.getBlock(), detoloader.addBack);
|
detoloader.getBlock(), detoloader.addBack);
|
||||||
|
lastLocation = event.getClickedBlock().getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -20,13 +20,15 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.VersionedCallable;
|
||||||
|
import de.steamwar.core.VersionedRunnable;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
@ -58,8 +60,8 @@ public class Detonator implements Listener {
|
|||||||
WAND.setItemMeta(im);
|
WAND.setItemMeta(im);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Detonator getDetonator(Player player){
|
public static Detonator getDetonator(Player player) {
|
||||||
if(!players.containsKey(player))
|
if (!players.containsKey(player))
|
||||||
return new Detonator(player);
|
return new Detonator(player);
|
||||||
return players.get(player);
|
return players.get(player);
|
||||||
}
|
}
|
||||||
@ -71,37 +73,29 @@ public class Detonator implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteDetonator(Player player) {
|
public static void deleteDetonator(Player player) {
|
||||||
if(players.containsKey(player))
|
if (players.containsKey(player))
|
||||||
players.remove(player);
|
HandlerList.unregisterAll(players.remove(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute() {
|
public void execute() {
|
||||||
for (Detoloader.DetonatorActivation activation: getLocations()) {
|
for (Detoloader.DetonatorActivation activation : getLocations()) {
|
||||||
|
|
||||||
Boolean powered;
|
if (activation.activation == -1) {
|
||||||
if(activation.activation == -1) switch (Core.getVersion()) {
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
case 15:
|
boolean powered = AutoLoader_12.getLever(activation.location.getBlock());
|
||||||
try {
|
|
||||||
powered = AutoLoader_15.getLever(activation.location.getBlock());
|
|
||||||
}catch (ClassCastException e) {
|
|
||||||
locs.remove(activation);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AutoLoader_15.setRedstone(activation.location, !powered);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
powered = AutoLoader_12.getLever(activation.location.getBlock());
|
|
||||||
AutoLoader_12.setRedstone(activation.location, !powered);
|
AutoLoader_12.setRedstone(activation.location, !powered);
|
||||||
}else switch (Core.getVersion()) {
|
}, 12), new VersionedRunnable(() -> {
|
||||||
case 15:
|
boolean powered = AutoLoader_15.getLever(activation.location.getBlock());
|
||||||
AutoLoader_15.setRedstone(activation.location, true);
|
AutoLoader_15.setRedstone(activation.location, !powered);
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () ->
|
}, 15));
|
||||||
AutoLoader_15.setRedstone(activation.location, false), activation.activation);
|
} else {
|
||||||
break;
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
default:
|
|
||||||
AutoLoader_12.setRedstone(activation.location, true);
|
AutoLoader_12.setRedstone(activation.location, true);
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () ->
|
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> AutoLoader_12.setRedstone(activation.location, false), activation.activation);
|
||||||
AutoLoader_12.setRedstone(activation.location, false), activation.activation);
|
}, 12), new VersionedRunnable(() -> {
|
||||||
|
AutoLoader_15.setRedstone(activation.location, true);
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> AutoLoader_15.setRedstone(activation.location, false), activation.activation);
|
||||||
|
}, 15));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§a" + locs.size() + " Punkt" + (locs.size() > 1 ? "e" : "") + " ausgelöst!"));
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§a" + locs.size() + " Punkt" + (locs.size() > 1 ? "e" : "") + " ausgelöst!"));
|
||||||
@ -109,49 +103,51 @@ public class Detonator implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if(!event.getPlayer().equals(player))
|
if (!event.getPlayer().equals(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getItem() == null) return;
|
if (event.getItem() == null) return;
|
||||||
if (event.getItem().isSimilar(WAND)) {
|
if (event.getItem().isSimilar(WAND)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case LEFT_CLICK_BLOCK:
|
case LEFT_CLICK_BLOCK:
|
||||||
Detoloader detoloader;
|
Detoloader detoloader = VersionedCallable.call(
|
||||||
switch(Core.getVersion()){
|
new VersionedCallable<>(() -> AutoLoader_12.onPlayerInteractLoader(event), 12),
|
||||||
case 15:
|
new VersionedCallable<>(() -> AutoLoader_15.onPlayerInteractLoader(event), 15));
|
||||||
detoloader = AutoLoader_15.onPlayerInteractLoader(event);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
detoloader = AutoLoader_12.onPlayerInteractLoader(event);
|
|
||||||
|
|
||||||
|
if (detoloader == null) {
|
||||||
|
return;
|
||||||
|
} else if (detoloader.activation == -1) {
|
||||||
|
print(detoloader.getBlock(), detoloader.addBack);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(detoloader == null || detoloader.activation == -1) return;
|
|
||||||
|
|
||||||
if(event.getPlayer().isSneaking()) {
|
|
||||||
if(locs.stream().filter(detonatorActivation -> detonatorActivation.location.equals(event.getClickedBlock().getLocation())).collect(Collectors.toList()).size() == 1) {
|
if (event.getPlayer().isSneaking()) {
|
||||||
|
if (locs.stream().filter(detonatorActivation -> detonatorActivation.location.equals(event.getClickedBlock().getLocation())).collect(Collectors.toList()).size() == 1) {
|
||||||
locs.removeIf(detonatorActivation -> detonatorActivation.location.equals(event.getClickedBlock().getLocation()));
|
locs.removeIf(detonatorActivation -> detonatorActivation.location.equals(event.getClickedBlock().getLocation()));
|
||||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" :
|
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" :
|
||||||
detoloader.getBlock(), detoloader.addBack);
|
detoloader.getBlock(), detoloader.addBack);
|
||||||
}else {
|
} else {
|
||||||
if(detoloader.getActivation() == 0) {
|
if (detoloader.getActivation() == 0) {
|
||||||
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
||||||
}else {
|
} else {
|
||||||
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
||||||
}
|
}
|
||||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" :
|
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" :
|
||||||
detoloader.getBlock(), detoloader.addBack);
|
detoloader.getBlock(), detoloader.addBack);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
locs.clear();
|
locs.clear();
|
||||||
if(detoloader.getActivation() == 0) {
|
if (detoloader.getActivation() == 0) {
|
||||||
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
||||||
}else {
|
} else {
|
||||||
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
||||||
}
|
}
|
||||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " getsetzt" :
|
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " getsetzt" :
|
||||||
detoloader.getBlock(), detoloader.addBack);
|
detoloader.getBlock(), detoloader.addBack);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
case RIGHT_CLICK_BLOCK:
|
case RIGHT_CLICK_BLOCK:
|
||||||
execute();
|
execute();
|
||||||
@ -162,7 +158,8 @@ public class Detonator implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
deleteDetonator(event.getPlayer());
|
if (event.getPlayer().equals(player))
|
||||||
|
deleteDetonator(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Detoloader.DetonatorActivation> getLocations() {
|
Set<Detoloader.DetonatorActivation> getLocations() {
|
||||||
@ -173,10 +170,15 @@ public class Detonator implements Listener {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(String message, boolean withSize){
|
public void clearLocs() {
|
||||||
if(withSize)
|
locs.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(String message, boolean withSize) {
|
||||||
|
if (withSize) {
|
||||||
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + getLocations().size()));
|
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + getLocations().size()));
|
||||||
else
|
}else {
|
||||||
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren