Skip to content

Commit

Permalink
move a pile of things to core
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 19, 2021
1 parent 0eb9c06 commit 24f8ed6
Show file tree
Hide file tree
Showing 36 changed files with 128 additions and 525 deletions.
33 changes: 4 additions & 29 deletions plugin/src/main/java/com/denizenscript/denizen/Denizen.java
Expand Up @@ -4,12 +4,10 @@
import com.denizenscript.denizen.events.bukkit.SavesReloadEvent;
import com.denizenscript.denizen.events.server.ServerPrestartScriptEvent;
import com.denizenscript.denizen.events.server.ServerStartScriptEvent;
import com.denizenscript.denizen.events.server.ServerStopScriptEvent;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.InventoryTag;
import com.denizenscript.denizen.objects.NPCTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizen.objects.notable.NotableManager;
import com.denizenscript.denizen.objects.properties.PropertyRegistry;
import com.denizenscript.denizen.scripts.commands.BukkitCommandRegistry;
import com.denizenscript.denizen.scripts.commands.player.ClickableCommand;
Expand Down Expand Up @@ -88,16 +86,9 @@ public static Denizen getInstance() {

public CommandManager commandManager;

public BukkitCommandRegistry commandRegistry;
public TriggerRegistry triggerRegistry;
public DenizenNPCHelper npcHelper;

@Deprecated
public BukkitCommandRegistry getCommandRegistry() {
return commandRegistry;
}

public TagManager tagManager;
public OldEventManager eventManager;

public BukkitWorldScriptHelper worldScriptHelper;
Expand All @@ -106,14 +97,8 @@ public BukkitCommandRegistry getCommandRegistry() {

public ExCommandHandler exCommand;

public final static long startTime = System.currentTimeMillis();

public DenizenCoreImplementation coreImplementation = new DenizenCoreImplementation();

public SavableMapFlagTracker serverFlagMap;

public long lastReloadTime;

/*
* Sets up Denizen on start of the CraftBukkit server.
*/
Expand Down Expand Up @@ -170,9 +155,8 @@ else if (javaVersion.startsWith("9") || javaVersion.startsWith("1.9") || javaVer
+ " If this message appears with both Denizen and Spigot fully up-to-date, contact the Denizen team (via GitHub, Spigot, or Discord) to request an update be built.");
getLogger().warning("-------------------------------------");
}
commandRegistry = new BukkitCommandRegistry();
BukkitCommandRegistry commandRegistry = new BukkitCommandRegistry();
triggerRegistry = new TriggerRegistry();
tagManager = new TagManager();
boolean citizensBork = false;
try {
// Activate dependencies
Expand Down Expand Up @@ -338,7 +322,7 @@ else if (javaVersion.startsWith("9") || javaVersion.startsWith("1.9") || javaVer
}
try {
AdjustCommand.specialAdjustables.put("server", ServerTagBase::adjustServer);
tagManager.registerCoreTags();
TagManager.registerCoreTags();
CommonRegistries.registerMainTagHandlers();
eventManager = new OldEventManager();
// Register all the modern script events
Expand Down Expand Up @@ -418,8 +402,6 @@ else if (javaVersion.startsWith("9") || javaVersion.startsWith("1.9") || javaVer
}
try {
exCommand.processTagList();
// Reload notes from file
NotableManager.reload();
// Process script files (events, etc).
DenizenCore.postLoadScripts();
Debug.log(ChatColor.LIGHT_PURPLE + "+-------------------------+");
Expand Down Expand Up @@ -495,13 +477,10 @@ public void onDisable() {
return;
}
hasDisabled = true;
ServerStopScriptEvent.instance.fire();
NotableManager.save();
DenizenCore.shutdown();
ScoreboardHelper._saveScoreboards();
InventoryScriptHelper._savePlayerInventories();
commandRegistry.disableCoreMembers();
triggerRegistry.disableCoreMembers();
DenizenCore.logInterceptor.standardOutput();
getLogger().log(Level.INFO, " v" + getDescription().getVersion() + " disabled.");
Bukkit.getServer().getScheduler().cancelTasks(this);
HandlerList.unregisterAll(this);
Expand Down Expand Up @@ -533,8 +512,7 @@ public void reloadSaves() {
ScoreboardHelper._recallScoreboards();
// Load maps from maps.yml
DenizenMapManager.reloadMaps();
// Reload server flags
serverFlagMap = SavableMapFlagTracker.loadFlagFile(new File(getDataFolder(), "server_flags").getPath());
DenizenCore.reloadSaves();
if (worldFlags == null) {
worldFlags = new WorldFlagHandler();
}
Expand All @@ -555,14 +533,11 @@ public FileConfiguration getScoreboards() {
}

public void saveSaves(boolean canSleep) {
// Save notes
NotableManager.save();
// Save scoreboards to scoreboards.yml
ScoreboardHelper._saveScoreboards();
// Save maps to maps.yml
DenizenMapManager.saveMaps();
// Save server flags
serverFlagMap.saveToFile(new File(getDataFolder(), "server_flags").getPath());
try {
scoreboardsConfig.save(scoreboardsConfigFile);
}
Expand Down
Expand Up @@ -2,7 +2,6 @@

import com.denizenscript.denizen.Denizen;
import com.denizenscript.denizen.objects.*;
import com.denizenscript.denizen.objects.notable.NotableManager;
import com.denizenscript.denizen.scripts.containers.core.EntityScriptHelper;
import com.denizenscript.denizen.scripts.containers.core.InventoryScriptHelper;
import com.denizenscript.denizen.scripts.containers.core.ItemScriptHelper;
Expand All @@ -12,6 +11,7 @@
import com.denizenscript.denizencore.flags.AbstractFlagTracker;
import com.denizenscript.denizencore.objects.core.ScriptTag;
import com.denizenscript.denizencore.objects.notable.Notable;
import com.denizenscript.denizencore.objects.notable.NoteManager;
import com.denizenscript.denizencore.tags.TagContext;
import com.denizenscript.denizencore.utilities.Deprecations;
import com.denizenscript.denizencore.utilities.debugging.Debug;
Expand Down Expand Up @@ -109,12 +109,12 @@ public boolean couldMatchArea(String text) {
if (text.startsWith("area_flagged:") || text.startsWith("biome:")) {
return true;
}
if (NotableManager.getSavedObject(text) instanceof AreaContainmentObject) {
if (NoteManager.getSavedObject(text) instanceof AreaContainmentObject) {
return true;
}
if (isAdvancedMatchable(text)) {
MatchHelper matcher = createMatcher(text);
for (Notable obj : NotableManager.nameToObject.values()) {
for (Notable obj : NoteManager.nameToObject.values()) {
if (obj instanceof AreaContainmentObject && matcher.doesMatch(((AreaContainmentObject) obj).getNoteName())) {
return true;
}
Expand Down Expand Up @@ -653,17 +653,17 @@ else if (lower.startsWith("chunk_flagged:")) {
}
else if (lower.startsWith("area_flagged:")) {
String flagName = inputText.substring("area_flagged:".length());
for (CuboidTag cuboid : NotableManager.getAllType(CuboidTag.class)) {
for (CuboidTag cuboid : NoteManager.getAllType(CuboidTag.class)) {
if (cuboid.isInsideCuboid(location) && cuboid.flagTracker.hasFlag(flagName)) {
return true;
}
}
for (EllipsoidTag ellipsoid : NotableManager.getAllType(EllipsoidTag.class)) {
for (EllipsoidTag ellipsoid : NoteManager.getAllType(EllipsoidTag.class)) {
if (ellipsoid.contains(location) && ellipsoid.flagTracker.hasFlag(flagName)) {
return true;
}
}
for (PolygonTag polygon : NotableManager.getAllType(PolygonTag.class)) {
for (PolygonTag polygon : NoteManager.getAllType(PolygonTag.class)) {
if (polygon.doesContainLocation(location) && polygon.flagTracker.hasFlag(flagName)) {
return true;
}
Expand All @@ -676,23 +676,23 @@ else if (lower.startsWith("biome:")) {
}
}
if (lower.equals("cuboid")) {
for (CuboidTag cuboid : NotableManager.getAllType(CuboidTag.class)) {
for (CuboidTag cuboid : NoteManager.getAllType(CuboidTag.class)) {
if (cuboid.isInsideCuboid(location)) {
return true;
}
}
return false;
}
else if (lower.equals("ellipsoid")) {
for (EllipsoidTag ellipsoid : NotableManager.getAllType(EllipsoidTag.class)) {
for (EllipsoidTag ellipsoid : NoteManager.getAllType(EllipsoidTag.class)) {
if (ellipsoid.contains(location)) {
return true;
}
}
return false;
}
else if (lower.equals("polygon")) {
for (PolygonTag polygon : NotableManager.getAllType(PolygonTag.class)) {
for (PolygonTag polygon : NoteManager.getAllType(PolygonTag.class)) {
if (polygon.doesContainLocation(location)) {
return true;
}
Expand Down Expand Up @@ -734,17 +734,17 @@ else if (PolygonTag.matches(inputText)) {
}
else if (isAdvancedMatchable(lower)) {
MatchHelper matcher = createMatcher(lower);
for (CuboidTag cuboid : NotableManager.getAllType(CuboidTag.class)) {
for (CuboidTag cuboid : NoteManager.getAllType(CuboidTag.class)) {
if (cuboid.isInsideCuboid(location) && matcher.doesMatch(cuboid.noteName)) {
return true;
}
}
for (EllipsoidTag ellipsoid : NotableManager.getAllType(EllipsoidTag.class)) {
for (EllipsoidTag ellipsoid : NoteManager.getAllType(EllipsoidTag.class)) {
if (ellipsoid.contains(location) && matcher.doesMatch(ellipsoid.noteName)) {
return true;
}
}
for (PolygonTag polygon : NotableManager.getAllType(PolygonTag.class)) {
for (PolygonTag polygon : NoteManager.getAllType(PolygonTag.class)) {
if (polygon.doesContainLocation(location) && matcher.doesMatch(polygon.noteName)) {
return true;
}
Expand Down Expand Up @@ -923,7 +923,7 @@ public static boolean compareInventoryToMatch(InventoryTag inv, MatchHelper matc
if (inv.getIdHolder() instanceof ScriptTag && matcher.doesMatch(((ScriptTag) inv.getIdHolder()).getName())) {
return true;
}
String notedId = NotableManager.getSavedId(inv);
String notedId = NoteManager.getSavedId(inv);
if (notedId != null && matcher.doesMatch(notedId)) {
return true;
}
Expand All @@ -936,7 +936,7 @@ public static boolean tryInventory(InventoryTag inv, String comparedto) {
return true;
}
if (comparedto.equals("notable") || comparedto.equals("note")) {
return NotableManager.isSaved(inv);
return NoteManager.isSaved(inv);
}
if (comparedto.startsWith("inventory_flagged:")) {
return inv.flagTracker != null && inv.flagTracker.hasFlag(comparedto.substring("inventory_flagged:".length()));
Expand Down
Expand Up @@ -200,7 +200,6 @@ public static void registerMainEvents() {
}
ScriptEvent.registerScriptEvent(new ServerPrestartScriptEvent());
ScriptEvent.registerScriptEvent(new ServerStartScriptEvent());
ScriptEvent.registerScriptEvent(new ServerStopScriptEvent());
ScriptEvent.registerScriptEvent(new TabCompleteScriptEvent());

// Vehicle
Expand Down
Expand Up @@ -2,14 +2,14 @@

import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.*;
import com.denizenscript.denizen.objects.notable.NotableManager;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizencore.flags.AbstractFlagTracker;
import com.denizenscript.denizencore.flags.FlaggableObject;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.notable.Notable;
import com.denizenscript.denizencore.objects.notable.NoteManager;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.Location;
Expand Down Expand Up @@ -297,25 +297,25 @@ public void processNewPosition(EntityTag entity, Location pos, Event eventCause)
}
HashSet<String> inAreas = entitiesInArea.get(entity.getUUID());
if (doTrackAll || matchers != null || flagTracked != null) {
for (CuboidTag cuboid : NotableManager.getAllType(CuboidTag.class)) {
for (CuboidTag cuboid : NoteManager.getAllType(CuboidTag.class)) {
if (anyMatch(cuboid.noteName, cuboid)) {
processSingle(cuboid, entity, inAreas, pos, eventCause);
}
}
for (EllipsoidTag ellipsoid : NotableManager.getAllType(EllipsoidTag.class)) {
for (EllipsoidTag ellipsoid : NoteManager.getAllType(EllipsoidTag.class)) {
if (anyMatch(ellipsoid.noteName, ellipsoid)) {
processSingle(ellipsoid, entity, inAreas, pos, eventCause);
}
}
for (PolygonTag polygon : NotableManager.getAllType(PolygonTag.class)) {
for (PolygonTag polygon : NoteManager.getAllType(PolygonTag.class)) {
if (anyMatch(polygon.noteName, polygon)) {
processSingle(polygon, entity, inAreas, pos, eventCause);
}
}
}
else {
for (String name : exactTracked) {
Notable obj = NotableManager.getSavedObject(name);
Notable obj = NoteManager.getSavedObject(name);
if (!(obj instanceof AreaContainmentObject)) {
Debug.echoError("Invalid area enter/exit event area '" + name + "'");
continue;
Expand Down
Expand Up @@ -2,11 +2,11 @@

import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizen.objects.notable.NotableManager;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.notable.NoteManager;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -86,7 +86,7 @@ public void onPlayerWalksOver(PlayerMoveEvent event) {
if (EntityTag.isNPC(event.getPlayer())) {
return;
}
notable = NotableManager.getSavedId(new LocationTag(event.getTo()).getBlockLocation());
notable = NoteManager.getSavedId(new LocationTag(event.getTo()).getBlockLocation());
if (notable == null) {
return;
}
Expand Down

This file was deleted.

Expand Up @@ -162,7 +162,7 @@ public ObjectTag setPrefix(String prefix) {

@Override
public AbstractFlagTracker getFlagTracker() {
return new RedirectionFlagTracker(DenizenCore.getImplementation().getServerFlags(), "__biomes." + biome.getName().replace(".", "&dot"));
return new RedirectionFlagTracker(DenizenCore.serverFlagMap, "__biomes." + biome.getName().replace(".", "&dot"));
}

@Override
Expand Down

0 comments on commit 24f8ed6

Please sign in to comment.