use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.
the class PlayerLocationManager method onSpawn.
@EventHandler
public void onSpawn(PlayerRespawnEvent e) {
Player player = e.getPlayer();
Location loc = player.getLocation();
SimpleLocation sloc = LocationUtil.convertToSimpleLocation(loc);
setCurrentBlockLocation(player.getUniqueId(), sloc);
}
use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.
the class LocationBasedTriggerManager method setTriggerForLocation.
protected void setTriggerForLocation(Location loc, T trigger) {
SimpleLocation sloc = LocationUtil.convertToSimpleLocation(loc);
setTriggerForLocation(sloc, trigger);
}
use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.
the class JavaPluginBridge method showGlowStones.
@Override
@SuppressWarnings("deprecation")
protected void showGlowStones(ICommandSender sender, Set<Entry<SimpleLocation, Trigger>> set) {
for (Entry<SimpleLocation, Trigger> entry : set) {
SimpleLocation sloc = entry.getKey();
Player player = sender.get();
player.sendBlockChange(new Location(Bukkit.getWorld(sloc.getWorld()), sloc.getX(), sloc.getY(), sloc.getZ()), Material.GLOWSTONE, (byte) 0);
}
}
use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.
the class AreaSelectionManager method onInteract.
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
UUID uuid = player.getUniqueId();
if (!selecting.contains(uuid))
return;
e.setCancelled(true);
if (!BukkitUtil.isLeftHandClick(e))
return;
SimpleLocation sloc = LocationUtil.convertToSimpleLocation(e.getClickedBlock().getLocation());
ClickResult result = null;
if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
result = onClick(ClickAction.LEFT_CLICK_BLOCK, uuid, sloc);
} else if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
result = onClick(ClickAction.RIGHT_CLICK_BLOCK, uuid, sloc);
}
if (result != null) {
switch(result) {
case DIFFERENTWORLD:
player.sendMessage(ChatColor.RED + "Positions have different world name.");
break;
case COMPLETE:
SimpleLocation left = leftPosition.get(uuid);
SimpleLocation right = rightPosition.get(uuid);
SimpleLocation smallest = getSmallest(left, right);
SimpleLocation largest = getLargest(left, right);
player.sendMessage(ChatColor.LIGHT_PURPLE + "Smallest: " + smallest + " , Largest: " + largest);
break;
case LEFTSET:
player.sendMessage(ChatColor.GREEN + "Left ready");
break;
case RIGHTSET:
player.sendMessage(ChatColor.GREEN + "Right ready");
break;
}
}
}
use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.
the class AbstractAreaTriggerManager method reload.
@Override
public void reload() {
FileFilter filter = new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().endsWith(".yml");
}
};
areaTriggers.clear();
for (File ymlfile : folder.listFiles(filter)) {
String triggerName = extractName(ymlfile);
SimpleLocation smallest = null;
SimpleLocation largest = null;
boolean isSync = false;
try {
smallest = SimpleLocation.valueOf(getData(ymlfile, SMALLEST));
largest = SimpleLocation.valueOf(getData(ymlfile, LARGEST));
isSync = getData(ymlfile, SYNC, false);
} catch (IOException e) {
e.printStackTrace();
plugin.getLogger().warning("Could not load Area Trigger " + ymlfile);
continue;
}
if (smallest == null || largest == null) {
plugin.getLogger().warning("Could not load Area Trigger" + ymlfile);
plugin.getLogger().warning("Could not find Smallest: or Largest:");
continue;
}
File scriptFolder = new File(folder, triggerName);
if (!scriptFolder.exists()) {
scriptFolder.mkdirs();
}
String enterScript = null;
File enterFile = null;
try {
enterFile = getTriggerFile(scriptFolder, "Enter.trg");
enterScript = FileUtil.readFromFile(enterFile);
} catch (IOException e1) {
e1.printStackTrace();
continue;
}
String exitScript = null;
File exitFile = null;
try {
exitFile = getTriggerFile(scriptFolder, "Exit.trg");
exitScript = FileUtil.readFromFile(exitFile);
} catch (IOException e1) {
e1.printStackTrace();
continue;
}
Area area = new Area(smallest, largest);
AreaTrigger trigger = new AreaTrigger(area, scriptFolder, triggerName);
trigger.setSync(isSync);
nameMapper.put(triggerName, trigger);
this.setupArea(trigger);
try {
if (enterScript != null) {
trigger.setEnterTrigger(enterScript);
}
} catch (TriggerInitFailedException e) {
e.printStackTrace();
continue;
}
try {
if (exitScript != null) {
trigger.setExitTrigger(exitScript);
}
} catch (TriggerInitFailedException e) {
e.printStackTrace();
continue;
}
}
}
Aggregations