(Breaking) Moved some packages around.

Most of the changes should not break *most* WorldEdit-using plugins,
but implementations of WorldEdit are broken by this change.
This commit is contained in:
sk89q
2014-04-02 19:08:50 -07:00
parent 6e70e8c862
commit 469cb8c8b3
185 changed files with 13303 additions and 13270 deletions

View File

@ -0,0 +1,105 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util;
/**
*
* @author sk89q
* @param <T>
*/
public class Countable<T> implements Comparable<Countable<T>> {
/**
* ID.
*/
private T id;
/**
* Amount.
*/
private int amount;
/**
* Construct the object.
*
* @param id
* @param amount
*/
public Countable(T id, int amount) {
this.id = id;
this.amount = amount;
}
/**
* @return the id
*/
public T getID() {
return id;
}
/**
* @param id the id to set
*/
public void setID(T id) {
this.id = id;
}
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* Decrement the amount.
*/
public void decrement() {
--this.amount;
}
/**
* Increment the amount.
*/
public void increment() {
++this.amount;
}
/**
* Comparison.
*
* @param other
* @return
*/
public int compareTo(Countable<T> other) {
if (amount > other.amount) {
return 1;
} else if (amount == other.amount) {
return 0;
} else {
return -1;
}
}
}

View File

@ -0,0 +1,65 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import java.util.logging.Level;
import java.io.PrintWriter;
import java.io.StringWriter;
/**
* Used for formatting.
*
* @author sk89q
*/
public class LogFormat extends Formatter {
@Override
public String format(LogRecord record) {
StringBuilder text = new StringBuilder();
Level level = record.getLevel();
if (level == Level.FINEST) {
text.append("[FINEST] ");
} else if (level == Level.FINER) {
text.append("[FINER] ");
} else if (level == Level.FINE) {
text.append("[FINE] ");
} else if (level == Level.INFO) {
text.append("[INFO] ");
} else if (level == Level.WARNING) {
text.append("[WARNING] ");
} else if (level == Level.SEVERE) {
text.append("[SEVERE] ");
}
text.append(record.getMessage());
text.append("\r\n");
Throwable t = record.getThrown();
if (t != null) {
StringWriter writer = new StringWriter();
t.printStackTrace(new PrintWriter(writer));
text.append(writer.toString());
}
return text.toString();
}
}

View File

@ -32,7 +32,7 @@ import java.util.Set;
import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.snapshots.SnapshotRepository;
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
/**
* Simple LocalConfiguration that loads settings using

View File

@ -26,7 +26,7 @@ import java.util.logging.Logger;
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.snapshots.SnapshotRepository;
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
/**
* A less simple implementation of {@link LocalConfiguration} using YAML configuration files.

View File

@ -0,0 +1,102 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.io;
import java.io.IOException;
import java.io.InputStream;
public class ForwardSeekableInputStream extends InputStream {
protected InputStream parent;
protected long position = 0;
public ForwardSeekableInputStream(InputStream parent) {
this.parent = parent;
}
@Override
public int read() throws IOException {
int ret = parent.read();
++position;
return ret;
}
@Override
public int available() throws IOException {
return parent.available();
}
@Override
public void close() throws IOException {
parent.close();
}
@Override
public synchronized void mark(int readlimit) {
parent.mark(readlimit);
}
@Override
public boolean markSupported() {
return parent.markSupported();
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
int read = super.read(b, off, len);
position += read;
return read;
}
@Override
public int read(byte[] b) throws IOException {
int read = parent.read(b);
position += read;
return read;
}
@Override
public synchronized void reset() throws IOException {
parent.reset();
}
@Override
public long skip(long n) throws IOException {
long skipped = parent.skip(n);
position += skipped;
return skipped;
}
public void seek(long n) throws IOException {
long diff = n - position;
if (diff < 0) {
throw new IOException("Can't seek backwards");
}
if (diff == 0) {
return;
}
if (skip(diff) < diff) {
throw new IOException("Failed to seek " + diff + " bytes");
}
}
}