net.minecraft.server.integrated.IntegratedServer Java Examples

The following examples show how to use net.minecraft.server.integrated.IntegratedServer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HyperiumHandlers.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@InvokeEvent
public void tick(TickEvent event) {
    // Runs first tick
    IntegratedServer integratedServer = Minecraft.getMinecraft().getIntegratedServer();
    if (integratedServer != null) {
        ICommandManager commandManager = integratedServer.getCommandManager();
        if (commandManager != null) {
            EventBus.INSTANCE.unregister(HyperiumHandlers.class);
        }
    }
}
 
Example #2
Source File: Mw.java    From mapwriter with MIT License 5 votes vote down vote up
public String getWorldName() {
	String worldName;
	if (this.multiplayer) {
		if (this.portNumberInWorldNameEnabled) {
			worldName = String.format("%s_%d", this.serverName, this.serverPort);
		} else {
			worldName = String.format("%s", this.serverName);
		}
		
	} else {
		// cannot use this.mc.theWorld.getWorldInfo().getWorldName() as it
		// is set statically to "MpServer".
		IntegratedServer server = this.mc.getIntegratedServer();
		worldName = (server != null) ? server.getFolderName() : "sp_world";
	}
	
	// strip invalid characters from the server name so that it
	// can't be something malicious like '..\..\..\windows\'
	worldName = MwUtil.mungeString(worldName);
	
	// if something went wrong make sure the name is not blank
	// (causes crash on start up due to empty configuration section)
	if (worldName == "") {
		worldName = "default";
	}
	return worldName;
}
 
Example #3
Source File: IntegratedServerMixin.java    From fabric-carpet with MIT License 4 votes vote down vote up
@Inject(method = "loadWorld", at = @At("HEAD"))
private void onSetupServerIntegrated(String string_1, String string_2, long long_1, LevelGeneratorType levelGeneratorType_1, JsonElement jsonElement_1, CallbackInfo ci) {
    CarpetServer.onServerLoaded((IntegratedServer) (Object) this);
}
 
Example #4
Source File: FileWorldGeneratorImplementation.java    From malmo with MIT License 4 votes vote down vote up
@Override
public boolean createWorld(MissionInit missionInit)
{
    if (this.mapFilename == null || this.mapFilename.length() == 0)
    {
        this.errorDetails = "No basemap URI provided - check your Mission XML.";
        return false;
    }
    File mapSource = new File(this.mapFilename);
    if (!mapSource.exists())
    {
        this.errorDetails = "Basemap file " + this.mapFilename + " was not found - check your Mission XML and ensure the file exists on the Minecraft client machine.";
        return false;
    }
    if (!mapSource.isDirectory())
    {
        this.errorDetails = "Basemap location " + this.mapFilename + " needs to be a folder. Check the path in your Mission XML.";
        return false;
    }
    File mapCopy = MapFileHelper.copyMapFiles(mapSource, this.fwparams.isDestroyAfterUse());
    if (mapCopy == null)
    {
        this.errorDetails = "Unable to copy " + this.mapFilename + " - is the hard drive full?";
        return false;
    }
    if (!Minecraft.getMinecraft().getSaveLoader().canLoadWorld(mapCopy.getName()))
    {
        this.errorDetails = "Minecraft is unable to load " + this.mapFilename + " - is it a valid saved world?";
        return false;
    }

    ISaveFormat isaveformat = Minecraft.getMinecraft().getSaveLoader();
    List<WorldSummary> worldlist;
    try
    {
        worldlist = isaveformat.getSaveList();
    }
    catch (AnvilConverterException anvilconverterexception)
    {
    	this.errorDetails = "Minecraft couldn't rebuild saved world list.";
        return false;
    }

    WorldSummary newWorld = null;
    for (WorldSummary ws : worldlist)
    {
        if (ws.getFileName().equals(mapCopy.getName()))
            newWorld = ws;
    }
    if (newWorld == null)
    {
        this.errorDetails = "Minecraft could not find the copied world.";
        return false;
    }

    net.minecraftforge.fml.client.FMLClientHandler.instance().tryLoadExistingWorld(null, newWorld);
    IntegratedServer server = Minecraft.getMinecraft().getIntegratedServer();
    String worldName = (server != null) ? server.getWorldName() : null;
    if (worldName == null || !worldName.equals(newWorld.getDisplayName()))
    {
        this.errorDetails = "Minecraft could not load " + this.mapFilename + " - is it a valid saved world?";
        return false;
    }
    MapFileHelper.cleanupTemporaryWorlds(mapCopy.getName());    // Now we are safely running a new file, we can attempt to clean up old ones.
    return true;
}
 
Example #5
Source File: Mw.java    From mapwriter with MIT License 4 votes vote down vote up
public void load() {
	
	if (this.ready) {
		return;
	}
	
	if ((this.mc.theWorld == null) || (this.mc.thePlayer == null)) {
		MwUtil.log("Mw.load: world or player is null, cannot load yet");
		return;
	}
	
	MwUtil.log("Mw.load: loading...");
	
	IntegratedServer server = this.mc.getIntegratedServer();
	this.multiplayer = (server == null);
	
	this.loadConfig();
	
	this.worldName = this.getWorldName();
	
	// get world and image directories
	File saveDir = this.saveDir;
	if (this.saveDirOverride.length() > 0) {
		File d = new File(this.saveDirOverride);
		if (d.isDirectory()) {
			saveDir = d;
		} else {
			MwUtil.log("error: no such directory %s", this.saveDirOverride);
		}
	}
	
	if (this.multiplayer) {
		this.worldDir = new File(new File(saveDir, "mapwriter_mp_worlds"), this.worldName);
	} else {
		this.worldDir = new File(new File(saveDir, "mapwriter_sp_worlds"), this.worldName);
	}
	
	this.loadWorldConfig();
	
	// create directories
	this.imageDir = new File(this.worldDir, "images");
	if (!this.imageDir.exists()) {
		this.imageDir.mkdirs();
	}
	if (!this.imageDir.isDirectory()) {
		MwUtil.log("Mapwriter: ERROR: could not create images directory '%s'", this.imageDir.getPath());
	}
	
	this.tickCounter = 0;
	this.onPlayerDeathAlreadyFired = false;
	
	//this.multiplayer = !this.mc.isIntegratedServerRunning();
	
	// marker manager only depends on the config being loaded
	this.markerManager = new MarkerManager();
	this.markerManager.load(this.worldConfig, catMarkers);
	
	this.playerTrail = new Trail(this, "player");
	
	// executor does not depend on anything
	this.executor = new BackgroundExecutor();
	
	// mapTexture depends on config being loaded
	this.mapTexture = new MapTexture(this.textureSize, this.linearTextureScalingEnabled);
	this.undergroundMapTexture = new UndergroundTexture(this, this.textureSize, this.linearTextureScalingEnabled);
	this.reloadBlockColours();
	// region manager depends on config, mapTexture, and block colours
	this.regionManager = new RegionManager(this.worldDir, this.imageDir, this.blockColours, this.minZoom, this.maxZoom);
	// overlay manager depends on mapTexture
	this.miniMap = new MiniMap(this);
	this.miniMap.view.setDimension(this.mc.thePlayer.dimension);
	
	this.chunkManager = new ChunkManager(this);
	
	this.ready = true;
	
	//if (!zoomLevelsExist) {
		//printBoth("recreating zoom levels");
		//this.regionManager.recreateAllZoomLevels();
	//}
}