plugin: remove hologramapi support. too tacky.

This commit is contained in:
Torrie Fischer 2021-06-10 23:06:36 -07:00
parent 2d5a171f72
commit 2fd43aba13
2 changed files with 0 additions and 151 deletions

View File

@ -45,7 +45,6 @@ public class Plugin extends JavaPlugin {
Logger log = Logger.getLogger("Regions");
RegionManager m_regions;
PlayerWatcher m_playerWatcher;
RegionPostManager m_regionPosts;
public RegionManager regionManager() {
return m_regions;
@ -65,14 +64,6 @@ public class Plugin extends JavaPlugin {
getCommand("regions").setExecutor(new RegionsCommand(this));
getCommand("regionop").setExecutor(new RegionOpCommand(this));
boolean useHolograms = getServer().getPluginManager().isPluginEnabled("HolographicDisplays");
if (!useHolograms) {
log.info("HolographicDisplays not enabled. Region posts will not have holograms.");
}
m_regionPosts = new RegionPostManager(m_regions, this, useHolograms);
// TODO: Make holograms configurable. Disabled by default for now.
//getServer().getPluginManager().registerEvents(m_regionPosts, this);
loadRegions();
m_playerWatcher.recalculatePlayerRegions(true);
org.bukkit.plugin.Plugin mapPlugin = getServer().getPluginManager().getPlugin("dynmap");
@ -120,7 +111,6 @@ public class Plugin extends JavaPlugin {
}
public void onDisable() {
m_regionPosts.release();
saveRegions();
log.info("Plugin disabled");
}

View File

@ -1,141 +0,0 @@
package us.camin.regions;
/**
* This file is part of Regions
*
* Regions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Regions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Regions. If not, see <http://www.gnu.org/licenses/>.
*
*/
import org.bukkit.event.Listener;
import org.bukkit.event.EventHandler;
import org.bukkit.Location;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.logging.Logger;
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
import us.camin.regions.events.PlayerNearRegionPostEvent;
import us.camin.regions.events.RegionCreateEvent;
import us.camin.regions.events.RegionRemoveEvent;
import us.camin.regions.ui.RegionPostBuilder;
import com.gmail.filoghost.holographicdisplays.api.Hologram;
public class RegionPostManager implements Listener {
Logger log = Logger.getLogger("Regions.RegionPostManager");
Plugin m_plugin;
RegionManager m_regions;
boolean m_useHolograms;
HashMap<Region, Hologram> m_regionHolograms;
//HashMap<Region, ArmorStand> m_armorStands;
public RegionPostManager(RegionManager regions, Plugin plugin, boolean useHolograms) {
//m_armorStands = new HashMap<Region, ArmorStand>();
m_regions = regions;
m_plugin = plugin;
m_useHolograms = useHolograms;
m_regionHolograms = new HashMap<>();
}
@EventHandler
public void onRegionCreate(RegionCreateEvent event) {
Location loc = event.region.location();
if (loc.getWorld().isChunkLoaded((int)loc.getX(), (int)loc.getY())) {
createHologram(event.region);
queueRebuild(event.region);
}
}
@EventHandler
public void onPlayerNearRegionPost(PlayerNearRegionPostEvent event) {
createHologram(event.region);
}
private void queueRebuild(Region region) {
if (region != null) {
log.info("Rebuilding region post for " + region.name());
m_plugin.getServer().getScheduler().runTask(m_plugin, () -> {
RegionPostBuilder builder = new RegionPostBuilder(region, m_plugin);
builder.build();
});
}
}
@EventHandler
public void onRegionDestroy(RegionRemoveEvent event) {
destroyHologram(event.region);
}
public void release() {
for(Region r : new ArrayList<>(m_regionHolograms.keySet())) {
destroyHologram(r);
}
/*for(Region r : new ArrayList<>(m_armorStands.keySet())) {
destroyHologram(r);
}*/
}
private void createHologram(Region r) {
if (!m_useHolograms) {
return;
}
Hologram hologram = m_regionHolograms.get(r);
if (hologram == null) {
hologram = HologramsAPI.createHologram(m_plugin, r.teleportLocation().clone().add(0.5, 0, 0.5));
hologram.appendTextLine(r.coloredName());
m_regionHolograms.put(r, hologram);
}
/*boolean needsRegen = false;
if (m_armorStands.containsKey(r)) {
// If we have an armor stand, but it isn't valid, regen
needsRegen = !m_armorStands.get(r).isValid();
} else {
// If we don't have an armor stand at all, regen
needsRegen = true;
}
if (needsRegen) {
log.info("Creating hologram for " + r.name());
Location markerLocation = r.teleportLocation().clone().add(0.5, 0, 0.5);
ArmorStand stand = (ArmorStand) r.location().getWorld().spawnEntity(markerLocation, EntityType.ARMOR_STAND);
stand.setVisible(false);
stand.setCustomName(r.coloredName());
stand.setMarker(true);
stand.setSmall(true);
stand.setRemoveWhenFarAway(true);
stand.setCustomNameVisible(true);
stand.setInvulnerable(true);
stand.setSilent(true);
m_armorStands.put(r, stand);
}*/
}
private void destroyHologram(Region r) {
if (!m_useHolograms) {
return;
}
Hologram hologram = m_regionHolograms.get(r);
if (hologram != null) {
hologram.delete();
}
/*log.info("Destroying hologram for " + r.name());
ArmorStand stand = m_armorStands.get(r);
if (stand != null && stand.isValid()) {
stand.remove();
}
m_armorStands.remove(r);*/
}
}