summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java
blob: f44e234895d98ace242d76e208c02c104d2c9d4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package org.bukkit.craftbukkit;

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldBorder;

public class CraftWorldBorder implements WorldBorder {

    private final World world;
    private final net.minecraft.server.WorldBorder handle;

    public CraftWorldBorder(CraftWorld world) {
        this.world = world;
        this.handle = world.getHandle().af(); // PAIL: Rename
    }

    @Override
    public void reset() {
        this.setSize(6.0E7D);
        this.setDamageAmount(0.2D);
        this.setDamageBuffer(5.0D);
        this.setWarningDistance(5);
        this.setWarningTime(15);
        this.setCenter(0, 0);
    }

    @Override
    public double getSize() {
        return this.handle.h(); // PAIL: Rename
    }

    @Override
    public void setSize(double newSize) {
        this.setSize(newSize, 0L);
    }

    @Override
    public void setSize(double newSize, long time) {
        // PAIL: TODO: Magic Values
        newSize = Math.min(6.0E7D, Math.max(1.0D, newSize));
        time = Math.min(9223372036854775L, Math.max(0L, time));

        if (time > 0L) {
            this.handle.a(this.handle.h(), newSize, time * 1000L); // PAIL: Rename
        } else {
            this.handle.a(newSize); // PAIL: Rename
        }
    }

    @Override
    public Location getCenter() {
        double x = this.handle.f(); // PAIL: Rename
        double z = this.handle.g(); // PAIL: Rename

        return new Location(this.world, x, 0, z);
    }

    @Override
    public void setCenter(double x, double z) {
        // PAIL: TODO: Magic Values
        x = Math.min(3.0E7D, Math.max(-3.0E7D, x));
        z = Math.min(3.0E7D, Math.max(-3.0E7D, z));

        this.handle.c(x, z); // PAIL: Rename
    }

    @Override
    public void setCenter(Location location) {
        this.setCenter(location.getX(), location.getZ());
    }

    @Override
    public double getDamageBuffer() {
        return this.handle.m(); // PAIL: Rename
    }

    @Override
    public void setDamageBuffer(double blocks) {
        this.handle.b(blocks); // PAIL: Rename
    }

    @Override
    public double getDamageAmount() {
        return this.handle.n(); // PAIL: Rename
    }

    @Override
    public void setDamageAmount(double damage) {
        this.handle.c(damage); // PAIL: Rename
    }

    @Override
    public int getWarningTime() {
        return this.handle.p(); // PAIL: Rename
    }

    @Override
    public void setWarningTime(int time) {
        this.handle.b(time); // PAIL: Rename
    }

    @Override
    public int getWarningDistance() {
        return this.handle.q(); // PAIL: Rename
    }

    @Override
    public void setWarningDistance(int distance) {
        this.handle.c(distance); // PAIL: Rename
    }
}