geforkt von Mirrors/FastAsyncWorldEdit
Hard-coded a list of items that can be used for WorldEdit.
Dieser Commit ist enthalten in:
Ursprung
c8054b95fe
Commit
6eaf5895e4
26
src/DisallowedItemException.java
Normale Datei
26
src/DisallowedItemException.java
Normale Datei
@ -0,0 +1,26 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class DisallowedItemException extends Exception {
|
||||
|
||||
}
|
@ -93,17 +93,38 @@ public class WorldEdit extends Plugin {
|
||||
* @param id
|
||||
* @return
|
||||
* @throws UnknownItemException
|
||||
* @throws DisallowedItemException
|
||||
*/
|
||||
private int getItem(String id) throws UnknownItemException {
|
||||
private int getItem(String id) throws UnknownItemException,
|
||||
DisallowedItemException {
|
||||
int foundID;
|
||||
|
||||
try {
|
||||
return Integer.parseInt(id);
|
||||
foundID = Integer.parseInt(id);
|
||||
} catch (NumberFormatException e) {
|
||||
try {
|
||||
return etc.getInstance().getDataSource().getItem(id);
|
||||
foundID = etc.getInstance().getDataSource().getItem(id);
|
||||
} catch (NumberFormatException e2) {
|
||||
throw new UnknownItemException();
|
||||
}
|
||||
}
|
||||
|
||||
if ((foundID >= 0 && foundID <= 5) ||
|
||||
(foundID >= 7 && foundID <= 20) ||
|
||||
foundID == 35 ||
|
||||
(foundID >= 41 && foundID <= 45) ||
|
||||
(foundID >= 47 && foundID <= 49) ||
|
||||
(foundID >= 52 && foundID <= 54) ||
|
||||
(foundID >= 56 && foundID <= 58) ||
|
||||
(foundID >= 60 && foundID <= 62) ||
|
||||
foundID == 67 ||
|
||||
foundID == 73 ||
|
||||
(foundID >= 78 && foundID <= 82) ||
|
||||
foundID == 85) {
|
||||
return foundID;
|
||||
} else {
|
||||
throw new DisallowedItemException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,8 +186,11 @@ public class WorldEdit extends Plugin {
|
||||
} catch (UnknownItemException e3) {
|
||||
player.sendMessage(Colors.Rose + "Unknown item.");
|
||||
return true;
|
||||
} catch (InsufficientArgumentsException e4) {
|
||||
player.sendMessage(Colors.Rose + e4.getMessage());
|
||||
} catch (DisallowedItemException e4) {
|
||||
player.sendMessage(Colors.Rose + "Disallowed item.");
|
||||
return true;
|
||||
} catch (InsufficientArgumentsException e5) {
|
||||
player.sendMessage(Colors.Rose + e5.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -186,7 +210,7 @@ public class WorldEdit extends Plugin {
|
||||
|
||||
private boolean handleEditCommand(Player player, String[] split)
|
||||
throws UnknownItemException, IncompleteRegionException,
|
||||
InsufficientArgumentsException
|
||||
InsufficientArgumentsException, DisallowedItemException
|
||||
{
|
||||
WorldEditSession session = getSession(player);
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren