Add Api world load/unload events and DhApiWorldProxy.get/setReadOnly()
This commit is contained in:
+26
-1
@@ -24,14 +24,39 @@ package com.seibel.distanthorizons.api.interfaces.world;
|
||||
* A world is equivalent to a single server connection or a singleplayer world.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-11-20
|
||||
* @version 2024-9-27
|
||||
* @since API 1.0.0
|
||||
*/
|
||||
public interface IDhApiWorldProxy
|
||||
{
|
||||
//===================//
|
||||
// getters / setters //
|
||||
//===================//
|
||||
|
||||
/** Returns true if a world is loaded. */
|
||||
boolean worldLoaded();
|
||||
|
||||
/**
|
||||
* Defaults to false. <br>
|
||||
* Setting this to true will prevent DH from updating or creating new LODs.
|
||||
*
|
||||
* @since API 4.0.0
|
||||
* @see IDhApiWorldProxy#getReadOnly()
|
||||
* @throws IllegalStateException if no world is loaded
|
||||
*/
|
||||
void setReadOnly(boolean readOnly) throws IllegalStateException;
|
||||
/**
|
||||
* @since API 4.0.0
|
||||
* @see IDhApiWorldProxy#setReadOnly(boolean)
|
||||
* @throws IllegalStateException if no world is loaded
|
||||
*/
|
||||
boolean getReadOnly() throws IllegalStateException;
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// level handlers //
|
||||
//================//
|
||||
|
||||
/**
|
||||
* In singleplayer this will return the level the player is currently in. <br>
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.api.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
|
||||
import com.seibel.distanthorizons.api.interfaces.world.IDhApiWorldProxy;
|
||||
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
|
||||
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
|
||||
|
||||
/**
|
||||
* Called after Distant Horizons finishes loading a new level. <br>
|
||||
* Note: this may be fired before Minecraft has loaded in the player.
|
||||
*
|
||||
* @see IDhApiWorldProxy
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2024-9-27
|
||||
* @since API 4.0.0
|
||||
*/
|
||||
public abstract class DhApiWorldLoadEvent implements IDhApiEvent<DhApiWorldLoadEvent.EventParam>
|
||||
{
|
||||
/** Fired after Distant Horizons loads a new level. */
|
||||
public abstract void onLevelLoad(DhApiEventParam<EventParam> input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final void fireEvent(DhApiEventParam<EventParam> input) { this.onLevelLoad(input); }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam implements IDhApiEventParam
|
||||
{
|
||||
public EventParam() { }
|
||||
|
||||
|
||||
@Override
|
||||
public EventParam copy() { return new EventParam(); }
|
||||
}
|
||||
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.api.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
|
||||
import com.seibel.distanthorizons.api.interfaces.world.IDhApiWorldProxy;
|
||||
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
|
||||
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
|
||||
|
||||
/**
|
||||
* Called after Distant Horizons has finished unloading a level.
|
||||
*
|
||||
* @see IDhApiWorldProxy
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2024-9-27
|
||||
* @since API 4.0.0
|
||||
*/
|
||||
public abstract class DhApiWorldUnloadEvent implements IDhApiEvent<DhApiWorldUnloadEvent.EventParam>
|
||||
{
|
||||
/** Fired before Distant Horizons unloads a level. */
|
||||
public abstract void onLevelUnload(DhApiEventParam<EventParam> input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final void fireEvent(DhApiEventParam<EventParam> input) { this.onLevelUnload(input); }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam implements IDhApiEventParam
|
||||
{
|
||||
public EventParam() { }
|
||||
|
||||
|
||||
@Override
|
||||
public DhApiWorldLoadEvent.EventParam copy() { return new DhApiWorldLoadEvent.EventParam(); }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user