Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stencil Brush (Rotating blocks) #323

Open
wants to merge 1 commit into
base: sponge-1.12
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -24,7 +18,6 @@
*/
public class VoxelSniper extends JavaPlugin
{
private static final String PLUGINS_VOXEL_SNIPER_SNIPER_CONFIG_XML = "plugins/VoxelSniper/SniperConfig.xml";
private static VoxelSniper instance;
private SniperManager sniperManager = new SniperManager(this);
private final VoxelSniperListener voxelSniperListener = new VoxelSniperListener(this);
Expand Down Expand Up @@ -70,59 +63,6 @@ public SniperManager getSniperManager()
return sniperManager;
}

/**
* Load and migrate legacy configuration.
*/
public void loadSniperConfiguration()
{
File configurationFile = new File(VoxelSniper.PLUGINS_VOXEL_SNIPER_SNIPER_CONFIG_XML);

if (!configurationFile.exists())
{
return;
}

JAXBContext context;
Unmarshaller unmarshaller;
try
{
context = JAXBContext.newInstance(LegacyConfigurationContainer.class);
unmarshaller = context.createUnmarshaller();
}
catch (JAXBException exception)
{
getLogger().log(Level.SEVERE, "Couldn't create Unmarshaller, while attempting to load legacy configuration.", exception);
return;
}

try
{
Object unmarshal = unmarshaller.unmarshal(configurationFile);
Preconditions.checkState(unmarshal instanceof LegacyConfigurationContainer, "Unmarshalled object is not of expected type.");
LegacyConfigurationContainer legacyConfiguration = (LegacyConfigurationContainer) unmarshal;
voxelSniperConfiguration.setUndoCacheSize(legacyConfiguration.undoCacheSize);
voxelSniperConfiguration.setLitesniperRestrictedItems(legacyConfiguration.litesniperRestrictedItems);
voxelSniperConfiguration.setLiteSniperMaxBrushSize(legacyConfiguration.liteSniperMaxBrushSize);
}
catch (JAXBException exception)
{
getLogger().log(Level.SEVERE, "Couldn't unmarshall legacy configuration.", exception);
return;
}
catch (IllegalStateException exception)
{
getLogger().log(Level.SEVERE, exception.getMessage(), exception);
return;
}

if (configurationFile.delete())
{
saveConfig();
reloadConfig();
getLogger().info("Migrated legacy configuration file.");
}
}

@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
{
Expand Down Expand Up @@ -155,7 +95,6 @@ public void onEnable()

saveDefaultConfig();
voxelSniperConfiguration = new VoxelSniperConfiguration(getConfig());
loadSniperConfiguration();

Bukkit.getPluginManager().registerEvents(this.voxelSniperListener, this);
getLogger().info("Registered Sniper Listener.");
Expand Down Expand Up @@ -244,19 +183,4 @@ public void registerBrushes()
brushManager.registerSniperBrush(WarpBrush.class, "w", "warp");
}

@XmlRootElement(name = "VoxelSniper")
private static class LegacyConfigurationContainer
{
private LegacyConfigurationContainer()
{
}

@XmlElementWrapper(name = "LiteSniperBannedIDs", required = false)
@XmlElement(name = "id", type = Integer.class)
List<Integer> litesniperRestrictedItems = new ArrayList<Integer>();
@XmlElement(name = "MaxLiteBrushSize", required = true, defaultValue = "5")
int liteSniperMaxBrushSize = 5;
@XmlElement(name = "SniperUndoCache", required = true, defaultValue = "20")
int undoCacheSize = 20;
}
}