001package net.tnemc.plugincore.sponge.impl; 002/* 003 * The New Plugin Core 004 * Copyright (C) 2022 - 2025 Daniel "creatorfromhell" Vidmar 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU Affero General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU Affero General Public License for more details. 015 * 016 * You should have received a copy of the GNU Affero General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 */ 019 020import net.tnemc.plugincore.core.compatibility.ChunkProvider; 021import net.tnemc.plugincore.core.compatibility.Location; 022import net.tnemc.plugincore.core.compatibility.WorldProvider; 023import org.jetbrains.annotations.NotNull; 024import org.spongepowered.api.world.server.ServerWorld; 025import org.spongepowered.math.vector.Vector3i; 026 027/** 028 * SpongeWorldProvider 029 * 030 * @author creatorfromhell 031 * @since 1.1.0.1 032 */ 033public class SpongeWorldProvider implements WorldProvider { 034 035 protected final ServerWorld world; 036 037 public SpongeWorldProvider(final ServerWorld world) { 038 this.world = world; 039 } 040 041 /** 042 * Returns the name associated with this object. 043 * 044 * @return a string representing the name. 045 */ 046 @Override 047 public @NotNull String name() { 048 049 return world.key().value(); 050 } 051 052 /** 053 * Returns the dimension of the world provider. 054 * 055 * @return a string representing the dimension of the world provider. 056 */ 057 @Override 058 public @NotNull String dimension() { 059 060 return world.properties().name(); 061 } 062 063 /** 064 * Retrieves the spawn location. 065 * 066 * @return a Location object representing the spawn location. 067 */ 068 @Override 069 public @NotNull Location spawn() { 070 071 final Vector3i spawn = world.properties().spawnPosition(); 072 073 return new Location(name(), spawn.x(), spawn.y(), spawn.z()); 074 } 075 076 /** 077 * Retrieves the phase of the moon. 078 * 079 * @return a string representing the phase of the moon. 080 */ 081 @Override 082 public @NotNull String moonPhase() { 083 084 return ""; 085 } 086 087 /** 088 * Retrieves the current weather conditions. 089 * 090 * @return a string representing the current weather conditions. 091 */ 092 @Override 093 public @NotNull String weather() { 094 095 return ""; 096 } 097 098 /** 099 * Retrieves the current world time. 100 * 101 * @return the current world time as a long value. 102 */ 103 @Override 104 public long worldTime() { 105 106 return 0; 107 } 108 109 /** 110 * Returns the current game time. 111 * 112 * @return the current game time as a long value. 113 */ 114 @Override 115 public long gameTime() { 116 117 return 0; 118 } 119 120 /** 121 * Retrieves a ChunkProvider object based on the provided coordinates. 122 * 123 * @param x The x-coordinate for the ChunkProvider. 124 * @param y The y-coordinate for the ChunkProvider. 125 * @param z The z-coordinate for the ChunkProvider. 126 * 127 * @return A ChunkProvider object that handles chunk-related operations for the specified 128 * coordinates. 129 */ 130 @Override 131 public ChunkProvider chunkProvider(final int x, final int y, final int z) { 132 133 return new SpongeChunkProvider(world.chunk(x, y, z)); 134 } 135}