001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package net.tridentsdk.server.world;
018
019import net.tridentsdk.server.packets.play.out.PacketPlayOutGameStateChange;
020import net.tridentsdk.server.packets.play.out.PacketPlayOutServerDifficulty;
021import net.tridentsdk.server.player.TridentPlayer;
022import net.tridentsdk.world.settings.*;
023
024import java.util.Set;
025
026/**
027 * Represents changable and unchangable attributes of a world
028 *
029 * @author The TridentSDK Team
030 */
031public class TridentWorldSettings implements WorldSettings {
032
033    private LevelType levelType = LevelType.DEFAULT;
034    private long seed = 0;
035    private Dimension dimension = Dimension.OVERWORLD;
036    private Difficulty difficulty = Difficulty.EASY;
037
038    public static WorldSettings load(TridentWorld world, WorldCreateOptions options) {
039        return new TridentWorldSettings();
040    }
041
042    @Override
043    public GameMode defaultGameMode() {
044        return null;
045    }
046
047    @Override
048    public void setGameMode(GameMode gameMode) {
049        // this.defaultGamemode = gameMode;
050
051        PacketPlayOutGameStateChange change = new PacketPlayOutGameStateChange();
052        change.set("reason", 3).set("value", (float) gameMode.asByte());
053        TridentPlayer.sendFiltered(change, p -> p.world().equals(this));
054    }
055
056    @Override
057    public LevelType levelType() {
058        return levelType;
059    }
060
061    @Override
062    public long seed() {
063        return seed;
064    }
065
066    @Override
067    public Dimension dimension() {
068        return dimension;
069    }
070
071    @Override
072    public Difficulty difficulty() {
073        return difficulty;
074    }
075
076    @Override
077    public void setDifficulty(Difficulty difficulty) {
078        // this.difficulty = difficulty;
079
080        PacketPlayOutServerDifficulty d = new PacketPlayOutServerDifficulty();
081        d.set("difficulty", d);
082        TridentPlayer.sendFiltered(d, p -> p.world().equals(this));
083    }
084
085    @Override
086    public boolean isRule(String rule) {
087        return false;
088    }
089
090    @Override
091    public Set<String> gameRules() {
092        return null;
093    }
094
095    @Override
096    public boolean allowPvp() {
097        return false;
098    }
099
100    @Override
101    public void setAllowPvp(boolean enable) {
102
103    }
104
105    @Override
106    public boolean generateStructures() {
107        return false;
108    }
109}